cap-util 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ module CapUtil
5
5
  def self.run_locally(cmd_str)
6
6
  cmd = Scmd.new(cmd_str)
7
7
 
8
- say " * running `#{cmd}'"
8
+ say_bulleted "running `#{cmd}'"
9
9
  cmd.run
10
10
  say_error(cmd.stderr) if !cmd.success?
11
11
 
@@ -15,7 +15,7 @@ module CapUtil
15
15
  def self.run_locally_with_stdin(cmd_str, input)
16
16
  cmd = Scmd.new(cmd_str)
17
17
 
18
- say " * running `#{cmd}'"
18
+ say_bulleted "running `#{cmd}'"
19
19
  cmd.run(input)
20
20
  say_error(cmd.stderr) if !cmd.success?
21
21
 
@@ -7,15 +7,19 @@ module CapUtil
7
7
  end
8
8
 
9
9
  def self.say(msg, *args)
10
- Capistrano::CLI.ui.say(msg, *args)
10
+ Capistrano::CLI.ui.say(" #{msg}", *args)
11
+ end
12
+
13
+ def self.say_bulleted(msg, *args)
14
+ Capistrano::CLI.ui.say(" * #{msg}", *args)
11
15
  end
12
16
 
13
17
  def self.say_error(msg, *args)
14
- say(" #{color "[ERROR]", :bold, :red} #{msg}", *args)
18
+ say("#{color "[ERROR]", :bold, :red} #{msg}", *args)
15
19
  end
16
20
 
17
21
  def self.say_warning(msg, *args)
18
- say(" #{color "[WARN]", :bold, :yellow} #{msg}", *args)
22
+ say("#{color "[WARN]", :bold, :yellow} #{msg}", *args)
19
23
  end
20
24
 
21
25
  module Say
@@ -26,10 +30,11 @@ module CapUtil
26
30
  end
27
31
 
28
32
  module SayMethods
29
- def color(*args); CapUtil.color(*args); end
30
- def say(*args); CapUtil.say(*args); end
31
- def say_error(*args); CapUtil.say_error(*args); end
32
- def say_warning(*args); CapUtil.say_warning(*args); end
33
+ def color(*args); CapUtil.color(*args); end
34
+ def say(*args); CapUtil.say(*args); end
35
+ def say_bulleted(*args); CapUtil.say_bulleted(*args); end
36
+ def say_error(*args); CapUtil.say_error(*args); end
37
+ def say_warning(*args); CapUtil.say_warning(*args); end
33
38
  end
34
39
 
35
40
  end
@@ -18,13 +18,20 @@ module CapUtil
18
18
  module Time
19
19
 
20
20
  def self.included(receiver)
21
- receiver.send(:extend, TimeMethods)
22
- receiver.send(:include, TimeMethods)
21
+ receiver.send(:extend, ClassMethods)
22
+ receiver.send(:include, InstanceMethods)
23
23
  end
24
24
 
25
- module TimeMethods
25
+ module ClassMethods
26
26
  def time(*args, &block); CapUtil.time(*args, &block); end
27
27
  end
28
28
 
29
+ module InstanceMethods
30
+ def time(name, &block)
31
+ @cap_util_timers ||= {}
32
+ CapUtil.time(@cap_util_timers, name, &block)
33
+ end
34
+ end
35
+
29
36
  end
30
37
  end
@@ -15,7 +15,7 @@ module CapUtil
15
15
  end
16
16
 
17
17
  def start(time=nil)
18
- CapUtil.say " Starting #{CapUtil.color @name, :cyan}." if !@quiet
18
+ CapUtil.say "Starting #{CapUtil.color @name, :cyan}." if !@quiet
19
19
  @start_time = (time || ::Time.now)
20
20
  end
21
21
 
@@ -24,7 +24,7 @@ module CapUtil
24
24
  @elapsed_time = @end_time - @start_time
25
25
  if !@quiet
26
26
  elapsed = self.class.pretty_time(@elapsed_time.to_i)
27
- CapUtil.say " #{CapUtil.color @name, :bold, :yellow} completed in"\
27
+ CapUtil.say "#{CapUtil.color @name, :bold, :yellow} completed in"\
28
28
  " #{CapUtil.color elapsed, :underline, :yellow}."
29
29
  end
30
30
  @end_time
@@ -1,3 +1,3 @@
1
1
  module CapUtil
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -10,7 +10,7 @@ module CapUtil
10
10
  subject { @mod }
11
11
 
12
12
  should have_imeth :halt, :time
13
- should have_imeths :color, :say, :say_error, :say_warning
13
+ should have_imeths :color, :say, :say_bulleted, :say_error, :say_warning
14
14
  should have_imeths :run_locally, :run_locally_with_stdin
15
15
 
16
16
  end
@@ -35,8 +35,8 @@ module CapUtil
35
35
  should have_cmeth :halt
36
36
  should have_imeth :halt
37
37
 
38
- should have_cmeths :color, :say, :say_error, :say_warning
39
- should have_imeths :color, :say, :say_error, :say_warning
38
+ should have_cmeths :color, :say, :say_bulleted, :say_error, :say_warning
39
+ should have_imeths :color, :say, :say_bulleted, :say_error, :say_warning
40
40
 
41
41
  should have_cmeths :run_locally, :run_locally_with_stdin
42
42
  should have_imeths :run_locally, :run_locally_with_stdin
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
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding