Class: ExtractI18n::Adapters::RubyAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/extract_i18n/adapters/ruby_adapter.rb

Instance Attribute Summary

Attributes inherited from Adapter

#file_key, #file_path, #on_ask, #options

Instance Method Summary collapse

Methods inherited from Adapter

for, #initialize, supports_relative_keys?

Constructor Details

This class inherits a constructor from ExtractI18n::Adapters::Adapter

Instance Method Details

#run(original_content) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/extract_i18n/adapters/ruby_adapter.rb', line 12

def run(original_content)
  buffer        = Parser::Source::Buffer.new('(example)')
  buffer.source = original_content
  temp = Parser::CurrentRuby.parse(original_content)
  rewriter = ExtractI18n::Adapters::Rewriter.new(
    file_key: file_key,
    on_ask: on_ask
  )
  # Rewrite the AST, returns a String with the new form.
  rewriter.rewrite(buffer, temp)
  # rescue StandardError => e
  #   puts 'Parsing error'
  #   puts e.inspect
end