Class: Romajic::Cop
- Inherits:
-
Object
- Object
- Romajic::Cop
- Defined in:
- lib/romajic/cop.rb
Overview
Search logic class of Romajic
Constant Summary collapse
- TARGET_KINDS =
CodeRay::TokenKinds.keys
Instance Method Summary collapse
-
#initialize(options) ⇒ Cop
constructor
Initialize a new Cop object.
-
#search ⇒ Object
Search romaji in the source files.
Constructor Details
Instance Method Details
#search ⇒ Object
Search romaji in the source files
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/romajic/cop.rb', line 26 def search Dir.glob(@config.target_file_pattern, File::FNM_CASEFOLD).each do |file_path| next if FileTest.directory?(file_path) extension = File.extname(file_path).sub(/^./, '').downcase if extension.empty? tokens = CodeRay.scan(File.read(file_path), :txt).tokens search_in_plain_text(tokens, file_path) else tokens = CodeRay.scan(File.read(file_path), extension.to_sym).tokens search_in_tokens(tokens, file_path) end end nil end |