Skip to content

Commit

Permalink
Merge branch 'master' into change_modes_to_mimetypes
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Sep 23, 2016
2 parents 88c74fa + 39ea9be commit 6564078
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/linguist/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ def self.colors
# 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

Expand Down Expand Up @@ -306,7 +307,7 @@ def initialize(attributes = {})
# 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 [].
Expand Down
8 changes: 8 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 9 additions & 5 deletions test/test_blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 17 additions & 5 deletions test/test_file_blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@
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)
Expand Down
2 changes: 1 addition & 1 deletion test/test_grammars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def submodule_license(submodule)

# 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
Expand Down
6 changes: 4 additions & 2 deletions test/test_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ def test_ace_mode
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
Expand Down

0 comments on commit 6564078

Please sign in to comment.