Class: HerokuHelper::Heroku

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku-helper/heroku.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Heroku

Returns a new instance of Heroku.



6
7
8
9
10
# File 'lib/heroku-helper/heroku.rb', line 6

def initialize(env)
  @environment = env.intern
  load_configuration
  puts "#{application_name} - #{environment}\n"      
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/heroku-helper/heroku.rb', line 4

def environment
  @environment
end

Instance Method Details

#add_addonsObject



37
38
39
40
41
# File 'lib/heroku-helper/heroku.rb', line 37

def add_addons
  addons.each do |addon|
    cmd 'heroku addons:add', addon, '--app', application_name
  end
end

#deployObject



12
13
14
15
16
17
18
19
# File 'lib/heroku-helper/heroku.rb', line 12

def deploy
  remote = cmd("git remote add git-remote-for-#{application_name} [email protected]:#{application_name}.git 2>&1")
  if remote !~ /remote git-remote-for-#{application_name} already exists/
    cmd("git push git-remote-for-#{application_name} master")
  else
    cmd("git push -f git-remote-for-#{application_name}")
  end
end

#restartObject



27
28
29
# File 'lib/heroku-helper/heroku.rb', line 27

def restart
  cmd 'heroku restart', '--app', application_name
end

#run(command) ⇒ Object



43
44
45
46
47
48
# File 'lib/heroku-helper/heroku.rb', line 43

def run(command)
  command = command.intern
  run_before_hook(command)
  send(command)
  run_after_hook(command)
end

#set_varsObject



31
32
33
34
35
# File 'lib/heroku-helper/heroku.rb', line 31

def set_vars
  environment_variables.each do |key, value|
    cmd 'heroku config:add', "#{key}=#{value}", '--app', application_name
  end
end

#shareObject



21
22
23
24
25
# File 'lib/heroku-helper/heroku.rb', line 21

def share
  contributors.each do |dev|
    cmd 'heroku sharing:add', dev, '--app', application_name
  end
end