bam 0.0.6

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,5 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ deploy.bam
5
+ bam/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bam.gemspec
4
+ gemspec
data/README.mdown ADDED
@@ -0,0 +1,27 @@
1
+ Bam
2
+ ===
3
+
4
+ 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. With a combination of rsync and git (well actually not really, bam simply allows git to do what git does best... version management).
5
+
6
+ Installation
7
+ ============
8
+
9
+ gem install bam
10
+
11
+ Usage
12
+ =====
13
+
14
+ cd into/your/project/root
15
+ bamify
16
+ # update the @server and @to variables in deploy.bam file
17
+ # work on your project
18
+ bam
19
+
20
+ TODO
21
+ ====
22
+
23
+ - Add revision history
24
+
25
+
26
+ Copyright (c) 2010 Vann Ek., released under the MIT license
27
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bam.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "bam/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "bam"
7
+ s.version = Bam::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Vann Ek"]
10
+ s.email = ["vann@innerfusion.net"]
11
+ s.homepage = "http://github.com/vanntastic/bam"
12
+ s.summary = %q{A super simple deployment utility}
13
+ s.description = %q{A super simple deployment utility using rsync and git}
14
+
15
+ s.rubyforge_project = "bam"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
data/bin/bam ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ begin
4
+ require "bam_helpers"
5
+ require "bam"
6
+ rescue LoadError
7
+ require "rubygems"
8
+ require "bam_helpers"
9
+ require "bam"
10
+ end
11
+
12
+ pwd = Dir.pwd
13
+ bampath = File.join(pwd, "deploy.bam")
14
+ if File.exists?(bampath)
15
+ @pre_deploy_tasks, @post_deploy_tasks = nil
16
+ deployfile = File.read(File.join(pwd,"deploy.bam"))
17
+ eval deployfile
18
+ ready_to = Bam::Deployment.new @server, @to, pwd
19
+ ready_to.deploy_tasks(@pre_deploy_tasks) unless @pre_deploy_tasks.nil?
20
+ ready_to.deploy
21
+ ready_to.deploy_tasks(@post_deploy_tasks) unless @post_deploy_tasks.nil?
22
+ else
23
+ puts "No deploy.bam file found, run bamify to generate one."
24
+ end
data/bin/bamify ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ # Bamify : generates the deploy.bam file for deploying using bam
4
+ # USAGE :
5
+ # bamify [path_to_project]
6
+ begin
7
+ require "bam_helpers"
8
+ rescue LoadError
9
+ require "rubygems"
10
+ require "bam_helpers"
11
+ end
12
+
13
+ include BamHelpers
14
+
15
+ def template
16
+ "
17
+ # Bam Deploy File
18
+ # ---------------
19
+ # All you have to do is change all the variables below...
20
+ # the ip or hostname of the server, can use the following conventions for this variable:
21
+ # - server_name # => if you have server_name setup in ~/.ssh/config
22
+ # - username@host
23
+ @server = 'login@yourhost.com'
24
+ # the location on the server don't forget to append the slash/
25
+ @to = '~/location/to/your/web/site/or/app/'
26
+
27
+ # pre_deploy_tasks : These are things that you can run locally before deployment
28
+ # @pre_deploy_tasks = ['rm -rf cache/*']
29
+ # @pre_deploy_tasks = []
30
+
31
+ # post_deploy_tasks : These are things that you can run locally before deployment
32
+ # @post_deploy_tasks = ['rm -rf cache/*']
33
+ # @post_deploy_tasks = []
34
+ "
35
+ end
36
+
37
+ def add_ignore_bam
38
+ `touch .gitignore` unless File.exists?(".gitignore")
39
+ no_bam_found = (`cat .gitignore | grep deploy.bam` == "")
40
+ `echo deploy.bam >> .gitignore` if no_bam_found
41
+ end
42
+
43
+ if ARGV[0] == "--help"
44
+ puts "bamify [path_to_project]"
45
+ else
46
+ path = ARGV[0] == "" ? ARGV[0] : Dir.pwd
47
+ bam_path = File.join(path, "deploy.bam")
48
+ File.open File.join(bam_path), "w+" do |file|
49
+ file << template
50
+ end
51
+ add_ignore_bam
52
+ puts wrap_borders("Bam! you're done! bam.deploy generated to : #{bam_path}")
53
+ # TODO : add editor options
54
+ end
55
+
@@ -0,0 +1,3 @@
1
+ module Bam
2
+ VERSION = "0.0.6"
3
+ end
data/lib/bam.rb ADDED
@@ -0,0 +1,47 @@
1
+ module Bam
2
+ class Deployment
3
+ include BamHelpers
4
+ PWD = Dir.pwd
5
+
6
+ def initialize(server, to, from)
7
+ @from = from
8
+ @server = server
9
+ @to = to
10
+ end
11
+
12
+ def has_git?
13
+ File.exists?(File.join PWD, ".git")
14
+ end
15
+
16
+ def has_git_ignores?
17
+ File.exists?(File.join PWD, ".gitignore")
18
+ end
19
+
20
+ def exclusions
21
+ return "" if !has_git_ignores? || !has_git?
22
+ git_ignore = File.join PWD, ".gitignore"
23
+ exclusions = `cat #{git_ignore}`.split("\n")
24
+ exclude_list = exclusions.map { |e| "--exclude '#{e}' " }
25
+ exclude_list = exclude_list.join
26
+ end
27
+
28
+ def deploy
29
+ puts("Starting deployment...")
30
+ # use -avzC to exclude .git and .svn repositories
31
+ cmd = "rsync -avzC #{@from} #{@server}:#{@to} #{exclusions}"
32
+ output = "OUTPUT: #{cmd}"
33
+ puts(wrap_borders(output))
34
+ system(cmd)
35
+ end
36
+
37
+ def deploy_tasks(tasks)
38
+ if tasks.length > 0
39
+ tasks.each do |task|
40
+ puts " - Executing deployment task: #{task}"
41
+ `#{task}`
42
+ end
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,14 @@
1
+ module BamHelpers
2
+ # terminal column width
3
+ def col_width
4
+ `stty size`.split(" ").last.to_i
5
+ end
6
+
7
+ def border
8
+ "="*col_width
9
+ end
10
+
11
+ def wrap_borders(content)
12
+ "#{border}\n#{content}\n#{border}"
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bam
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 6
10
+ version: 0.0.6
11
+ platform: ruby
12
+ authors:
13
+ - Vann Ek
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-20 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: A super simple deployment utility using rsync and git
23
+ email:
24
+ - vann@innerfusion.net
25
+ executables:
26
+ - bam
27
+ - bamify
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - README.mdown
36
+ - Rakefile
37
+ - bam.gemspec
38
+ - bin/bam
39
+ - bin/bamify
40
+ - lib/bam.rb
41
+ - lib/bam/version.rb
42
+ - lib/bam_helpers.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/vanntastic/bam
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options: []
49
+
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ requirements: []
71
+
72
+ rubyforge_project: bam
73
+ rubygems_version: 1.3.7
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: A super simple deployment utility
77
+ test_files: []
78
+