Fix for interpreters not getting add to samples.json

This commit is contained in:
Brandon Keepers
2014-11-20 11:14:05 -05:00
parent 231ad86176
commit eccea65641
2 changed files with 6 additions and 3 deletions

View File

@@ -52,14 +52,16 @@ module Linguist
}) })
end end
else else
path = File.join(dirname, filename)
if File.extname(filename) == "" if File.extname(filename) == ""
raise "#{File.join(dirname, filename)} is missing an extension, maybe it belongs in filenames/ subdir" raise "#{path} is missing an extension, maybe it belongs in filenames/ subdir"
end end
yield({ yield({
:path => File.join(dirname, filename), :path => path,
:language => category, :language => category,
:interpreter => File.exist?(filename) ? Linguist.interpreter_from_shebang(File.read(filename)) : nil, :interpreter => Linguist.interpreter_from_shebang(File.read(path)),
:extname => File.extname(filename) :extname => File.extname(filename)
}) })
end end

View File

@@ -34,6 +34,7 @@ class TestSamples < Test::Unit::TestCase
assert_equal data['languages_total'], data['languages'].inject(0) { |n, (_, c)| n += c } assert_equal data['languages_total'], data['languages'].inject(0) { |n, (_, c)| n += c }
assert_equal data['tokens_total'], data['language_tokens'].inject(0) { |n, (_, c)| n += c } assert_equal data['tokens_total'], data['language_tokens'].inject(0) { |n, (_, c)| n += c }
assert_equal data['tokens_total'], data['tokens'].inject(0) { |n, (_, ts)| n += ts.inject(0) { |m, (_, c)| m += c } } assert_equal data['tokens_total'], data['tokens'].inject(0) { |n, (_, ts)| n += ts.inject(0) { |m, (_, c)| m += c } }
assert !data["interpreters"].empty?
end end
# Check that there aren't samples with extensions that aren't explicitly defined in languages.yml # Check that there aren't samples with extensions that aren't explicitly defined in languages.yml