HeSYINUvSBZfxqA-capistrano_colors 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{HeSYINUvSBZfxqA-capistrano_colors}
5
+ s.version = "0.5.5"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Mathias Stjernstrom"]
9
+ s.date = %q{2011-03-17}
10
+ s.description = %q{Simple gem to display colors in capistrano output.}
11
+ s.email = %q{mathias@globalinn.com}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/capistrano_colors.rb", "lib/capistrano_colors/configuration.rb", "lib/capistrano_colors/logger.rb"]
13
+ s.files = ["README.rdoc", "Rakefile", "HeSYINUvSBZfxqA-capistrano_colors.gemspec", "lib/capistrano_colors.rb", "lib/capistrano_colors/configuration.rb", "lib/capistrano_colors/logger.rb" ]
14
+ s.homepage = %q{http://github.com/stjernstrom/capistrano_colors}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capistrano_colors", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{capistranocolor}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{Simple gem to display colors in capistrano output.}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<HeSYINUvSBZfxqA-capistrano>, [">= 2.3.0"])
27
+ else
28
+ s.add_dependency(%q<HeSYINUvSBZfxqA-capistrano>, [">= 2.3.0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<HeSYINUvSBZfxqA-capistrano>, [">= 2.3.0"])
32
+ end
33
+ end
@@ -0,0 +1,130 @@
1
+ == DESCRIPTION
2
+
3
+ The aim of capistrano_colors is to make the capistrano output more userfriendly.
4
+ When capistrano_colors is included in your deploy.rb capistrano output gets nice and shiny colors.
5
+
6
+ == INSTALLATION
7
+
8
+ sudo gem install capistrano_colors
9
+
10
+ == USAGE
11
+
12
+ === Per project installation
13
+
14
+ In config/deploy.rb
15
+
16
+ require 'capistrano_colors'
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
+ * :prepend - Text to be prepended to the output
39
+ * :timestamp - Show current time with the output
40
+
41
+ === match
42
+ :match is a simple regular expression for the row that should be matched.
43
+
44
+ === color
45
+ :color can have the following values:
46
+
47
+ * :hide (hides the row completely)
48
+ * :none
49
+ * :black
50
+ * :red
51
+ * :green
52
+ * :yellow
53
+ * :blue
54
+ * :magenta
55
+ * :cyan
56
+ * :white
57
+
58
+ === prio
59
+ :prio is a Integer defining the matchers prio.
60
+
61
+ === attribute
62
+ :attribute can have the following values:
63
+
64
+ * :bright
65
+ * :dim
66
+ * :underscore
67
+ * :blink
68
+ * :reverse
69
+ * :hidden
70
+
71
+ == Example
72
+
73
+ require 'capistrano_colors'
74
+
75
+ capistrano_color_matchers = [
76
+ { :match => /command finished/, :color => :hide, :prio => 10 },
77
+ { :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore },
78
+ { :match => /^transaction: commit$/, :color => :magenta, :prio => 10, :attribute => :blink },
79
+ { :match => /git/, :color => :white, :prio => 20, :attribute => :reverse },
80
+ ]
81
+
82
+ colorize( capistrano_color_matchers )
83
+
84
+
85
+ == CHANGES
86
+
87
+ v.0.5.5
88
+
89
+ - Added :timestamp option. Submitted by Mike Gunderloy
90
+
91
+ v.0.5.0
92
+
93
+ - Total rewrite and that is why we have a big version bump ;)
94
+ - Moved modules/classes to separate files.
95
+ - Wrote a simple color-regexp-match-engine.
96
+ - Possible to make you own custom color-matchers.
97
+
98
+ v.0.2.1
99
+
100
+ - Bugfix for some err: messages that where not printed in red.
101
+ - Moved console colors to constants
102
+ - Simple cleanup
103
+
104
+ == AUTHOR
105
+
106
+ Mathias Stjernström (http://pastbedti.me/)
107
+
108
+ == LICENSE
109
+
110
+ MIT License
111
+ Copyright (c) 2007 - 2008
112
+
113
+ Permission is hereby granted, free of charge, to any person obtaining
114
+ a copy of this software and associated documentation files (the
115
+ 'Software'), to deal in the Software without restriction, including
116
+ without limitation the rights to use, copy, modify, merge, publish,
117
+ distribute, sub-license, and/or sell copies of the Software, and to
118
+ permit persons to whom the Software is furnished to do so, subject to
119
+ the following conditions:
120
+
121
+ The above copyright notice and this permission notice shall be
122
+ included in all copies or substantial portions of the Software.
123
+
124
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
125
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
126
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
127
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
128
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
129
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
130
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ require 'capistrano/configuration'
2
+ require 'capistrano/logger'
3
+
4
+ require 'capistrano_colors/configuration'
5
+ require 'capistrano_colors/logger'
6
+
7
+ # DEBUG
8
+ Capistrano::Logger.add_color_matcher({ :match => /executing `.*/, :color => :green, :level => 2, :prio => -10, :prepend => "== Currently ", :timestamp => true })
9
+ Capistrano::Logger.add_color_matcher({ :match => /.*/, :color => :yellow, :level => 2, :prio => -20 })
10
+
11
+ # INFO
12
+ Capistrano::Logger.add_color_matcher({ :match => /.*out\] (fatal:|ERROR:).*/, :color => :red, :level => 1, :prio => -10 })
13
+ Capistrano::Logger.add_color_matcher({ :match => /Permission denied/, :color => :red, :level => 1, :prio => -20 })
14
+ Capistrano::Logger.add_color_matcher({ :match => /sh: .+: command not found/, :color => :magenta, :level => 1, :prio => -30 })
15
+
16
+ # IMPORTANT
17
+ Capistrano::Logger.add_color_matcher({ :match => /^err ::/, :color => :red, :level => 0, :prio => -10 })
18
+ Capistrano::Logger.add_color_matcher({ :match => /.*/, :color => :blue, :level => 0, :prio => -20 })
@@ -0,0 +1,70 @@
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, :prepend => "$$$" },
16
+ # { :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore, :timestamp => true },
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
+ # == Text alterations
53
+ #
54
+ # :prepend gives static text to be prepended to the output
55
+ # :timestamp adds the current time before the output
56
+ #
57
+ def colorize(options)
58
+
59
+ if options.class == Array
60
+ options.each do |opt|
61
+ Capistrano::Logger.add_color_matcher( opt )
62
+ end
63
+ else
64
+ Capistrano::Logger.add_color_matcher( options )
65
+
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,72 @@
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] || line_prefix =~ filter[:match]
41
+ color = filter[:color]
42
+ attribute = filter[:attribute]
43
+ message = filter[:prepend] + message unless filter[:prepend].nil?
44
+ message = Time.now.strftime('%T') + ' ' + message if filter[:timestamp]
45
+ break
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ if color != :hide
52
+ current_color = CAP_COLORS[color]
53
+ current_attribute = CAP_ATTRIBUTES[attribute]
54
+
55
+ line_prefix = colorize(line_prefix.to_s, current_color, current_attribute, nil) unless line_prefix.nil?
56
+ org_log(level, colorize(message, current_color, current_attribute), line_prefix)
57
+ end
58
+
59
+ end
60
+
61
+ def self.add_color_matcher( options ) #:nodoc:
62
+ @@color_matchers.push( options )
63
+ end
64
+
65
+ def colorize(message, color, attribute, nl = "\n")
66
+ attribute = "#{attribute};" if attribute
67
+ "\e[#{attribute}#{color}m" + message.strip + "\e[0m#{nl}"
68
+ end
69
+
70
+ end
71
+
72
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: HeSYINUvSBZfxqA-capistrano_colors
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 5
10
+ version: 0.5.5
11
+ platform: ruby
12
+ authors:
13
+ - Mathias Stjernstrom
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-17 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 2
30
+ - 3
31
+ - 0
32
+ version: 2.3.0
33
+ prerelease: false
34
+ type: :development
35
+ requirement: *id001
36
+ name: HeSYINUvSBZfxqA-capistrano
37
+ description: Simple gem to display colors in capistrano output.
38
+ email: mathias@globalinn.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README.rdoc
45
+ - lib/capistrano_colors.rb
46
+ - lib/capistrano_colors/configuration.rb
47
+ - lib/capistrano_colors/logger.rb
48
+ files:
49
+ - README.rdoc
50
+ - Rakefile
51
+ - HeSYINUvSBZfxqA-capistrano_colors.gemspec
52
+ - lib/capistrano_colors.rb
53
+ - lib/capistrano_colors/configuration.rb
54
+ - lib/capistrano_colors/logger.rb
55
+ has_rdoc: true
56
+ homepage: http://github.com/stjernstrom/capistrano_colors
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options:
61
+ - --line-numbers
62
+ - --inline-source
63
+ - --title
64
+ - Capistrano_colors
65
+ - --main
66
+ - README.rdoc
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 11
84
+ segments:
85
+ - 1
86
+ - 2
87
+ version: "1.2"
88
+ requirements: []
89
+
90
+ rubyforge_project: capistranocolor
91
+ rubygems_version: 1.6.2
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Simple gem to display colors in capistrano output.
95
+ test_files: []
96
+