Sha256: c8e1a5c01e7a48fb63d062052f21f2f3bc1046dee924edc89194e9ced6f4caff

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

module Localeapp
  module CLI
    class Push
      include ::Localeapp::ApiCall

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

      def execute(file_path = nil)
        @output.puts "Localeapp Push"
        @output.puts ""

        @file_path = file_path

        file = sanitize_file(file_path)
        if file
          @output.puts "Pushing file:"
          api_call :import,
            :payload => { :file => file },
            :success => :report_success,
            :failure => :report_failure,
            :max_connection_attempts => 3
        else
          @output.puts "Could not load file"
        end
      end

      def report_success(response)
        @output.puts "Success!"
        @output.puts ""
        @output.puts "#{@file_path} queued for processing."
      end

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

      private
      def sanitize_file(file_path)
        if File.exist?(file_path)
          File.new(file_path)
        else
          nil
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
localeapp-0.2.0 lib/localeapp/cli/push.rb
localeapp-0.1.2 lib/localeapp/cli/push.rb
localeapp-0.1.1 lib/localeapp/cli/push.rb
localeapp-0.0.11 lib/localeapp/cli/push.rb
localeapp-0.0.10 lib/localeapp/cli/push.rb
localeapp-0.0.8 lib/localeapp/cli/push.rb