capistrano_colors 0.5.4 → 0.5.5

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.
@@ -34,7 +34,9 @@ When capistrano_colors is included in your deploy.rb capistrano output gets nice
34
34
  * :color - The color we want on the matching rows.
35
35
  * :prio - What prio should this rule have (higher = more prio)
36
36
  * :attribute - Special effect (:underline, :reverse, :blink)
37
- * :level - Specify if this matcher should be bound to some of capistranos log levels (info,debug,...)
37
+ * :level - Specify if this matcher should be bound to some of capistranos log levels (info,debug,...)
38
+ * :prepend - Text to be prepended to the output
39
+ * :timestamp - Show current time with the output
38
40
 
39
41
  === match
40
42
  :match is a simple regular expression for the row that should be matched.
@@ -82,6 +84,10 @@ When capistrano_colors is included in your deploy.rb capistrano output gets nice
82
84
 
83
85
  == CHANGES
84
86
 
87
+ v.0.5.5
88
+
89
+ - Added :timestamp option. Submitted by Mike Gunderloy
90
+
85
91
  v.0.5.0
86
92
 
87
93
  - Total rewrite and that is why we have a big version bump ;)
data/Rakefile CHANGED
@@ -1,16 +1 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
4
-
5
- Echoe.new('capistrano_colors', '0.5.4') do |p|
6
- p.description = "Simple gem to display colors in capistrano output."
7
- p.url = "http://github.com/stjernstrom/capistrano_colors"
8
- p.author = "Mathias Stjernstrom"
9
- p.email = "mathias@globalinn.com"
10
- p.ignore_pattern = ["tmp/*", "script/*"]
11
- p.development_dependencies = ["capistrano >=2.3.0"]
12
- p.project = "capistranocolor"
13
- end
14
-
15
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
16
-
1
+ require "bundler/gem_tasks"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{capistrano_colors}
5
- s.version = "0.5.4"
5
+ s.version = "0.5.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mathias Stjernstrom"]
@@ -5,7 +5,7 @@ require 'capistrano_colors/configuration'
5
5
  require 'capistrano_colors/logger'
6
6
 
7
7
  # DEBUG
8
- Capistrano::Logger.add_color_matcher({ :match => /executing `.*/, :color => :green, :level => 2, :prio => -10, :prepend => "== Currently " })
8
+ Capistrano::Logger.add_color_matcher({ :match => /executing `.*/, :color => :green, :level => 2, :prio => -10, :prepend => "== Currently ", :timestamp => true })
9
9
  Capistrano::Logger.add_color_matcher({ :match => /.*/, :color => :yellow, :level => 2, :prio => -20 })
10
10
 
11
11
  # INFO
@@ -12,8 +12,8 @@ module Capistrano
12
12
  # require 'capistrano_colors'
13
13
  #
14
14
  # capistrano_color_matchers = [
15
- # { :match => /command finished/, :color => :hide, :prio => 10 },
16
- # { :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore },
15
+ # { :match => /command finished/, :color => :hide, :prio => 10, :prepend => "$$$" },
16
+ # { :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore, :timestamp => true },
17
17
  # { :match => /^transaction: commit$/, :color => :magenta, :prio => 10, :attribute => :blink },
18
18
  # { :match => /git/, :color => :white, :prio => 20, :attribute => :reverse },
19
19
  # ]
@@ -48,6 +48,11 @@ module Capistrano
48
48
  # * :reverse
49
49
  # * :hidden
50
50
  #
51
+ #
52
+ # == Text alterations
53
+ #
54
+ # :prepend gives static text to be prepended to the output
55
+ # :timestamp adds the current time before the output
51
56
  #
52
57
  def colorize(options)
53
58
 
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  class Logger
3
3
 
4
- CAP_COLORS = {
4
+ CAP_COLORS = {
5
5
  :none => "0",
6
6
  :black => "30",
7
7
  :red => "31",
@@ -11,7 +11,7 @@ module Capistrano
11
11
  :magenta => "35",
12
12
  :cyan => "36",
13
13
  :white => "37"
14
- }
14
+ }
15
15
 
16
16
  CAP_ATTRIBUTES = {
17
17
  :bright => 1,
@@ -23,28 +23,29 @@ module Capistrano
23
23
  }
24
24
 
25
25
  @@color_matchers = []
26
-
26
+
27
27
  alias_method :org_log, :log
28
28
 
29
29
  def log(level, message, line_prefix=nil) #:nodoc:
30
-
30
+
31
31
  color = :none
32
32
  attribute = nil
33
-
33
+
34
34
  # Sort matchers in reverse order so we can break if we found a match.
35
35
  @@sorted_color_matchers ||= @@color_matchers.sort_by { |i| -i[:prio] }
36
-
36
+
37
37
  @@sorted_color_matchers.each do |filter|
38
-
38
+
39
39
  if (filter[:level] == level || filter[:level].nil?)
40
40
  if message =~ filter[:match] || line_prefix =~ filter[:match]
41
41
  color = filter[:color]
42
42
  attribute = filter[:attribute]
43
43
  message = filter[:prepend] + message unless filter[:prepend].nil?
44
+ message = Time.now.strftime('%T') + ' ' + message if filter[:timestamp]
44
45
  break
45
46
  end
46
47
  end
47
-
48
+
48
49
  end
49
50
 
50
51
  if color != :hide
@@ -54,13 +55,13 @@ module Capistrano
54
55
  line_prefix = colorize(line_prefix.to_s, current_color, current_attribute, nil) unless line_prefix.nil?
55
56
  org_log(level, colorize(message, current_color, current_attribute), line_prefix)
56
57
  end
57
-
58
+
58
59
  end
59
60
 
60
61
  def self.add_color_matcher( options ) #:nodoc:
61
62
  @@color_matchers.push( options )
62
- end
63
-
63
+ end
64
+
64
65
  def colorize(message, color, attribute, nl = "\n")
65
66
  attribute = "#{attribute};" if attribute
66
67
  "\e[#{attribute}#{color}m" + message.strip + "\e[0m#{nl}"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_colors
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease: false
4
+ hash: 1
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 4
10
- version: 0.5.4
9
+ - 5
10
+ version: 0.5.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mathias Stjernstrom
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-17 00:00:00 +01:00
19
- default_executable:
18
+ date: 2011-03-17 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: capistrano
@@ -53,7 +52,6 @@ files:
53
52
  - lib/capistrano_colors/configuration.rb
54
53
  - lib/capistrano_colors/logger.rb
55
54
  - Manifest
56
- has_rdoc: true
57
55
  homepage: http://github.com/stjernstrom/capistrano_colors
58
56
  licenses: []
59
57
 
@@ -89,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
87
  requirements: []
90
88
 
91
89
  rubyforge_project: capistranocolor
92
- rubygems_version: 1.3.7
90
+ rubygems_version: 1.8.10
93
91
  signing_key:
94
92
  specification_version: 3
95
93
  summary: Simple gem to display colors in capistrano output.