pulsar 0.0.1.pre

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p286@pulsar"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.16.13 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ if [[ -s Gemfile ]] && {
38
+ ! builtin command -v bundle >/dev/null ||
39
+ builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ }
41
+ then
42
+ printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ gem install bundler
44
+ fi
45
+ if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ then
47
+ bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ fi
49
+
50
+ alias pulsar="ruby bin/pulsar"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pulsar.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 NebuLab
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,46 @@
1
+ # Pulsar
2
+
3
+ NebuLab's central capistrano deploy resource.
4
+
5
+
6
+ A quick example. To run any cap command for an application specified in a configuration repo you can run:
7
+
8
+ ```
9
+ deploy -c=<configuration-repo-git-url> <application> <stage> <capistrano_args>
10
+ ```
11
+
12
+ A couple of concrete examples:
13
+
14
+ ```
15
+ deploy -c=git@github.com:nebulab/deploy-configuration.git nebulab production --tasks
16
+
17
+ deploy -c=git@github.com:nebulab/deploy-configuration.git nebulab staging # Deploy on staging
18
+
19
+ deploy -c=git@github.com:nebulab/deploy-configuration.git farmavillage production deploy:check
20
+ ```
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ gem 'pulsar'
27
+
28
+ And then execute:
29
+
30
+ $ bundle
31
+
32
+ Or install it yourself as:
33
+
34
+ $ gem install pulsar
35
+
36
+ ## Usage
37
+
38
+ TODO: Write usage instructions here
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pulsar'
4
+
5
+ class PulsarCommand < Clamp::Command
6
+ include Helpers::Clamp::Pulsar
7
+
8
+ option [ "-v", "--verbose" ], :flag,
9
+ "Print out all the things!!!",
10
+ :default => false
11
+
12
+ option [ "-k", "--keep-capfile" ], :flag,
13
+ "Dont't remove the generated capfile in the tmp/ directory.",
14
+ :default => false
15
+
16
+ option [ "-l", "--log-level" ], "LOG LEVEL",
17
+ "How much output will Capistrano spit out. Can be any of: important, info, debug.",
18
+ :default => "important"
19
+
20
+ option [ "-c", "--conf-repo" ], "REPO URL",
21
+ "A git repository with deploy configurations, mainly apps and recipes.",
22
+ :required => true
23
+
24
+ option [ "-b", "--conf-branch" ], "REPO BRANCH",
25
+ "Specify a branch for the configuration repository.",
26
+ :default => "master"
27
+
28
+ parameter "APPLICATION", "The application which you would like to deploy. For example: nebulab"
29
+ parameter "ENVIRONMENT", "The environment on which you would like to deploy. For example: production" do |env|
30
+ %w(production staging development).include?(env) ? env : raise(ArgumentError)
31
+ end
32
+ parameter "[TASKS] ...", "The tasks that will be passed to the final `cap` command. For example: --tasks, deploy, deploy:check", :default => "deploy"
33
+
34
+ def execute
35
+ target = "#{application}:#{environment}"
36
+
37
+ fetch_repo
38
+ create_capfile
39
+ build_capfile(target)
40
+
41
+ cap_args = [tasks_list].flatten.join(" ")
42
+ run_cmd("cap --file #{capfile_path} #{cap_args}", :verbose => verbose?)
43
+
44
+ remove_capfile unless keep_capfile?
45
+ remove_repo
46
+ end
47
+ end
48
+
49
+ PulsarCommand.run
@@ -0,0 +1,30 @@
1
+ Dir['lib/helpers/clamp/**/*.rb'].each { |mod| require("./#{mod}") }
2
+
3
+ module Helpers
4
+ module Capistrano
5
+ module RecipeLoader
6
+ class DSL
7
+ include Helpers::Clamp::Pulsar
8
+
9
+ def initialize(cap_conf, &dsl_code)
10
+ @cap_conf = cap_conf
11
+ instance_eval(&dsl_code)
12
+ end
13
+
14
+ def method_missing(meth, *args, &block)
15
+ if File.directory?("#{config_path}/recipes/#{meth}")
16
+ args.each do |arg|
17
+ @cap_conf.load("#{config_path}/recipes/#{meth}/#{arg}.rb")
18
+ end
19
+ else
20
+ super
21
+ end
22
+ end
23
+ end
24
+
25
+ def load_recipes(&block)
26
+ DSL.new(self, &block)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,93 @@
1
+ require 'fileutils'
2
+
3
+ module Helpers
4
+ module Clamp
5
+ module Pulsar
6
+ include FileUtils
7
+
8
+ def build_capfile(args)
9
+ app, stage = args.split(":")
10
+
11
+ # Variables
12
+ set_log_level
13
+ include_base_conf
14
+ include_app(app, stage) if app
15
+
16
+ # Recipes
17
+ include_app_recipes(app, stage) if app
18
+ end
19
+
20
+ def capfile_path
21
+ @capfile_name ||= "tmp/capfile-#{Time.now.strftime("%Y-%m-%d-%H%M%S")}"
22
+ end
23
+
24
+ def config_path
25
+ @configuration_path ||= "tmp/conf_repo"
26
+ end
27
+
28
+ def create_capfile
29
+ touch(capfile_path, :verbose => verbose?)
30
+ end
31
+
32
+ def fetch_repo
33
+ git_options = "--quiet --depth=1 --branch #{conf_branch}"
34
+ run_cmd("git clone #{git_options} #{conf_repo} #{config_path}", :verbose => verbose?)
35
+ end
36
+
37
+ def include_app(app, stage=nil)
38
+ app_file = "#{config_path}/apps/#{app}/defaults.rb"
39
+ stage_file = "#{config_path}/apps/#{app}/#{stage}.rb"
40
+
41
+ if File.exists?(app_file)
42
+ run_cmd("cat #{app_file} >> #{capfile_path}", :verbose => verbose?)
43
+ end
44
+
45
+ if stage
46
+ run_cmd("cat #{stage_file} >> #{capfile_path}", :verbose => verbose?)
47
+ end
48
+ end
49
+
50
+ def include_app_recipes(app, stage=nil)
51
+ recipes_dir = "#{config_path}/apps/#{app}/recipes"
52
+
53
+ Dir.glob("#{recipes_dir}/*.rb").each do |recipe|
54
+ run_cmd("cat #{recipe} >> #{capfile_path}", :verbose => verbose?)
55
+ end
56
+
57
+ if stage
58
+ Dir.glob("#{recipes_dir}/#{stage}/*.rb").each do |recipe|
59
+ run_cmd("cat #{recipe} >> #{capfile_path}", :verbose => verbose?)
60
+ end
61
+ end
62
+ end
63
+
64
+ def include_base_conf
65
+ run_cmd("cat #{config_path}/apps/base.rb >> #{capfile_path}", :verbose => verbose?)
66
+ end
67
+
68
+ def remove_capfile
69
+ rm_rf(capfile_path, :verbose => verbose?)
70
+ end
71
+
72
+ def remove_repo
73
+ rm_rf(config_path, :verbose => verbose?)
74
+ end
75
+
76
+ def run_cmd(cmd, opts)
77
+ puts cmd if opts[:verbose]
78
+ system(cmd)
79
+ end
80
+
81
+ def set_log_level
82
+ level = log_level.upcase
83
+ levels = %w(IMPORTANT INFO DEBUG)
84
+
85
+ level = levels.first unless levels.include?(level)
86
+
87
+ cmd = "echo 'logger.level = logger.level = Capistrano::Logger::#{level}' >> #{capfile_path}"
88
+
89
+ run_cmd(cmd, :verbose => verbose?)
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,7 @@
1
+ require "pulsar/version"
2
+
3
+ module Pulsar
4
+ require 'clamp'
5
+
6
+ Dir['lib/helpers/clamp/**/*.rb'].each { |mod| require("./#{mod}") }
7
+ end
@@ -0,0 +1,3 @@
1
+ module Pulsar
2
+ VERSION = "0.0.1.pre"
3
+ end
File without changes
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pulsar/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "pulsar"
8
+ gem.version = Pulsar::VERSION
9
+ gem.authors = ["Alberto Vena", "Matteo Latini"]
10
+ gem.email = ["info@nebulab.it"]
11
+ gem.description = %q{NebuLab's central capistrano deploy resource.}
12
+ gem.summary = %q{
13
+ A simple gem that parses capistrano configuration froma another (private) repository
14
+ providing a simple solution to managing multiple systems without installing capistrano
15
+ configurations in each app.
16
+ }
17
+ gem.homepage = "https://github.com/nebulab/deploy"
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ["lib"]
23
+
24
+ gem.add_dependency "clamp", "~> 0.5"
25
+ gem.add_dependency "capistrano", "~> 2.13"
26
+ gem.add_dependency "colored", "~> 1.2"
27
+ gem.add_dependency "spinning_cursor", "~> 0.1"
28
+
29
+ # Capistrano recipes, to be moved to separate repo
30
+ gem.add_dependency "airbrake", "~> 3.1"
31
+ gem.add_dependency "whenever", "~> 0.8"
32
+ gem.add_dependency "delayed_job", "~> 3.0"
33
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pulsar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Alberto Vena
9
+ - Matteo Latini
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-12-10 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: clamp
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '0.5'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '0.5'
31
+ - !ruby/object:Gem::Dependency
32
+ name: capistrano
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '2.13'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '2.13'
47
+ - !ruby/object:Gem::Dependency
48
+ name: colored
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '1.2'
63
+ - !ruby/object:Gem::Dependency
64
+ name: spinning_cursor
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: '0.1'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: '0.1'
79
+ - !ruby/object:Gem::Dependency
80
+ name: airbrake
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: '3.1'
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '3.1'
95
+ - !ruby/object:Gem::Dependency
96
+ name: whenever
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: '0.8'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: delayed_job
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: '3.0'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ version: '3.0'
127
+ description: NebuLab's central capistrano deploy resource.
128
+ email:
129
+ - info@nebulab.it
130
+ executables:
131
+ - pulsar
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - .gitignore
136
+ - .rvmrc
137
+ - Gemfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - bin/pulsar
142
+ - lib/helpers/capistrano/recipe_loader.rb
143
+ - lib/helpers/clamp/pulsar.rb
144
+ - lib/pulsar.rb
145
+ - lib/pulsar/version.rb
146
+ - lib/tasks/.gitkeep
147
+ - pulsar.gemspec
148
+ - tmp/.gitkeep
149
+ homepage: https://github.com/nebulab/deploy
150
+ licenses: []
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ! '>'
165
+ - !ruby/object:Gem::Version
166
+ version: 1.3.1
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 1.8.24
170
+ signing_key:
171
+ specification_version: 3
172
+ summary: A simple gem that parses capistrano configuration froma another (private)
173
+ repository providing a simple solution to managing multiple systems without installing
174
+ capistrano configurations in each app.
175
+ test_files: []