darkside_capistrano_colors 0.5.3

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.
@@ -0,0 +1,3 @@
1
+ pkg
2
+ doc
3
+ Manifest
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Darkside
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,126 @@
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
+ This gem is a fork of the original capistrano_colors by Mathias Stjernström with some small changes to work with ree and rvm.
7
+
8
+ == INSTALLATION
9
+
10
+ sudo gem install darkside_capistrano_colors
11
+
12
+ == USAGE
13
+
14
+ === Per project installation
15
+
16
+ In config/deploy.rb
17
+
18
+ require 'capistrano_colors'
19
+
20
+
21
+ === System wide installation
22
+
23
+ Create/Modify you ~/.caprc with the following
24
+
25
+ require 'capistrano_colors'
26
+
27
+
28
+ == Creating you own color matchers
29
+
30
+ Create a custom colormatcher with the colorize command.
31
+ colorize can be called with a hash of options or an array of hashes.
32
+
33
+ The options hash should have the following fields.
34
+
35
+ * :match - A regular expression of the row to match.
36
+ * :color - The color we want on the matching rows.
37
+ * :prio - What prio should this rule have (higher = more prio)
38
+ * :attribute - Special effect (:underline, :reverse, :blink)
39
+ * :level - Specify if this matcher should be bound to some of capistranos log levels (info,debug,...)
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.0
88
+
89
+ - Total rewrite and that is why we have a big version bump ;)
90
+ - Moved modules/classes to separate files.
91
+ - Wrote a simple color-regexp-match-engine.
92
+ - Possible to make you own custom color-matchers.
93
+
94
+ v.0.2.1
95
+
96
+ - Bugfix for some err: messages that where not printed in red.
97
+ - Moved console colors to constants
98
+ - Simple cleanup
99
+
100
+ == AUTHOR
101
+
102
+ Mathias Stjernström (http://pastbedti.me/)
103
+
104
+ == LICENSE
105
+
106
+ MIT License
107
+ Copyright (c) 2007 - 2008
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining
110
+ a copy of this software and associated documentation files (the
111
+ 'Software'), to deal in the Software without restriction, including
112
+ without limitation the rights to use, copy, modify, merge, publish,
113
+ distribute, sub-license, and/or sell copies of the Software, and to
114
+ permit persons to whom the Software is furnished to do so, subject to
115
+ the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be
118
+ included in all copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
121
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
123
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
124
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
125
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
126
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "darkside_capistrano_colors"
8
+ gem.summary = %Q{Fork of capistrano_colors, colorize your capistrano output}
9
+ gem.description = %Q{}
10
+ gem.email = "leonardobighetti@gmail.com"
11
+ gem.homepage = "http://github.com/darkside/capistrano_colors"
12
+ gem.authors = ["Darkside", "Mathias Stjernstrom"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency(%q<capistrano>, [">= 2.3.0"])
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "capistrano_colors #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.3
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{darkside_capistrano_colors}
5
+ s.version = "0.5.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Mathias Stjernstrom", "Leonardo Bighetti"]
9
+ s.date = %q{2010-03-09}
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/configuration.rb", "lib/capistrano/logger.rb", "lib/capistrano_colors.rb"]
13
+ s.files = ["README.rdoc", "Rakefile", "lib/capistrano/configuration.rb", "lib/capistrano/logger.rb", "lib/capistrano_colors.rb", "Manifest", "capistrano_colors.gemspec"]
14
+ s.homepage = %q{http://github.com/darkside/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.5}
19
+ s.summary = %q{Simple gem to display colors in capistrano output. Fork of Mathias capistrano_colors.}
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::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<capistrano>, [">= 2.3.0"])
27
+ else
28
+ s.add_dependency(%q<capistrano>, [">= 2.3.0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<capistrano>, [">= 2.3.0"])
32
+ end
33
+ end
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{darkside_capistrano_colors}
8
+ s.version = "0.5.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Darkside", "Mathias Stjernstrom"]
12
+ s.date = %q{2010-08-26}
13
+ s.description = %q{}
14
+ s.email = %q{leonardobighetti@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "capistrano_colors.gemspec",
26
+ "darkside_capistrano_colors.gemspec",
27
+ "lib/capistrano/configuration.rb",
28
+ "lib/capistrano/logger.rb",
29
+ "lib/capistrano_colors.rb",
30
+ "test/helper.rb",
31
+ "test/test_capistrano_colors.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/darkside/capistrano_colors}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.7}
37
+ s.summary = %q{Fork of capistrano_colors, colorize your capistrano output}
38
+ s.test_files = [
39
+ "test/helper.rb",
40
+ "test/test_capistrano_colors.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
49
+ s.add_runtime_dependency(%q<capistrano>, [">= 2.3.0"])
50
+ else
51
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
52
+ s.add_dependency(%q<capistrano>, [">= 2.3.0"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
56
+ s.add_dependency(%q<capistrano>, [">= 2.3.0"])
57
+ end
58
+ end
59
+
@@ -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,71 @@
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
+
28
+ def log(level, message, line_prefix=nil) #:nodoc:
29
+
30
+ color = :none
31
+ attribute = nil
32
+
33
+ # Sort matchers in reverse order so we can break if we found a match.
34
+ @@sorted_color_matchers ||= @@color_matchers.sort_by { |i| -i[:prio] }
35
+
36
+ @@sorted_color_matchers.each do |filter|
37
+
38
+ if (filter[:level] == level || filter[:level].nil?)
39
+ if message =~ filter[:match]
40
+ color = filter[:color]
41
+ attribute = filter[:attribute]
42
+ message = filter[:prepend] + message unless filter[:prepend].nil?
43
+ break
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ if color != :hide
50
+ current_color = CAP_COLORS[color]
51
+ current_attribute = CAP_ATTRIBUTES[attribute]
52
+
53
+ line_prefix = colorize(line_prefix.to_s, current_color, current_attribute, nil) unless line_prefix.nil?
54
+ org_log(level, colorize(message, current_color, current_attribute), line_prefix)
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
+ alias_method :org_log, :log
69
+ end
70
+
71
+ end
@@ -0,0 +1,17 @@
1
+ dir = File.dirname(__FILE__)
2
+
3
+ require dir + '/capistrano/configuration'
4
+ require dir + '/capistrano/logger'
5
+
6
+ # DEBUG
7
+ Capistrano::Logger.add_color_matcher({ :match => /executing `.*/, :color => :green, :level => 2, :prio => -10, :prepend => "== Currently " })
8
+ Capistrano::Logger.add_color_matcher({ :match => /.*/, :color => :yellow, :level => 2, :prio => -20 })
9
+
10
+ # INFO
11
+ Capistrano::Logger.add_color_matcher({ :match => /.*out\] (fatal:|ERROR:).*/, :color => :red, :level => 1, :prio => -10 })
12
+ Capistrano::Logger.add_color_matcher({ :match => /Permission denied/, :color => :red, :level => 1, :prio => -20 })
13
+ Capistrano::Logger.add_color_matcher({ :match => /sh: .+: command not found/, :color => :magenta, :level => 1, :prio => -30 })
14
+
15
+ # IMPORTANT
16
+ Capistrano::Logger.add_color_matcher({ :match => /^err ::/, :color => :red, :level => 0, :prio => -10 })
17
+ Capistrano::Logger.add_color_matcher({ :match => /.*/, :color => :blue, :level => 0, :prio => -20 })
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'capistrano_colors'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestCapistranoColors < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: darkside_capistrano_colors
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 3
10
+ version: 0.5.3
11
+ platform: ruby
12
+ authors:
13
+ - Darkside
14
+ - Mathias Stjernstrom
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-08-26 00:00:00 -03:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: thoughtbot-shoulda
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: capistrano
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 2
47
+ - 3
48
+ - 0
49
+ version: 2.3.0
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ description: ""
53
+ email: leonardobighetti@gmail.com
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ extra_rdoc_files:
59
+ - LICENSE
60
+ - README.rdoc
61
+ files:
62
+ - .gitignore
63
+ - LICENSE
64
+ - README.rdoc
65
+ - Rakefile
66
+ - VERSION
67
+ - capistrano_colors.gemspec
68
+ - darkside_capistrano_colors.gemspec
69
+ - lib/capistrano/configuration.rb
70
+ - lib/capistrano/logger.rb
71
+ - lib/capistrano_colors.rb
72
+ - test/helper.rb
73
+ - test/test_capistrano_colors.rb
74
+ has_rdoc: true
75
+ homepage: http://github.com/darkside/capistrano_colors
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --charset=UTF-8
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Fork of capistrano_colors, colorize your capistrano output
108
+ test_files:
109
+ - test/helper.rb
110
+ - test/test_capistrano_colors.rb