cap-util 1.0.1 → 1.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.
@@ -23,6 +23,10 @@ module CapUtil
23
23
  @cmds_run << cmd
24
24
  end
25
25
 
26
+ def sudo(cmd, *args)
27
+ run("sudo #{cmd}", *args)
28
+ end
29
+
26
30
  def fetch(var_name)
27
31
  self.send("fetch_#{var_name}")
28
32
  end
data/lib/cap-util/run.rb CHANGED
@@ -59,6 +59,10 @@ module CapUtil
59
59
  run_as(user, cmd_str, opts) {|ch, stream, out| ch.send_data(input + "\n")}
60
60
  end
61
61
 
62
+ def sudo(*args, &block)
63
+ cap.sudo(*args, &block)
64
+ end
65
+
62
66
  end
63
67
 
64
68
  end
data/lib/cap-util/say.rb CHANGED
@@ -7,11 +7,11 @@ module CapUtil
7
7
  end
8
8
 
9
9
  def self.say(msg, *args)
10
- Capistrano::CLI.ui.say(" #{msg}", *args)
10
+ say_raw(" #{msg}", *args)
11
11
  end
12
12
 
13
13
  def self.say_bulleted(msg, *args)
14
- Capistrano::CLI.ui.say(" * #{msg}", *args)
14
+ say_raw(" * #{msg}", *args)
15
15
  end
16
16
 
17
17
  def self.say_error(msg, *args)
@@ -22,6 +22,10 @@ module CapUtil
22
22
  say("#{color "[WARN]", :bold, :yellow} #{msg}", *args)
23
23
  end
24
24
 
25
+ def self.say_raw(msg, *args)
26
+ Capistrano::CLI.ui.say(msg, *args) if !ENV['CAPUTIL_SILENCE_SAY']
27
+ end
28
+
25
29
  module Say
26
30
 
27
31
  def self.included(receiver)
@@ -1,3 +1,3 @@
1
1
  module CapUtil
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -41,6 +41,7 @@ module CapUtil
41
41
  should have_cmeths :run_locally, :run_locally_with_stdin
42
42
  should have_imeths :run_locally, :run_locally_with_stdin
43
43
  should have_imeths :run, :run_with_stdin, :run_as, :run_as_with_stdin
44
+ should have_imeths :sudo
44
45
 
45
46
  should have_cmeth :time
46
47
  should have_imeth :time
@@ -12,7 +12,7 @@ module CapUtil
12
12
  subject { @fc }
13
13
 
14
14
  should have_imeths :method_missing, :respond_to?
15
- should have_imeths :run, :fetch, :role
15
+ should have_imeths :run, :sudo, :fetch, :role
16
16
  should have_readers :roles, :cmds_run
17
17
 
18
18
  should "store off cmds that have been run" do
@@ -20,6 +20,9 @@ module CapUtil
20
20
 
21
21
  subject.run('a_cmd', 1)
22
22
  assert_equal 'a_cmd', subject.cmds_run.last
23
+
24
+ subject.sudo('a_cmd', 1)
25
+ assert_equal 'sudo a_cmd', subject.cmds_run.last
23
26
  end
24
27
 
25
28
  end
data/test/helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # this file is automatically required in when you require 'assert' in your tests
2
2
  # put test helpers here
3
+ ENV['CAPUTIL_SILENCE_SAY'] = 'yes'
3
4
 
4
5
  # add root dir to the load path
5
6
  $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap-util
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 0
9
8
  - 1
10
- version: 1.0.1
9
+ - 0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,10 +16,10 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-01-15 00:00:00 Z
19
+ date: 2013-02-04 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: assert
22
+ prerelease: false
23
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
@@ -30,11 +30,11 @@ dependencies:
30
30
  - 1
31
31
  - 0
32
32
  version: "1.0"
33
- type: :development
34
33
  requirement: *id001
35
- prerelease: false
34
+ name: assert
35
+ type: :development
36
36
  - !ruby/object:Gem::Dependency
37
- name: capistrano
37
+ prerelease: false
38
38
  version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
@@ -44,11 +44,11 @@ dependencies:
44
44
  segments:
45
45
  - 0
46
46
  version: "0"
47
- type: :runtime
48
47
  requirement: *id002
49
- prerelease: false
48
+ name: capistrano
49
+ type: :runtime
50
50
  - !ruby/object:Gem::Dependency
51
- name: scmd
51
+ prerelease: false
52
52
  version_requirements: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
@@ -59,9 +59,9 @@ dependencies:
59
59
  - 2
60
60
  - 0
61
61
  version: "2.0"
62
- type: :runtime
63
62
  requirement: *id003
64
- prerelease: false
63
+ name: scmd
64
+ type: :runtime
65
65
  description: A set of utilities for writing cap tasks.
66
66
  email:
67
67
  - kelly@kellyredding.com
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  requirements: []
135
135
 
136
136
  rubyforge_project:
137
- rubygems_version: 1.8.24
137
+ rubygems_version: 1.8.15
138
138
  signing_key:
139
139
  specification_version: 3
140
140
  summary: A set of utilities for writing cap tasks.