Merge pull request #2447 from Ryman/rustup

Split on comma in language name if no match is found
This commit is contained in:
Arfon Smith
2015-08-07 10:28:21 +01:00
4 changed files with 2351 additions and 3 deletions

View File

@@ -150,7 +150,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.find_by_name(name)
name && @name_index[name.downcase]
name && (@name_index[name.downcase] || @name_index[name.split(',').first.downcase])
end
# Public: Look up Language by one of its aliases.
@@ -164,7 +164,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.find_by_alias(name)
name && @alias_index[name.downcase]
name && (@alias_index[name.downcase] || @alias_index[name.split(',').first.downcase])
end
# Public: Look up Languages by filename.
@@ -240,7 +240,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.[](name)
name && @index[name.downcase]
name && (@index[name.downcase] || @index[name.split(',').first.downcase])
end
# Public: A List of popular languages

2324
samples/Rust/hashmap.rs Normal file

File diff suppressed because it is too large Load Diff

12
samples/Rust/main.rs Normal file
View File

@@ -0,0 +1,12 @@
extern crate foo;
extern crate bar;
use foo::{self, quix};
use bar::car::*;
use bar;
fn main() {
println!("Hello {}", "World");
panic!("Goodbye")
}

View File

@@ -263,6 +263,18 @@ class TestLanguage < Minitest::Test
assert_equal 'AGS Script', Language.find_by_alias('AGS').name
end
def test_find_ignores_comma
assert_equal 'Rust', Language['rust,no_run'].name
end
def test_find_by_name_ignores_comma
assert_equal Language['Rust'], Language.find_by_name('rust,no_run')
end
def test_find_by_alias_ignores_comma
assert_equal Language['Rust'], Language.find_by_alias('rust,no_run')
end
def test_name
assert_equal 'Perl', Language['Perl'].name
assert_equal 'Python', Language['Python'].name