mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge pull request #2447 from Ryman/rustup
Split on comma in language name if no match is found
This commit is contained in:
@@ -150,7 +150,7 @@ module Linguist
|
|||||||
#
|
#
|
||||||
# Returns the Language or nil if none was found.
|
# Returns the Language or nil if none was found.
|
||||||
def self.find_by_name(name)
|
def self.find_by_name(name)
|
||||||
name && @name_index[name.downcase]
|
name && (@name_index[name.downcase] || @name_index[name.split(',').first.downcase])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Look up Language by one of its aliases.
|
# Public: Look up Language by one of its aliases.
|
||||||
@@ -164,7 +164,7 @@ module Linguist
|
|||||||
#
|
#
|
||||||
# Returns the Language or nil if none was found.
|
# Returns the Language or nil if none was found.
|
||||||
def self.find_by_alias(name)
|
def self.find_by_alias(name)
|
||||||
name && @alias_index[name.downcase]
|
name && (@alias_index[name.downcase] || @alias_index[name.split(',').first.downcase])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Look up Languages by filename.
|
# Public: Look up Languages by filename.
|
||||||
@@ -240,7 +240,7 @@ module Linguist
|
|||||||
#
|
#
|
||||||
# Returns the Language or nil if none was found.
|
# Returns the Language or nil if none was found.
|
||||||
def self.[](name)
|
def self.[](name)
|
||||||
name && @index[name.downcase]
|
name && (@index[name.downcase] || @index[name.split(',').first.downcase])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: A List of popular languages
|
# Public: A List of popular languages
|
||||||
|
|||||||
2324
samples/Rust/hashmap.rs
Normal file
2324
samples/Rust/hashmap.rs
Normal file
File diff suppressed because it is too large
Load Diff
12
samples/Rust/main.rs
Normal file
12
samples/Rust/main.rs
Normal 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")
|
||||||
|
}
|
||||||
@@ -263,6 +263,18 @@ class TestLanguage < Minitest::Test
|
|||||||
assert_equal 'AGS Script', Language.find_by_alias('AGS').name
|
assert_equal 'AGS Script', Language.find_by_alias('AGS').name
|
||||||
end
|
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
|
def test_name
|
||||||
assert_equal 'Perl', Language['Perl'].name
|
assert_equal 'Perl', Language['Perl'].name
|
||||||
assert_equal 'Python', Language['Python'].name
|
assert_equal 'Python', Language['Python'].name
|
||||||
|
|||||||
Reference in New Issue
Block a user