Sha256: d7f273536504d38c034276d40cff1585326d364f7586020c92cddbb3fc3072a4

Contents?: true

Size: 827 Bytes

Versions: 8

Compression:

Stored size: 827 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(JSON.parse(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

8 entries across 8 versions & 1 rubygems

Version Path
localeapp-0.3.1 lib/localeapp/cli/pull.rb
localeapp-0.3.0 lib/localeapp/cli/pull.rb
localeapp-0.2.0 lib/localeapp/cli/pull.rb
localeapp-0.1.2 lib/localeapp/cli/pull.rb
localeapp-0.1.1 lib/localeapp/cli/pull.rb
localeapp-0.0.11 lib/localeapp/cli/pull.rb
localeapp-0.0.10 lib/localeapp/cli/pull.rb
localeapp-0.0.8 lib/localeapp/cli/pull.rb