paratrooper 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gem 'heroku', '~> 2', github: 'heroku/heroku'
4
3
  gemspec
data/Gemfile.lock CHANGED
@@ -1,37 +1,18 @@
1
- GIT
2
- remote: git://github.com/heroku/heroku.git
3
- revision: 5b50420ed9677622485ca018b04ad11ba4da48ab
4
- specs:
5
- heroku (2.34.0)
6
- heroku-api (~> 0.3.7)
7
- launchy (>= 0.3.2)
8
- netrc (~> 0.7.7)
9
- rest-client (~> 1.6.1)
10
- rubyzip
11
-
12
1
  PATH
13
2
  remote: .
14
3
  specs:
15
- Heroku Deployment (1.0.0)
4
+ paratrooper (0.0.1)
5
+ heroku-api
16
6
 
17
7
  GEM
18
8
  remote: http://rubygems.org/
19
9
  specs:
20
- addressable (2.3.2)
21
10
  excon (0.16.10)
22
11
  heroku-api (0.3.7)
23
12
  excon (~> 0.16.10)
24
- launchy (2.1.2)
25
- addressable (~> 2.3)
26
- mime-types (1.19)
27
- netrc (0.7.7)
28
- rest-client (1.6.7)
29
- mime-types (>= 1.16)
30
- rubyzip (0.9.9)
31
13
 
32
14
  PLATFORMS
33
15
  ruby
34
16
 
35
17
  DEPENDENCIES
36
- Heroku Deployment!
37
- heroku (~> 2)!
18
+ paratrooper!
@@ -0,0 +1,79 @@
1
+ require 'heroku-api'
2
+
3
+ module Paratrooper
4
+ class Deploy
5
+ attr_reader :app_name, :heroku, :tag_name
6
+
7
+ def initialize(app_name, options = {})
8
+ @app_name = app_name
9
+ @heroku = options[:heroku_auth] || Heroku::API.new(api_key: ENV['HEROKU_API_KEY'])
10
+ @tag_name = options[:tag]
11
+ end
12
+
13
+ def activate_maintenance_mode
14
+ notify_screen("Activating Maintenance Mode")
15
+ heroku.post_app_maintenance(app_name, '1')
16
+ end
17
+
18
+ def deactivate_maintenance_mode
19
+ notify_screen("Deactivating Maintenance Mode")
20
+ heroku.post_app_maintenance(app_name, '0')
21
+ end
22
+
23
+ def update_repo_tag
24
+ unless tag_name.empty?
25
+ notify_screen("Updating Repo Tag: #{tag_name}")
26
+ system "git tag #{tag_name} -f"
27
+ system "git push origin #{tag_name}"
28
+ end
29
+ end
30
+
31
+ def push_repo(branch = 'master')
32
+ notify_screen("Pushing #{branch} to Heroku")
33
+ system "git push -f #{git_remote} #{branch}"
34
+ end
35
+
36
+ def run_migrations
37
+ notify_screen("Running database migrations")
38
+ system "heroku run rake db:migrate --app #{app_name}"
39
+ end
40
+
41
+ def app_restart
42
+ heroku.post_ps_restart(app_name)
43
+ end
44
+
45
+ def warm_instance(wait_time = 5)
46
+ sleep wait_time
47
+ notify_screen("Accessing #{app_url} to warm up your application")
48
+ system "curl -Il http://#{app_url}"
49
+ end
50
+
51
+ def default_deploy
52
+ activate_maintenance_mode
53
+ update_repo_tag
54
+ push_repo
55
+ run_migrations
56
+ app_restart
57
+ deactivate_maintenance_mode
58
+ warm_instance
59
+ end
60
+ alias_method :deploy, :default_deploy
61
+
62
+ private
63
+ def git_remote
64
+ "git@heroku.com:#{app_name}.git"
65
+ end
66
+
67
+ def app_url
68
+ heroku.get_domains(app_name).body.last['domain']
69
+ end
70
+
71
+ def notify_screen(message)
72
+ puts
73
+ puts "=" * 80
74
+ puts ">> #{message}"
75
+ puts "=" * 80
76
+ puts
77
+ end
78
+ end
79
+ end
@@ -1,3 +1,3 @@
1
1
  module Paratrooper
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/paratrooper.rb CHANGED
@@ -1,82 +1,6 @@
1
- require 'heroku'
2
1
  require "paratrooper/version"
2
+ require 'paratrooper/deploy'
3
3
 
4
- class Paratrooper
5
- attr_reader :app_name, :heroku_auth, :tag_name
4
+ module Paratrooper
6
5
 
7
- def initialize(app_name, options = {})
8
- @app_name = app_name
9
- @heroku_auth = options[:heroku_auth] || Heroku::Auth
10
- @tag_name = options[:tag]
11
- end
12
-
13
- def activate_maintenance_mode
14
- notify_screen("Activating Maintenance Mode")
15
- heroku.post_app_maintenance(app_name, '1')
16
- end
17
-
18
- def deactivate_maintenance_mode
19
- notify_screen("Deactivating Maintenance Mode")
20
- heroku.post_app_maintenance(app_name, '0')
21
- end
22
-
23
- def update_repo_tag
24
- unless tag_name.empty?
25
- notify_screen("Updating Repo Tag: #{tag_name}")
26
- system "git tag #{tag_name} -f"
27
- system "git push origin #{tag_name}"
28
- end
29
- end
30
-
31
- def push_repo(branch = 'master')
32
- notify_screen("Pushing #{branch} to Heroku")
33
- system "git push -f #{git_remote} #{branch}"
34
- end
35
-
36
- def run_migrations
37
- notify_screen("Running database migrations")
38
- system "heroku run rake db:migrate --app #{app_name}"
39
- end
40
-
41
- def app_restart
42
- heroku.post_ps_restart(app_name)
43
- end
44
-
45
- def warm_instance(wait_time = 5)
46
- sleep wait_time
47
- notify_screen("Accessing #{app_url} to warm up your application")
48
- system "curl -Il http://#{app_url}"
49
- end
50
-
51
- def default_deploy
52
- activate_maintenance_mode
53
- update_repo_tag
54
- push_repo
55
- run_migrations
56
- app_restart
57
- deactivate_maintenance_mode
58
- warm_instance
59
- end
60
- alias_method :deploy, :default_deploy
61
-
62
- private
63
- def git_remote
64
- "git@heroku.com:#{app_name}.git"
65
- end
66
-
67
- def app_url
68
- heroku.get_domains(app_name).body.last['domain']
69
- end
70
-
71
- def heroku
72
- heroku_auth.api
73
- end
74
-
75
- def notify_screen(message)
76
- puts
77
- puts "=" * 80
78
- puts ">> #{message}"
79
- puts "=" * 80
80
- puts
81
- end
82
6
  end
data/paratrooper.gemspec CHANGED
@@ -16,4 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'heroku-api'
19
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paratrooper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,23 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
  date: 2013-01-15 00:00:00.000000000 Z
14
- dependencies: []
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: heroku-api
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
15
31
  description: Library to create task for deployment to Heroku
16
32
  email:
17
33
  - matt.polito@gmail.com
@@ -20,12 +36,14 @@ executables: []
20
36
  extensions: []
21
37
  extra_rdoc_files: []
22
38
  files:
39
+ - .gitignore
23
40
  - Gemfile
24
41
  - Gemfile.lock
25
42
  - LICENSE.txt
26
43
  - README.md
27
44
  - Rakefile
28
45
  - lib/paratrooper.rb
46
+ - lib/paratrooper/deploy.rb
29
47
  - lib/paratrooper/version.rb
30
48
  - paratrooper.gemspec
31
49
  homepage: http://github.com/hashrocket/paratrooper