capistrano_colors 0.2.1 → 0.5.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.
- data/Manifest +3 -2
- data/README.rdoc +75 -1
- data/Rakefile +1 -1
- data/capistrano_colors.gemspec +6 -4
- data/lib/capistrano/configuration.rb +65 -0
- data/lib/capistrano/logger.rb +70 -0
- data/lib/capistrano_colors.rb +14 -41
- data.tar.gz.sig +4 -0
- metadata +30 -5
- metadata.gz.sig +0 -0
data/Manifest
CHANGED
data/README.rdoc
CHANGED
@@ -9,12 +9,86 @@ When capistrano_colors is included in your deploy.rb capistrano output gets nice
|
|
9
9
|
|
10
10
|
== USAGE
|
11
11
|
|
12
|
-
|
12
|
+
=== Per project installation
|
13
|
+
|
14
|
+
In config/deploy.rb
|
13
15
|
|
14
16
|
require 'capistrano_colors'
|
15
17
|
|
18
|
+
|
19
|
+
=== System wide installation
|
20
|
+
|
21
|
+
Create/Modify you ~/.caprc with the following
|
22
|
+
|
23
|
+
require 'capistrano_colors'
|
24
|
+
|
25
|
+
|
26
|
+
== Creating you own color matchers
|
27
|
+
|
28
|
+
Create a custom colormatcher with the colorize command.
|
29
|
+
colorize can be called with a hash of options or an array of hashes.
|
30
|
+
|
31
|
+
The options hash should have the following fields.
|
32
|
+
|
33
|
+
* :match - A regular expression of the row to match.
|
34
|
+
* :color - The color we want on the matching rows.
|
35
|
+
* :prio - What prio should this rule have (higher = more prio)
|
36
|
+
* :attribute - Special effect (:underline, :reverse, :blink)
|
37
|
+
* :level - Specify if this matcher should be bound to some of capistranos log levels (info,debug,...)
|
38
|
+
|
39
|
+
=== match
|
40
|
+
:match is a simple regular expression for the row that should be matched.
|
41
|
+
|
42
|
+
=== color
|
43
|
+
:color can have the following values:
|
44
|
+
|
45
|
+
* :hide (hides the row completely)
|
46
|
+
* :none
|
47
|
+
* :black
|
48
|
+
* :red
|
49
|
+
* :green
|
50
|
+
* :yellow
|
51
|
+
* :blue
|
52
|
+
* :magenta
|
53
|
+
* :cyan
|
54
|
+
* :white
|
55
|
+
|
56
|
+
=== prio
|
57
|
+
:prio is a Integer defining the matchers prio.
|
58
|
+
|
59
|
+
=== attribute
|
60
|
+
:attribute can have the following values:
|
61
|
+
|
62
|
+
* :bright
|
63
|
+
* :dim
|
64
|
+
* :underscore
|
65
|
+
* :blink
|
66
|
+
* :reverse
|
67
|
+
* :hidden
|
68
|
+
|
69
|
+
== Example
|
70
|
+
|
71
|
+
require 'capistrano_colors'
|
72
|
+
|
73
|
+
capistrano_color_matchers = [
|
74
|
+
{ :match => /command finished/, :color => :hide, :prio => 10 },
|
75
|
+
{ :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore },
|
76
|
+
{ :match => /^transaction: commit$/, :color => :magenta, :prio => 10, :attribute => :blink },
|
77
|
+
{ :match => /git/, :color => :white, :prio => 20, :attribute => :reverse },
|
78
|
+
]
|
79
|
+
|
80
|
+
colorize( capistrano_color_matchers )
|
81
|
+
|
82
|
+
|
16
83
|
== CHANGES
|
17
84
|
|
85
|
+
v.0.5.0
|
86
|
+
|
87
|
+
- Total rewrite and that is why we have a big version bump ;)
|
88
|
+
- Moved modules/classes to separate files.
|
89
|
+
- Wrote a simple color-regexp-match-engine.
|
90
|
+
- Possible to make you own custom color-matchers.
|
91
|
+
|
18
92
|
v.0.2.1
|
19
93
|
|
20
94
|
- Bugfix for some err: messages that where not printed in red.
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('capistrano_colors', '0.
|
5
|
+
Echoe.new('capistrano_colors', '0.5.0') do |p|
|
6
6
|
p.description = "Simple gem to display colors in capistrano output."
|
7
7
|
p.url = "http://github.com/stjernstrom/capistrano_colors"
|
8
8
|
p.author = "Mathias Stjernstrom"
|
data/capistrano_colors.gemspec
CHANGED
@@ -2,21 +2,23 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{capistrano_colors}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.5.0"
|
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"]
|
9
|
-
s.
|
9
|
+
s.cert_chain = ["/Users/mathias/.ssh/gem-public_cert.pem"]
|
10
|
+
s.date = %q{2009-01-04}
|
10
11
|
s.description = %q{Simple gem to display colors in capistrano output.}
|
11
12
|
s.email = %q{mathias@globalinn.com}
|
12
|
-
s.extra_rdoc_files = ["lib/capistrano_colors.rb", "README.rdoc"]
|
13
|
-
s.files = ["
|
13
|
+
s.extra_rdoc_files = ["lib/capistrano/configuration.rb", "lib/capistrano/logger.rb", "lib/capistrano_colors.rb", "README.rdoc"]
|
14
|
+
s.files = ["lib/capistrano/configuration.rb", "lib/capistrano/logger.rb", "lib/capistrano_colors.rb", "Rakefile", "README.rdoc", "Manifest", "capistrano_colors.gemspec"]
|
14
15
|
s.has_rdoc = true
|
15
16
|
s.homepage = %q{http://github.com/stjernstrom/capistrano_colors}
|
16
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capistrano_colors", "--main", "README.rdoc"]
|
17
18
|
s.require_paths = ["lib"]
|
18
19
|
s.rubyforge_project = %q{capistranocolor}
|
19
20
|
s.rubygems_version = %q{1.3.1}
|
21
|
+
s.signing_key = %q{/Users/mathias/.ssh/gem-private_key.pem}
|
20
22
|
s.summary = %q{Simple gem to display colors in capistrano output.}
|
21
23
|
|
22
24
|
if s.respond_to? :specification_version then
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Capistrano
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
# Add custom colormatchers
|
5
|
+
#
|
6
|
+
# Passing a hash or a array of hashes with custom colormatchers.
|
7
|
+
#
|
8
|
+
# Add the following to your deploy.rb or in your ~/.caprc
|
9
|
+
#
|
10
|
+
# == Example:
|
11
|
+
#
|
12
|
+
# require 'capistrano_colors'
|
13
|
+
#
|
14
|
+
# capistrano_color_matchers = [
|
15
|
+
# { :match => /command finished/, :color => :hide, :prio => 10 },
|
16
|
+
# { :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore },
|
17
|
+
# { :match => /^transaction: commit$/, :color => :magenta, :prio => 10, :attribute => :blink },
|
18
|
+
# { :match => /git/, :color => :white, :prio => 20, :attribute => :reverse },
|
19
|
+
# ]
|
20
|
+
#
|
21
|
+
# colorize( capistrano_color_matchers )
|
22
|
+
#
|
23
|
+
# You can call colorize multiple time with either a hash or an array of hashes multiple times.
|
24
|
+
#
|
25
|
+
# == Colors:
|
26
|
+
#
|
27
|
+
# :color can have the following values:
|
28
|
+
#
|
29
|
+
# * :hide (hides the row completely)
|
30
|
+
# * :none
|
31
|
+
# * :black
|
32
|
+
# * :red
|
33
|
+
# * :green
|
34
|
+
# * :yellow
|
35
|
+
# * :blue
|
36
|
+
# * :magenta
|
37
|
+
# * :cyan
|
38
|
+
# * :white
|
39
|
+
#
|
40
|
+
# == Attributes:
|
41
|
+
#
|
42
|
+
# :attribute can have the following values:
|
43
|
+
#
|
44
|
+
# * :bright
|
45
|
+
# * :dim
|
46
|
+
# * :underscore
|
47
|
+
# * :blink
|
48
|
+
# * :reverse
|
49
|
+
# * :hidden
|
50
|
+
#
|
51
|
+
#
|
52
|
+
def colorize(options)
|
53
|
+
|
54
|
+
if options.class == Array
|
55
|
+
options.each do |opt|
|
56
|
+
Capistrano::Logger.add_color_matcher( opt )
|
57
|
+
end
|
58
|
+
else
|
59
|
+
Capistrano::Logger.add_color_matcher( options )
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Capistrano
|
2
|
+
class Logger
|
3
|
+
|
4
|
+
CAP_COLORS = {
|
5
|
+
:none => "0",
|
6
|
+
:black => "30",
|
7
|
+
:red => "31",
|
8
|
+
:green => "32",
|
9
|
+
:yellow => "33",
|
10
|
+
:blue => "34",
|
11
|
+
:magenta => "35",
|
12
|
+
:cyan => "36",
|
13
|
+
:white => "37"
|
14
|
+
}
|
15
|
+
|
16
|
+
CAP_ATTRIBUTES = {
|
17
|
+
:bright => 1,
|
18
|
+
:dim => 2,
|
19
|
+
:underscore => 4,
|
20
|
+
:blink => 5,
|
21
|
+
:reverse => 7,
|
22
|
+
:hidden => 8
|
23
|
+
}
|
24
|
+
|
25
|
+
@@color_matchers = []
|
26
|
+
|
27
|
+
alias_method :org_log, :log
|
28
|
+
|
29
|
+
def log(level, message, line_prefix=nil) #:nodoc:
|
30
|
+
|
31
|
+
color = :none
|
32
|
+
attribute = nil
|
33
|
+
|
34
|
+
# Sort matchers in reverse order so we can break if we found a match.
|
35
|
+
@@sorted_color_matchers ||= @@color_matchers.sort_by { |i| -i[:prio] }
|
36
|
+
|
37
|
+
@@sorted_color_matchers.each do |filter|
|
38
|
+
|
39
|
+
if (filter[:level] == level || filter[:level].nil?)
|
40
|
+
if message =~ filter[:match]
|
41
|
+
color = filter[:color]
|
42
|
+
attribute = filter[:attribute]
|
43
|
+
message = filter[:prepend] + message unless filter[:prepend].nil?
|
44
|
+
break
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
if color != :hide
|
51
|
+
current_color = CAP_COLORS[color]
|
52
|
+
current_attribute = CAP_ATTRIBUTES[attribute]
|
53
|
+
line_prefix = colorize(line_prefix.to_s, current_color, current_attribute) unless line_prefix.nil?
|
54
|
+
org_log(level, colorize(message, current_color, current_attribute), line_prefix=nil)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.add_color_matcher( options ) #:nodoc:
|
60
|
+
@@color_matchers.push( options )
|
61
|
+
end
|
62
|
+
|
63
|
+
def colorize(message, color, attribute, nl = "\n")
|
64
|
+
attribute = "#{attribute};" if attribute
|
65
|
+
"\e[#{attribute}#{color}m" + message.strip + "\e[0m#{nl}"
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/lib/capistrano_colors.rb
CHANGED
@@ -1,46 +1,19 @@
|
|
1
|
-
puts "\e[36m == capistrano_colors loaded ==\e[0m"
|
1
|
+
puts "\n\e[36m == capistrano_colors loaded ==\e[0m\n\n"
|
2
2
|
|
3
|
-
|
4
|
-
class Logger
|
3
|
+
dir = File.dirname(__FILE__)
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
CC_GREEN = "32"
|
9
|
-
CC_YELLOW = "33"
|
10
|
-
CC_BLUE = "34"
|
5
|
+
require dir + '/capistrano/configuration'
|
6
|
+
require dir + '/capistrano/logger'
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
# DEBUG
|
9
|
+
Capistrano::Logger.add_color_matcher({ :match => /executing `.*/, :color => :green, :level => 2, :prio => -10, :prepend => "== Currently " })
|
10
|
+
Capistrano::Logger.add_color_matcher({ :match => /.*/, :color => :yellow, :level => 2, :prio => -20 })
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
log(DEBUG, colorize(message, CC_YELLOW), line_prefix)
|
21
|
-
end
|
22
|
-
end
|
12
|
+
# INFO
|
13
|
+
Capistrano::Logger.add_color_matcher({ :match => /.*out\] (fatal:|ERROR:).*/, :color => :red, :level => 1, :prio => -10 })
|
14
|
+
Capistrano::Logger.add_color_matcher({ :match => /Permission denied/, :color => :red, :level => 1, :prio => -20 })
|
15
|
+
Capistrano::Logger.add_color_matcher({ :match => /sh: .+: command not found/, :color => :magenta, :level => 1, :prio => -30 })
|
23
16
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
color = CC_STD
|
29
|
-
end
|
30
|
-
log(INFO, colorize(message,color), line_prefix)
|
31
|
-
end
|
32
|
-
|
33
|
-
def important(message, line_prefix=nil)
|
34
|
-
if line_prefix =~ /^err ::/
|
35
|
-
color = CC_RED
|
36
|
-
else
|
37
|
-
color = CC_BLUE
|
38
|
-
end
|
39
|
-
log(IMPORTANT, colorize(message, color), line_prefix) if !message.strip.empty?
|
40
|
-
end
|
41
|
-
|
42
|
-
def trace(message, line_prefix=nil)
|
43
|
-
log(TRACE, message, line_prefix)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
17
|
+
# IMPORTANT
|
18
|
+
Capistrano::Logger.add_color_matcher({ :match => /^err ::/, :color => :red, :level => 0, :prio => -10 })
|
19
|
+
Capistrano::Logger.add_color_matcher({ :match => /.*/, :color => :blue, :level => 0, :prio => -20 })
|
data.tar.gz.sig
ADDED
metadata
CHANGED
@@ -1,15 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano_colors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Stjernstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMRAwDgYDVQQDDAdtYXRo
|
14
|
+
aWFzMRkwFwYKCZImiZPyLGQBGRYJZ2xvYmFsaW5uMRMwEQYKCZImiZPyLGQBGRYD
|
15
|
+
Y29tMB4XDTA4MTIyMTA3MTEzM1oXDTA5MTIyMTA3MTEzM1owQjEQMA4GA1UEAwwH
|
16
|
+
bWF0aGlhczEZMBcGCgmSJomT8ixkARkWCWdsb2JhbGlubjETMBEGCgmSJomT8ixk
|
17
|
+
ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL30OXlyee2o
|
18
|
+
stQFrTZRtzsAH4wQ/jKIUO43zRTtaHnMKsy8Ga0T2piNN35Qq1yZNlf2fGl3LopI
|
19
|
+
w+wLMQYeCjY6fjbTXDGHbaiT3qE/F/RHlv8at29ztpaCQfeL33DGCohrRGYWouD9
|
20
|
+
j0wOnPrwHE2fGDqKTYXhgiAIIzmwqn1kcAIzm3V9WRvYE97IDVHvFcMRydbxlGgW
|
21
|
+
rHgRvGuBs5jf+rCpGvakoZjDZx3ueF9AphaMun70z2fYWiH3pY3g65tkf5C8JBT5
|
22
|
+
HyiHEwCNXu7bMYA2OMA+EGVpHZh/+78XrE+hRvKvHz6TF8pfKiTf/ukEvDWqxHyk
|
23
|
+
a9V6BS2FEG8CAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
24
|
+
BBYEFPuAbY2bxHbIT15IcJcelQii+AoNMA0GCSqGSIb3DQEBBQUAA4IBAQANgGbP
|
25
|
+
F9S1YGw38ZwkZX4k9ZuaO87stEewkR+TEQ7R1ptiW8I/bR59hBkl9wuXSC9Ho6B/
|
26
|
+
yryfubWJdlLykn32PJsaPUnNEejLSCWtAWNkyGltBxNMhVNEiHuxaxnRqblPHKYE
|
27
|
+
fn0zqKANa+mbFtx3SvgkOwEFyCpioEi8DDlFWhb4F4V+a0NGxhI4w7htmT7pG4vc
|
28
|
+
TnHw2b9dwzo8dd+ujNcWKHhu6jL9kgB3B5ZuA7S16E1wd1QSPWO/3U35mCg4M+FB
|
29
|
+
/+sSKAOKmwvZIG32pl7mMoi3gw9k2LpQiJLrBrMA7KDgwefuPc46/J4uwcK18Byg
|
30
|
+
snErBd/zMF/MOW0s
|
31
|
+
-----END CERTIFICATE-----
|
11
32
|
|
12
|
-
date:
|
33
|
+
date: 2009-01-04 00:00:00 +01:00
|
13
34
|
default_executable:
|
14
35
|
dependencies:
|
15
36
|
- !ruby/object:Gem::Dependency
|
@@ -29,14 +50,18 @@ executables: []
|
|
29
50
|
extensions: []
|
30
51
|
|
31
52
|
extra_rdoc_files:
|
53
|
+
- lib/capistrano/configuration.rb
|
54
|
+
- lib/capistrano/logger.rb
|
32
55
|
- lib/capistrano_colors.rb
|
33
56
|
- README.rdoc
|
34
57
|
files:
|
35
|
-
-
|
58
|
+
- lib/capistrano/configuration.rb
|
59
|
+
- lib/capistrano/logger.rb
|
36
60
|
- lib/capistrano_colors.rb
|
37
|
-
- Manifest
|
38
61
|
- Rakefile
|
39
62
|
- README.rdoc
|
63
|
+
- Manifest
|
64
|
+
- capistrano_colors.gemspec
|
40
65
|
has_rdoc: true
|
41
66
|
homepage: http://github.com/stjernstrom/capistrano_colors
|
42
67
|
post_install_message:
|
metadata.gz.sig
ADDED
Binary file
|