Merge pull request #461 from github/detect-csv

Add `csv?` BlobHelper
This commit is contained in:
Ted Nyman
2013-04-04 14:36:08 -07:00
3 changed files with 14 additions and 0 deletions

View File

@@ -158,6 +158,13 @@ module Linguist
extname.downcase == '.stl'
end
# Public: Is this blob a CSV file?
#
# Return true or false
def csv?
text? && extname.downcase == '.csv'
end
# Public: Is the blob a PDF?
#
# Return true or false

3
samples/Text/cars.csv Normal file
View File

@@ -0,0 +1,3 @@
Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38
1 Year Make Model Length
2 1997 Ford E350 2.34
3 2000 Mercury Cougar 2.38

View File

@@ -137,6 +137,10 @@ class TestBlob < Test::Unit::TestCase
assert blob("Text/cube.stl").solid?
end
def test_csv
assert blob("Text/cars.csv").csv?
end
def test_pdf
assert blob("Binary/foo.pdf").pdf?
end