paratrooper 0.4.0 → 1.0.0
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/README.md +38 -5
- data/lib/paratrooper/deploy.rb +7 -5
- data/lib/paratrooper/system_caller.rb +5 -3
- data/lib/paratrooper/version.rb +1 -1
- data/spec/paratrooper/deploy_spec.rb +17 -4
- data/spec/paratrooper/heroku_wrapper_spec.rb +2 -1
- data/spec/paratrooper/local_api_key_extractor_spec.rb +5 -0
- metadata +2 -2
    
        data/README.md
    CHANGED
    
    | @@ -1,8 +1,10 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            Library for handling common tasks when deploying to [Heroku](http://heroku.com)
         | 
| 1 | 
            +
            ## Paratrooper
         | 
| 4 2 |  | 
| 3 | 
            +
            [](http://badge.fury.io/rb/paratrooper)
         | 
| 5 4 | 
             
            [](https://travis-ci.org/mattpolito/paratrooper)
         | 
| 5 | 
            +
            [](https://codeclimate.com/github/mattpolito/paratrooper)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Make your complex deploy to [Heroku][] easy.
         | 
| 6 8 |  | 
| 7 9 | 
             
            ## Installation
         | 
| 8 10 |  | 
| @@ -20,8 +22,6 @@ Or install it yourself as: | |
| 20 22 |  | 
| 21 23 | 
             
            ## Usage
         | 
| 22 24 |  | 
| 23 | 
            -
            >> Note: Before getting started, ensure that `ENV['HEROKU_API_KEY']` is set. If you do not know your api key, you can `cat ~/.netrc`. Your api key will be listed as password in that file. This is necessary until reading your crendentials out of the `.netrc` file is implemented.
         | 
| 24 | 
            -
             | 
| 25 25 | 
             
            Instantiate Paratrooper with the name of your heroku application
         | 
| 26 26 |  | 
| 27 27 | 
             
            ```ruby
         | 
| @@ -36,6 +36,30 @@ Paratrooper::Deploy.new('amazing-app', tag: 'staging') | |
| 36 36 |  | 
| 37 37 | 
             
            Then there are methods available to perform common tasks like creating git tags, running migrations, and warming your application instance.
         | 
| 38 38 |  | 
| 39 | 
            +
            ## Authentication
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            Authentication with your Heroku account can happen in a few different ways
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            * Providing API Key
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            ```ruby
         | 
| 46 | 
            +
            Paratrooper::Deploy.new('app', api_key: 'API_KEY')
         | 
| 47 | 
            +
            ```
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            * Via environment variable
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            ```ruby
         | 
| 52 | 
            +
            ENV['HEROKU_API_KEY'] = 'API_KEY'
         | 
| 53 | 
            +
            Paratrooper::Deploy.new('app')
         | 
| 54 | 
            +
            ```
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            * Local file storage
         | 
| 57 | 
            +
              This method works via a local Netrc file. Storage of this key is handled via the [Heroku Toolbelt][]. This is the default and preferred method of providing your authentication key.
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            ```ruby
         | 
| 60 | 
            +
            Paratrooper::Deploy.new('app')
         | 
| 61 | 
            +
            ```
         | 
| 62 | 
            +
             | 
| 39 63 | 
             
            ## Sensible Default Deployment
         | 
| 40 64 |  | 
| 41 65 | 
             
            You can use the objects methods any way you'd like but we've provided a sensible default at `Paratrooper#deploy`
         | 
| @@ -72,6 +96,11 @@ namespace :deploy do | |
| 72 96 | 
             
            end
         | 
| 73 97 | 
             
            ```
         | 
| 74 98 |  | 
| 99 | 
            +
            ## Nice to haves
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            * deploy to heroku from tags
         | 
| 102 | 
            +
            * send [New Relic][] a notification to toggle heartbeat during deploy
         | 
| 103 | 
            +
             | 
| 75 104 | 
             
            ## Contributing
         | 
| 76 105 |  | 
| 77 106 | 
             
            1. Fork it
         | 
| @@ -79,3 +108,7 @@ end | |
| 79 108 | 
             
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 80 109 | 
             
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 81 110 | 
             
            5. Create new Pull Request
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            [Heroku]: http://heroku.com
         | 
| 113 | 
            +
            [Heroku Toolbelt]: http://toolbelt.heroku.com
         | 
| 114 | 
            +
            [New Relic]: http://newrelic.com
         | 
    
        data/lib/paratrooper/deploy.rb
    CHANGED
    
    | @@ -4,13 +4,15 @@ require 'paratrooper/system_caller' | |
| 4 4 |  | 
| 5 5 | 
             
            module Paratrooper
         | 
| 6 6 | 
             
              class Deploy
         | 
| 7 | 
            -
                attr_reader :app_name, :formatter, :system_caller, :heroku, :tag_name
         | 
| 7 | 
            +
                attr_reader :app_name, :formatter, :system_caller, :heroku, :tag_name,
         | 
| 8 | 
            +
                  :deploy_tag
         | 
| 8 9 |  | 
| 9 10 | 
             
                def initialize(app_name, options = {})
         | 
| 10 11 | 
             
                  @app_name      = app_name
         | 
| 11 12 | 
             
                  @formatter     = options[:formatter] || DefaultFormatter.new
         | 
| 12 13 | 
             
                  @heroku        = options[:heroku] || HerokuWrapper.new(app_name, options)
         | 
| 13 14 | 
             
                  @tag_name      = options[:tag]
         | 
| 15 | 
            +
                  @deploy_tag    = options[:deploy_tag] || 'master'
         | 
| 14 16 | 
             
                  @system_caller = options[:system_caller] || SystemCaller.new
         | 
| 15 17 | 
             
                end
         | 
| 16 18 |  | 
| @@ -27,14 +29,14 @@ module Paratrooper | |
| 27 29 | 
             
                def update_repo_tag
         | 
| 28 30 | 
             
                  unless tag_name.nil? || tag_name.empty?
         | 
| 29 31 | 
             
                    notify_screen("Updating Repo Tag: #{tag_name}")
         | 
| 30 | 
            -
                    system_call "git tag #{tag_name} -f"
         | 
| 32 | 
            +
                    system_call "git tag #{tag_name} #{deploy_tag} -f"
         | 
| 31 33 | 
             
                    system_call "git push origin #{tag_name}"
         | 
| 32 34 | 
             
                  end
         | 
| 33 35 | 
             
                end
         | 
| 34 36 |  | 
| 35 | 
            -
                def push_repo | 
| 36 | 
            -
                  notify_screen("Pushing #{ | 
| 37 | 
            -
                  system_call "git push -f #{git_remote} #{ | 
| 37 | 
            +
                def push_repo
         | 
| 38 | 
            +
                  notify_screen("Pushing #{deploy_tag} to Heroku")
         | 
| 39 | 
            +
                  system_call "git push -f #{git_remote} #{deploy_tag}:master"
         | 
| 38 40 | 
             
                end
         | 
| 39 41 |  | 
| 40 42 | 
             
                def run_migrations
         | 
    
        data/lib/paratrooper/version.rb
    CHANGED
    
    
| @@ -105,9 +105,22 @@ describe Paratrooper::Deploy do | |
| 105 105 | 
             
                    deployer.update_repo_tag
         | 
| 106 106 | 
             
                  end
         | 
| 107 107 |  | 
| 108 | 
            -
                   | 
| 109 | 
            -
                     | 
| 110 | 
            -
             | 
| 108 | 
            +
                  context "when deploy_tag is available" do
         | 
| 109 | 
            +
                    before do
         | 
| 110 | 
            +
                      options.merge!(deploy_tag: 'deploy_this')
         | 
| 111 | 
            +
                    end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                    it 'creates a git tag at deploy_tag reference point' do
         | 
| 114 | 
            +
                      system_caller.should_receive(:execute).with('git tag awesome deploy_this -f')
         | 
| 115 | 
            +
                      deployer.update_repo_tag
         | 
| 116 | 
            +
                    end
         | 
| 117 | 
            +
                  end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                  context "when no deploy_tag is available" do
         | 
| 120 | 
            +
                    it 'creates a git tag at HEAD' do
         | 
| 121 | 
            +
                      system_caller.should_receive(:execute).with('git tag awesome master -f')
         | 
| 122 | 
            +
                      deployer.update_repo_tag
         | 
| 123 | 
            +
                    end
         | 
| 111 124 | 
             
                  end
         | 
| 112 125 |  | 
| 113 126 | 
             
                  it 'pushes git tag' do
         | 
| @@ -138,7 +151,7 @@ describe Paratrooper::Deploy do | |
| 138 151 | 
             
                end
         | 
| 139 152 |  | 
| 140 153 | 
             
                it 'pushes repo to heroku' do
         | 
| 141 | 
            -
                  expected_call = 'git push -f git@heroku.com:app.git master'
         | 
| 154 | 
            +
                  expected_call = 'git push -f git@heroku.com:app.git master:master'
         | 
| 142 155 | 
             
                  system_caller.should_receive(:execute).with(expected_call)
         | 
| 143 156 | 
             
                  deployer.push_repo
         | 
| 144 157 | 
             
                end
         | 
| @@ -9,7 +9,8 @@ describe Paratrooper::HerokuWrapper do | |
| 9 9 | 
             
              let(:options) { Hash.new }
         | 
| 10 10 | 
             
              let(:default_options) do
         | 
| 11 11 | 
             
                {
         | 
| 12 | 
            -
                  heroku_api: heroku_api
         | 
| 12 | 
            +
                  heroku_api: heroku_api,
         | 
| 13 | 
            +
                  key_extractor: double(:key_extractor, get_credentials: 'API_KEY')
         | 
| 13 14 | 
             
                }
         | 
| 14 15 | 
             
              end
         | 
| 15 16 | 
             
              let(:heroku_api) { double(:heroku_api) }
         | 
| @@ -1,10 +1,15 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'fileutils'
         | 
| 2 3 | 
             
            require 'paratrooper/local_api_key_extractor'
         | 
| 3 4 |  | 
| 4 5 | 
             
            describe Paratrooper::LocalApiKeyExtractor do
         | 
| 5 6 | 
             
              let(:netrc_klass) { double(:netrc_klass, default_path: fixture_file_path) }
         | 
| 6 7 | 
             
              let(:fixture_file_path) { fixture_path('netrc') }
         | 
| 7 8 |  | 
| 9 | 
            +
              before do
         | 
| 10 | 
            +
                File.chmod(0600, fixture_file_path)
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 8 13 | 
             
              describe 'file association' do
         | 
| 9 14 | 
             
                context 'when file path is provided' do
         | 
| 10 15 | 
             
                  let(:extractor) { described_class.new(file_path: fixture_file_path) }
         | 
    
        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. | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2013-02- | 
| 13 | 
            +
            date: 2013-02-08 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: rake
         |