mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Merge branch 'master' into change_modes_to_mimetypes
This commit is contained in:
		| @@ -267,6 +267,7 @@ module Linguist | |||||||
|     # Returns an Array of Languages. |     # Returns an Array of Languages. | ||||||
|     def self.ace_modes |     def self.ace_modes | ||||||
|       warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set." |       warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set." | ||||||
|  |       warn caller | ||||||
|       @ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase } |       @ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase } | ||||||
|     end |     end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -35,3 +35,11 @@ def sample_blob_memory(name) | |||||||
|   content = File.read(filepath) |   content = File.read(filepath) | ||||||
|   Linguist::Blob.new(name, content) |   Linguist::Blob.new(name, content) | ||||||
| end | end | ||||||
|  |  | ||||||
|  | def silence_warnings | ||||||
|  |   original_verbosity = $VERBOSE | ||||||
|  |   $VERBOSE = nil | ||||||
|  |   yield | ||||||
|  | ensure | ||||||
|  |   $VERBOSE = original_verbosity | ||||||
|  | end | ||||||
|   | |||||||
| @@ -4,15 +4,19 @@ class TestBlob < Minitest::Test | |||||||
|   include Linguist |   include Linguist | ||||||
|  |  | ||||||
|   def setup |   def setup | ||||||
|  |     silence_warnings do | ||||||
|       # git blobs are normally loaded as ASCII-8BIT since they may contain data |       # git blobs are normally loaded as ASCII-8BIT since they may contain data | ||||||
|       # with arbitrary encoding not known ahead of time |       # with arbitrary encoding not known ahead of time | ||||||
|       @original_external = Encoding.default_external |       @original_external = Encoding.default_external | ||||||
|       Encoding.default_external = Encoding.find("ASCII-8BIT") |       Encoding.default_external = Encoding.find("ASCII-8BIT") | ||||||
|     end |     end | ||||||
|  |   end | ||||||
|  |  | ||||||
|   def teardown |   def teardown | ||||||
|  |     silence_warnings do | ||||||
|       Encoding.default_external = @original_external |       Encoding.default_external = @original_external | ||||||
|     end |     end | ||||||
|  |   end | ||||||
|  |  | ||||||
|   def script_blob(name) |   def script_blob(name) | ||||||
|     blob = sample_blob_memory(name) |     blob = sample_blob_memory(name) | ||||||
|   | |||||||
| @@ -3,16 +3,28 @@ require_relative "./helper" | |||||||
| class TestFileBlob < Minitest::Test | class TestFileBlob < Minitest::Test | ||||||
|   include Linguist |   include Linguist | ||||||
|  |  | ||||||
|  |   def silence_warnings | ||||||
|  |     original_verbosity = $VERBOSE | ||||||
|  |     $VERBOSE = nil | ||||||
|  |     yield | ||||||
|  |   ensure | ||||||
|  |     $VERBOSE = original_verbosity | ||||||
|  |   end | ||||||
|  |  | ||||||
|   def setup |   def setup | ||||||
|  |     silence_warnings do | ||||||
|       # git blobs are normally loaded as ASCII-8BIT since they may contain data |       # git blobs are normally loaded as ASCII-8BIT since they may contain data | ||||||
|       # with arbitrary encoding not known ahead of time |       # with arbitrary encoding not known ahead of time | ||||||
|       @original_external = Encoding.default_external |       @original_external = Encoding.default_external | ||||||
|       Encoding.default_external = Encoding.find("ASCII-8BIT") |       Encoding.default_external = Encoding.find("ASCII-8BIT") | ||||||
|     end |     end | ||||||
|  |   end | ||||||
|  |  | ||||||
|   def teardown |   def teardown | ||||||
|  |     silence_warnings do | ||||||
|       Encoding.default_external = @original_external |       Encoding.default_external = @original_external | ||||||
|     end |     end | ||||||
|  |   end | ||||||
|  |  | ||||||
|   def script_blob(name) |   def script_blob(name) | ||||||
|     blob = sample_blob(name) |     blob = sample_blob(name) | ||||||
|   | |||||||
| @@ -154,7 +154,7 @@ class TestGrammars < Minitest::Test | |||||||
|  |  | ||||||
|     # Neither Licensee nor our own regex was able to detect the license, let's check the readme |     # Neither Licensee nor our own regex was able to detect the license, let's check the readme | ||||||
|     files = Dir[File.join(ROOT, submodule, "*")] |     files = Dir[File.join(ROOT, submodule, "*")] | ||||||
|     if readme = files.find { |path| File.basename(path) =~ /\Areadme\b/i } |     if readme = files.find { |file| File.basename(file) =~ /\Areadme\b/i } | ||||||
|       classify_license(readme) |       classify_license(readme) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|   | |||||||
| @@ -345,9 +345,11 @@ class TestLanguage < Minitest::Test | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   def test_ace_modes |   def test_ace_modes | ||||||
|  |     silence_warnings do | ||||||
|       assert Language.ace_modes.include?(Language['Ruby']) |       assert Language.ace_modes.include?(Language['Ruby']) | ||||||
|       assert Language.ace_modes.include?(Language['FORTRAN']) |       assert Language.ace_modes.include?(Language['FORTRAN']) | ||||||
|     end |     end | ||||||
|  |   end | ||||||
|  |  | ||||||
|   def test_codemirror_mode |   def test_codemirror_mode | ||||||
|     assert_equal 'text/x-c++src', Language['C++'].codemirror_mode |     assert_equal 'text/x-c++src', Language['C++'].codemirror_mode | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user