Class: Localeapp::CLI::Pull
- Inherits:
-
Object
- Object
- Localeapp::CLI::Pull
- Includes:
- ApiCall
- Defined in:
- lib/localeapp/cli/pull.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(output = $stdout) ⇒ Pull
constructor
A new instance of Pull.
- #report_failure(response) ⇒ Object
- #update_backend(response) ⇒ Object
Methods included from ApiCall
Constructor Details
#initialize(output = $stdout) ⇒ Pull
Returns a new instance of Pull.
6 7 8 |
# File 'lib/localeapp/cli/pull.rb', line 6 def initialize(output = $stdout) @output = output end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/localeapp/cli/pull.rb', line 10 def execute @output.puts "Localeapp Pull" @output.puts "" @output.puts "Fetching translations:" api_call :translations, :success => :update_backend, :failure => :report_failure, :max_connection_attempts => 3 end |
#report_failure(response) ⇒ Object
29 30 31 |
# File 'lib/localeapp/cli/pull.rb', line 29 def report_failure(response) @output.puts "Failed!" end |
#update_backend(response) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/localeapp/cli/pull.rb', line 21 def update_backend(response) @output.puts "Success!" @output.puts "Updating backend:" Localeapp.updater.update(JSON.parse(response)) @output.puts "Success!" Localeapp.poller.write_synchronization_data!(Time.now.to_i, Time.now.to_i) end |