Class: Localeapp::CLI::Push

Inherits:
Object
  • Object
show all
Includes:
ApiCall
Defined in:
lib/localeapp/cli/push.rb

Instance Method Summary collapse

Methods included from ApiCall

#api_call

Constructor Details

#initialize(output = $stdout) ⇒ Push

Returns a new instance of Push.



6
7
8
# File 'lib/localeapp/cli/push.rb', line 6

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

Instance Method Details

#execute(file_path = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/localeapp/cli/push.rb', line 10

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

#report_failure(response) ⇒ Object



35
36
37
# File 'lib/localeapp/cli/push.rb', line 35

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

#report_success(response) ⇒ Object



29
30
31
32
33
# File 'lib/localeapp/cli/push.rb', line 29

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