From b68732f0c7bd3c9a005230aa6bc4bc84a60fd31b Mon Sep 17 00:00:00 2001 From: Yaroslav Shirokov Date: Thu, 4 Apr 2013 14:01:09 -0700 Subject: [PATCH] Add detection for CSV --- lib/linguist/blob_helper.rb | 7 +++++++ samples/Text/cars.csv | 3 +++ test/test_blob.rb | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 samples/Text/cars.csv diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 5ca2b8b0..8e0e3262 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -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 diff --git a/samples/Text/cars.csv b/samples/Text/cars.csv new file mode 100644 index 00000000..73280e55 --- /dev/null +++ b/samples/Text/cars.csv @@ -0,0 +1,3 @@ +Year,Make,Model,Length +1997,Ford,E350,2.34 +2000,Mercury,Cougar,2.38 \ No newline at end of file diff --git a/test/test_blob.rb b/test/test_blob.rb index 836eb72f..f26fb842 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -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