Class: ToptranslationCli::Pull

Inherits:
Object
  • Object
show all
Defined in:
lib/toptranslation_cli/pull.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePull



14
15
16
17
18
19
20
# File 'lib/toptranslation_cli/pull.rb', line 14

def initialize
  ToptranslationCli.configuration.load

  @pastel = Pastel.new
  @spinner_settings = { success_mark: @pastel.green('+'), error_mark: @pastel.red('-') }
  @spinner = TTY::Spinner.new("[#{@pastel.yellow(':spinner')}] :title", @spinner_settings)
end

Class Method Details

.runObject



10
11
12
# File 'lib/toptranslation_cli/pull.rb', line 10

def self.run
  new.run
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/toptranslation_cli/pull.rb', line 22

def run
  changed = changed_files(remote_files, local_files)
  download_files(changed)
rescue RestClient::BadRequest
  @spinner.error(@pastel.red('invalid access token')) if @spinner.spinning?
  exit 1
rescue RestClient::NotFound
  @spinner.error(@pastel.red('project not found')) if @spinner.spinning?
  exit 1
end