Class: I18nliner::Processors::RubyProcessor
Constant Summary
collapse
- CONTROLLER_PATH =
%r{\A(.*/)?app/controllers/(.*)_controller\.rb\z}
Instance Attribute Summary
#file_count, #translation_count
Instance Method Summary
collapse
#check_file, #check_files, default_pattern, #files, inherited, #initialize, #noop_checker
Instance Method Details
#check_contents(source, scope = Scope.new) ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/i18nliner/processors/ruby_processor.rb', line 11
def check_contents(source, scope = Scope.new)
return if source !~ Extractors::RubyExtractor.pattern
sexps = RubyParser.new.parse(pre_process(source))
= Extractors::RubyExtractor.new(sexps, scope)
.each_translation do |key, value|
@translation_count += 1
@translations.line = .current_line
@translations[key] = value
end
end
|
#pre_process(source) ⇒ Object
43
44
45
|
# File 'lib/i18nliner/processors/ruby_processor.rb', line 43
def pre_process(source)
source
end
|
#scope_for(path) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/i18nliner/processors/ruby_processor.rb', line 28
def scope_for(path)
scope = path.dup
if scope.sub!(CONTROLLER_PATH, '\2')
scope = scope.gsub(/\/_?/, '.')
ControllerScope.new(scope, :allow_relative => true, :context => self)
else
Scope.root
end
end
|
#source_for(file) ⇒ Object
22
23
24
|
# File 'lib/i18nliner/processors/ruby_processor.rb', line 22
def source_for(file)
File.read(file)
end
|