cap-util 0.4.0 → 1.0.0.rc1
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/cap-util.gemspec +4 -4
- data/lib/cap-util/halt.rb +3 -3
- data/lib/cap-util/run.rb +18 -13
- data/lib/cap-util/version.rb +1 -1
- data/test/cap_util_tests.rb +5 -5
- data/test/local_cmd_runner_tests.rb +18 -0
- data/test/unset_var_tests.rb +4 -4
- metadata +25 -16
data/cap-util.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.description = %q{A set of utilities for writing cap tasks.}
|
8
8
|
gem.summary = %q{A set of utilities for writing cap tasks.}
|
9
9
|
|
10
|
-
gem.authors = ["Kelly Redding"]
|
11
|
-
gem.email = ["kelly@kellyredding.com"]
|
10
|
+
gem.authors = ["Kelly Redding", "Collin Redding"]
|
11
|
+
gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
|
12
12
|
gem.homepage = "http://github.com/redding/cap-util"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
|
19
|
-
gem.add_development_dependency("assert")
|
19
|
+
gem.add_development_dependency("assert", ["~>1.0"])
|
20
20
|
gem.add_dependency("capistrano")
|
21
|
-
gem.add_dependency("scmd", ["~>
|
21
|
+
gem.add_dependency("scmd", ["~>2.0"])
|
22
22
|
|
23
23
|
end
|
data/lib/cap-util/halt.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module CapUtil
|
2
2
|
|
3
|
-
class
|
3
|
+
class Halted < RuntimeError
|
4
4
|
def backtrace; []; end
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.halt(msg='
|
8
|
-
raise CapUtil::
|
7
|
+
def self.halt(msg='halted')
|
8
|
+
raise CapUtil::Halted, color(msg, :bold, :yellow)
|
9
9
|
end
|
10
10
|
|
11
11
|
module Halt
|
data/lib/cap-util/run.rb
CHANGED
@@ -2,24 +2,29 @@ require 'scmd'
|
|
2
2
|
|
3
3
|
module CapUtil
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
class LocalCmdRunner
|
6
|
+
def initialize(cmd_str)
|
7
|
+
@cmd = Scmd.new(cmd_str)
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def run!(input=nil)
|
11
|
+
CapUtil.say_bulleted "running `#{@cmd}'"
|
12
|
+
@cmd.run(input)
|
11
13
|
|
12
|
-
|
14
|
+
if !@cmd.success?
|
15
|
+
CapUtil.say_error(@cmd.stderr)
|
16
|
+
CapUtil.halt
|
17
|
+
end
|
18
|
+
@cmd
|
19
|
+
end
|
13
20
|
end
|
14
21
|
|
15
|
-
def self.
|
16
|
-
|
17
|
-
|
18
|
-
say_bulleted "running `#{cmd}'"
|
19
|
-
cmd.run(input)
|
20
|
-
say_error(cmd.stderr) if !cmd.success?
|
22
|
+
def self.run_locally(cmd_str)
|
23
|
+
LocalCmdRunner.new(cmd_str).run!
|
24
|
+
end
|
21
25
|
|
22
|
-
|
26
|
+
def self.run_locally_with_stdin(cmd_str, input)
|
27
|
+
LocalCmdRunner.new(cmd_str).run!(input)
|
23
28
|
end
|
24
29
|
|
25
30
|
module Run
|
data/lib/cap-util/version.rb
CHANGED
data/test/cap_util_tests.rb
CHANGED
@@ -18,8 +18,8 @@ module CapUtil
|
|
18
18
|
class HaltTests < CapUtilTests
|
19
19
|
desc "`halt` util methods"
|
20
20
|
|
21
|
-
should "raise a `
|
22
|
-
assert_raises(CapUtil::
|
21
|
+
should "raise a `Halted` custom exception" do
|
22
|
+
assert_raises(CapUtil::Halted) { subject.halt }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -49,10 +49,10 @@ module CapUtil
|
|
49
49
|
|
50
50
|
end
|
51
51
|
|
52
|
-
class
|
53
|
-
desc "the
|
52
|
+
class HaltedTests < Assert::Context
|
53
|
+
desc "the CapUtil Halted custom exception"
|
54
54
|
setup do
|
55
|
-
@err = CapUtil::
|
55
|
+
@err = CapUtil::Halted.new
|
56
56
|
end
|
57
57
|
subject { @err }
|
58
58
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'assert'
|
2
|
+
|
3
|
+
require 'cap-util/run'
|
4
|
+
|
5
|
+
module CapUtil
|
6
|
+
|
7
|
+
class LocalCmdRunnerTests < Assert::Context
|
8
|
+
desc "the local cmd runner helper class"
|
9
|
+
setup do
|
10
|
+
@cmd_runner = LocalCmdRunner.new("echo hi")
|
11
|
+
end
|
12
|
+
subject { @cmd_runner }
|
13
|
+
|
14
|
+
should have_imeth :run!
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/test/unset_var_tests.rb
CHANGED
@@ -16,15 +16,15 @@ module CapUtil
|
|
16
16
|
assert_kind_of ::Proc, subject
|
17
17
|
end
|
18
18
|
|
19
|
-
should "raise `
|
20
|
-
assert_raises(CapUtil::
|
19
|
+
should "raise `Halted` when called" do
|
20
|
+
assert_raises(CapUtil::Halted) { subject.call }
|
21
21
|
end
|
22
22
|
|
23
23
|
should "raise with a default msg based on the variable name" do
|
24
24
|
exp_msg = ":#{@var_name} var not set."
|
25
25
|
begin
|
26
26
|
subject.call
|
27
|
-
rescue CapUtil::
|
27
|
+
rescue CapUtil::Halted => err
|
28
28
|
assert_match exp_msg, err.message
|
29
29
|
end
|
30
30
|
end
|
@@ -34,7 +34,7 @@ module CapUtil
|
|
34
34
|
unset = CapUtil::UnsetVar.new(@var_name, exp_msg)
|
35
35
|
begin
|
36
36
|
unset.call
|
37
|
-
rescue CapUtil::
|
37
|
+
rescue CapUtil::Halted => err
|
38
38
|
assert_match exp_msg, err.message
|
39
39
|
end
|
40
40
|
end
|
metadata
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cap-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -3810944636
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
- 4
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 1.0.0.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Kelly Redding
|
16
|
+
- Collin Redding
|
14
17
|
autorequire:
|
15
18
|
bindir: bin
|
16
19
|
cert_chain: []
|
17
20
|
|
18
|
-
date: 2012-
|
21
|
+
date: 2012-11-21 00:00:00 Z
|
19
22
|
dependencies:
|
20
23
|
- !ruby/object:Gem::Dependency
|
21
24
|
name: assert
|
22
25
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
26
|
none: false
|
24
27
|
requirements:
|
25
|
-
- -
|
28
|
+
- - ~>
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
30
|
+
hash: 15
|
28
31
|
segments:
|
32
|
+
- 1
|
29
33
|
- 0
|
30
|
-
version: "0"
|
34
|
+
version: "1.0"
|
31
35
|
type: :development
|
32
36
|
requirement: *id001
|
33
37
|
prerelease: false
|
@@ -52,17 +56,18 @@ dependencies:
|
|
52
56
|
requirements:
|
53
57
|
- - ~>
|
54
58
|
- !ruby/object:Gem::Version
|
55
|
-
hash:
|
59
|
+
hash: 3
|
56
60
|
segments:
|
57
|
-
-
|
58
|
-
-
|
59
|
-
version: "
|
61
|
+
- 2
|
62
|
+
- 0
|
63
|
+
version: "2.0"
|
60
64
|
type: :runtime
|
61
65
|
requirement: *id003
|
62
66
|
prerelease: false
|
63
67
|
description: A set of utilities for writing cap tasks.
|
64
68
|
email:
|
65
69
|
- kelly@kellyredding.com
|
70
|
+
- collin.redding@me.com
|
66
71
|
executables: []
|
67
72
|
|
68
73
|
extensions: []
|
@@ -95,6 +100,7 @@ files:
|
|
95
100
|
- test/git_branch_tests.rb
|
96
101
|
- test/helper.rb
|
97
102
|
- test/irb.rb
|
103
|
+
- test/local_cmd_runner_tests.rb
|
98
104
|
- test/rake_task_tests.rb
|
99
105
|
- test/server_roles_tests.rb
|
100
106
|
- test/server_roles_yaml_tests.rb
|
@@ -121,12 +127,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
128
|
none: false
|
123
129
|
requirements:
|
124
|
-
- - "
|
130
|
+
- - ">"
|
125
131
|
- !ruby/object:Gem::Version
|
126
|
-
hash:
|
132
|
+
hash: 25
|
127
133
|
segments:
|
128
|
-
-
|
129
|
-
|
134
|
+
- 1
|
135
|
+
- 3
|
136
|
+
- 1
|
137
|
+
version: 1.3.1
|
130
138
|
requirements: []
|
131
139
|
|
132
140
|
rubyforge_project:
|
@@ -140,6 +148,7 @@ test_files:
|
|
140
148
|
- test/git_branch_tests.rb
|
141
149
|
- test/helper.rb
|
142
150
|
- test/irb.rb
|
151
|
+
- test/local_cmd_runner_tests.rb
|
143
152
|
- test/rake_task_tests.rb
|
144
153
|
- test/server_roles_tests.rb
|
145
154
|
- test/server_roles_yaml_tests.rb
|