cap-util 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -2
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +5 -5
- data/cap-util.gemspec +3 -3
- data/lib/cap-util/bundler_cmd.rb +39 -0
- data/lib/cap-util/fake_cap.rb +2 -0
- data/lib/cap-util/git_branch.rb +1 -1
- data/lib/cap-util/halt.rb +1 -1
- data/lib/cap-util/local_cmd_runner.rb +25 -0
- data/lib/cap-util/run.rb +3 -20
- data/lib/cap-util/server_roles.rb +1 -1
- data/lib/cap-util/server_roles_yaml.rb +1 -1
- data/lib/cap-util/shared_path.rb +1 -1
- data/lib/cap-util/timer.rb +3 -3
- data/lib/cap-util/unset_var.rb +1 -1
- data/lib/cap-util/version.rb +1 -1
- data/test/helper.rb +2 -0
- data/test/support/{an_cap_util.rb → a_cap_util.rb} +1 -1
- data/test/support/factory.rb +6 -0
- data/test/system/cap_util_tests.rb +13 -11
- data/test/unit/bundler_cmd_tests.rb +74 -0
- data/test/unit/fake_cap_tests.rb +4 -4
- data/test/unit/git_branch_tests.rb +3 -3
- data/test/unit/local_cmd_runner_tests.rb +5 -5
- data/test/unit/server_roles_tests.rb +3 -3
- data/test/unit/server_roles_yaml_tests.rb +4 -4
- data/test/unit/shared_path_tests.rb +5 -4
- data/test/unit/timer_tests.rb +3 -3
- data/test/unit/unset_var_tests.rb +3 -3
- metadata +26 -52
- data/Rakefile +0 -1
- data/lib/cap-util/rake_task.rb +0 -30
- data/test/unit/rake_task_tests.rb +0 -56
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
data.tar.gz: 229e3d012cb4b9d4de75204d8e4209a7433f5e40
|
4
|
+
metadata.gz: 77c2d3b510b28ac994fe2f0c308513ecae44695b
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: d3e6105125963b5d5e90111b045a2b6a97740e3a3f7933e11185cd0dc1b000206b73ff56def64da5f335229d7f84ad046d053f6180937f2aff51ea184b9e7fa4
|
7
|
+
metadata.gz: 519dcfde9af4888f1cd8c15d76ed70ad3eff6aa4d63bfafc96e270a8a5d056aaf23b28cac862ab451bac10634151cfcac05fd1a811266247343ad98d2bc845dd
|
data/Gemfile
CHANGED
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -53,19 +53,19 @@ set :application, CapUtil::UnsetVar.new(:application)
|
|
53
53
|
set :stage, CapUtil::UnsetVar(:stage, "no stage task used")
|
54
54
|
```
|
55
55
|
|
56
|
-
##
|
56
|
+
## BundlerCmd util
|
57
57
|
|
58
|
-
This util is handy for running
|
58
|
+
This util is handy for running bundler system cmds remotely using a cap task. It constructs a command that cd's to a root dir with a Gemfile and runs the specified cmd using `bundle exec`.
|
59
59
|
|
60
|
-
By default, it expects the
|
60
|
+
By default, it expects the Gemfile to be in the `:current_path` and uses no ENV vars. These defaults can be overriden by passing options to the constructor.
|
61
61
|
|
62
62
|
To use, do something like:
|
63
63
|
|
64
64
|
```ruby
|
65
65
|
# in your Capfile...
|
66
66
|
|
67
|
-
task :
|
68
|
-
CapUtil::
|
67
|
+
task :some_bundler_task do
|
68
|
+
CapUtil::BundlerCmd.new(self, 'ruby script/do_someting.rb').run
|
69
69
|
end
|
70
70
|
```
|
71
71
|
|
data/cap-util.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = CapUtil::VERSION
|
9
9
|
gem.authors = ["Kelly Redding", "Collin Redding"]
|
10
10
|
gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
|
11
|
-
gem.description = %q{A set of utilities for writing cap tasks.}
|
12
11
|
gem.summary = %q{A set of utilities for writing cap tasks.}
|
12
|
+
gem.description = %q{A set of utilities for writing cap tasks.}
|
13
13
|
gem.homepage = "http://github.com/redding/cap-util"
|
14
14
|
gem.license = 'MIT'
|
15
15
|
|
@@ -18,9 +18,9 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_development_dependency("assert", ["~> 2.15"])
|
21
|
+
gem.add_development_dependency("assert", ["~> 2.15.0"])
|
22
22
|
|
23
|
-
gem.add_dependency("scmd", ["~> 3.0"])
|
23
|
+
gem.add_dependency("scmd", ["~> 3.0.0"])
|
24
24
|
gem.add_dependency("capistrano", ["~> 2.0"])
|
25
25
|
|
26
26
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'cap-util'
|
2
|
+
|
3
|
+
module CapUtil
|
4
|
+
|
5
|
+
# This defines a base utiltiy for building bundler commands to run.
|
6
|
+
|
7
|
+
class BundlerCmd
|
8
|
+
include CapUtil
|
9
|
+
|
10
|
+
attr_reader :cmd
|
11
|
+
|
12
|
+
def initialize(cap, cmd, opts = nil)
|
13
|
+
opts ||= {}
|
14
|
+
@cap = cap
|
15
|
+
|
16
|
+
opts[:root] ||= :current_path
|
17
|
+
opts[:env] ||= ""
|
18
|
+
|
19
|
+
cmd_root = @cap.send(opts[:root])
|
20
|
+
|
21
|
+
@cmd = "cd #{cmd_root} && #{opts[:env]} bundle exec #{cmd}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def run; super(@cmd); end
|
25
|
+
|
26
|
+
module TestHelpers
|
27
|
+
|
28
|
+
def assert_bundler_cmd(util, *args)
|
29
|
+
assert_kind_of BundlerCmd, util
|
30
|
+
|
31
|
+
exp = BundlerCmd.new(*args)
|
32
|
+
assert_equal exp.cmd, util.cmd
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/cap-util/fake_cap.rb
CHANGED
data/lib/cap-util/git_branch.rb
CHANGED
data/lib/cap-util/halt.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'cap-util'
|
2
|
+
require 'scmd'
|
3
|
+
|
4
|
+
module CapUtil
|
5
|
+
|
6
|
+
class LocalCmdRunner
|
7
|
+
|
8
|
+
def initialize(cmd_str)
|
9
|
+
@cmd = Scmd.new(cmd_str)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run!(input = nil)
|
13
|
+
CapUtil.say_bulleted "running `#{@cmd}'"
|
14
|
+
@cmd.run(input)
|
15
|
+
|
16
|
+
if !@cmd.success?
|
17
|
+
CapUtil.say_error(@cmd.stderr)
|
18
|
+
CapUtil.halt
|
19
|
+
end
|
20
|
+
@cmd
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/cap-util/run.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'cap-util/local_cmd_runner'
|
2
2
|
|
3
3
|
module CapUtil
|
4
4
|
|
5
|
-
class LocalCmdRunner
|
6
|
-
def initialize(cmd_str)
|
7
|
-
@cmd = Scmd.new(cmd_str)
|
8
|
-
end
|
9
|
-
|
10
|
-
def run!(input=nil)
|
11
|
-
CapUtil.say_bulleted "running `#{@cmd}'"
|
12
|
-
@cmd.run(input)
|
13
|
-
|
14
|
-
if !@cmd.success?
|
15
|
-
CapUtil.say_error(@cmd.stderr)
|
16
|
-
CapUtil.halt
|
17
|
-
end
|
18
|
-
@cmd
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
5
|
def self.run_locally(cmd_str)
|
23
6
|
LocalCmdRunner.new(cmd_str).run!
|
24
7
|
end
|
@@ -46,11 +29,11 @@ module CapUtil
|
|
46
29
|
cap.run(*args, &block)
|
47
30
|
end
|
48
31
|
|
49
|
-
def run_with_stdin(cmd_str, input, opts={})
|
32
|
+
def run_with_stdin(cmd_str, input, opts = {})
|
50
33
|
run(cmd_str, opts.merge(:pty => true)) {|ch, stream, out| ch.send_data(input + "\n")}
|
51
34
|
end
|
52
35
|
|
53
|
-
def run_as(user, cmd_str, opts={}, &block)
|
36
|
+
def run_as(user, cmd_str, opts = {}, &block)
|
54
37
|
as_cmd_str = "su #{user} -lc '#{cmd_str.gsub("'", "\\'")}'"
|
55
38
|
run(as_cmd_str, opts, &block)
|
56
39
|
end
|
data/lib/cap-util/shared_path.rb
CHANGED
data/lib/cap-util/timer.rb
CHANGED
@@ -9,17 +9,17 @@ module CapUtil
|
|
9
9
|
|
10
10
|
attr_reader :name, :start_time, :end_time, :elapsed_time
|
11
11
|
|
12
|
-
def initialize(name, quiet=nil)
|
12
|
+
def initialize(name, quiet = nil)
|
13
13
|
@name, @start_time, @end_time, @elapsed_time = name, 0, 0, 0
|
14
14
|
@quiet = !!(quiet == :quiet)
|
15
15
|
end
|
16
16
|
|
17
|
-
def start(time=nil)
|
17
|
+
def start(time = nil)
|
18
18
|
CapUtil.say "Starting #{CapUtil.color @name, :cyan}." if !@quiet
|
19
19
|
@start_time = (time || ::Time.now)
|
20
20
|
end
|
21
21
|
|
22
|
-
def end(time=nil)
|
22
|
+
def end(time = nil)
|
23
23
|
@end_time = (time || ::Time.now)
|
24
24
|
@elapsed_time = @end_time - @start_time
|
25
25
|
if !@quiet
|
data/lib/cap-util/unset_var.rb
CHANGED
data/lib/cap-util/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'assert'
|
2
|
-
require '
|
2
|
+
require 'cap-util'
|
3
3
|
|
4
|
-
|
4
|
+
require 'test/support/a_cap_util'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
module CapUtil
|
7
|
+
|
8
|
+
class ModuleSystemTests < Assert::Context
|
9
|
+
desc "CapUtil the module"
|
8
10
|
setup do
|
9
11
|
@mod = CapUtil
|
10
12
|
end
|
@@ -16,18 +18,18 @@ module CapUtilSysTests
|
|
16
18
|
|
17
19
|
end
|
18
20
|
|
19
|
-
class HaltTests <
|
20
|
-
desc "`halt`
|
21
|
+
class HaltTests < ModuleSystemTests
|
22
|
+
desc "`halt` methods"
|
21
23
|
|
22
24
|
should "raise a `Halted` custom exception" do
|
23
25
|
assert_raises(CapUtil::Halted) { subject.halt }
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
class
|
28
|
-
desc "the
|
29
|
+
class MixinSystemTests < Assert::Context
|
30
|
+
desc "CapUtil the mixin"
|
29
31
|
setup do
|
30
|
-
@cap_util = TestHelpers::
|
32
|
+
@cap_util = TestHelpers::ACapUtil.new(CapUtil::FakeCap.new)
|
31
33
|
end
|
32
34
|
subject { @cap_util }
|
33
35
|
|
@@ -51,8 +53,8 @@ module CapUtilSysTests
|
|
51
53
|
|
52
54
|
end
|
53
55
|
|
54
|
-
class HaltedTests <
|
55
|
-
desc "
|
56
|
+
class HaltedTests < ModuleSystemTests
|
57
|
+
desc "Halted"
|
56
58
|
setup do
|
57
59
|
@err = CapUtil::Halted.new
|
58
60
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'cap-util/bundler_cmd'
|
3
|
+
|
4
|
+
class CapUtil::BundlerCmd
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::BundlerCmd"
|
8
|
+
setup do
|
9
|
+
@fake_cap = CapUtil::FakeCap.new
|
10
|
+
@fake_cap.current_path = "/a/current/path"
|
11
|
+
@fake_cap.release_path = "/dat/release/path"
|
12
|
+
|
13
|
+
@util = CapUtil::BundlerCmd.new(@fake_cap, 'ls -la')
|
14
|
+
end
|
15
|
+
subject{ @util }
|
16
|
+
|
17
|
+
should have_imeths :run
|
18
|
+
|
19
|
+
should "build a bundler cmd to run" do
|
20
|
+
assert_includes '&& bundle exec ls -la', subject.cmd
|
21
|
+
end
|
22
|
+
|
23
|
+
should "use cap's current path by default" do
|
24
|
+
assert_includes "cd #{@fake_cap.current_path} &&", subject.cmd
|
25
|
+
end
|
26
|
+
|
27
|
+
should "use a custom cap path if given" do
|
28
|
+
util = CapUtil::BundlerCmd.new(@fake_cap, '', :root => :release_path)
|
29
|
+
assert_includes "cd #{@fake_cap.release_path} &&", util.cmd
|
30
|
+
end
|
31
|
+
|
32
|
+
should "use a custom env var string if given" do
|
33
|
+
util = CapUtil::BundlerCmd.new(@fake_cap, 'ls -la', :env => "FOO=bar")
|
34
|
+
assert_includes "&& FOO=bar bundle exec ls", util.cmd
|
35
|
+
end
|
36
|
+
|
37
|
+
should "run its cmd" do
|
38
|
+
exp_cmd = "cd /a/current/path && bundle exec ls -la"
|
39
|
+
subject.run
|
40
|
+
|
41
|
+
assert_equal exp_cmd, @fake_cap.cmds_run.last
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class TestHelpersTests < UnitTests
|
47
|
+
include TestHelpers
|
48
|
+
|
49
|
+
desc "TestHelpers"
|
50
|
+
setup do
|
51
|
+
@context = Class.new{ include TestHelpers }.new
|
52
|
+
end
|
53
|
+
subject{ @context }
|
54
|
+
|
55
|
+
should have_imeths :assert_bundler_cmd
|
56
|
+
|
57
|
+
should "prove a util is a bundler cmd that was built correctly" do
|
58
|
+
assert_bundler_cmd(@util, @fake_cap, 'ls -la')
|
59
|
+
assert_bundler_cmd(@util, @fake_cap, 'ls -la', :root => :current_path)
|
60
|
+
assert_bundler_cmd(@util, @fake_cap, 'ls -la', :env => '')
|
61
|
+
|
62
|
+
util = CapUtil::BundlerCmd.new(@fake_cap, 'ls -la', {
|
63
|
+
:root => :release_path,
|
64
|
+
:env => "FOO=bar"
|
65
|
+
})
|
66
|
+
assert_bundler_cmd(util, @fake_cap, 'ls -la', {
|
67
|
+
:root => :release_path,
|
68
|
+
:env => "FOO=bar"
|
69
|
+
})
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/test/unit/fake_cap_tests.rb
CHANGED
@@ -3,16 +3,16 @@ require 'cap-util/fake_cap'
|
|
3
3
|
|
4
4
|
class CapUtil::FakeCap
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::FakeCap"
|
8
8
|
setup do
|
9
9
|
@fc = CapUtil::FakeCap.new
|
10
10
|
end
|
11
|
-
subject
|
11
|
+
subject{ @fc }
|
12
12
|
|
13
|
+
should have_readers :roles, :cmds_run
|
13
14
|
should have_imeths :method_missing, :respond_to?
|
14
15
|
should have_imeths :run, :sudo, :fetch, :role
|
15
|
-
should have_readers :roles, :cmds_run
|
16
16
|
|
17
17
|
should "store off cmds that have been run" do
|
18
18
|
assert_empty subject.cmds_run
|
@@ -3,9 +3,9 @@ require 'cap-util/git_branch'
|
|
3
3
|
|
4
4
|
class CapUtil::GitBranch
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
8
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::GitBranch"
|
8
|
+
subject{ CapUtil::GitBranch }
|
9
9
|
|
10
10
|
should have_imeth :current
|
11
11
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'assert'
|
2
|
-
require 'cap-util/
|
2
|
+
require 'cap-util/local_cmd_runner'
|
3
3
|
|
4
4
|
class CapUtil::LocalCmdRunner
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::LocalCmdRunner"
|
8
8
|
setup do
|
9
|
-
@
|
9
|
+
@runner = CapUtil::LocalCmdRunner.new("echo hi")
|
10
10
|
end
|
11
|
-
subject
|
11
|
+
subject{ @runner }
|
12
12
|
|
13
13
|
should have_imeth :run!
|
14
14
|
|
@@ -3,8 +3,8 @@ require 'cap-util/server_roles'
|
|
3
3
|
|
4
4
|
class CapUtil::ServerRoles
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::ServerRoles"
|
8
8
|
setup do
|
9
9
|
roles_yaml = <<YAML
|
10
10
|
---
|
@@ -15,7 +15,7 @@ YAML
|
|
15
15
|
@fake_cap = CapUtil::FakeCap.new
|
16
16
|
@server_roles = CapUtil::ServerRoles.new(@fake_cap, roles_yaml)
|
17
17
|
end
|
18
|
-
subject
|
18
|
+
subject{ @server_roles }
|
19
19
|
|
20
20
|
should have_reader :roles
|
21
21
|
should have_imeth :apply
|
@@ -3,12 +3,12 @@ require 'cap-util/server_roles_yaml'
|
|
3
3
|
|
4
4
|
class CapUtil::ServerRolesYaml
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::ServerRolesYaml"
|
8
8
|
setup do
|
9
|
-
@roles_yaml = CapUtil::ServerRolesYaml.new(CapUtil::FakeCap.new
|
9
|
+
@roles_yaml = CapUtil::ServerRolesYaml.new(CapUtil::FakeCap.new)
|
10
10
|
end
|
11
|
-
subject
|
11
|
+
subject{ @roles_yaml }
|
12
12
|
|
13
13
|
should have_imeths :get, :validate, :valid?, :read
|
14
14
|
should have_reader :desc, :source
|
@@ -1,19 +1,20 @@
|
|
1
1
|
require 'assert'
|
2
|
+
require 'cap-util/shared_path'
|
3
|
+
|
2
4
|
require 'fileutils'
|
3
5
|
require 'pathname'
|
4
|
-
require 'cap-util/shared_path'
|
5
6
|
|
6
7
|
class CapUtil::SharedPath
|
7
8
|
|
8
|
-
class
|
9
|
-
desc "
|
9
|
+
class UnitTests < Assert::Context
|
10
|
+
desc "CapUtil::SharedPath"
|
10
11
|
setup do
|
11
12
|
@fake_cap = CapUtil::FakeCap.new
|
12
13
|
@fake_cap.shared_path = Pathname.new File.expand_path("tmp/shared")
|
13
14
|
|
14
15
|
@shared_path = CapUtil::SharedPath.new(@fake_cap)
|
15
16
|
end
|
16
|
-
subject
|
17
|
+
subject{ @shared_path }
|
17
18
|
|
18
19
|
should have_imeths :rm_rf
|
19
20
|
|
data/test/unit/timer_tests.rb
CHANGED
@@ -3,12 +3,12 @@ require 'cap-util/timer'
|
|
3
3
|
|
4
4
|
class CapUtil::Timer
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::Timer"
|
8
8
|
setup do
|
9
9
|
@timer_util = CapUtil::Timer.new('a timer', :quiet)
|
10
10
|
end
|
11
|
-
subject
|
11
|
+
subject{ @timer_util }
|
12
12
|
|
13
13
|
should have_readers :name, :start_time, :end_time, :elapsed_time
|
14
14
|
should have_imeths :start, :end
|
@@ -3,13 +3,13 @@ require 'cap-util/unset_var'
|
|
3
3
|
|
4
4
|
module CapUtil::UnsetVar
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "CapUtil::UnsetVar"
|
8
8
|
setup do
|
9
9
|
@var_name = 'test'
|
10
10
|
@unset = CapUtil::UnsetVar.new(@var_name)
|
11
11
|
end
|
12
|
-
subject
|
12
|
+
subject{ @unset }
|
13
13
|
|
14
14
|
should "be a proc" do
|
15
15
|
assert_kind_of ::Proc, subject
|
metadata
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cap-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 4
|
9
|
-
- 0
|
10
|
-
version: 1.4.0
|
4
|
+
version: 1.5.0
|
11
5
|
platform: ruby
|
12
6
|
authors:
|
13
7
|
- Kelly Redding
|
@@ -16,53 +10,38 @@ autorequire:
|
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
12
|
|
19
|
-
date:
|
13
|
+
date: 2016-01-07 00:00:00 Z
|
20
14
|
dependencies:
|
21
15
|
- !ruby/object:Gem::Dependency
|
16
|
+
name: assert
|
17
|
+
prerelease: false
|
22
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
19
|
requirements:
|
25
20
|
- - ~>
|
26
21
|
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 2
|
30
|
-
- 15
|
31
|
-
version: "2.15"
|
22
|
+
version: 2.15.0
|
32
23
|
type: :development
|
33
|
-
name: assert
|
34
24
|
version_requirements: *id001
|
35
|
-
prerelease: false
|
36
25
|
- !ruby/object:Gem::Dependency
|
26
|
+
name: scmd
|
27
|
+
prerelease: false
|
37
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
29
|
requirements:
|
40
30
|
- - ~>
|
41
31
|
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
segments:
|
44
|
-
- 3
|
45
|
-
- 0
|
46
|
-
version: "3.0"
|
32
|
+
version: 3.0.0
|
47
33
|
type: :runtime
|
48
|
-
name: scmd
|
49
34
|
version_requirements: *id002
|
50
|
-
prerelease: false
|
51
35
|
- !ruby/object:Gem::Dependency
|
36
|
+
name: capistrano
|
37
|
+
prerelease: false
|
52
38
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
39
|
requirements:
|
55
40
|
- - ~>
|
56
41
|
- !ruby/object:Gem::Version
|
57
|
-
hash: 3
|
58
|
-
segments:
|
59
|
-
- 2
|
60
|
-
- 0
|
61
42
|
version: "2.0"
|
62
43
|
type: :runtime
|
63
|
-
name: capistrano
|
64
44
|
version_requirements: *id003
|
65
|
-
prerelease: false
|
66
45
|
description: A set of utilities for writing cap tasks.
|
67
46
|
email:
|
68
47
|
- kelly@kellyredding.com
|
@@ -76,15 +55,15 @@ extra_rdoc_files: []
|
|
76
55
|
files:
|
77
56
|
- .gitignore
|
78
57
|
- Gemfile
|
79
|
-
- LICENSE
|
58
|
+
- LICENSE
|
80
59
|
- README.md
|
81
|
-
- Rakefile
|
82
60
|
- cap-util.gemspec
|
83
61
|
- lib/cap-util.rb
|
62
|
+
- lib/cap-util/bundler_cmd.rb
|
84
63
|
- lib/cap-util/fake_cap.rb
|
85
64
|
- lib/cap-util/git_branch.rb
|
86
65
|
- lib/cap-util/halt.rb
|
87
|
-
- lib/cap-util/
|
66
|
+
- lib/cap-util/local_cmd_runner.rb
|
88
67
|
- lib/cap-util/run.rb
|
89
68
|
- lib/cap-util/say.rb
|
90
69
|
- lib/cap-util/server_roles.rb
|
@@ -95,12 +74,13 @@ files:
|
|
95
74
|
- lib/cap-util/unset_var.rb
|
96
75
|
- lib/cap-util/version.rb
|
97
76
|
- test/helper.rb
|
98
|
-
- test/support/
|
77
|
+
- test/support/a_cap_util.rb
|
78
|
+
- test/support/factory.rb
|
99
79
|
- test/system/cap_util_tests.rb
|
80
|
+
- test/unit/bundler_cmd_tests.rb
|
100
81
|
- test/unit/fake_cap_tests.rb
|
101
82
|
- test/unit/git_branch_tests.rb
|
102
83
|
- test/unit/local_cmd_runner_tests.rb
|
103
|
-
- test/unit/rake_task_tests.rb
|
104
84
|
- test/unit/server_roles_tests.rb
|
105
85
|
- test/unit/server_roles_yaml_tests.rb
|
106
86
|
- test/unit/shared_path_tests.rb
|
@@ -109,44 +89,38 @@ files:
|
|
109
89
|
homepage: http://github.com/redding/cap-util
|
110
90
|
licenses:
|
111
91
|
- MIT
|
92
|
+
metadata: {}
|
93
|
+
|
112
94
|
post_install_message:
|
113
95
|
rdoc_options: []
|
114
96
|
|
115
97
|
require_paths:
|
116
98
|
- lib
|
117
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
-
none: false
|
119
100
|
requirements:
|
120
|
-
-
|
101
|
+
- &id004
|
102
|
+
- ">="
|
121
103
|
- !ruby/object:Gem::Version
|
122
|
-
hash: 3
|
123
|
-
segments:
|
124
|
-
- 0
|
125
104
|
version: "0"
|
126
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
106
|
requirements:
|
129
|
-
-
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
hash: 3
|
132
|
-
segments:
|
133
|
-
- 0
|
134
|
-
version: "0"
|
107
|
+
- *id004
|
135
108
|
requirements: []
|
136
109
|
|
137
110
|
rubyforge_project:
|
138
|
-
rubygems_version:
|
111
|
+
rubygems_version: 2.5.1
|
139
112
|
signing_key:
|
140
|
-
specification_version:
|
113
|
+
specification_version: 4
|
141
114
|
summary: A set of utilities for writing cap tasks.
|
142
115
|
test_files:
|
143
116
|
- test/helper.rb
|
144
|
-
- test/support/
|
117
|
+
- test/support/a_cap_util.rb
|
118
|
+
- test/support/factory.rb
|
145
119
|
- test/system/cap_util_tests.rb
|
120
|
+
- test/unit/bundler_cmd_tests.rb
|
146
121
|
- test/unit/fake_cap_tests.rb
|
147
122
|
- test/unit/git_branch_tests.rb
|
148
123
|
- test/unit/local_cmd_runner_tests.rb
|
149
|
-
- test/unit/rake_task_tests.rb
|
150
124
|
- test/unit/server_roles_tests.rb
|
151
125
|
- test/unit/server_roles_yaml_tests.rb
|
152
126
|
- test/unit/shared_path_tests.rb
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
data/lib/cap-util/rake_task.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'cap-util'
|
2
|
-
|
3
|
-
module CapUtil
|
4
|
-
|
5
|
-
# This defines a base utiltiy for building tasks that run rake tasks. Pass
|
6
|
-
# in the rake task name and this will make sure it is run with the appropriate
|
7
|
-
# settings and environment
|
8
|
-
|
9
|
-
class RakeTask
|
10
|
-
include CapUtil
|
11
|
-
|
12
|
-
attr_reader :cmd
|
13
|
-
|
14
|
-
def initialize(cap, task, opts=nil)
|
15
|
-
@cap = cap
|
16
|
-
|
17
|
-
opts ||= {}
|
18
|
-
opts[:root] ||= :current_path
|
19
|
-
opts[:rake] ||= "bundle exec rake"
|
20
|
-
opts[:env] ||= ""
|
21
|
-
rakefile_root = cap.send(opts[:root])
|
22
|
-
|
23
|
-
@cmd = "cd #{rakefile_root} && #{opts[:env]} #{opts[:rake]} #{task}"
|
24
|
-
end
|
25
|
-
|
26
|
-
def run; super(@cmd); end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
require 'cap-util/rake_task'
|
3
|
-
|
4
|
-
class CapUtil::RakeTask
|
5
|
-
|
6
|
-
class BaseTests < Assert::Context
|
7
|
-
desc "the rake task util"
|
8
|
-
setup do
|
9
|
-
@fake_cap = CapUtil::FakeCap.new
|
10
|
-
@fake_cap.fetch_rake = "bundle exec rake"
|
11
|
-
@fake_cap.current_path = "/a/current/path"
|
12
|
-
@fake_cap.release_path = "/dat/release/path"
|
13
|
-
@rake_task_util = CapUtil::RakeTask.new(@fake_cap, 'a:task:to:run')
|
14
|
-
end
|
15
|
-
subject { @rake_task_util }
|
16
|
-
|
17
|
-
should have_imeths :run
|
18
|
-
|
19
|
-
should "build a rake task to run" do
|
20
|
-
assert_match 'rake ', subject.cmd
|
21
|
-
assert_match ' a:task:to:run', subject.cmd
|
22
|
-
end
|
23
|
-
|
24
|
-
should "run the task with bundler by default" do
|
25
|
-
assert_match 'bundle exec rake', subject.cmd
|
26
|
-
end
|
27
|
-
|
28
|
-
should "run the task with a custom rake if given" do
|
29
|
-
task = CapUtil::RakeTask.new(@fake_cap, '', :rake => '/path/to/rake')
|
30
|
-
assert_match '/path/to/rake', task.cmd
|
31
|
-
end
|
32
|
-
|
33
|
-
should "use cap's current path by default" do
|
34
|
-
assert_match "cd #{@fake_cap.current_path} &&", subject.cmd
|
35
|
-
end
|
36
|
-
|
37
|
-
should "use a custom cap path if given" do
|
38
|
-
task = CapUtil::RakeTask.new(@fake_cap, '', :root => :release_path)
|
39
|
-
assert_match "cd #{@fake_cap.release_path} &&", task.cmd
|
40
|
-
end
|
41
|
-
|
42
|
-
should "use a custom env var string if given" do
|
43
|
-
task = CapUtil::RakeTask.new(@fake_cap, '', :env => "FOO=bar")
|
44
|
-
assert_match "FOO=bar bundle", task.cmd
|
45
|
-
end
|
46
|
-
|
47
|
-
should "run its rake cmd" do
|
48
|
-
exp_cmd = "cd /a/current/path && bundle exec rake a:task:to:run"
|
49
|
-
subject.run
|
50
|
-
|
51
|
-
assert_equal exp_cmd, @fake_cap.cmds_run.last
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|