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.
|
||||
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 caller
|
||||
@ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase }
|
||||
end
|
||||
|
||||
@@ -306,7 +307,7 @@ module Linguist
|
||||
# Set legacy search term
|
||||
@search_term = attributes[:search_term] || default_alias_name
|
||||
|
||||
# Set the language_id
|
||||
# Set the language_id
|
||||
@language_id = attributes[:language_id]
|
||||
|
||||
# Set extensions or default to [].
|
||||
|
||||
@@ -35,3 +35,11 @@ def sample_blob_memory(name)
|
||||
content = File.read(filepath)
|
||||
Linguist::Blob.new(name, content)
|
||||
end
|
||||
|
||||
def silence_warnings
|
||||
original_verbosity = $VERBOSE
|
||||
$VERBOSE = nil
|
||||
yield
|
||||
ensure
|
||||
$VERBOSE = original_verbosity
|
||||
end
|
||||
|
||||
@@ -4,14 +4,18 @@ class TestBlob < Minitest::Test
|
||||
include Linguist
|
||||
|
||||
def setup
|
||||
# git blobs are normally loaded as ASCII-8BIT since they may contain data
|
||||
# with arbitrary encoding not known ahead of time
|
||||
@original_external = Encoding.default_external
|
||||
Encoding.default_external = Encoding.find("ASCII-8BIT")
|
||||
silence_warnings do
|
||||
# git blobs are normally loaded as ASCII-8BIT since they may contain data
|
||||
# with arbitrary encoding not known ahead of time
|
||||
@original_external = Encoding.default_external
|
||||
Encoding.default_external = Encoding.find("ASCII-8BIT")
|
||||
end
|
||||
end
|
||||
|
||||
def teardown
|
||||
Encoding.default_external = @original_external
|
||||
silence_warnings do
|
||||
Encoding.default_external = @original_external
|
||||
end
|
||||
end
|
||||
|
||||
def script_blob(name)
|
||||
|
||||
@@ -3,15 +3,27 @@ require_relative "./helper"
|
||||
class TestFileBlob < Minitest::Test
|
||||
include Linguist
|
||||
|
||||
def silence_warnings
|
||||
original_verbosity = $VERBOSE
|
||||
$VERBOSE = nil
|
||||
yield
|
||||
ensure
|
||||
$VERBOSE = original_verbosity
|
||||
end
|
||||
|
||||
def setup
|
||||
# git blobs are normally loaded as ASCII-8BIT since they may contain data
|
||||
# with arbitrary encoding not known ahead of time
|
||||
@original_external = Encoding.default_external
|
||||
Encoding.default_external = Encoding.find("ASCII-8BIT")
|
||||
silence_warnings do
|
||||
# git blobs are normally loaded as ASCII-8BIT since they may contain data
|
||||
# with arbitrary encoding not known ahead of time
|
||||
@original_external = Encoding.default_external
|
||||
Encoding.default_external = Encoding.find("ASCII-8BIT")
|
||||
end
|
||||
end
|
||||
|
||||
def teardown
|
||||
Encoding.default_external = @original_external
|
||||
silence_warnings do
|
||||
Encoding.default_external = @original_external
|
||||
end
|
||||
end
|
||||
|
||||
def script_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
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -345,8 +345,10 @@ class TestLanguage < Minitest::Test
|
||||
end
|
||||
|
||||
def test_ace_modes
|
||||
assert Language.ace_modes.include?(Language['Ruby'])
|
||||
assert Language.ace_modes.include?(Language['FORTRAN'])
|
||||
silence_warnings do
|
||||
assert Language.ace_modes.include?(Language['Ruby'])
|
||||
assert Language.ace_modes.include?(Language['FORTRAN'])
|
||||
end
|
||||
end
|
||||
|
||||
def test_codemirror_mode
|
||||
|
||||
Reference in New Issue
Block a user