Sha256: 85aa7a8cd7b4072a5f3af49dab7ede7f0874b9a15f287a9fa430927275ddc1ea

Contents?: true

Size: 911 Bytes

Versions: 10

Compression:

Stored size: 911 Bytes

Contents

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

      def execute(locale_key = nil)
        @locale_key = locale_key
        @output.puts "Localeapp Pull\n\n" \
          "Fetching#{locale_key ? ' ' << locale_key : ''} translations:"

        api_call :export,
          :success => :update_backend,
          :failure => :report_failure,
          :max_connection_attempts => 1
      end

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

      def report_failure(response)
        @output.puts "Failed!"
        fail APIResponseError, "API returned #{response.code} status code"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
localeapp-3.3.0 lib/localeapp/cli/pull.rb
localeapp-3.2.0 lib/localeapp/cli/pull.rb
localeapp-3.1.3 lib/localeapp/cli/pull.rb
localeapp-3.1.2 lib/localeapp/cli/pull.rb
localeapp-3.1.1 lib/localeapp/cli/pull.rb
localeapp-3.1.0 lib/localeapp/cli/pull.rb
localeapp-3.0.1 lib/localeapp/cli/pull.rb
localeapp-3.0.0 lib/localeapp/cli/pull.rb
localeapp-2.5.0 lib/localeapp/cli/pull.rb
localeapp-2.4.0 lib/localeapp/cli/pull.rb