Class: I18nliner::Processors::AbstractProcessor
- Inherits:
-
Object
- Object
- I18nliner::Processors::AbstractProcessor
- Defined in:
- lib/i18nliner/processors/abstract_processor.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file_count ⇒ Object
readonly
Returns the value of attribute file_count.
-
#translation_count ⇒ Object
readonly
Returns the value of attribute translation_count.
Class Method Summary collapse
Instance Method Summary collapse
- #check_file(file) ⇒ Object
- #check_files ⇒ Object
- #files ⇒ Object
-
#initialize(translations, options = {}) ⇒ AbstractProcessor
constructor
A new instance of AbstractProcessor.
- #noop_checker(file) {|file| ... } ⇒ Object
Constructor Details
#initialize(translations, options = {}) ⇒ AbstractProcessor
Returns a new instance of AbstractProcessor.
10 11 12 13 14 15 16 17 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 10 def initialize(translations, = {}) @translations = translations @translation_count = 0 @file_count = 0 @only = [:only] @checker = [:checker] || method(:noop_checker) @pattern = [:pattern] || self.class.default_pattern end |
Instance Attribute Details
#file_count ⇒ Object (readonly)
Returns the value of attribute file_count.
8 9 10 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 8 def file_count @file_count end |
#translation_count ⇒ Object (readonly)
Returns the value of attribute translation_count.
8 9 10 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 8 def translation_count @translation_count end |
Class Method Details
.default_pattern(*pattern) ⇒ Object
48 49 50 51 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 48 def self.default_pattern(*pattern) @pattern ||= [] @pattern.concat(pattern) end |
.inherited(klass) ⇒ Object
44 45 46 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 44 def self.inherited(klass) Processors.register klass end |
Instance Method Details
#check_file(file) ⇒ Object
39 40 41 42 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 39 def check_file(file) @file_count += 1 check_contents(source_for(file), scope_for(file)) end |
#check_files ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 31 def check_files Dir.chdir(I18nliner.base_path) do files.each do |file| @checker.call file, &method(:check_file) end end end |
#files ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 23 def files @files ||= begin files = Globby.select(Array(@pattern)) files = files.select(Array(@only.dup)) if @only files.reject(I18nliner.ignore) end end |
#noop_checker(file) {|file| ... } ⇒ Object
19 20 21 |
# File 'lib/i18nliner/processors/abstract_processor.rb', line 19 def noop_checker(file) yield file end |