Class: Codeland::Starter::Integrations::Heroku

Inherits:
Object
  • Object
show all
Defined in:
lib/codeland/starter/integrations/heroku.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeroku

Returns a new instance of Heroku.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/codeland/starter/integrations/heroku.rb', line 10

def initialize
  token = if Configuration['heroku']
            Configuration['heroku']['oauth_token']
          else
            yaml = Starter.config.yaml
            message = "Missing heroku key in #{yaml}"
            missing_config(message)
          end
  @app = {}
  @success = false
  @api = PlatformAPI.connect_oauth(token)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



8
9
10
# File 'lib/codeland/starter/integrations/heroku.rb', line 8

def app
  @app
end

Instance Method Details

#createObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/codeland/starter/integrations/heroku.rb', line 28

def create
  begin
    @app = create_app(Starter.name)
    @success = true
  rescue Excon::Errors::Unauthorized
    yaml = Starter.config.yaml
    missing_config("Please verify the Heroku oauth key in #{yaml}")
  rescue Excon::Errors::UnprocessableEntity
    @app = create_random_app
    @success = true
  ensure
    add_git_remote
  end
end

#outputObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/codeland/starter/integrations/heroku.rb', line 43

def output
  if success?
    puts "    Heroku created with\n    URL: \#{app['web_url']}\n    Git remote: \#{app['git_url']}\n    MESSAGE\n  else\n    puts 'heroku failed'\n    puts app\n  end\nend\n".gsub(/^\s{12}/, '')

#performObject



23
24
25
26
# File 'lib/codeland/starter/integrations/heroku.rb', line 23

def perform
  create
  output
end