Class: DeployGate::Commands::Deploy::Push

Inherits:
Object
  • Object
show all
Defined in:
lib/deploygate/commands/deploy/push.rb

Constant Summary collapse

BASE_URL =
'https://deploygate.com'
COMMAND =
'push'

Class Method Summary collapse

Class Method Details

.openable?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/deploygate/commands/deploy/push.rb', line 43

def openable?
  RbConfig::CONFIG['host_os'].include?('darwin')
end

.upload(args, options) ⇒ void

This method returns an undefined value.

Parameters:

  • args (Array)
  • options (Commander::Command::Options)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/deploygate/commands/deploy/push.rb', line 13

def upload(args, options)
  session = DeployGate::Session.new()
  unless session.login?
    Login.()
    session = DeployGate::Session.new()
  end

  message          = options.message
  owner            = options.user || session.name
  distribution_key = options.distribution_key
  open             = options.open
  disable_notify   = options.disable_notify
  command          = options.command || COMMAND
  file_path        = args.first

  data = nil
  print I18n.t('commands.deploy.push.upload.loading', owner: owner)
  begin
    data = DeployGate::Deploy.push(command, file_path, owner, message, distribution_key, disable_notify) {
      print '.'
      sleep 0.2
    }
  rescue => e
    upload_error(e)
  end

  upload_success(data, open)
end

.upload_error(error) ⇒ void

This method returns an undefined value.

Parameters:

  • error (StandardError)


65
66
67
68
# File 'lib/deploygate/commands/deploy/push.rb', line 65

def upload_error(error)
  puts HighLine.color(I18n.t('commands.deploy.push.upload_error'), HighLine::RED)
  raise error
end

.upload_success(data, open) ⇒ void

This method returns an undefined value.

Parameters:

  • data (Hash)
  • open (Boolean)


50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/deploygate/commands/deploy/push.rb', line 50

def upload_success(data, open)
  puts HighLine.color(I18n.t('commands.deploy.push.upload_success.done'), HighLine::GREEN)
  puts I18n.t('commands.deploy.push.upload_success.data_message',
              application_name: data[:application_name],
              owner_name: data[:owner_name],
              package_name: data[:package_name],
              revision: data[:revision],
              web_url: data[:web_url])
  if((open || data[:revision] == 1) && openable?)
    Launchy.open(data[:web_url])
  end
end