Class: ElasticDot::Command::Apps

Inherits:
Base
  • Object
show all
Defined in:
lib/elasticdot/command/apps.rb

Class Method Summary collapse

Class Method Details

.create(args, opts) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/elasticdot/command/apps.rb', line 2

def self.create(args, opts)
  info = api.post '/domains', domain: args[0]

  if info['error']
    puts info['error']
    exit 1
  end

  puts "Creating app #{info['app_name']}... done"
  puts "http://#{info['app_name']}.elasticdot.io/ | #{info['app_repo']}"

  create_git_remote 'elasticdot', info['app_repo']
end

.destroy(opts) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/elasticdot/command/apps.rb', line 27

def self.destroy(opts)
  find_app! opts

  spinner "Destroying app #{@app}..." do
    api.delete "/domains/#{@app}"
  end
end

.info(opts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/elasticdot/command/apps.rb', line 35

def self.info(opts)
  find_app! opts

  h = api.get "/domains/#{@app}"

  puts "=== #{@app}"
  puts
  puts "Git URL:\t#{h['git_repo']}"
  puts "Owner Email:\t#{h['owner_email']}"
  puts "Region:\t\tEU"
  #   puts "Slug Size:\t#{h['slug_size']}"
  puts "Web URL:\thttp://#{h['live_address']}"

  return unless (db = h['db'])

  puts
  puts "=== Database #{db['identifier']}"
  puts "Plan:           \t#{db['plan']['name']}"
  puts "Nodes:          \t#{db['plan']['nodes']}" unless db['plan']['shared']
  puts "Version:        \t#{db['version']}"
  puts "Status:         \t#{db['status']}"
  puts "Name:           \t#{db['name']}"
  puts "User:           \t#{db['user']}"
  puts "Password:       \t#{db['pass']}"
  puts "URI:            \t#{db['uri']}"
  puts "Tables:         \t#{db['tables']}"
  puts "Disk Space Used:\t#{db['space_used']}"
  puts "AVG CPU Load:   \t#{db['cpu_load']}"
  puts "Created at:     \t#{db['created_at']}"
end

.listObject



66
67
68
69
70
# File 'lib/elasticdot/command/apps.rb', line 66

def self.list
  apps = api.get "/apps?type=web"
  puts '=== My Apps'
  apps.each { |app| puts app }
end

.open(opts) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/elasticdot/command/apps.rb', line 16

def self.open(opts)
  require 'launchy'

  find_app! opts

  spinner "Opening #{@app}..." do
    info = api.get "/domains/#{@app}"
    Launchy.open info['live_address']
  end
end