Sha256: d7ddba49e70310d13c3d22d678f0c9764ef72abb96e1fcfde4c09db4329dbc1b

Contents?: true

Size: 826 Bytes

Versions: 3

Compression:

Stored size: 826 Bytes

Contents

module Localeapp
  module CLI
    class Pull
      include ::Localeapp::ApiCall

      def initialize(output = $stdout)
        @output = output
      end

      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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
localeapp-0.4.1 lib/localeapp/cli/pull.rb
localeapp-0.4.0 lib/localeapp/cli/pull.rb
localeapp-0.3.2 lib/localeapp/cli/pull.rb