heroku-headless 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :build => :spec
8
+
9
+ task :default => :spec
@@ -16,4 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = HerokuHeadless::VERSION
17
17
 
18
18
  gem.add_runtime_dependency "heroku-api"
19
+ gem.add_runtime_dependency "rendezvous"
20
+ gem.add_development_dependency "rspec"
21
+ gem.add_development_dependency "pry"
19
22
  end
@@ -5,3 +5,26 @@ require "heroku-headless/creates_uuids"
5
5
  require "heroku-headless/talks_to_heroku"
6
6
 
7
7
  require "heroku-headless/deployer"
8
+
9
+ module HerokuHeadless
10
+ class << self
11
+ attr_accessor :configuration
12
+ end
13
+
14
+ def self.configure
15
+ self.configuration ||= Configuration.new
16
+ yield(configuration)
17
+ end
18
+
19
+ def self.heroku
20
+ @@heroku ||= Heroku::API.new(:mock => HerokuHeadless.configuration.mock_mode)
21
+ end
22
+
23
+ class Configuration
24
+ attr_accessor :mock_mode, :post_deploy_commands
25
+
26
+ def initialize
27
+ @post_deploy_commands = []
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,6 @@
1
1
  require 'pathname'
2
2
  require 'tmpdir'
3
+ require 'rendezvous'
3
4
 
4
5
  module HerokuHeadless
5
6
  class Deployer
@@ -19,6 +20,7 @@ module HerokuHeadless
19
20
  prep_temp_dir
20
21
  setup_ssh_key
21
22
  do_action('push git to heroku'){ push_head_to_app }
23
+ do_action('post_deploy_hooks'){ run_post_deploy_hooks }
22
24
 
23
25
  ensure
24
26
  cleanup
@@ -88,6 +90,18 @@ module HerokuHeadless
88
90
  system( {'GIT_SSH'=>custom_git_ssh_path.to_s}, "git push git@heroku.com:#{@app_name}.git HEAD:master" )
89
91
  end
90
92
 
93
+ def run_post_deploy_hooks
94
+ HerokuHeadless.configuration.post_deploy_commands.each do | command |
95
+ do_action( command ){ run_command(command) }
96
+ end
97
+ end
98
+
99
+ def run_command(cmd)
100
+ data = heroku.post_ps(@app_name, cmd, :attach => true).body
101
+ rendezvous_url = data['rendezvous_url']
102
+ Rendezvous.start(:url => rendezvous_url) unless rendezvous_url.nil?
103
+ end
104
+
91
105
  def custom_git_ssh_path
92
106
  @tmpdir.join('git-ssh')
93
107
  end
@@ -3,7 +3,7 @@ require 'heroku-api'
3
3
  module HerokuHeadless
4
4
  module TalksToHeroku
5
5
  def heroku
6
- @heroku ||= Heroku::API.new()
6
+ HerokuHeadless.heroku
7
7
  end
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module HerokuHeadless
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'HerokuHeadless' do
4
+ let(:heroku) { HerokuHeadless.heroku }
5
+
6
+ it "should fail to deploy a missing app" do
7
+ HerokuHeadless::Deployer.deploy('missing_app')
8
+ $?.exitstatus.should_not eq 0
9
+ end
10
+
11
+ it "should successfully deploy an existing app" do
12
+ heroku.post_app(:name => 'existing_app')
13
+ # Creating an app on heroku actually isn't enough to make the git push pass!
14
+ HerokuHeadless::Deployer.any_instance.should_receive(:push_git)
15
+ HerokuHeadless::Deployer.deploy('existing_app')
16
+ $?.exitstatus.should eq 0
17
+ end
18
+
19
+ it "should call post-deploy actions" do
20
+ heroku.post_app(:name => 'app_with_db')
21
+
22
+ HerokuHeadless.configure do | config |
23
+ config.post_deploy_commands = [
24
+ 'echo hello',
25
+ 'echo success'
26
+ ]
27
+ end
28
+
29
+ HerokuHeadless::Deployer.any_instance.should_receive(:push_git)
30
+ HerokuHeadless::Deployer.any_instance.should_receive(:run_command).with('echo hello')
31
+ HerokuHeadless::Deployer.any_instance.should_receive(:run_command).with('echo success')
32
+
33
+ HerokuHeadless::Deployer.deploy('app_with_db')
34
+ $?.exitstatus.should eq 0
35
+ end
36
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+ require 'heroku-headless'
3
+
4
+ HerokuHeadless.configure do | config |
5
+ config.mock_mode = true
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-headless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-21 00:00:00.000000000 Z
12
+ date: 2013-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: heroku-api
@@ -27,6 +27,54 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rendezvous
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: pry
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
30
78
  description: Push from your git repo to a heroku app without any external configuration.
31
79
  email:
32
80
  - phodgson@thoughtworks.com
@@ -48,6 +96,8 @@ files:
48
96
  - lib/heroku-headless/documents_actions.rb
49
97
  - lib/heroku-headless/talks_to_heroku.rb
50
98
  - lib/heroku-headless/version.rb
99
+ - spec/deploy_spec.rb
100
+ - spec/spec_helper.rb
51
101
  homepage: https://github.com/moredip/heroku-headless
52
102
  licenses: []
53
103
  post_install_message:
@@ -73,5 +123,6 @@ signing_key:
73
123
  specification_version: 3
74
124
  summary: Heroku's workflow is geared towards pushing to a heroku app from a dev workstation.
75
125
  This gem makes it easy to push to a heroku app as part of a CI/CD setup.
76
- test_files: []
77
- has_rdoc:
126
+ test_files:
127
+ - spec/deploy_spec.rb
128
+ - spec/spec_helper.rb