From 032125b11438ba3d829068fe9a5ccc4a39d7792d Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 10 Jun 2013 11:06:18 -0500 Subject: [PATCH] Axe indexable? --- lib/linguist/blob_helper.rb | 30 ------------------------------ test/test_blob.rb | 14 -------------- 2 files changed, 44 deletions(-) diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index b538a11f..2d6b9ed0 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -278,36 +278,6 @@ module Linguist @_generated ||= Generated.generated?(name, lambda { data }) end - # Public: Should the blob be indexed for searching? - # - # Excluded: - # - Files over 0.1MB - # - Non-text files - # - Languages marked as not searchable - # - Generated source files - # - # Please add additional test coverage to - # `test/test_blob.rb#test_indexable` if you make any changes. - # - # Return true or false - def indexable? - if size > 100 * 1024 - false - elsif binary? - false - elsif extname == '.txt' - true - elsif language.nil? - false - elsif !language.searchable? - false - elsif generated? - false - else - true - end - end - # Public: Detects the Language of the blob. # # May load Blob#data diff --git a/test/test_blob.rb b/test/test_blob.rb index 74a247d0..fa96db5d 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -287,20 +287,6 @@ class TestBlob < Test::Unit::TestCase assert blob("Test/fixtures/random.rkt").vendored? end - def test_indexable - assert blob("Ruby/foo.rb").indexable? - assert !blob("Text/defu.nkt").indexable? - assert !blob("Text/dump.sql").indexable? - assert !blob("Binary/github.po").indexable? - assert !blob("Binary/linguist.gem").indexable? - - # large binary blobs should fail on size check first, not call - # into charlock_holmes and alloc big buffers for testing encoding - b = blob("Binary/octocat.ai") - b.expects(:binary?).never - assert !b.indexable? - end - def test_language Samples.each do |sample| blob = blob(sample[:path])