pulsar 0.0.6 → 0.1.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.
Files changed (36) hide show
  1. data/.rspec +0 -2
  2. data/.rvmrc +1 -0
  3. data/README.md +3 -1
  4. data/bin/pulsar-utils +5 -0
  5. data/lib/pulsar/commands/all.rb +1 -1
  6. data/lib/pulsar/commands/init.rb +1 -1
  7. data/lib/pulsar/commands/list.rb +3 -21
  8. data/lib/pulsar/commands/main.rb +32 -13
  9. data/lib/pulsar/commands/utils.rb +10 -0
  10. data/lib/pulsar/helpers/all.rb +4 -0
  11. data/lib/pulsar/options/all.rb +4 -0
  12. data/lib/pulsar/options/conf_repo.rb +28 -0
  13. data/lib/pulsar/options/shared.rb +14 -0
  14. data/lib/pulsar/version.rb +1 -1
  15. data/lib/pulsar.rb +2 -2
  16. data/pulsar.gemspec +5 -4
  17. data/spec/pulsar/commands/list_spec.rb +6 -1
  18. data/spec/pulsar/commands/main_spec.rb +149 -7
  19. data/spec/pulsar/commands/utils_spec.rb +33 -0
  20. data/spec/spec_helper.rb +13 -2
  21. data/spec/support/dummies/dummy_app/config.ru +3 -0
  22. data/spec/support/{dummy_conf → dummies/dummy_conf}/Gemfile +0 -0
  23. data/spec/support/{dummy_conf → dummies/dummy_conf}/apps/base.rb +3 -1
  24. data/spec/support/{dummy_conf → dummies/dummy_conf}/apps/dummy_app/defaults.rb +2 -0
  25. data/spec/support/{dummy_conf → dummies/dummy_conf}/apps/dummy_app/production.rb +2 -0
  26. data/spec/support/dummies/dummy_conf/apps/dummy_app/recipes/custom_recipe.rb +1 -0
  27. data/spec/support/dummies/dummy_conf/apps/dummy_app/recipes/production/custom_recipe.rb +1 -0
  28. data/spec/support/dummies/dummy_conf/apps/dummy_app/recipes/staging/custom_recipe.rb +1 -0
  29. data/spec/support/{dummy_conf → dummies/dummy_conf}/apps/dummy_app/staging.rb +2 -0
  30. data/spec/support/{dummy_conf → dummies/dummy_conf}/recipes/generic/recipe.rb +0 -0
  31. data/spec/support/modules/helpers.rb +26 -3
  32. metadata +53 -26
  33. data/lib/pulsar/commands/cap.rb +0 -56
  34. data/lib/pulsar/tasks/.gitkeep +0 -0
  35. data/spec/pulsar/commands/cap_spec.rb +0 -52
  36. data/spec/support/dummy_conf/apps/dummy_app/recipes/.gitkeep +0 -0
data/.rspec CHANGED
@@ -1,3 +1 @@
1
1
  --color
2
- --format
3
- nested
data/.rvmrc CHANGED
@@ -48,3 +48,4 @@ then
48
48
  fi
49
49
 
50
50
  alias pulsar="ruby bin/pulsar"
51
+ alias pulsar-utils="ruby bin/pulsar-utils"
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Pulsar
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/nebulab/pulsar.png?branch=master)](http://travis-ci.org/nebulab/pulsar)
3
+ [![Gem Version](https://badge.fury.io/rb/pulsar.png)](http://badge.fury.io/rb/pulsar)
4
+ [![Build Status](https://secure.travis-ci.org/nebulab/pulsar.png?branch=master)](http://travis-ci.org/nebulab/pulsar)
5
+ [![Coverage Status](https://coveralls.io/repos/nebulab/pulsar/badge.png?branch=master)](https://coveralls.io/r/nebulab/pulsar)
4
6
  [![Code Climate](https://codeclimate.com/github/nebulab/pulsar.png)](https://codeclimate.com/github/nebulab/pulsar)
5
7
 
6
8
  Pulsar is a little tool that helps with deploys. Its main purpose is building capfiles for [Capistrano](https://rubygems.org/gems/capistrano)
data/bin/pulsar-utils ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pulsar'
4
+
5
+ Pulsar::UtilsCommand.run
@@ -1,6 +1,6 @@
1
1
  module Pulsar
2
2
  autoload :MainCommand, "pulsar/commands/main"
3
- autoload :CapCommand, "pulsar/commands/cap"
3
+ autoload :UtilsCommand, "pulsar/commands/utils"
4
4
  autoload :ListCommand, "pulsar/commands/list"
5
5
  autoload :InitCommand, "pulsar/commands/init"
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module Pulsar
2
- class InitCommand < MainCommand
2
+ class InitCommand < UtilsCommand
3
3
  parameter "CONFIGURATION_PATH", "where to generate your configuration repository"
4
4
 
5
5
  def execute
@@ -1,25 +1,7 @@
1
1
  module Pulsar
2
- class ListCommand < MainCommand
3
- option [ "-k", "--keep-capfile" ], :flag,
4
- "don't remove the generated capfile in the TMP DIR directory",
5
- :default => false
6
-
7
- option [ "-r", "--keep-repo" ], :flag,
8
- "don't remove the downloaded configuration repository from the TMP DIR directory",
9
- :default => false
10
-
11
- option [ "-c", "--conf-repo" ], "REPO URL",
12
- "a git repository with deploy configurations, mainly apps and recipes",
13
- :required => true
14
-
15
- option [ "-b", "--conf-branch" ], "REPO BRANCH",
16
- "specify a branch for the configuration repository",
17
- :default => "master"
18
-
19
- option [ "-d", "--tmp-dir" ], "TMP DIR",
20
- "a directory where to put the configuration repo to build capfile with",
21
- :default => "/tmp/pulsar"
22
-
2
+ class ListCommand < UtilsCommand
3
+ include Pulsar::Options::ConfRepo
4
+
23
5
  def execute
24
6
  Bundler.with_clean_env do
25
7
  fetch_repo
@@ -1,22 +1,41 @@
1
1
  module Pulsar
2
2
  class MainCommand < Clamp::Command
3
3
  include Pulsar::Helpers::Clamp
4
+ include Pulsar::Options::Shared
5
+ include Pulsar::Options::ConfRepo
6
+
7
+ option [ "-l", "--log-level" ], "LOG LEVEL",
8
+ "how much output will Capistrano print out. Can be any of: important, info, debug",
9
+ :default => "important"
4
10
 
5
- #
6
- # Global options
7
- #
8
- option [ "-V", "--version" ], :flag, "print out pulsar version" do
9
- puts(VERSION)
10
- exit(0)
11
+ option [ "-s", "--skip-cap-run" ], :flag,
12
+ "do everything pulsar does (build a Capfile) but don't run the cap command",
13
+ :default => false
14
+
15
+ parameter "APPLICATION", "the application which you would like to deploy" unless File.exists?("#{Dir.pwd}/config.ru")
16
+ parameter "ENVIRONMENT", "the environment on which you would like to deploy" do |env|
17
+ %w(production staging development).include?(env) ? env : raise(ArgumentError)
11
18
  end
19
+ parameter "[TASKS] ...", "the arguments and/or options that will be passed to capistrano", :default => "deploy"
20
+
21
+ def execute
22
+ app = application rescue File.basename(Dir.pwd)
23
+ target = "#{app}:#{environment}"
12
24
 
13
- option [ "-v", "--verbose" ], :flag, "print out what pulsar is doing", :default => false
25
+ Bundler.with_clean_env do
26
+ fetch_repo
27
+ bundle_install
28
+ create_capfile
29
+ build_capfile(target)
14
30
 
15
- #
16
- # Sub commands
17
- #
18
- subcommand "cap", "build a capfile from configuration repo and execute the cap command on it", CapCommand
19
- subcommand "list", "list all available apps and environments which you can deploy", ListCommand
20
- subcommand "init", "generate a new configuration repo with some basic recipes to use with pulsar", InitCommand
31
+ unless skip_cap_run?
32
+ cap_args = [tasks_list].flatten.join(" ")
33
+ run_capistrano(cap_args)
34
+ end
35
+
36
+ remove_capfile unless keep_capfile?
37
+ remove_repo unless keep_repo?
38
+ end
39
+ end
21
40
  end
22
41
  end
@@ -0,0 +1,10 @@
1
+ module Pulsar
2
+ class UtilsCommand < Clamp::Command
3
+ include Pulsar::Helpers::Clamp
4
+ include Pulsar::Options::Shared
5
+
6
+ subcommand "list", "list all available apps and environments which you can deploy", ListCommand
7
+ subcommand "init", "generate a new configuration repo with some basic recipes to use with pulsar", InitCommand
8
+ end
9
+ end
10
+
@@ -0,0 +1,4 @@
1
+ module Pulsar::Helpers
2
+ autoload :Capistrano, "pulsar/helpers/capistrano"
3
+ autoload :Clamp, "pulsar/helpers/clamp"
4
+ end
@@ -0,0 +1,4 @@
1
+ module Pulsar::Options
2
+ autoload :ConfRepo, "pulsar/options/conf_repo"
3
+ autoload :Shared, "pulsar/options/shared"
4
+ end
@@ -0,0 +1,28 @@
1
+ module Pulsar
2
+ module Options
3
+ module ConfRepo
4
+ def self.included(base)
5
+ base.option [ "-c", "--conf-repo" ], "REPO URL",
6
+ "a git repository with deploy configurations, mainly apps and recipes",
7
+ :environment_variable => "PULSAR_CONF_REPO",
8
+ :required => true
9
+
10
+ base.option [ "-k", "--keep-capfile" ], :flag,
11
+ "don't remove the generated capfile in the TMP DIR directory",
12
+ :default => false
13
+
14
+ base.option [ "-r", "--keep-repo" ], :flag,
15
+ "don't remove the downloaded configuration repository from the TMP DIR directory",
16
+ :default => false
17
+
18
+ base.option [ "-b", "--conf-branch" ], "REPO BRANCH",
19
+ "specify a branch for the configuration repository",
20
+ :default => "master"
21
+
22
+ base.option [ "-d", "--tmp-dir" ], "TMP DIR",
23
+ "a directory where to put the configuration repo to build capfile with",
24
+ :default => "/tmp/pulsar"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ module Pulsar
2
+ module Options
3
+ module Shared
4
+ def self.included(base)
5
+ base.option [ "-V", "--version" ], :flag, "print out pulsar version" do
6
+ puts(VERSION)
7
+ exit(0)
8
+ end
9
+
10
+ base.option [ "-v", "--verbose" ], :flag, "print out what pulsar is doing", :default => false
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Pulsar
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/pulsar.rb CHANGED
@@ -4,7 +4,7 @@ module Pulsar
4
4
  require "clamp"
5
5
  require "bundler"
6
6
  require "colored"
7
- require "pulsar/helpers/clamp"
8
- require "pulsar/helpers/capistrano"
7
+ require "pulsar/helpers/all"
8
+ require "pulsar/options/all"
9
9
  require "pulsar/commands/all"
10
10
  end
data/pulsar.gemspec CHANGED
@@ -8,11 +8,11 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Pulsar::VERSION
9
9
  gem.authors = ["Alberto Vena", "Matteo Latini"]
10
10
  gem.email = ["info@nebulab.it"]
11
- gem.description = %q{NebuLab's central capistrano deploy resource.}
11
+ gem.description = %q{Manage your Capistrano deployments with ease}
12
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.
13
+ Pulsar helps with Capistrano configuration management. It uses a repository
14
+ to store all your precious configurations and recipes to build Capistrano
15
+ deploys on it.
16
16
  }
17
17
  gem.homepage = "https://github.com/nebulab/pulsar"
18
18
 
@@ -28,4 +28,5 @@ Gem::Specification.new do |gem|
28
28
  gem.add_development_dependency "rake"
29
29
  gem.add_development_dependency "rspec", "~> 2.12"
30
30
  gem.add_development_dependency "rr", "~> 1.0"
31
+ gem.add_development_dependency "coveralls", "~> 0.6.3"
31
32
  end
@@ -14,7 +14,12 @@ describe Pulsar::ListCommand do
14
14
 
15
15
  context "--conf-repo option" do
16
16
  it "is required" do
17
- expect { pulsar.parse([""]) }.to raise_error(Clamp::UsageError)
17
+ expect { pulsar.parse([]) }.to raise_error(Clamp::UsageError)
18
+ end
19
+
20
+ it "supports environment variable" do
21
+ ENV["PULSAR_CONF_REPO"] = dummy_conf_path
22
+ expect { pulsar.parse([]) }.not_to raise_error(Clamp::UsageError)
18
23
  end
19
24
 
20
25
  it "supports directories" do
@@ -3,6 +3,95 @@ require 'spec_helper'
3
3
  describe Pulsar::MainCommand do
4
4
  let(:pulsar) { Pulsar::MainCommand.new("") }
5
5
 
6
+ before(:each) { reload_main_command }
7
+
8
+ it "builds a Capfile file in tmp dir" do
9
+ expect { pulsar.run(full_cap_args + dummy_app) }.to change{ Dir.glob("#{tmp_path}/capfile-*").length }.by(1)
10
+ end
11
+
12
+ it "copies a the repo over to temp directory" do
13
+ expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
14
+ end
15
+
16
+ it "copies a the repo when there is a dir with same name" do
17
+ system("mkdir #{tmp_path}/conf-repo")
18
+ expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
19
+ end
20
+
21
+ it "uses dirname when inside a rack app directory" do
22
+ FileUtils.cd(dummy_rack_app_path) do
23
+ reload_main_command
24
+
25
+ expect { pulsar.run(full_cap_args + %w(production)) }.to change{ Dir.glob("#{tmp_path}/capfile-*").length }.by(1)
26
+ end
27
+ end
28
+
29
+ context "Capfile" do
30
+ it "uses base.rb in staging stage" do
31
+ pulsar.run(full_cap_args + dummy_app(:staging))
32
+
33
+ latest_capfile.should include("# This is apps/base.rb")
34
+ end
35
+
36
+ it "uses base.rb in production stage" do
37
+ pulsar.run(full_cap_args + dummy_app)
38
+
39
+ latest_capfile.should include("# This is apps/base.rb")
40
+ end
41
+
42
+ it "uses defaults.rb in staging stage" do
43
+ pulsar.run(full_cap_args + dummy_app(:staging))
44
+
45
+ latest_capfile.should include("# This is apps/dummy_app/defaults.rb")
46
+ end
47
+
48
+ it "uses defaults.rb in production stage" do
49
+ pulsar.run(full_cap_args + dummy_app)
50
+
51
+ latest_capfile.should include("# This is apps/dummy_app/defaults.rb")
52
+ end
53
+
54
+ it "uses defaults.rb in staging stage only" do
55
+ pulsar.run(full_cap_args + dummy_app(:staging))
56
+
57
+ latest_capfile.should include("# This is apps/dummy_app/staging.rb")
58
+ latest_capfile.should_not include("# This is apps/dummy_app/production.rb")
59
+ end
60
+
61
+ it "uses defaults.rb in production stage only" do
62
+ pulsar.run(full_cap_args + dummy_app)
63
+
64
+ latest_capfile.should include("# This is apps/dummy_app/production.rb")
65
+ latest_capfile.should_not include("# This is apps/dummy_app/staging.rb")
66
+ end
67
+
68
+ it "uses custom recipes in staging stage" do
69
+ pulsar.run(full_cap_args + dummy_app(:staging))
70
+
71
+ latest_capfile.should include("# This is apps/dummy_app/recipes/custom_recipe.rb")
72
+ end
73
+
74
+ it "uses custom recipes in production stage" do
75
+ pulsar.run(full_cap_args + dummy_app)
76
+
77
+ latest_capfile.should include("# This is apps/dummy_app/recipes/custom_recipe.rb")
78
+ end
79
+
80
+ it "uses custom staging recipes in staging stage only" do
81
+ pulsar.run(full_cap_args + dummy_app(:staging))
82
+
83
+ latest_capfile.should include("# This is apps/dummy_app/recipes/staging/custom_recipe.rb")
84
+ latest_capfile.should_not include("# This is apps/dummy_app/recipes/production/custom_recipe.rb")
85
+ end
86
+
87
+ it "uses custom production recipes in production stage only" do
88
+ pulsar.run(full_cap_args + dummy_app)
89
+
90
+ latest_capfile.should include("# This is apps/dummy_app/recipes/production/custom_recipe.rb")
91
+ latest_capfile.should_not include("# This is apps/dummy_app/recipes/staging/custom_recipe.rb")
92
+ end
93
+ end
94
+
6
95
  context "--version option" do
7
96
  before do
8
97
  begin
@@ -22,13 +111,66 @@ describe Pulsar::MainCommand do
22
111
  end
23
112
  end
24
113
 
25
- context "subcommands" do
26
- it "should be cap and list and init" do
27
- help = pulsar.help
28
- help.should =~ /Subcommands:/
29
- help.should =~ /cap/
30
- help.should =~ /list/
31
- help.should =~ /init/
114
+ context "--conf-repo option" do
115
+ it "is required" do
116
+ expect { pulsar.parse([]) }.to raise_error(Clamp::UsageError)
117
+ end
118
+
119
+ it "supports environment variable" do
120
+ ENV["PULSAR_CONF_REPO"] = dummy_conf_path
121
+ expect { pulsar.parse(dummy_app) }.not_to raise_error(Clamp::UsageError)
122
+ end
123
+
124
+ it "supports directories" do
125
+ expect { pulsar.run(full_cap_args + dummy_app) }.not_to raise_error(Errno::ENOENT)
126
+ end
127
+ end
128
+
129
+ context "--tmp-dir option" do
130
+ it "is supported" do
131
+ expect { pulsar.parse(base_args + %w(--tmp-dir dummy_tmp) + dummy_app) }.to_not raise_error(Clamp::UsageError)
132
+ end
133
+ end
134
+
135
+ context "--keep-capfile option" do
136
+ it "is supported" do
137
+ expect { pulsar.parse(base_args + %w(--keep-capfile) + dummy_app) }.to_not raise_error(Clamp::UsageError)
138
+ end
139
+ end
140
+
141
+ context "--skip-cap-run option" do
142
+ it "is supported" do
143
+ expect { pulsar.parse(base_args + %w(--skip-cap-run) + dummy_app) }.to_not raise_error(Clamp::UsageError)
144
+ end
145
+ end
146
+
147
+ context "--keep-repo option" do
148
+ it "is supported" do
149
+ expect { pulsar.parse(base_args + %w(--keep-repo) + dummy_app) }.to_not raise_error(Clamp::UsageError)
150
+ end
151
+ end
152
+
153
+ context "--log-level option" do
154
+ it "is supported" do
155
+ expect { pulsar.parse(base_args + %w(--log-level debug) + dummy_app) }.to_not raise_error(Clamp::UsageError)
156
+ end
157
+
158
+ it "supports Capistrano IMPORTANT" do
159
+ pulsar.run(full_cap_args + %w(--log-level important) + dummy_app)
160
+
161
+ latest_capfile.should include("logger.level = logger.level = Capistrano::Logger::IMPORTANT")
162
+ end
163
+
164
+ it "supports Capistrano INFO" do
165
+ pulsar.run(full_cap_args + %w(--log-level info) + dummy_app)
166
+
167
+ latest_capfile.should include("logger.level = logger.level = Capistrano::Logger::INFO")
168
+ end
169
+
170
+ it "supports Capistrano DEBUG" do
171
+ pulsar.run(full_cap_args + %w(--log-level debug) + dummy_app)
172
+
173
+ latest_capfile.should include("logger.level = logger.level = Capistrano::Logger::DEBUG")
32
174
  end
33
175
  end
34
176
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pulsar::UtilsCommand do
4
+ let(:pulsar) { Pulsar::UtilsCommand.new("") }
5
+
6
+ context "--version option" do
7
+ before do
8
+ begin
9
+ pulsar.parse(["--version"])
10
+ rescue SystemExit => e
11
+ @system_exit = e
12
+ end
13
+ end
14
+
15
+ it "shows version" do
16
+ stdout.should include(Pulsar::VERSION)
17
+ end
18
+
19
+ it "exits with a zero status" do
20
+ @system_exit.should_not be_nil
21
+ @system_exit.status.should == 0
22
+ end
23
+ end
24
+
25
+ context "subcommands" do
26
+ it "should be cap and list and init" do
27
+ help = pulsar.help
28
+ help.should =~ /Subcommands:/
29
+ help.should =~ /list/
30
+ help.should =~ /init/
31
+ end
32
+ end
33
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,15 @@
1
1
  require "rspec"
2
2
  require "stringio"
3
3
  require "fileutils"
4
+ require "coveralls"
4
5
  require "pulsar"
5
6
  require "pulsar/commands/main"
7
+ require "pulsar/commands/utils"
8
+
9
+ #
10
+ # Code coverage
11
+ #
12
+ Coveralls.wear!
6
13
 
7
14
  #
8
15
  # Require all helper modules
@@ -10,12 +17,16 @@ require "pulsar/commands/main"
10
17
  Dir[File.join(File.dirname(__FILE__), 'support/modules/**/*.rb')].each { |f| require f }
11
18
 
12
19
  RSpec.configure do |config|
13
- config.mock_with :rr
20
+ config.mock_with :rspec
14
21
 
15
22
  config.include Helpers
16
23
  config.include OutputCapture
17
24
 
18
- config.around(:each) do
25
+ config.before(:all) do
26
+ ENV.delete("PULSAR_CONF_REPO")
27
+ end
28
+
29
+ config.after(:each) do
19
30
  FileUtils.rm_rf(Dir.glob("#{File.dirname(__FILE__)}/support/tmp/*"))
20
31
  end
21
32
  end
@@ -0,0 +1,3 @@
1
+ #
2
+ # This is a dummy rack file...
3
+ #
@@ -1,3 +1,5 @@
1
+ # This is apps/base.rb
2
+
1
3
  #
2
4
  # Require and extend with additional modules
3
5
  #
@@ -19,7 +21,7 @@ require 'bundler/capistrano'
19
21
  # Load default recipes
20
22
  #
21
23
  load_recipes do
22
- generic :notify, :cleanup, :rake
24
+ generic :recipe
23
25
  end
24
26
 
25
27
  #
@@ -1,3 +1,5 @@
1
+ # This is apps/dummy_app/defaults.rb
2
+
1
3
  set :application, "dummy_app"
2
4
 
3
5
  load_recipes do
@@ -1,3 +1,5 @@
1
+ # This is apps/dummy_app/production.rb
2
+
1
3
  server "dummy.it", :db, :web, :app, :primary => true
2
4
 
3
5
  set :stage, "production"
@@ -0,0 +1 @@
1
+ # This is apps/dummy_app/recipes/custom_recipe.rb
@@ -0,0 +1 @@
1
+ # This is apps/dummy_app/recipes/production/custom_recipe.rb
@@ -0,0 +1 @@
1
+ # This is apps/dummy_app/recipes/staging/custom_recipe.rb
@@ -1,3 +1,5 @@
1
+ # This is apps/dummy_app/staging.rb
2
+
1
3
  server "staging.dummy.it", :db, :web, :app, :primary => true
2
4
 
3
5
  set :stage, "staging"
@@ -12,14 +12,37 @@ module Helpers
12
12
  end
13
13
 
14
14
  def dummy_conf_path
15
- File.join(File.dirname(__FILE__), "..", "dummy_conf")
15
+ File.join(File.dirname(__FILE__), "..", "dummies", "dummy_conf")
16
+ end
17
+
18
+ def dummy_rack_app_path
19
+ File.join(File.dirname(__FILE__), "..", "dummies", "dummy_app")
16
20
  end
17
21
 
18
22
  def tmp_path
19
23
  File.join(File.dirname(__FILE__), "..", "tmp")
20
24
  end
21
25
 
22
- def dummy_app
23
- [ "dummy_app", "production" ]
26
+ def dummy_app(stage = :production)
27
+ [ "dummy_app", stage.to_s ]
28
+ end
29
+
30
+ def latest_capfile
31
+ capfile = File.open(Dir.glob("#{tmp_path}/capfile-*").first)
32
+ content = capfile.read
33
+ capfile.close
34
+
35
+ content
36
+ end
37
+
38
+ def reload_main_command
39
+ Pulsar.instance_eval{ remove_const :MainCommand }
40
+ load "pulsar/commands/main.rb"
41
+
42
+ stub_bundle_install
43
+ end
44
+
45
+ def stub_bundle_install
46
+ Pulsar::MainCommand.any_instance.stub(:bundle_install)
24
47
  end
25
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulsar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.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-03-13 00:00:00.000000000 Z
13
+ date: 2013-03-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: clamp
@@ -108,11 +108,28 @@ dependencies:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.0'
111
- description: NebuLab's central capistrano deploy resource.
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: 0.6.3
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ version: 0.6.3
127
+ description: Manage your Capistrano deployments with ease
112
128
  email:
113
129
  - info@nebulab.it
114
130
  executables:
115
131
  - pulsar
132
+ - pulsar-utils
116
133
  extensions: []
117
134
  extra_rdoc_files: []
118
135
  files:
@@ -125,12 +142,13 @@ files:
125
142
  - README.md
126
143
  - Rakefile
127
144
  - bin/pulsar
145
+ - bin/pulsar-utils
128
146
  - lib/pulsar.rb
129
147
  - lib/pulsar/commands/all.rb
130
- - lib/pulsar/commands/cap.rb
131
148
  - lib/pulsar/commands/init.rb
132
149
  - lib/pulsar/commands/list.rb
133
150
  - lib/pulsar/commands/main.rb
151
+ - lib/pulsar/commands/utils.rb
134
152
  - lib/pulsar/generators/init_repo/Gemfile
135
153
  - lib/pulsar/generators/init_repo/README.md
136
154
  - lib/pulsar/generators/init_repo/apps/base.rb
@@ -143,24 +161,30 @@ files:
143
161
  - lib/pulsar/generators/init_repo/recipes/generic/cleanup.rb
144
162
  - lib/pulsar/generators/init_repo/recipes/generic/rake.rb
145
163
  - lib/pulsar/generators/init_repo/recipes/rails/.gitkeep
164
+ - lib/pulsar/helpers/all.rb
146
165
  - lib/pulsar/helpers/capistrano.rb
147
166
  - lib/pulsar/helpers/clamp.rb
148
- - lib/pulsar/tasks/.gitkeep
167
+ - lib/pulsar/options/all.rb
168
+ - lib/pulsar/options/conf_repo.rb
169
+ - lib/pulsar/options/shared.rb
149
170
  - lib/pulsar/version.rb
150
171
  - pulsar.gemspec
151
- - spec/pulsar/commands/cap_spec.rb
152
172
  - spec/pulsar/commands/init_spec.rb
153
173
  - spec/pulsar/commands/list_spec.rb
154
174
  - spec/pulsar/commands/main_spec.rb
175
+ - spec/pulsar/commands/utils_spec.rb
155
176
  - spec/pulsar/helpers/clamp_spec.rb
156
177
  - spec/spec_helper.rb
157
- - spec/support/dummy_conf/Gemfile
158
- - spec/support/dummy_conf/apps/base.rb
159
- - spec/support/dummy_conf/apps/dummy_app/defaults.rb
160
- - spec/support/dummy_conf/apps/dummy_app/production.rb
161
- - spec/support/dummy_conf/apps/dummy_app/recipes/.gitkeep
162
- - spec/support/dummy_conf/apps/dummy_app/staging.rb
163
- - spec/support/dummy_conf/recipes/generic/recipe.rb
178
+ - spec/support/dummies/dummy_app/config.ru
179
+ - spec/support/dummies/dummy_conf/Gemfile
180
+ - spec/support/dummies/dummy_conf/apps/base.rb
181
+ - spec/support/dummies/dummy_conf/apps/dummy_app/defaults.rb
182
+ - spec/support/dummies/dummy_conf/apps/dummy_app/production.rb
183
+ - spec/support/dummies/dummy_conf/apps/dummy_app/recipes/custom_recipe.rb
184
+ - spec/support/dummies/dummy_conf/apps/dummy_app/recipes/production/custom_recipe.rb
185
+ - spec/support/dummies/dummy_conf/apps/dummy_app/recipes/staging/custom_recipe.rb
186
+ - spec/support/dummies/dummy_conf/apps/dummy_app/staging.rb
187
+ - spec/support/dummies/dummy_conf/recipes/generic/recipe.rb
164
188
  - spec/support/modules/helpers.rb
165
189
  - spec/support/modules/output_capture.rb
166
190
  - spec/support/tmp/.gitkeep
@@ -178,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
202
  version: '0'
179
203
  segments:
180
204
  - 0
181
- hash: -1640336626814053383
205
+ hash: 2803214498054614513
182
206
  required_rubygems_version: !ruby/object:Gem::Requirement
183
207
  none: false
184
208
  requirements:
@@ -187,29 +211,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
211
  version: '0'
188
212
  segments:
189
213
  - 0
190
- hash: -1640336626814053383
214
+ hash: 2803214498054614513
191
215
  requirements: []
192
216
  rubyforge_project:
193
217
  rubygems_version: 1.8.24
194
218
  signing_key:
195
219
  specification_version: 3
196
- summary: A simple gem that parses capistrano configuration froma another (private)
197
- repository providing a simple solution to managing multiple systems without installing
198
- capistrano configurations in each app.
220
+ summary: Pulsar helps with Capistrano configuration management. It uses a repository
221
+ to store all your precious configurations and recipes to build Capistrano deploys
222
+ on it.
199
223
  test_files:
200
- - spec/pulsar/commands/cap_spec.rb
201
224
  - spec/pulsar/commands/init_spec.rb
202
225
  - spec/pulsar/commands/list_spec.rb
203
226
  - spec/pulsar/commands/main_spec.rb
227
+ - spec/pulsar/commands/utils_spec.rb
204
228
  - spec/pulsar/helpers/clamp_spec.rb
205
229
  - spec/spec_helper.rb
206
- - spec/support/dummy_conf/Gemfile
207
- - spec/support/dummy_conf/apps/base.rb
208
- - spec/support/dummy_conf/apps/dummy_app/defaults.rb
209
- - spec/support/dummy_conf/apps/dummy_app/production.rb
210
- - spec/support/dummy_conf/apps/dummy_app/recipes/.gitkeep
211
- - spec/support/dummy_conf/apps/dummy_app/staging.rb
212
- - spec/support/dummy_conf/recipes/generic/recipe.rb
230
+ - spec/support/dummies/dummy_app/config.ru
231
+ - spec/support/dummies/dummy_conf/Gemfile
232
+ - spec/support/dummies/dummy_conf/apps/base.rb
233
+ - spec/support/dummies/dummy_conf/apps/dummy_app/defaults.rb
234
+ - spec/support/dummies/dummy_conf/apps/dummy_app/production.rb
235
+ - spec/support/dummies/dummy_conf/apps/dummy_app/recipes/custom_recipe.rb
236
+ - spec/support/dummies/dummy_conf/apps/dummy_app/recipes/production/custom_recipe.rb
237
+ - spec/support/dummies/dummy_conf/apps/dummy_app/recipes/staging/custom_recipe.rb
238
+ - spec/support/dummies/dummy_conf/apps/dummy_app/staging.rb
239
+ - spec/support/dummies/dummy_conf/recipes/generic/recipe.rb
213
240
  - spec/support/modules/helpers.rb
214
241
  - spec/support/modules/output_capture.rb
215
242
  - spec/support/tmp/.gitkeep
@@ -1,56 +0,0 @@
1
- module Pulsar
2
- class CapCommand < MainCommand
3
- option [ "-k", "--keep-capfile" ], :flag,
4
- "don't remove the generated capfile in the TMP DIR directory",
5
- :default => false
6
-
7
- option [ "-r", "--keep-repo" ], :flag,
8
- "don't remove the downloaded configuration repository from the TMP DIR directory",
9
- :default => false
10
-
11
- option [ "-l", "--log-level" ], "LOG LEVEL",
12
- "how much output will Capistrano print out. Can be any of: important, info, debug",
13
- :default => "important"
14
-
15
- option [ "-c", "--conf-repo" ], "REPO URL",
16
- "a git repository with deploy configurations, mainly apps and recipes",
17
- :required => true
18
-
19
- option [ "-b", "--conf-branch" ], "REPO BRANCH",
20
- "specify a branch for the configuration repository",
21
- :default => "master"
22
-
23
- option [ "-d", "--tmp-dir" ], "TMP DIR",
24
- "a directory where to put the configuration repo to build capfile with",
25
- :default => "/tmp/pulsar"
26
-
27
- option [ "-s", "--skip-cap-run" ], :flag,
28
- "do everything pulsar does (build a Capfile) but don't run the cap command",
29
- :default => false
30
-
31
- parameter "APPLICATION", "the application which you would like to deploy"
32
- parameter "ENVIRONMENT", "the environment on which you would like to deploy" do |env|
33
- %w(production staging development).include?(env) ? env : raise(ArgumentError)
34
- end
35
- parameter "[TASKS] ...", "the tasks/args that will be passed to the final `cap` command", :default => "deploy"
36
-
37
- def execute
38
- target = "#{application}:#{environment}"
39
-
40
- Bundler.with_clean_env do
41
- fetch_repo
42
- bundle_install
43
- create_capfile
44
- build_capfile(target)
45
-
46
- unless skip_cap_run?
47
- cap_args = [tasks_list].flatten.join(" ")
48
- run_capistrano(cap_args)
49
- end
50
-
51
- remove_capfile unless keep_capfile?
52
- remove_repo unless keep_repo?
53
- end
54
- end
55
- end
56
- end
File without changes
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Pulsar::CapCommand do
4
- let(:pulsar) { Pulsar::CapCommand.new("cap") }
5
-
6
- it "builds a Capfile file in tmp dir" do
7
- expect { pulsar.run(full_cap_args + dummy_app) }.to change{ Dir.glob("#{tmp_path}/capfile-*").length }.by(1)
8
- end
9
-
10
- it "copies a the repo over to temp directory" do
11
- expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
12
- end
13
-
14
- it "copies a the repo when there is a dir with same name" do
15
- system("mkdir #{tmp_path}/conf-repo")
16
- expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
17
- end
18
-
19
- context "--conf-repo option" do
20
- it "is required" do
21
- expect { pulsar.parse([""]) }.to raise_error(Clamp::UsageError)
22
- end
23
-
24
- it "supports directories" do
25
- expect { pulsar.run(full_cap_args + dummy_app) }.not_to raise_error(Errno::ENOENT)
26
- end
27
- end
28
-
29
- context "--tmp-dir option" do
30
- it "is supported" do
31
- expect { pulsar.parse(base_args + %w(--tmp-dir dummy_tmp) + dummy_app) }.to_not raise_error(Clamp::UsageError)
32
- end
33
- end
34
-
35
- context "--keep-capfile option" do
36
- it "is supported" do
37
- expect { pulsar.parse(base_args + %w(--keep-capfile) + dummy_app) }.to_not raise_error(Clamp::UsageError)
38
- end
39
- end
40
-
41
- context "--skip-cap-run option" do
42
- it "is supported" do
43
- expect { pulsar.parse(base_args + %w(--skip-cap-run) + dummy_app) }.to_not raise_error(Clamp::UsageError)
44
- end
45
- end
46
-
47
- context "--keep-repo option" do
48
- it "is supported" do
49
- expect { pulsar.parse(base_args + %w(--keep-repo) + dummy_app) }.to_not raise_error(Clamp::UsageError)
50
- end
51
- end
52
- end