Class: Localeapp::CLI::Pull

Inherits:
Command
  • Object
show all
Includes:
ApiCall
Defined in:
lib/localeapp/cli/pull.rb

Instance Method Summary collapse

Methods included from ApiCall

#api_call

Methods inherited from Command

#initialize, #initialize_config, #load_config_file, #set_command_line_arguments

Constructor Details

This class inherits a constructor from Localeapp::CLI::Command

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/localeapp/cli/pull.rb', line 6

def execute
  @output.puts "Localeapp Pull"
  @output.puts ""

  @output.puts "Fetching translations:"
  api_call :export,
    :success => :update_backend,
    :failure => :report_failure,
    :max_connection_attempts => 3
end

#report_failure(response) ⇒ Object



25
26
27
# File 'lib/localeapp/cli/pull.rb', line 25

def report_failure(response)
  @output.puts "Failed!"
end

#update_backend(response) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/localeapp/cli/pull.rb', line 17

def update_backend(response)
  @output.puts "Success!"
  @output.puts "Updating backend:"
  Localeapp.updater.dump(Localeapp.load_yaml(response))
  @output.puts "Success!"
  Localeapp.poller.write_synchronization_data!(Time.now.to_i, Time.now.to_i)
end