paratrooper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'heroku', '~> 2', github: 'heroku/heroku'
4
+ gemspec
@@ -0,0 +1,37 @@
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
+ PATH
13
+ remote: .
14
+ specs:
15
+ Heroku Deployment (1.0.0)
16
+
17
+ GEM
18
+ remote: http://rubygems.org/
19
+ specs:
20
+ addressable (2.3.2)
21
+ excon (0.16.10)
22
+ heroku-api (0.3.7)
23
+ 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
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ Heroku Deployment!
37
+ heroku (~> 2)!
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Hashrocket
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ # Paratrooper
2
+
3
+ Library for handling common tasks when deploying to [Heroku](http://heroku.com)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'paratrooper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install paratrooper
18
+
19
+ ## Usage
20
+
21
+ Instantiate Paratrooper with the name of your heroku application
22
+
23
+ ```ruby
24
+ Paratrooper.new('amazing-app')
25
+ ```
26
+
27
+ also you can provide a tag name for repository use
28
+
29
+ ```ruby
30
+ Paratrooper.new('amazing-app', tag: 'staging')
31
+ ```
32
+
33
+ Then there are methods available to perform common tasks like creating git tags, running migrations, and warming your application instance.
34
+
35
+ ## Sensible Default Deployment
36
+
37
+ You can use the objects methods any way you'd like but we've provided a sensible default at `Paratrooper#deploy`
38
+
39
+ This will perform the following tasks:
40
+
41
+ * Activating maintenance mode
42
+ * Create or update a git tag (if provided)
43
+ * Push changes to Heroku
44
+ * Run database migrations
45
+ * Restart the application
46
+ * Deactivate maintenance mode
47
+ * Warm application instance
48
+
49
+ ## Example Usage
50
+
51
+ ```ruby
52
+ require 'paratrooper'
53
+
54
+ namespace :deploy do
55
+ desc 'Deploy app in staging environment'
56
+ task :staging do
57
+ deployment = Paratrooper.new("amazing-staging-app", tag: 'staging')
58
+
59
+ deployment.deploy
60
+ end
61
+
62
+ desc 'Deploy app in production environment'
63
+ task :production do
64
+ deployment = Paratrooper.new("amazing-production-app", tag: 'production')
65
+
66
+ deployment.deploy
67
+ end
68
+ end
69
+ ```
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,82 @@
1
+ require 'heroku'
2
+ require "paratrooper/version"
3
+
4
+ class Paratrooper
5
+ attr_reader :app_name, :heroku_auth, :tag_name
6
+
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
+ end
@@ -0,0 +1,3 @@
1
+ module Paratrooper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'paratrooper/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "paratrooper"
8
+ gem.version = Paratrooper::VERSION
9
+ gem.authors = ['Matt Polito', 'Brandon Farmer']
10
+ gem.email = ['matt.polito@gmail.com', 'bthesorceror@gmail.com']
11
+ gem.description = %q{Library to create task for deployment to Heroku}
12
+ gem.summary = %q{Library to create task for deployment to Heroku}
13
+ gem.homepage = "http://github.com/hashrocket/paratrooper"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paratrooper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Polito
9
+ - Brandon Farmer
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-01-15 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Library to create task for deployment to Heroku
16
+ email:
17
+ - matt.polito@gmail.com
18
+ - bthesorceror@gmail.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - lib/paratrooper.rb
29
+ - lib/paratrooper/version.rb
30
+ - paratrooper.gemspec
31
+ homepage: http://github.com/hashrocket/paratrooper
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.24
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Library to create task for deployment to Heroku
55
+ test_files: []