From 80473e58498ecd80262e7a04a431f2379561b264 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 18 Jun 2011 20:19:34 -0500 Subject: [PATCH] Case-sensitive lexer name lookup --- lib/linguist/lexer.rb | 12 ++++++------ test/test_lexer.rb | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/linguist/lexer.rb b/lib/linguist/lexer.rb index ab7260d0..d3642081 100644 --- a/lib/linguist/lexer.rb +++ b/lib/linguist/lexer.rb @@ -33,7 +33,7 @@ module Linguist # Public: Look up Lexer by its proper name. # - # name - The case-insensitive String name of the Lexer + # name - The String name of the Lexer # # Examples # @@ -42,12 +42,12 @@ module Linguist # # Returns the Lexer or nil if none was found. def self.find_by_name(name) - @name_index[name.downcase] + @name_index[name] end # Public: Look up Lexer by one of its aliases. # - # name - A case-sensitive String alias of the Lexer + # name - A String alias of the Lexer # # Examples # @@ -75,7 +75,7 @@ module Linguist # Public: Look up Lexer by name or alias. # - # name - A case-insensitive String name or alias + # name - A String name or alias # # Lexer['Ruby'] # => # @@ -133,11 +133,11 @@ module Linguist @lexers << lexer # All Lexer names should be unique. Warn if there is a duplicate. - if @name_index.key?(lexer.name.downcase) + if @name_index.key?(lexer.name) warn "Duplicate lexer name: #{lexer.name}" end - @name_index[lexer.name.downcase] = lexer + @name_index[lexer.name] = lexer lexer.aliases.each do |name| # All Lexer aliases should be unique. Warn if there is a duplicate. diff --git a/test/test_lexer.rb b/test/test_lexer.rb index 897a26d0..dc10254d 100644 --- a/test/test_lexer.rb +++ b/test/test_lexer.rb @@ -7,8 +7,6 @@ class TestLexer < Test::Unit::TestCase def test_find_by_name assert_equal Lexer['Ruby'], Lexer.find_by_name('Ruby') - assert_equal Lexer['Ruby'], Lexer.find_by_name('ruby') - assert_equal Lexer['Ruby'], Lexer.find_by_name('RUBY') end def test_find_all_by_name