Class: I18nliner::Commands::Dump
- Inherits:
-
GenericCommand
- Object
- GenericCommand
- I18nliner::Commands::Dump
- Defined in:
- lib/i18nliner/commands/dump.rb
Instance Attribute Summary collapse
-
#yml_file ⇒ Object
readonly
Returns the value of attribute yml_file.
Instance Method Summary collapse
-
#initialize(options) ⇒ Dump
constructor
A new instance of Dump.
- #run ⇒ Object
Methods inherited from GenericCommand
Methods included from BasicFormatter
Constructor Details
#initialize(options) ⇒ Dump
Returns a new instance of Dump.
9 10 11 12 13 14 |
# File 'lib/i18nliner/commands/dump.rb', line 9 def initialize() super @translations = @options[:translations] @yml_file = @options[:file] || File.join(I18nliner.base_path, "config", "locales", "generated", "#{I18n.default_locale}.yml") end |
Instance Attribute Details
#yml_file ⇒ Object (readonly)
Returns the value of attribute yml_file.
7 8 9 |
# File 'lib/i18nliner/commands/dump.rb', line 7 def yml_file @yml_file end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/i18nliner/commands/dump.rb', line 16 def run FileUtils.mkdir_p File.dirname(yml_file) File.open(yml_file, "w") do |file| file.write({I18n.default_locale.to_s => @translations}.ya2yaml(:syck_compatible => true)) end puts "Wrote default translations to #{yml_file}" unless @options[:silent] end |