"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/test_samples.rb" between
linguist-7.23.0.tar.gz and linguist-7.24.0.tar.gz

About: Linguist is a library mainly to detect the programming language used in a file (on GitHub.com it is used to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and generate language breakdown graphs).

test_samples.rb  (linguist-7.23.0):test_samples.rb  (linguist-7.24.0)
skipping to change at line 86 skipping to change at line 86
# If a language extension isn't globally unique then make sure there are sampl es # If a language extension isn't globally unique then make sure there are sampl es
Linguist::Language.all.each do |language| Linguist::Language.all.each do |language|
define_method "test_#{language.name}_has_samples" do define_method "test_#{language.name}_has_samples" do
language.extensions.each do |extension| language.extensions.each do |extension|
language_matches = Language.find_by_extension(extension) language_matches = Language.find_by_extension(extension)
# Check for samples if more than one language matches the given extensio n. # Check for samples if more than one language matches the given extensio n.
if language_matches.length > 1 if language_matches.length > 1
language_matches.each do |match| language_matches.each do |match|
generic = Strategy::Extension.generic? extension generic = Strategy::Extension.generic? extension
samples = generic ? "test/fixtures/Generic/#{extension.sub(/^\./, "" samples = generic ? "test/fixtures/Generic/#{extension.sub(/^\./, ""
)}/#{match.name}/*" : "samples/#{match.name}/*#{extension}" )}/#{match.name}/*" : "samples/#{match.name}/*#{case_insensitive_glob(extension)
assert Dir.glob(samples, File::FNM_CASEFOLD).any?, "Missing samples }"
in #{samples.inspect}. See https://github.com/github/linguist/blob/master/CONTRI assert Dir.glob(samples).any?, "Missing samples in #{samples.inspect
BUTING.md" }. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
end end
end end
end end
language.filenames.each do |filename| language.filenames.each do |filename|
# Check for samples if more than one language matches the given filename # Check for samples if more than one language matches the given filename
if Language.find_by_filename(filename).size > 1 if Language.find_by_filename(filename).size > 1
sample = "samples/#{language.name}/filenames/#{filename}" sample = "samples/#{language.name}/filenames/#{filename}"
assert File.exist?(sample), assert File.exist?(sample),
"Missing sample in #{sample.inspect}. See https://github.com/github/ linguist/blob/master/CONTRIBUTING.md" "Missing sample in #{sample.inspect}. See https://github.com/github/ linguist/blob/master/CONTRIBUTING.md"
end end
end end
end end
end end
def case_insensitive_glob(extension)
glob = ""
extension.each_char do |c|
glob += c.downcase != c.upcase ? "[#{c.downcase}#{c.upcase}]" : c
end
glob
end
end end
 End of changes. 2 change blocks. 
5 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)