Class: ExtractI18n::FileProcessor
- Inherits:
-
Object
- Object
- ExtractI18n::FileProcessor
- Defined in:
- lib/extract_i18n/file_processor.rb
Constant Summary collapse
- PROMPT =
TTY::Prompt.new
- PASTEL =
Pastel.new
Instance Method Summary collapse
-
#initialize(file_path:, write_to:, locale:, options: {}) ⇒ FileProcessor
constructor
A new instance of FileProcessor.
- #run ⇒ Object
Constructor Details
#initialize(file_path:, write_to:, locale:, options: {}) ⇒ FileProcessor
Returns a new instance of FileProcessor.
13 14 15 16 17 18 19 20 21 |
# File 'lib/extract_i18n/file_processor.rb', line 13 def initialize(file_path:, write_to:, locale:, options: {}) @file_path = file_path @file_key = ExtractI18n.file_key(@file_path) @locale = locale @write_to = write_to @options = @i18n_changes = {} end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/extract_i18n/file_processor.rb', line 23 def run puts " reading #{@file_path}" read_and_transform do |result| puts Diffy::Diff.new(original_content, result, context: 1).to_s(:color) if PROMPT.yes?("Save changes?") File.write(@file_path, result) update_i18n_yml_file puts PASTEL.green("Saved #{@file_path}") end end end |