capistrano-log_with_awesome 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ examples/campfire.rb
data/Capfile ADDED
@@ -0,0 +1,14 @@
1
+ # Only needed in development
2
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
3
+ require 'capistrano/log_with_awesome'
4
+
5
+ # Load the example
6
+ Dir['examples/*.rb'].each { |plugin| load(plugin) }
7
+
8
+ # Stub deploy tasks to demonstrate the awesome
9
+ server 'localhost', :local
10
+ set :application, 'test'
11
+ set :deploy_to, '/tmp'
12
+ task :deploy do
13
+ run "uname -a"
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Jesse Newland
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.
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ = capistrano-log_with_awesome
2
+
3
+ Awesome callbacks for capistrano logging.
4
+
5
+ Require the gem in your <tt>config/deploy.rb</tt> or <tt>Capfile</tt>:
6
+
7
+ require 'capistrano/log_with_awesome'
8
+
9
+ Want to upload the full log to a directory after a deploy?
10
+
11
+ on :exit do
12
+ put full_log, "#{deploy_to}/shared/log/last_deploy.log"
13
+ end
14
+
15
+ Want to halt deploy if a command you're running generates output you don't
16
+ like but returns a status code of 0?
17
+
18
+ on :log_message do
19
+ raise Exception if message =~ /oh snap/
20
+ end
21
+
22
+ Want to pipe your capistrano log to Campfire?
23
+
24
+ require 'tinder'
25
+ campfire = Tinder::Campfire.new 'yourdomain', :ssl => true
26
+ campfire.login 'APIKEY', 'X'
27
+ set :room, campfire.find_room_by_name('Log')
28
+
29
+ # Paste the full log to Campfire after a deploy
30
+ on :exit do
31
+ room.paste full_log
32
+ end
33
+
34
+ # Log every single cap log line to Campfire, as it happens. Insane.
35
+ on :log_message do
36
+ room.speak message
37
+ end
38
+
39
+ == Note on Patches/Pull Requests
40
+
41
+ * Fork the project.
42
+ * Make your feature addition or bug fix.
43
+ * Add tests for it. This is important so I don't break it in a
44
+ future version unintentionally.
45
+ * Commit, do not mess with rakefile, version, or history.
46
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
47
+ * Send me a pull request. Bonus points for topic branches.
48
+
49
+ == Copyright
50
+
51
+ Copyright (c) 2010 Jesse Newland. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift 'lib'
2
+ require 'capistrano/log_with_awesome/version'
3
+ require 'rake'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.version = Capistrano::LogWithAwesome::VERSION
9
+ gem.name = "capistrano-log_with_awesome"
10
+ gem.summary = %Q{logging callbacks for capistrano}
11
+ gem.description = %Q{logging callbacks for capistrano}
12
+ gem.email = "jnewland@gmail.com"
13
+ gem.homepage = "http://github.com/jnewland/capistrano-log_with_awesome"
14
+ gem.authors = ["Jesse Newland"]
15
+ gem.add_dependency "capistrano", ">= 2.5.14"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
@@ -0,0 +1,55 @@
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{capistrano-log_with_awesome}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jesse Newland"]
12
+ s.date = %q{2010-02-27}
13
+ s.description = %q{logging callbacks for capistrano}
14
+ s.email = %q{jnewland@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "Capfile",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "capistrano-log_with_awesome.gemspec",
26
+ "examples/campfire.rb.example",
27
+ "examples/raise.rb",
28
+ "examples/upload.rb",
29
+ "lib/capistrano/log_with_awesome.rb",
30
+ "lib/capistrano/log_with_awesome/version.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/jnewland/capistrano-log_with_awesome}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.5}
36
+ s.summary = %q{logging callbacks for capistrano}
37
+ s.test_files = [
38
+ "examples/raise.rb",
39
+ "examples/upload.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<capistrano>, [">= 2.5.14"])
48
+ else
49
+ s.add_dependency(%q<capistrano>, [">= 2.5.14"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<capistrano>, [">= 2.5.14"])
53
+ end
54
+ end
55
+
@@ -0,0 +1,15 @@
1
+ require 'json'
2
+ require 'tinder'
3
+ campfire = Tinder::Campfire.new 'yourdomain', :ssl => true
4
+ campfire.login 'APIKEY', 'X'
5
+ set :room, campfire.find_room_by_name('Log')
6
+
7
+ # Paste the full log to Campfire after a deploy
8
+ on :exit do
9
+ room.paste full_log
10
+ end
11
+
12
+ # Log every single cap log line to Campfire, as it happens. Insane.
13
+ on :log_message do
14
+ room.speak message
15
+ end
data/examples/raise.rb ADDED
@@ -0,0 +1,4 @@
1
+ on :log_message do
2
+ # Raise an exception and halt the deploy if you're on an ATT 3G card
3
+ raise Exception if message =~ /mycingular/
4
+ end
@@ -0,0 +1,3 @@
1
+ on :exit do
2
+ put full_log, "#{deploy_to}/deploy.log"
3
+ end
@@ -0,0 +1,58 @@
1
+ require 'capistrano'
2
+
3
+ module Capistrano
4
+ class LogWithAwesome < Capistrano::Logger
5
+ #replaces the built in Capistrano logger with awesome
6
+ def self.init(config)
7
+ @config = config
8
+ level = @config.logger.level
9
+ @config.logger = new
10
+ @config.logger.level = level
11
+ end
12
+
13
+ def self.log_with_awesome(message)
14
+ @buffer ||= []
15
+ @buffer << message
16
+ @config.set :message, message
17
+ @config.set :full_log, @buffer.join("\n")
18
+ @config.silently_trigger(:log_message)
19
+ end
20
+
21
+ # Log and do awesome things
22
+ # I wish there was a nicer way to do this. Hax on device.puts, maybe?
23
+ def log(level, message, line_prefix=nil)
24
+ if level <= self.level
25
+ indent = "%*s" % [Capistrano::Logger::MAX_LEVEL, "*" * (Capistrano::Logger::MAX_LEVEL - level)]
26
+ (RUBY_VERSION >= "1.9" ? message.lines : message).each do |line|
27
+ if line_prefix
28
+ self.class.log_with_awesome "#{indent} [#{line_prefix}] #{line.strip}"
29
+ else
30
+ self.class.log_with_awesome "#{indent} #{line.strip}"
31
+ end
32
+ end
33
+ end
34
+ super(level, message, line_prefix)
35
+ end
36
+ end
37
+ end
38
+
39
+ module Capistrano
40
+ class Configuration
41
+ module Callbacks
42
+ # Trigger the named event without logging.it
43
+ def silently_trigger(event, task=nil)
44
+ pending = Array(callbacks[event]).select { |c| c.applies_to?(task) }
45
+ if pending.any?
46
+ pending.each { |callback| callback.call }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ # load last in order to repoen rather than define
54
+ require 'capistrano/log_with_awesome/version'
55
+
56
+ Capistrano::Configuration.instance.load do
57
+ Capistrano::LogWithAwesome.init(self)
58
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ class LogWithAwesome
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-log_with_awesome
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jesse Newland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-27 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.5.14
24
+ version:
25
+ description: logging callbacks for capistrano
26
+ email: jnewland@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .gitignore
36
+ - Capfile
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - capistrano-log_with_awesome.gemspec
41
+ - examples/campfire.rb.example
42
+ - examples/raise.rb
43
+ - examples/upload.rb
44
+ - lib/capistrano/log_with_awesome.rb
45
+ - lib/capistrano/log_with_awesome/version.rb
46
+ has_rdoc: true
47
+ homepage: http://github.com/jnewland/capistrano-log_with_awesome
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --charset=UTF-8
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.5
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: logging callbacks for capistrano
74
+ test_files:
75
+ - examples/raise.rb
76
+ - examples/upload.rb