Class: Push2heroku::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/push2heroku/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callbacks) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/push2heroku/base.rb', line 7

def initialize(callbacks)
  @project_name = File.basename(Dir.getwd)
  @callbacks = callbacks

  git = Git.new
  @branch_name = git.current_branch
  @current_user = git.current_user

  @named_branches = ConfigLoader.new('push2heroku.yml').named_branches

  @heroku_app_name = "#{url_prefix}-#{url_suffix}".downcase.chomp('-')[0..29] #heroku only allows upto 30 characters in name

  ENV['BRANCH_NAME'] = branch_name
  ENV['HEROKU_APP_NAME'] = heroku_app_name
  @settings = ConfigLoader.new('push2heroku.yml').settings(branch_name)

  @commands = []
end

Instance Attribute Details

#branch_nameObject

Returns the value of attribute branch_name.



4
5
6
# File 'lib/push2heroku/base.rb', line 4

def branch_name
  @branch_name
end

#callbacksObject (readonly)

Returns the value of attribute callbacks.



5
6
7
# File 'lib/push2heroku/base.rb', line 5

def callbacks
  @callbacks
end

#commandsObject

Returns the value of attribute commands.



4
5
6
# File 'lib/push2heroku/base.rb', line 4

def commands
  @commands
end

#current_userObject

Returns the value of attribute current_user.



4
5
6
# File 'lib/push2heroku/base.rb', line 4

def current_user
  @current_user
end

#heroku_app_nameObject

Returns the value of attribute heroku_app_name.



4
5
6
# File 'lib/push2heroku/base.rb', line 4

def heroku_app_name
  @heroku_app_name
end

#named_branchesObject

Returns the value of attribute named_branches.



4
5
6
# File 'lib/push2heroku/base.rb', line 4

def named_branches
  @named_branches
end

#project_nameObject (readonly)

Returns the value of attribute project_name.



5
6
7
# File 'lib/push2heroku/base.rb', line 5

def project_name
  @project_name
end

#settingsObject

Returns the value of attribute settings.



4
5
6
# File 'lib/push2heroku/base.rb', line 4

def settings
  @settings
end

Instance Method Details

#pushObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/push2heroku/base.rb', line 26

def push
  build_commands
  feedback_to_user
  commands.each do |cmd|
    begin
      puts "Going to execute: #{cmd}"
      sh cmd
    rescue Exception => e
      puts "command that failed was: #{cmd}"
      puts e
    end
  end
end