bam 0.0.7 → 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.
- checksums.yaml +7 -0
 - data/.gitignore +1 -1
 - data/Gemfile.lock +17 -0
 - data/README.mdown +65 -19
 - data/bin/bam +42 -8
 - data/bin/bamify +23 -10
 - data/lib/bam/version.rb +1 -1
 - data/lib/bam.rb +37 -9
 - data/lib/bam_helpers.rb +4 -0
 - metadata +22 -44
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c6133090fcc988d9ea1c9c3168aea68b8a05addc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f303d8b78d31fabbe5a9d317b66443ccc976259e
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4e7ed579472c196bf94d58d9be094894f2000843664f1e875d971cb8fe97f5000f07c2e25c8b26d1c30eae3ed051fde2909539689ad503f5aa2840dc79b34117
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4fe3931c07e71081dfa42a28a04244b876e3dbed4bf75a6ee7985f923433fab2999c6d7991a3c716a3a66bccf9473349e49c57cc31d3f7aca3f34f96b894be47
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/Gemfile.lock
    ADDED
    
    
    
        data/README.mdown
    CHANGED
    
    | 
         @@ -1,26 +1,23 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            Bam
         
     | 
| 
       2 
     | 
    
         
            -
            ===
         
     | 
| 
      
 1 
     | 
    
         
            +
            ## Bam
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            A super simple deployment utility, it's basically an opinionated abstraction of rsync served in a capistrano fashion. Capistrano is a super cool utility, I love it, I use it all the time. But for smaller projects (websites, sinatra apps, etc), I think it's simply overkill. The great thing about bam is that you don't need to learn another DSL, it's simply just ruby that you need to edit in the deploy file to configure your deployment recipe.
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            Installation
         
     | 
| 
       7 
     | 
    
         
            -
            ============
         
     | 
| 
      
 5 
     | 
    
         
            +
            ### Installation
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
7 
     | 
    
         
             
                gem install bam
         
     | 
| 
       10 
8 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
            Usage
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
            ### Usage
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       13 
11 
     | 
    
         | 
| 
       14 
12 
     | 
    
         
             
                cd into/your/project/root
         
     | 
| 
       15 
13 
     | 
    
         
             
                bamify
         
     | 
| 
       16 
     | 
    
         
            -
                # update the @server and @to variables in deploy.bam file
         
     | 
| 
      
 14 
     | 
    
         
            +
                # update the @server and @to variables in deploy.bam.rb file
         
     | 
| 
       17 
15 
     | 
    
         
             
                # work on your project
         
     | 
| 
       18 
16 
     | 
    
         
             
                bam
         
     | 
| 
       19 
17 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            How deploy.bam works
         
     | 
| 
       21 
     | 
    
         
            -
            ====================
         
     | 
| 
      
 18 
     | 
    
         
            +
            ### How deploy.bam.rb works
         
     | 
| 
       22 
19 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            After you run <code>bamify</code>, it generates a <code>deploy.bam</code> file, which looks like:
         
     | 
| 
      
 20 
     | 
    
         
            +
            After you run <code>bamify</code>, it generates a <code>deploy.bam.rb</code> file, which looks like:
         
     | 
| 
       24 
21 
     | 
    
         | 
| 
       25 
22 
     | 
    
         
             
                # Bam Deploy File
         
     | 
| 
       26 
23 
     | 
    
         
             
                # ---------------
         
     | 
| 
         @@ -30,31 +27,80 @@ After you run <code>bamify</code>, it generates a <code>deploy.bam</code> file, 
     | 
|
| 
       30 
27 
     | 
    
         
             
                #   - username@host
         
     | 
| 
       31 
28 
     | 
    
         
             
                @server = 'login@yourhost.com'
         
     | 
| 
       32 
29 
     | 
    
         
             
                # the location on the server don't forget to append the slash/
         
     | 
| 
      
 30 
     | 
    
         
            +
                # make sure that it's the parent folder that you are uploading to,
         
     | 
| 
      
 31 
     | 
    
         
            +
                # for example:
         
     | 
| 
      
 32 
     | 
    
         
            +
                #   instead of...
         
     | 
| 
      
 33 
     | 
    
         
            +
                #     @to = '~/public_html/your_site/'
         
     | 
| 
      
 34 
     | 
    
         
            +
                #   do...
         
     | 
| 
      
 35 
     | 
    
         
            +
                #     @to = '~/public_html/'
         
     | 
| 
       33 
36 
     | 
    
         
             
                @to = '~/location/to/your/web/site/or/app/'
         
     | 
| 
       34 
37 
     | 
    
         | 
| 
      
 38 
     | 
    
         
            +
                # add list of file to always include in deployments
         
     | 
| 
      
 39 
     | 
    
         
            +
                @always_include = %w()
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                # remote tasks : these are tasks that you want to run on the server
         
     | 
| 
      
 42 
     | 
    
         
            +
                # @remote_tasks = { :restart_app => 'touch /my/cool/app/restart.txt' }
         
     | 
| 
      
 43 
     | 
    
         
            +
                @remote_tasks = {}
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
       35 
45 
     | 
    
         
             
                # pre_deploy_tasks : These are things that you can run locally before deployment
         
     | 
| 
       36 
46 
     | 
    
         
             
                # @pre_deploy_tasks = ['rm -rf cache/*']
         
     | 
| 
       37 
     | 
    
         
            -
                 
     | 
| 
      
 47 
     | 
    
         
            +
                @pre_deploy_tasks = []
         
     | 
| 
       38 
48 
     | 
    
         | 
| 
       39 
49 
     | 
    
         
             
                # post_deploy_tasks : These are things that you can run locally before deployment
         
     | 
| 
       40 
50 
     | 
    
         
             
                # @post_deploy_tasks = ['rm -rf cache/*']
         
     | 
| 
       41 
     | 
    
         
            -
                 
     | 
| 
      
 51 
     | 
    
         
            +
                @post_deploy_tasks = []
         
     | 
| 
       42 
52 
     | 
    
         | 
| 
       43 
53 
     | 
    
         
             
            Simply set <code>@server</code> to your hostname or ip of your server and set <code>@to</code> to the location
         
     | 
| 
       44 
54 
     | 
    
         
             
            on the server where the your project is located, make sure that it's the parent folder (and don't forget to
         
     | 
| 
       45 
55 
     | 
    
         
             
            append the slash '/'), so instead of <code>~/public_html/project_name/</code> you would do <code>~/public_html/</code>
         
     | 
| 
       46 
56 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
            =============================
         
     | 
| 
      
 57 
     | 
    
         
            +
            ### Command line options
         
     | 
| 
       49 
58 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
            ```
         
     | 
| 
      
 60 
     | 
    
         
            +
            # pass the --help flag for all options
         
     | 
| 
      
 61 
     | 
    
         
            +
            bam --help
         
     | 
| 
      
 62 
     | 
    
         
            +
            ```
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            * --dry : execute a dry run
         
     | 
| 
      
 65 
     | 
    
         
            +
            * --deploy : runs the deployment, this is the default task
         
     | 
| 
      
 66 
     | 
    
         
            +
            * --version : prints the current version
         
     | 
| 
      
 67 
     | 
    
         
            +
            * --remote : execute a remote command, split multiple tasks with a ':'
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            ### Pre, Post and Remote Deployment Tasks
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            You can run pre, post and remote deployment tasks by assigning or setting the `@pre_deploy_tasks`, `@post_deploy_tasks` and `@remote_tasks` variables. Here's an example, note that `@remote_tasks` is a Hash:
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            ```
         
     | 
| 
      
 74 
     | 
    
         
            +
            @pre_deploy_tasks = ['rm -rf cache/*']
         
     | 
| 
      
 75 
     | 
    
         
            +
            @post_deploy_tasks = ['rm -rf log/*']
         
     | 
| 
      
 76 
     | 
    
         
            +
            @remote_tasks = {
         
     | 
| 
      
 77 
     | 
    
         
            +
                :restart_app => "touch /path/to/app/restart.txt"
         
     | 
| 
      
 78 
     | 
    
         
            +
            }
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            # run remote tasks in your pre or post tasks array by adding a remote:[task_name] in your array like:
         
     | 
| 
      
 81 
     | 
    
         
            +
            @post_deploy_tasks = ['rm-rf log/*', 'remote:restart_app']
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            # execute remote tasks like:
         
     | 
| 
      
 84 
     | 
    
         
            +
            bam --remote restart_app
         
     | 
| 
      
 85 
     | 
    
         
            +
            ```
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            ### Ignoring Files and Directories on Deployment
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            What if you don't want to push certain files or directories to your host? Say you have log or tmp files that would otherwise take up space. Well if you use git, you don't have to worry simply add them to .gitignore and bam is smart enough to ignore those files on deploy as well. 
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            ### Add exceptions to ignore list
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            There could be some situations where you wouldn't want to exclude all the entries in `.gitignore`, if that's the case, simply add those entries to the `@always_include` variable. Here's an example:
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            ```
         
     | 
| 
      
 96 
     | 
    
         
            +
            @always_include = %w(app.min.js dist.min.js)
         
     | 
| 
      
 97 
     | 
    
         
            +
            ```
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            ### TODO
         
     | 
| 
       54 
100 
     | 
    
         | 
| 
       55 
101 
     | 
    
         
             
            - Add static revision history for integrated rollbacks
         
     | 
| 
       56 
102 
     | 
    
         
             
            - Maybe use choice or highline to prompt to fill in values?
         
     | 
| 
       57 
     | 
    
         
            -
            - Maybe add in remote tasks
         
     | 
| 
      
 103 
     | 
    
         
            +
            - Maybe add in remote tasks : DONE!
         
     | 
| 
       58 
104 
     | 
    
         | 
| 
       59 
105 
     | 
    
         | 
| 
       60 
106 
     | 
    
         
             
            Copyright (c) 2010 Vann Ek., released under the MIT license
         
     | 
    
        data/bin/bam
    CHANGED
    
    | 
         @@ -1,24 +1,58 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby -wKU
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            begin 
         
     | 
| 
      
 4 
     | 
    
         
            +
              require "optparse"
         
     | 
| 
       4 
5 
     | 
    
         
             
              require "bam_helpers"
         
     | 
| 
       5 
6 
     | 
    
         
             
              require "bam"
         
     | 
| 
      
 7 
     | 
    
         
            +
              require "bam/version"
         
     | 
| 
       6 
8 
     | 
    
         
             
            rescue LoadError
         
     | 
| 
      
 9 
     | 
    
         
            +
              require "optparse"
         
     | 
| 
       7 
10 
     | 
    
         
             
              require "rubygems"
         
     | 
| 
       8 
11 
     | 
    
         
             
              require "bam_helpers"
         
     | 
| 
       9 
12 
     | 
    
         
             
              require "bam"
         
     | 
| 
      
 13 
     | 
    
         
            +
              require "bam/version"
         
     | 
| 
       10 
14 
     | 
    
         
             
            end
         
     | 
| 
       11 
15 
     | 
    
         | 
| 
      
 16 
     | 
    
         
            +
            include BamHelpers
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            options = {
         
     | 
| 
      
 19 
     | 
    
         
            +
              :deploy => true
         
     | 
| 
      
 20 
     | 
    
         
            +
            }
         
     | 
| 
       12 
21 
     | 
    
         
             
            pwd = Dir.pwd
         
     | 
| 
       13 
     | 
    
         
            -
            bampath = File.join(pwd, "deploy.bam")
         
     | 
| 
      
 22 
     | 
    
         
            +
            bampath = File.join(pwd, "deploy.bam.rb")
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            OptionParser.new do |opts|
         
     | 
| 
      
 25 
     | 
    
         
            +
              opts.banner = "Usage: bam [options]"
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              opts.on("-t", "--dry", "Do a dry run") { |v| options[:dry_run] = true }
         
     | 
| 
      
 28 
     | 
    
         
            +
              opts.on("-d", "--deploy", "Deploy project (DEFAULT)") { |v| options[:deploy] = true }
         
     | 
| 
      
 29 
     | 
    
         
            +
              opts.on("-v", "--version", "Display version") { |v| puts "Version: #{Bam::VERSION}"; exit }   
         
     | 
| 
      
 30 
     | 
    
         
            +
              opts.on('-r', '--remote TASKS', "Run a remote task, split multiple tasks with ':'") do |task|
         
     | 
| 
      
 31 
     | 
    
         
            +
                options[:remote_tasks] = task.split(":")
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            end.parse!
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       14 
36 
     | 
    
         
             
            if File.exists?(bampath)
         
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
       16 
     | 
    
         
            -
               
     | 
| 
      
 37 
     | 
    
         
            +
              deployfile = File.read(File.join(pwd,"deploy.bam.rb"))
         
     | 
| 
      
 38 
     | 
    
         
            +
              # this will give use access to @pre_deploy_tasks, @post_deploy_tasks, @always_include, @remote_tasks 
         
     | 
| 
       17 
39 
     | 
    
         
             
              eval deployfile
         
     | 
| 
       18 
     | 
    
         
            -
               
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 40 
     | 
    
         
            +
              task_config = {
         
     | 
| 
      
 41 
     | 
    
         
            +
                :pre => @pre_deploy_tasks,
         
     | 
| 
      
 42 
     | 
    
         
            +
                :post => @post_deploy_tasks,
         
     | 
| 
      
 43 
     | 
    
         
            +
                :always_include => @always_include,
         
     | 
| 
      
 44 
     | 
    
         
            +
                :remote => @remote_tasks
         
     | 
| 
      
 45 
     | 
    
         
            +
              }
         
     | 
| 
      
 46 
     | 
    
         
            +
              ready_to = Bam::Deployment.new @server, @to, pwd, options[:dry_run], task_config
         
     | 
| 
      
 47 
     | 
    
         
            +
              
         
     | 
| 
      
 48 
     | 
    
         
            +
              puts wrap_borders("Executing DRY RUN") if options[:dry_run] 
         
     | 
| 
      
 49 
     | 
    
         
            +
              if options[:remote_tasks]
         
     | 
| 
      
 50 
     | 
    
         
            +
                options[:remote_tasks].each do |task|
         
     | 
| 
      
 51 
     | 
    
         
            +
                  ready_to.remote_exec task 
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              else
         
     | 
| 
      
 54 
     | 
    
         
            +
                ready_to.deploy
         
     | 
| 
      
 55 
     | 
    
         
            +
              end  
         
     | 
| 
       22 
56 
     | 
    
         
             
            else
         
     | 
| 
       23 
     | 
    
         
            -
              puts "No deploy.bam file found, run bamify to generate one."
         
     | 
| 
      
 57 
     | 
    
         
            +
              puts "No deploy.bam.rb file found, run bamify to generate one."
         
     | 
| 
       24 
58 
     | 
    
         
             
            end
         
     | 
    
        data/bin/bamify
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby -wKU
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # Bamify : generates the deploy.bam file for deploying using bam
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Bamify : generates the deploy.bam.rb file for deploying using bam
         
     | 
| 
       4 
4 
     | 
    
         
             
            # USAGE :
         
     | 
| 
       5 
5 
     | 
    
         
             
            # bamify [path_to_project]
         
     | 
| 
       6 
6 
     | 
    
         
             
            begin 
         
     | 
| 
         @@ -30,31 +30,44 @@ def template 
     | 
|
| 
       30 
30 
     | 
    
         
             
            #     @to = '~/public_html/'
         
     | 
| 
       31 
31 
     | 
    
         
             
            @to = '~/location/to/your/web/site/or/app/'
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
      
 33 
     | 
    
         
            +
            # add list of file to always include in deployments
         
     | 
| 
      
 34 
     | 
    
         
            +
            @always_include = %w()
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            # remote tasks : these are tasks that you want to run on the server
         
     | 
| 
      
 37 
     | 
    
         
            +
            # @remote_tasks = { :restart_app => 'touch /my/cool/app/restart.txt' }
         
     | 
| 
      
 38 
     | 
    
         
            +
            @remote_tasks = {}
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       33 
40 
     | 
    
         
             
            # pre_deploy_tasks : These are things that you can run locally before deployment
         
     | 
| 
       34 
41 
     | 
    
         
             
            # @pre_deploy_tasks = ['rm -rf cache/*']
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
            @pre_deploy_tasks = []
         
     | 
| 
       36 
43 
     | 
    
         | 
| 
       37 
44 
     | 
    
         
             
            # post_deploy_tasks : These are things that you can run locally before deployment
         
     | 
| 
       38 
45 
     | 
    
         
             
            # @post_deploy_tasks = ['rm -rf cache/*']
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
            @post_deploy_tasks = []
         
     | 
| 
       40 
47 
     | 
    
         
             
            "
         
     | 
| 
       41 
48 
     | 
    
         
             
            end
         
     | 
| 
       42 
49 
     | 
    
         | 
| 
       43 
50 
     | 
    
         
             
            def add_ignore_bam
         
     | 
| 
       44 
51 
     | 
    
         
             
              `touch .gitignore` unless File.exists?(".gitignore")
         
     | 
| 
       45 
     | 
    
         
            -
              no_bam_found = (`cat .gitignore | grep deploy.bam` == "")
         
     | 
| 
       46 
     | 
    
         
            -
              `echo deploy.bam >> .gitignore` if no_bam_found
         
     | 
| 
      
 52 
     | 
    
         
            +
              no_bam_found = (`cat .gitignore | grep deploy.bam.rb` == "")
         
     | 
| 
      
 53 
     | 
    
         
            +
              `echo deploy.bam.rb >> .gitignore` if no_bam_found
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            def help_message
         
     | 
| 
      
 57 
     | 
    
         
            +
              <<-help
         
     | 
| 
      
 58 
     | 
    
         
            +
            bamify [path_to_project]
         
     | 
| 
      
 59 
     | 
    
         
            +
              --ignore-bam: add bam.deploy file to .gitignore list
         
     | 
| 
      
 60 
     | 
    
         
            +
              help
         
     | 
| 
       47 
61 
     | 
    
         
             
            end
         
     | 
| 
       48 
62 
     | 
    
         | 
| 
       49 
63 
     | 
    
         
             
            if ARGV[0] == "--help"
         
     | 
| 
       50 
     | 
    
         
            -
              puts  
     | 
| 
      
 64 
     | 
    
         
            +
              puts help_message
         
     | 
| 
       51 
65 
     | 
    
         
             
            else
         
     | 
| 
       52 
66 
     | 
    
         
             
              path = ARGV[0] == "" ? ARGV[0] : Dir.pwd
         
     | 
| 
       53 
     | 
    
         
            -
              bam_path = File.join(path, "deploy.bam")
         
     | 
| 
      
 67 
     | 
    
         
            +
              bam_path = File.join(path, "deploy.bam.rb")
         
     | 
| 
       54 
68 
     | 
    
         
             
              File.open File.join(bam_path), "w+" do |file|
         
     | 
| 
       55 
69 
     | 
    
         
             
                file << template
         
     | 
| 
       56 
70 
     | 
    
         
             
              end
         
     | 
| 
       57 
     | 
    
         
            -
              add_ignore_bam
         
     | 
| 
       58 
     | 
    
         
            -
              puts wrap_borders("Bam! you're done! bam. 
     | 
| 
       59 
     | 
    
         
            -
              # TODO : add editor options 
         
     | 
| 
      
 71 
     | 
    
         
            +
              add_ignore_bam if ARGV[0] == "--ignore-bam"
         
     | 
| 
      
 72 
     | 
    
         
            +
              puts wrap_borders("Bam! you're done! deploy.bam.rb generated to : #{bam_path}")
         
     | 
| 
       60 
73 
     | 
    
         
             
            end
         
     | 
    
        data/lib/bam/version.rb
    CHANGED
    
    
    
        data/lib/bam.rb
    CHANGED
    
    | 
         @@ -3,10 +3,12 @@ module Bam 
     | 
|
| 
       3 
3 
     | 
    
         
             
                include BamHelpers
         
     | 
| 
       4 
4 
     | 
    
         
             
                PWD = Dir.pwd
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
                def initialize(server, to, from)
         
     | 
| 
      
 6 
     | 
    
         
            +
                def initialize(server, to, from, dry_run, task_config)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  @from = from
         
     | 
| 
       8 
8 
     | 
    
         
             
                  @server = server
         
     | 
| 
       9 
9 
     | 
    
         
             
                  @to = to
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @dry_run = dry_run || false
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @task_config = task_config
         
     | 
| 
       10 
12 
     | 
    
         
             
                end
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
14 
     | 
    
         
             
                def has_git?
         
     | 
| 
         @@ -17,30 +19,56 @@ module Bam 
     | 
|
| 
       17 
19 
     | 
    
         
             
                  File.exists?(File.join PWD, ".gitignore")
         
     | 
| 
       18 
20 
     | 
    
         
             
                end
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
                # gets a list of exclusions - exceptions
         
     | 
| 
      
 23 
     | 
    
         
            +
                def get_exclusions
         
     | 
| 
      
 24 
     | 
    
         
            +
                  return "" if !has_git_ignores? || !has_git?   
         
     | 
| 
       22 
25 
     | 
    
         
             
                  git_ignore = File.join PWD, ".gitignore"
         
     | 
| 
       23 
     | 
    
         
            -
                  exclusions = `cat #{git_ignore}`.split("\n")
         
     | 
| 
       24 
     | 
    
         
            -
                   
     | 
| 
      
 26 
     | 
    
         
            +
                  exclusions = `cat #{git_ignore}`.split("\n") 
         
     | 
| 
      
 27 
     | 
    
         
            +
                  exclusions - @task_config[:always_include] 
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                def exclusions
         
     | 
| 
      
 31 
     | 
    
         
            +
                  exclude_list = get_exclusions.map { |e| "--exclude '#{e}' " }
         
     | 
| 
       25 
32 
     | 
    
         
             
                  exclude_list = exclude_list.join
         
     | 
| 
       26 
33 
     | 
    
         
             
                end
         
     | 
| 
       27 
34 
     | 
    
         | 
| 
      
 35 
     | 
    
         
            +
                def remote_exec(name)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  remote_task = @task_config[:remote][name.to_sym]
         
     | 
| 
      
 37 
     | 
    
         
            +
                  if remote_task.nil?
         
     | 
| 
      
 38 
     | 
    
         
            +
                    puts "[REMOTE] TASK: #{name} does not exist"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  else
         
     | 
| 
      
 40 
     | 
    
         
            +
                    exec_cmd = "ssh #{@server} '#{remote_task}'"
         
     | 
| 
      
 41 
     | 
    
         
            +
                    puts @dry_run ? "[REMOTE] #{name} : #{remote_task}" : "[REMOTE] #{name}"
         
     | 
| 
      
 42 
     | 
    
         
            +
                    system exec_cmd unless @dry_run
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       28 
46 
     | 
    
         
             
                def deploy
         
     | 
| 
       29 
     | 
    
         
            -
                  puts 
     | 
| 
      
 47 
     | 
    
         
            +
                  puts "PRE-DEPLOYMENT TASKS: \n\n"
         
     | 
| 
      
 48 
     | 
    
         
            +
                  deploy_tasks @task_config[:pre]
         
     | 
| 
      
 49 
     | 
    
         
            +
                  puts(wrap_top("STARTING DEPLOYMENT:"))
         
     | 
| 
       30 
50 
     | 
    
         
             
                  # use -avzC to exclude .git and .svn repositories
         
     | 
| 
       31 
51 
     | 
    
         
             
                  cmd = "rsync -avzC #{@from} #{@server}:#{@to} #{exclusions}"
         
     | 
| 
       32 
52 
     | 
    
         
             
                  output = "OUTPUT: #{cmd}"
         
     | 
| 
       33 
53 
     | 
    
         
             
                  puts(wrap_borders(output))
         
     | 
| 
       34 
     | 
    
         
            -
                   
     | 
| 
      
 54 
     | 
    
         
            +
                  puts "POST-DEPLOYMENT TASKS: \n\n"
         
     | 
| 
      
 55 
     | 
    
         
            +
                  deploy_tasks @task_config[:post]
         
     | 
| 
      
 56 
     | 
    
         
            +
                  system(cmd) unless @dry_run
         
     | 
| 
       35 
57 
     | 
    
         
             
                end
         
     | 
| 
       36 
58 
     | 
    
         | 
| 
       37 
59 
     | 
    
         
             
                def deploy_tasks(tasks)
         
     | 
| 
       38 
60 
     | 
    
         
             
                  if tasks.length > 0
         
     | 
| 
       39 
61 
     | 
    
         
             
                    tasks.each do |task|
         
     | 
| 
       40 
     | 
    
         
            -
                       
     | 
| 
       41 
     | 
    
         
            -
                       
     | 
| 
      
 62 
     | 
    
         
            +
                      remote_task = task.split("remote:")
         
     | 
| 
      
 63 
     | 
    
         
            +
                      if remote_task.length > 1
         
     | 
| 
      
 64 
     | 
    
         
            +
                        remote_exec remote_task[1]
         
     | 
| 
      
 65 
     | 
    
         
            +
                      else 
         
     | 
| 
      
 66 
     | 
    
         
            +
                        puts "[LOCAL] #{task}"
         
     | 
| 
      
 67 
     | 
    
         
            +
                        `#{task}` unless @dry_run
         
     | 
| 
      
 68 
     | 
    
         
            +
                      end
         
     | 
| 
       42 
69 
     | 
    
         
             
                    end
         
     | 
| 
       43 
70 
     | 
    
         
             
                  end
         
     | 
| 
      
 71 
     | 
    
         
            +
                  puts "\n"
         
     | 
| 
       44 
72 
     | 
    
         
             
                end
         
     | 
| 
       45 
73 
     | 
    
         | 
| 
       46 
74 
     | 
    
         
             
              end
         
     | 
    
        data/lib/bam_helpers.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,37 +1,27 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --- !ruby/object:Gem::Specification 
     | 
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: bam
         
     | 
| 
       3 
     | 
    
         
            -
            version: !ruby/object:Gem::Version 
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       6 
     | 
    
         
            -
              segments: 
         
     | 
| 
       7 
     | 
    
         
            -
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              - 7
         
     | 
| 
       10 
     | 
    
         
            -
              version: 0.0.7
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
       11 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
     | 
    
         
            -
            authors: 
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
       13 
7 
     | 
    
         
             
            - Vann Ek
         
     | 
| 
       14 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       15 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            date: 2010-10-20 00:00:00 -05:00
         
     | 
| 
       19 
     | 
    
         
            -
            default_executable: 
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-11-19 00:00:00.000000000 Z
         
     | 
| 
       20 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
13 
     | 
    
         
             
            description: A super simple deployment utility using rsync and git
         
     | 
| 
       23 
     | 
    
         
            -
            email: 
     | 
| 
      
 14 
     | 
    
         
            +
            email:
         
     | 
| 
       24 
15 
     | 
    
         
             
            - vann@innerfusion.net
         
     | 
| 
       25 
     | 
    
         
            -
            executables: 
     | 
| 
      
 16 
     | 
    
         
            +
            executables:
         
     | 
| 
       26 
17 
     | 
    
         
             
            - bam
         
     | 
| 
       27 
18 
     | 
    
         
             
            - bamify
         
     | 
| 
       28 
19 
     | 
    
         
             
            extensions: []
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
20 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            - .gitignore
         
     | 
| 
      
 21 
     | 
    
         
            +
            files:
         
     | 
| 
      
 22 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
       34 
23 
     | 
    
         
             
            - Gemfile
         
     | 
| 
      
 24 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
       35 
25 
     | 
    
         
             
            - README.mdown
         
     | 
| 
       36 
26 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       37 
27 
     | 
    
         
             
            - bam.gemspec
         
     | 
| 
         @@ -40,39 +30,27 @@ files: 
     | 
|
| 
       40 
30 
     | 
    
         
             
            - lib/bam.rb
         
     | 
| 
       41 
31 
     | 
    
         
             
            - lib/bam/version.rb
         
     | 
| 
       42 
32 
     | 
    
         
             
            - lib/bam_helpers.rb
         
     | 
| 
       43 
     | 
    
         
            -
            has_rdoc: true
         
     | 
| 
       44 
33 
     | 
    
         
             
            homepage: http://github.com/vanntastic/bam
         
     | 
| 
       45 
34 
     | 
    
         
             
            licenses: []
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
       47 
36 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       48 
37 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            require_paths: 
         
     | 
| 
      
 38 
     | 
    
         
            +
            require_paths:
         
     | 
| 
       51 
39 
     | 
    
         
             
            - lib
         
     | 
| 
       52 
     | 
    
         
            -
            required_ruby_version: !ruby/object:Gem::Requirement 
     | 
| 
       53 
     | 
    
         
            -
               
     | 
| 
       54 
     | 
    
         
            -
              requirements: 
         
     | 
| 
      
 40 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 41 
     | 
    
         
            +
              requirements:
         
     | 
| 
       55 
42 
     | 
    
         
             
              - - ">="
         
     | 
| 
       56 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       57 
     | 
    
         
            -
                   
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                  version: "0"
         
     | 
| 
       61 
     | 
    
         
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       62 
     | 
    
         
            -
              none: false
         
     | 
| 
       63 
     | 
    
         
            -
              requirements: 
         
     | 
| 
      
 43 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 44 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 45 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 46 
     | 
    
         
            +
              requirements:
         
     | 
| 
       64 
47 
     | 
    
         
             
              - - ">="
         
     | 
| 
       65 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       66 
     | 
    
         
            -
                   
     | 
| 
       67 
     | 
    
         
            -
                  segments: 
         
     | 
| 
       68 
     | 
    
         
            -
                  - 0
         
     | 
| 
       69 
     | 
    
         
            -
                  version: "0"
         
     | 
| 
      
 48 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 49 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       70 
50 
     | 
    
         
             
            requirements: []
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
51 
     | 
    
         
             
            rubyforge_project: bam
         
     | 
| 
       73 
     | 
    
         
            -
            rubygems_version:  
     | 
| 
      
 52 
     | 
    
         
            +
            rubygems_version: 2.4.5.1
         
     | 
| 
       74 
53 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       75 
     | 
    
         
            -
            specification_version:  
     | 
| 
      
 54 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
       76 
55 
     | 
    
         
             
            summary: A super simple deployment utility
         
     | 
| 
       77 
56 
     | 
    
         
             
            test_files: []
         
     | 
| 
       78 
     | 
    
         
            -
             
     |