caphub 0.0.1

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 ADDED
@@ -0,0 +1,98 @@
1
+ ## Caphub
2
+
3
+ Generate centralized capistrano skeleton for multiple deployment.
4
+
5
+ ## Caphub Concept
6
+
7
+ Main idea of caphub is separate deployment and application code. So instead of `capify` your each project create **one** caphub repository and put **all** configurations/recipes there.
8
+
9
+ Benefits:
10
+
11
+ * no deployment/application code mix.
12
+ * all deployment located in place.
13
+ * ability to deploy multiple projects
14
+ * deployment is not limited application deployment - deploy your system configurations too! (nginx/haproxy/etc configs)
15
+ * easy to share configurations/recipes among multiple deployment.
16
+ * uptodate synchronizing with remote repository (with capistrano-uptodate).
17
+ * generate layout with caphub or write it yourself from scratch with your own recipes
18
+
19
+ ## Description
20
+
21
+ Caphub is simple generation tool that follows *caphub concept*.
22
+
23
+ Caphub generates similar layout that does usual `capify` command.
24
+ Core of caphub skeleton is [capistrano-multiconfig](https://github.com/railsware/capistrano-multiconfig) gem that allows to recursively build multiple configurations.
25
+
26
+ Another included gems are optional but might be useful:
27
+
28
+ * [capistrano_colors](https://github.com/stjernstrom/capistrano_colors)
29
+ * [capistrano-uptodate](https://github.com/railsware/capistrano-uptodate/README.md)
30
+ * [capistrano-patch](https://github.com/railsware/capistrano-patch/README.md)
31
+ * [capistrano-calendar](https://github.com/railsware/capistrano-calendar/README.md)
32
+
33
+ ## Installation
34
+
35
+ $ gem install caphub
36
+
37
+ ## Usage
38
+
39
+ Generate caphub layout:
40
+
41
+ $ cuphub my-deploy
42
+
43
+ Creating directory my-deploy
44
+ Creating capistrano skeleton in my-deploy
45
+ Initializating git repository in my-deploy
46
+
47
+ Layout example:
48
+
49
+ $ tree --dirsfirst my-deploy
50
+ my-deploy
51
+ ├── config
52
+ │   ├── deploy
53
+ │   └── deploy.rb
54
+ ├── recipes
55
+ ├── Capfile
56
+ ├── Gemfile
57
+ └── Gemfile.lock
58
+
59
+ Review gems into `Gemfile` and initialize gems:
60
+
61
+ $ bundle install
62
+
63
+ Push repository remote server:
64
+
65
+ git remote add origin your/remote/git/repo/url
66
+ git push -u origin master
67
+
68
+ ### Configurations
69
+
70
+ Put own configuration in `config/deploy`.
71
+
72
+ E.g create `config/deploy/blog/production.rb` and it will be automatically available:
73
+
74
+ $ bundle exec cap -T
75
+ cap blog:production # Load blog:production configuration
76
+
77
+ Use any recipe with configuration task (similar to multistage extension). E.g:
78
+
79
+ $ bundle exec cap blog:production deploy:setup
80
+
81
+ ### Recipes
82
+
83
+ Add gems that contains capistrano recipes to `Gemfile`.
84
+
85
+ Configure and require recipes into `Capfile`.
86
+
87
+ Put own recipes to `recipes` directory.
88
+
89
+ ## References
90
+
91
+ * [capistrano](https://github.com/capistrano/capistrano)
92
+ * [capistrano-ext](https://github.com/capistrano/capistrano-ext)
93
+ * [capistrano_colors](https://github.com/stjernstrom/capistrano_colors)
94
+ * [capistrano-multiconfig](https://github.com/railsware/capistrano-multiconfig)
95
+ * [capistrano-uptodate](https://github.com/railsware/capistrano-uptodate/README.md)
96
+ * [capistrano-patch](https://github.com/railsware/capistrano-patch/README.md)
97
+ * [capistrano-calendar](https://github.com/railsware/capistrano-calendar/README.md)
98
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/caphub ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'caphub'
4
+ Caphub::Runner.run
data/caphup.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "caphub/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "caphub"
7
+ s.version = Caphub::VERSION
8
+ s.authors = ["Andriy Yanko"]
9
+ s.email = ["andriy.yanko@gmail.com"]
10
+ s.homepage = "https://github.com/railsware/caphub"
11
+ s.summary = %q{Generate centralized capistrano skeleton for multiple deployment}
12
+ s.description = %q{Generate centralized capistrano skeleton for multiple deployment}
13
+
14
+ s.rubyforge_project = "caphub"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,59 @@
1
+ require 'optparse'
2
+ require 'fileutils'
3
+
4
+ module Caphub
5
+ class Runner
6
+ class << self
7
+ def run
8
+ runner = new(ARGV)
9
+ runner.parse_options!
10
+ runner.run!
11
+ end
12
+ end
13
+
14
+ def initialize(args)
15
+ @args = args.dup
16
+ @options = {}
17
+ end
18
+
19
+ attr_reader :options
20
+
21
+ def parse_options!
22
+ OptionParser.new do |opts|
23
+ opts.banner = "Usage: #{File.basename($0)} [path]"
24
+ opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
25
+ opts.on_tail('-v', '--version', "Show version") { puts Caphub::VERSION; exit }
26
+
27
+ begin
28
+ opts.parse!(ARGV)
29
+ rescue OptionParser::ParseError => e
30
+ warn e.message
31
+ puts opts
32
+ exit 1
33
+ end
34
+ end
35
+
36
+ abort "Please specify the directory for capistrano hub" if @args.empty?
37
+ abort "'#{@args.first}' exists." if File.exists?(@args.first)
38
+
39
+ @options[:target] = @args.first
40
+ end
41
+
42
+ def skeleton_dir
43
+ File.expand_path('../../../skeleton', __FILE__)
44
+ end
45
+
46
+ def run!
47
+ target = options[:target]
48
+
49
+ puts "Creating directory #{target}"
50
+ FileUtils.mkdir(target)
51
+
52
+ puts "Creating capistrano skeleton in #{target}"
53
+ FileUtils.cp_r("#{skeleton_dir}/.", target)
54
+
55
+ puts "Initializating git repository in #{target}"
56
+ Dir.chdir(target) { `git init`; `git add .` }
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module Caphub
2
+ VERSION = "0.0.1"
3
+ end
data/lib/caphub.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "caphub/version"
2
+ require "caphub/runner"
data/skeleton/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby-1.8.7
data/skeleton/Capfile ADDED
@@ -0,0 +1,33 @@
1
+ #
2
+ # Load deploy capistrano recipe
3
+ #
4
+ load 'deploy'
5
+
6
+ #
7
+ # Configure libraries/recipes from Gemfile
8
+ #
9
+
10
+ # https://github.com/stjernstrom/capistrano_colors/README.rdoc
11
+ require 'capistrano_colors'
12
+
13
+ # https://github.com/railsware/capistrano-multiconfig/README.md
14
+ require 'capistrano/multiconfig'
15
+
16
+ # https://github.com/railsware/capistrano-uptodate/README.md
17
+ require 'capistrano/uptodate'
18
+
19
+ # https://github.com/railsware/capistrano-patch/README.md
20
+ require 'capistrano/patch'
21
+
22
+ # https://github.com/railsware/capistrano-calendar/README.md
23
+ require 'capistrano/calendar'
24
+
25
+ #
26
+ # Load all custom recipes
27
+ #
28
+ Dir['recipes/**/*.rb'].each { |recipe| load(recipe) }
29
+
30
+ # Load main configuration
31
+ load 'config/deploy'
32
+
33
+ # vim syntax=ruby
data/skeleton/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "capistrano"
4
+
5
+ gem "capistrano_colors"
6
+
7
+ gem "capistrano-multiconfig"
8
+ gem "capistrano-uptodate"
9
+ gem "capistrano-patch"
10
+ gem "capistrano-calendar"
File without changes
File without changes
@@ -0,0 +1,39 @@
1
+ #
2
+ # Put here shared configuration shared among all children
3
+ #
4
+ # Read more about configurations:
5
+ # https://github.com/railsware/capistrano-multiconfig/README.md
6
+
7
+ # Configuration example for layout like:
8
+ # config/deploy/{NAMESPACE}/.../#{PROJECT_NAME}/{STAGE_NAME}.rb
9
+
10
+ set :scm, :git
11
+
12
+ set :git_shallow_clone, 1
13
+
14
+ set :deploy_via, :export
15
+
16
+ set :branch, lambda { Capistrano::CLI.ui.ask "SCM branch: " }
17
+
18
+ set(:application) { config_name.split(':').reverse[1] }
19
+
20
+ set(:stage) { config_name.split(':').last }
21
+
22
+ set(:rails_env) { stage }
23
+
24
+ set(:rake) { use_bundle ? "bundle exec rake" : "rake" }
25
+
26
+ set(:repository) { "git://scm.mycompany.com/#{application}.git" }
27
+
28
+ set(:deploy_to) { "/var/www/#{application}" }
29
+
30
+ set :calendar_username, 'vasya.pupkin@gmail.com'
31
+
32
+ set :calendar_password, 'qwery123456'
33
+
34
+ set(:calendar_name) { "mycompany-#{stage}" }
35
+
36
+ after 'deploy' do
37
+ set :calendar_event_title, "[DEPLOYED] #{application} #{branch}: #{real_revision}"
38
+ top.calendar.create_event
39
+ end
File without changes
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: caphub
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Andriy Yanko
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-04 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Generate centralized capistrano skeleton for multiple deployment
22
+ email:
23
+ - andriy.yanko@gmail.com
24
+ executables:
25
+ - caphub
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - README.md
32
+ - Rakefile
33
+ - bin/caphub
34
+ - caphup.gemspec
35
+ - lib/caphub.rb
36
+ - lib/caphub/runner.rb
37
+ - lib/caphub/version.rb
38
+ - skeleton/.rvmrc
39
+ - skeleton/Capfile
40
+ - skeleton/Gemfile
41
+ - skeleton/Gemfile.lock
42
+ - skeleton/config/deploy.rb
43
+ - skeleton/config/deploy/.gitkeep
44
+ - skeleton/recipes/.gitkeep
45
+ homepage: https://github.com/railsware/caphub
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project: caphub
74
+ rubygems_version: 1.8.6
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Generate centralized capistrano skeleton for multiple deployment
78
+ test_files: []
79
+