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'

Class Method Summary collapse

Class Method Details

.openable?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/deploygate/commands/deploy/push.rb', line 40

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)


12
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
# File 'lib/deploygate/commands/deploy/push.rb', line 12

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

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

  data = nil
  print "Uploading to #{owner}.."
  begin
    data = DeployGate::Deploy.push(file_path, owner, message, 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)


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

def upload_error(error)
  Message::Error.print('failed')
  raise error
end

.upload_success(data, open) ⇒ void

This method returns an undefined value.

Parameters:

  • data (Hash)
  • open (Boolean)


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

def upload_success(data, open)
  Message::Success.print('done')
  data_message = "Name: \\t\\t \#{data[:application_name]}\nOwner: \\t\\t \#{data[:owner_name]}\nPackage: \\t \#{data[:package_name]}\nRevision: \\t \#{data[:revision]}\nURL: \\t\\t \#{data[:web_url]}\n"
  puts(data_message)
  if((open || data[:revision] == 1) && openable?)
    system "open #{data[:web_url]}"
  end
end