mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Add Blob#binary?
This commit is contained in:
		@@ -26,8 +26,12 @@ module Linguist
 | 
				
			|||||||
      defined?(Grit::Submodule) && @blob.kind_of?(Grit::Submodule)
 | 
					      defined?(Grit::Submodule) && @blob.kind_of?(Grit::Submodule)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def binary?
 | 
				
			||||||
 | 
					      mime_type == 'octet-stream' || !(text? || image?)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def file?
 | 
					    def file?
 | 
				
			||||||
      image? || !text? || mime_type == 'octet-stream'
 | 
					      image? || binary?
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def text?
 | 
					    def text?
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,14 @@ class TestBlob < Test::Unit::TestCase
 | 
				
			|||||||
    assert_equal 15, blob("foo.rb").size
 | 
					    assert_equal 15, blob("foo.rb").size
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def test_binary
 | 
				
			||||||
 | 
					    assert blob("linguist.gem").binary?
 | 
				
			||||||
 | 
					    assert blob("git.deb").binary?
 | 
				
			||||||
 | 
					    assert blob("git.exe").binary?
 | 
				
			||||||
 | 
					    assert !blob("file.txt").binary?
 | 
				
			||||||
 | 
					    assert !blob("octocat.png").binary?
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def test_file
 | 
					  def test_file
 | 
				
			||||||
    assert blob("octocat.png").file?
 | 
					    assert blob("octocat.png").file?
 | 
				
			||||||
    assert blob("linguist.gem").file?
 | 
					    assert blob("linguist.gem").file?
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user