Skip to content

Commit

Permalink
rename CaseIgnoringWordList to WordList::CaseIgnoring
Browse files Browse the repository at this point in the history
  • Loading branch information
korny committed Aug 19, 2011
1 parent 5b0d3ed commit 5dd7ca6
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
1 change: 1 addition & 0 deletions Changes-1.0.textile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ h3. @WordList@


Stripped down to 19 LOC. Stripped down to 19 LOC.


* *RENAMED* @CaseIgnoringWordList@ to @WordList::CaseIgnoring@
* *REMOVED* caching option because it creates memory leaks. * *REMOVED* caching option because it creates memory leaks.
* *REMOVED* block option. * *REMOVED* block option.


Expand Down
8 changes: 4 additions & 4 deletions etc/CodeRay.tmproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
<string>../README_INDEX.rdoc</string> <string>../README_INDEX.rdoc</string>
<key>lastUsed</key> <key>lastUsed</key>
<date>2011-08-19T02:16:06Z</date> <date>2011-08-19T02:16:06Z</date>
<key>selected</key>
<true/>
</dict> </dict>
<dict> <dict>
<key>filename</key> <key>filename</key>
<string>../README.textile</string> <string>../README.textile</string>
<key>lastUsed</key> <key>lastUsed</key>
<date>2011-08-19T02:05:36Z</date> <date>2011-08-19T02:29:46Z</date>
<key>selected</key>
<true/>
</dict> </dict>
<dict> <dict>
<key>filename</key> <key>filename</key>
<string>../.travis.yml</string> <string>../.travis.yml</string>
<key>lastUsed</key> <key>lastUsed</key>
<date>2011-08-19T02:05:37Z</date> <date>2011-08-19T02:21:33Z</date>
</dict> </dict>
<dict> <dict>
<key>filename</key> <key>filename</key>
Expand Down
6 changes: 3 additions & 3 deletions lib/coderay/helpers/word_list.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module CodeRay
# WordList is optimized to be used in Scanners, # WordList is optimized to be used in Scanners,
# typically to decide whether a given ident is a special token. # typically to decide whether a given ident is a special token.
# #
# For case insensitive words use CaseIgnoringWordList. # For case insensitive words use WordList::CaseIgnoring.
# #
# Example: # Example:
# #
Expand Down Expand Up @@ -60,9 +60,9 @@ def add words, value = true
end end




# A CaseIgnoringWordList is like a WordList, only that # A CaseIgnoring WordList is like a WordList, only that
# keys are compared case-insensitively (normalizing keys using +downcase+). # keys are compared case-insensitively (normalizing keys using +downcase+).
class CaseIgnoringWordList < WordList class WordList::CaseIgnoring < WordList


def [] key def [] key
super key.downcase super key.downcase
Expand Down
4 changes: 1 addition & 3 deletions lib/coderay/scanner.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
module CodeRay module CodeRay


autoload :WordList, 'coderay/helpers/word_list' autoload :WordList, 'coderay/helpers/word_list'
# FIXME: Rename CaseIgnoringWordList to WordList::CaseIgnoring.
autoload :CaseIgnoringWordList, 'coderay/helpers/word_list'


# = Scanners # = Scanners
# #
Expand Down Expand Up @@ -155,7 +153,7 @@ def initialize code = '', options = {}
setup setup
end end


# Sets back the scanner. Subclasses should to define the reset_instance # Sets back the scanner. Subclasses should redefine the reset_instance
# method instead of this one. # method instead of this one.
def reset def reset
super super
Expand Down
4 changes: 2 additions & 2 deletions lib/coderay/scanners/delphi.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class Delphi < Scanner
'virtual', 'write', 'writeonly', 'virtual', 'write', 'writeonly',
] # :nodoc: ] # :nodoc:


IDENT_KIND = CaseIgnoringWordList.new(:ident). IDENT_KIND = WordList::CaseIgnoring.new(:ident).
add(KEYWORDS, :keyword). add(KEYWORDS, :keyword).
add(DIRECTIVES, :directive) # :nodoc: add(DIRECTIVES, :directive) # :nodoc:


NAME_FOLLOWS = CaseIgnoringWordList.new(false). NAME_FOLLOWS = WordList::CaseIgnoring.new(false).
add(%w(procedure function .)) # :nodoc: add(%w(procedure function .)) # :nodoc:


protected protected
Expand Down
5 changes: 2 additions & 3 deletions lib/coderay/scanners/html.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HTML < Scanner
onvolumechange onwaiting onvolumechange onwaiting
) )


IN_ATTRIBUTE = CaseIgnoringWordList.new(nil). IN_ATTRIBUTE = WordList::CaseIgnoring.new(nil).
add(EVENT_ATTRIBUTES, :script) add(EVENT_ATTRIBUTES, :script)


ATTR_NAME = /[\w.:-]+/ # :nodoc: ATTR_NAME = /[\w.:-]+/ # :nodoc:
Expand All @@ -58,8 +58,7 @@ class HTML < Scanner
'"' => /[^&">\n]+/, '"' => /[^&">\n]+/,
} # :nodoc: } # :nodoc:


def reset # :nodoc: def reset_instance # :nodoc:
# FIXME: why not overwrite reset_instance?
super super
@state = :initial @state = :initial
end end
Expand Down
2 changes: 1 addition & 1 deletion lib/coderay/scanners/php.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ module Words # :nodoc:
$argc $argv $argc $argv
] ]


IDENT_KIND = CaseIgnoringWordList.new(:ident). IDENT_KIND = WordList::CaseIgnoring.new(:ident).
add(KEYWORDS, :keyword). add(KEYWORDS, :keyword).
add(TYPES, :predefined_type). add(TYPES, :predefined_type).
add(LANGUAGE_CONSTRUCTS, :keyword). add(LANGUAGE_CONSTRUCTS, :keyword).
Expand Down
2 changes: 1 addition & 1 deletion lib/coderay/scanners/sql.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SQL < Scanner


PREDEFINED_CONSTANTS = %w( null true false ) PREDEFINED_CONSTANTS = %w( null true false )


IDENT_KIND = CaseIgnoringWordList.new(:ident). IDENT_KIND = WordList::CaseIgnoring.new(:ident).
add(KEYWORDS, :keyword). add(KEYWORDS, :keyword).
add(OBJECTS, :type). add(OBJECTS, :type).
add(COMMANDS, :class). add(COMMANDS, :class).
Expand Down
4 changes: 2 additions & 2 deletions test/unit/word_list.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def test_word_list
end end


def test_case_ignoring_word_list def test_case_ignoring_word_list
list = CaseIgnoringWordList.new(:ident).add(['foobar'], :reserved) list = WordList::CaseIgnoring.new(:ident).add(['foobar'], :reserved)
assert_equal :ident, list['foo'] assert_equal :ident, list['foo']
assert_equal :reserved, list['foobar'] assert_equal :reserved, list['foobar']
assert_equal :reserved, list['FooBar'] assert_equal :reserved, list['FooBar']
assert_equal 1, list.size assert_equal 1, list.size


list = CaseIgnoringWordList.new(:ident).add(['FooBar'], :reserved) list = WordList::CaseIgnoring.new(:ident).add(['FooBar'], :reserved)
assert_equal :ident, list['foo'] assert_equal :ident, list['foo']
assert_equal :reserved, list['foobar'] assert_equal :reserved, list['foobar']
assert_equal :reserved, list['FooBar'] assert_equal :reserved, list['FooBar']
Expand Down

0 comments on commit 5dd7ca6

Please sign in to comment.