Class: Command::App

Inherits:
Object
  • Object
show all
Defined in:
lib/cg/command/app.rb

Class Method Summary collapse

Class Method Details

.create(email = "") ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cg/command/app.rb', line 6

def self.create(email = "")
  response = CG::API.create_app_request(email)
  if response["success"] == false
    response["errors"].each do |k,v|
      puts "#{k.capitalize} #{v.first}\n".red
    end
  else
    puts "Application successfully created.".green
    puts "Add the following lines to the file config/initializers/codegears.rb:\n".green
    puts "require \"cg\"\n".green
    puts "CG::App.configure do |instance|".green
    puts "  instance.id           = \"#{response['id']}\"".green
    puts "  instance.secret_id    = \"#{response['secret_id']}\"".green
    puts "  instance.secret_token = \"#{response['secret_token']}\"\n".green
    puts "end\n".green
    puts "And restart application to start using the CodeGears platform.".green
  end
end

.status(id = "") ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/cg/command/app.rb', line 25

def self.status(id = "")
  response = CG::API.show_app_request(id)
  if response["success"] == false
    puts "Application not found".red
  else
    status = response["active"]
    puts "Active: #{status}".send(status ? :green : :red)
  end
end