class PolyglotCli::Command::Pull

Public Class Methods

init(options) click to toggle source
# File lib/polyglot_cli/commands/pull.rb, line 8
def self.init(options)
  new(options).call
end
new(options) click to toggle source
# File lib/polyglot_cli/commands/pull.rb, line 12
def initialize(options)
  @options = options
end

Public Instance Methods

call() click to toggle source
# File lib/polyglot_cli/commands/pull.rb, line 16
def call
  languages(option_locale).each do |language|
    PolyglotCli::IO::Locale.write(locale_path, translation_hash(language))
  end
  update_config
  success
end

Private Instance Methods

locale_path() click to toggle source
# File lib/polyglot_cli/commands/pull.rb, line 26
def locale_path
  option_path || config[:locale_path]
end
option_locale() click to toggle source
# File lib/polyglot_cli/commands/pull.rb, line 30
def option_locale
  @options.locale
end
option_path() click to toggle source
# File lib/polyglot_cli/commands/pull.rb, line 34
def option_path
  @options.path
end
translation_hash(language) click to toggle source
# File lib/polyglot_cli/commands/pull.rb, line 38
def translation_hash(language)
  hash = { language.locale => {} }

  remote_translations(language).each do |t|
    hash[language.locale].deep_merge!(nest(t.translation_key.name, t.value))
  end

  hash
end