Skip to content

Commit

Permalink
Axe indexable?
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jun 10, 2013
1 parent b1a1371 commit 032125b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
30 changes: 0 additions & 30 deletions lib/linguist/blob_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,36 +278,6 @@ def generated?
@_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
Expand Down
14 changes: 0 additions & 14 deletions test/test_blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,6 @@ def test_vendored
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])
Expand Down

0 comments on commit 032125b

Please sign in to comment.