blazing 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -2
- data/blazing.gemspec +2 -0
- data/lib/blazing.rb +1 -0
- data/lib/blazing/logger.rb +27 -0
- data/lib/blazing/recipe.rb +0 -3
- data/lib/blazing/runner.rb +3 -6
- data/lib/blazing/target.rb +4 -0
- data/lib/blazing/templates/hook.erb +4 -1
- data/lib/blazing/version.rb +1 -1
- metadata +33 -23
- data/lib/blazing/cli_logger.rb +0 -114
- data/lib/blazing/cli_logging.rb +0 -58
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
blazing (0.2.
|
4
|
+
blazing (0.2.1)
|
5
5
|
activesupport
|
6
6
|
grit
|
7
7
|
i18n
|
8
|
+
logging
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: http://rubygems.org/
|
@@ -22,7 +23,10 @@ GEM
|
|
22
23
|
guard (>= 0.8.4)
|
23
24
|
i18n (0.6.0)
|
24
25
|
json (1.6.1)
|
25
|
-
|
26
|
+
little-plugger (1.1.2)
|
27
|
+
logging (1.6.1)
|
28
|
+
little-plugger (>= 1.1.2)
|
29
|
+
mime-types (1.17.2)
|
26
30
|
multi_json (1.0.3)
|
27
31
|
rake (0.9.2)
|
28
32
|
rb-fsevent (0.4.0)
|
data/blazing.gemspec
CHANGED
@@ -28,7 +28,9 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency('guard-rspec')
|
29
29
|
s.add_development_dependency('growl')
|
30
30
|
s.add_development_dependency('rb-fsevent')
|
31
|
+
|
31
32
|
s.add_dependency('grit')
|
33
|
+
s.add_dependency('logging')
|
32
34
|
|
33
35
|
# TODO: Get rid of those, just used for guessing recipe names etc in lib/recipes.rb
|
34
36
|
s.add_dependency "activesupport"
|
data/lib/blazing.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'logging'
|
2
|
+
|
3
|
+
include Logging.globally
|
4
|
+
|
5
|
+
# here we setup a color scheme called 'bright'
|
6
|
+
Logging.color_scheme( 'bright',
|
7
|
+
:levels => {
|
8
|
+
:debug => :green,
|
9
|
+
:info => :green,
|
10
|
+
:warn => :yellow,
|
11
|
+
:error => [:white, :on_red],
|
12
|
+
:fatal => [:white, :on_red]
|
13
|
+
}
|
14
|
+
)
|
15
|
+
|
16
|
+
Logging.appenders.stdout(
|
17
|
+
'stdout',
|
18
|
+
:layout => Logging.layouts.pattern(
|
19
|
+
:pattern => ' ------> [blazing] %-5l: %m\n',
|
20
|
+
:color_scheme => 'bright'
|
21
|
+
)
|
22
|
+
)
|
23
|
+
|
24
|
+
Logging.logger.root.appenders = 'stdout'
|
25
|
+
Logging.logger.root.level = :info
|
26
|
+
|
27
|
+
Logging.consolidate :root
|
data/lib/blazing/recipe.rb
CHANGED
data/lib/blazing/runner.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
require 'erb'
|
2
|
-
require 'blazing/cli_logging'
|
3
2
|
require 'grit'
|
4
3
|
|
5
4
|
class Blazing::Runner
|
6
5
|
|
7
|
-
include Blazing::CLILogging
|
8
|
-
|
9
6
|
def initialize(config = nil, target = nil)
|
10
7
|
if config
|
11
8
|
@config = config
|
@@ -20,8 +17,8 @@ class Blazing::Runner
|
|
20
17
|
end
|
21
18
|
|
22
19
|
def init_command
|
23
|
-
info
|
24
|
-
info
|
20
|
+
logger.info "Creating an example config file in #{Blazing::DEFAULT_CONFIG_LOCATION}"
|
21
|
+
logger.info "Customize it to your needs"
|
25
22
|
|
26
23
|
Dir.mkdir 'config' unless File.exists? 'config'
|
27
24
|
configuration_file = ERB.new(File.read("#{Blazing::TEMPLATE_ROOT}/config.erb")).result
|
@@ -34,7 +31,7 @@ class Blazing::Runner
|
|
34
31
|
def setup_git_remotes
|
35
32
|
repository = Grit::Repo.new(Dir.pwd)
|
36
33
|
@config.targets.each do |target|
|
37
|
-
info
|
34
|
+
logger.info "Adding new remote #{target.name} pointing to #{target.location}"
|
38
35
|
repository.config["remote.#{target.name}.url"] = target.location
|
39
36
|
end
|
40
37
|
end
|
data/lib/blazing/target.rb
CHANGED
@@ -13,16 +13,19 @@ class Blazing::Target
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def setup
|
16
|
+
logger.info "Setting up repository for #{name} in #{location}"
|
16
17
|
@shell.run "ssh #{user}@#{host} '#{init_repository} && #{setup_repository}'"
|
17
18
|
end
|
18
19
|
|
19
20
|
def apply_hook
|
21
|
+
logger.info "Generating and uploading post-receive hook for #{name}"
|
20
22
|
hook = ERB.new(File.read("#{Blazing::TEMPLATE_ROOT}/hook.erb")).result(binding)
|
21
23
|
|
22
24
|
File.open(Blazing::TMP_HOOK, "wb") do |f|
|
23
25
|
f.puts hook
|
24
26
|
end
|
25
27
|
|
28
|
+
logger.debug "Copying hook for #{name} to #{location}"
|
26
29
|
copy_hook
|
27
30
|
@shell.run "ssh #{user}@#{host} #{make_hook_executable}"
|
28
31
|
end
|
@@ -46,6 +49,7 @@ class Blazing::Target
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def copy_hook
|
52
|
+
logger.debug "Making hook executable"
|
49
53
|
@shell.run "scp #{Blazing::TMP_HOOK} #{user}@#{host}:#{path}/.git/hooks/post-receive"
|
50
54
|
end
|
51
55
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
echo "
|
3
|
+
echo "------"
|
4
|
+
echo "------ [blazing] ENTERING POST RECEIVE HOOK FOR: <%= name %>"
|
5
|
+
echo "------"
|
4
6
|
|
5
7
|
cd ..
|
6
8
|
GIT_DIR='.git'
|
@@ -8,6 +10,7 @@ GIT_DIR='.git'
|
|
8
10
|
while read oldrev newrev refname
|
9
11
|
do
|
10
12
|
# Reset so we dont have unstaged changes... and then checkout the pushed ref
|
13
|
+
echo "------> [blazing] Doing a hard reset and checking out $refname since thats what you pushed"
|
11
14
|
git reset --hard HEAD
|
12
15
|
git checkout $refname
|
13
16
|
done
|
data/lib/blazing/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blazing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-27 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
16
|
-
requirement: &
|
16
|
+
requirement: &70129527165280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70129527165280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70129527164400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.9.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70129527164400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70129527163660 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70129527163660
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard
|
49
|
-
requirement: &
|
49
|
+
requirement: &70129527162880 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70129527162880
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70129527162160 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70129527162160
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: growl
|
71
|
-
requirement: &
|
71
|
+
requirement: &70129527161380 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70129527161380
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rb-fsevent
|
82
|
-
requirement: &
|
82
|
+
requirement: &70129527160620 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70129527160620
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: grit
|
93
|
-
requirement: &
|
93
|
+
requirement: &70129527159680 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,21 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70129527159680
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: logging
|
104
|
+
requirement: &70129527158820 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70129527158820
|
102
113
|
- !ruby/object:Gem::Dependency
|
103
114
|
name: activesupport
|
104
|
-
requirement: &
|
115
|
+
requirement: &70129527158020 !ruby/object:Gem::Requirement
|
105
116
|
none: false
|
106
117
|
requirements:
|
107
118
|
- - ! '>='
|
@@ -109,10 +120,10 @@ dependencies:
|
|
109
120
|
version: '0'
|
110
121
|
type: :runtime
|
111
122
|
prerelease: false
|
112
|
-
version_requirements: *
|
123
|
+
version_requirements: *70129527158020
|
113
124
|
- !ruby/object:Gem::Dependency
|
114
125
|
name: i18n
|
115
|
-
requirement: &
|
126
|
+
requirement: &70129527157080 !ruby/object:Gem::Requirement
|
116
127
|
none: false
|
117
128
|
requirements:
|
118
129
|
- - ! '>='
|
@@ -120,7 +131,7 @@ dependencies:
|
|
120
131
|
version: '0'
|
121
132
|
type: :runtime
|
122
133
|
prerelease: false
|
123
|
-
version_requirements: *
|
134
|
+
version_requirements: *70129527157080
|
124
135
|
description: painless git push deployments for everyone
|
125
136
|
email:
|
126
137
|
- felipekaufmann@gmail.com
|
@@ -141,10 +152,9 @@ files:
|
|
141
152
|
- bin/blazing
|
142
153
|
- blazing.gemspec
|
143
154
|
- lib/blazing.rb
|
144
|
-
- lib/blazing/cli_logger.rb
|
145
|
-
- lib/blazing/cli_logging.rb
|
146
155
|
- lib/blazing/config.rb
|
147
156
|
- lib/blazing/dsl_setter.rb
|
157
|
+
- lib/blazing/logger.rb
|
148
158
|
- lib/blazing/recipe.rb
|
149
159
|
- lib/blazing/runner.rb
|
150
160
|
- lib/blazing/shell.rb
|
data/lib/blazing/cli_logger.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Borrowed from: https://raw.github.com/davetron5000/methadone/master/lib/methadone/cli_logging.rb
|
3
|
-
#
|
4
|
-
|
5
|
-
require 'logger'
|
6
|
-
|
7
|
-
module Blazing
|
8
|
-
# A Logger instance that gives better control of messaging the user
|
9
|
-
# and logging app activity. At it's most basic, you would use
|
10
|
-
# #info as a replacement for +puts+ and #error as a replacement
|
11
|
-
# for <tt>STDERR.puts</tt>. Since this is a logger, however, you
|
12
|
-
# can also use #debug, #warn, and #fatal, and you can control
|
13
|
-
# the format and "logging level" as such.
|
14
|
-
#
|
15
|
-
# So, by default:
|
16
|
-
# * #debug messages do not appear anywhere
|
17
|
-
# * #info messages appear on the standard output
|
18
|
-
# * #warn, #error, and #fata messagse appear on the standard error
|
19
|
-
# * The default format of messages is simply the message, no logging cruft
|
20
|
-
#
|
21
|
-
# You can customize this in several ways:
|
22
|
-
#
|
23
|
-
# * You can override the devices used by passing different devices to the constructor
|
24
|
-
# * You can adjust the level of message that goes to the error logger via error_level=
|
25
|
-
# * You can adjust the format for messages to the error logger separately via error_formatter=
|
26
|
-
#
|
27
|
-
# === Example
|
28
|
-
#
|
29
|
-
# logger = CLILogger.new
|
30
|
-
# logger.debug("Starting up") # => only the standard output gets this
|
31
|
-
# logger.warn("careful!") # => only the standard error gets this
|
32
|
-
# logger.error("Something went wrong!") # => only the standard error gets this
|
33
|
-
#
|
34
|
-
# logger = CLILogger.new
|
35
|
-
# logger.error_level = Logger::ERROR
|
36
|
-
# logger.debug("Starting up") # => only the standard output gets this
|
37
|
-
# logger.warn("careful!") # => only the standard OUTPUT gets this
|
38
|
-
# logger.error("Something went wrong!") # => only the standard error gets this
|
39
|
-
#
|
40
|
-
# logger = CLILogger.new('logfile.txt')
|
41
|
-
# logger.debug("Starting up") # => logfile.txt gets this
|
42
|
-
# logger.error("Something went wrong!") # => BOTH logfile.txt AND the standard error get this
|
43
|
-
class CLILogger < Logger
|
44
|
-
BLANK_FORMAT = proc { |severity,datetime,progname,msg|
|
45
|
-
msg + "\n"
|
46
|
-
}
|
47
|
-
|
48
|
-
# Helper to proxy methods to the super class AND to the internal error logger
|
49
|
-
#
|
50
|
-
# +symbol+:: Symbol for name of the method to proxy
|
51
|
-
def self.proxy_method(symbol) #:nodoc:
|
52
|
-
old_name = "old_#{symbol}".to_sym
|
53
|
-
alias_method old_name,symbol
|
54
|
-
define_method symbol do |*args,&block|
|
55
|
-
send(old_name,*args,&block)
|
56
|
-
@stderr_logger.send(symbol,*args,&block)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
proxy_method :'formatter='
|
61
|
-
proxy_method :'datetime_format='
|
62
|
-
|
63
|
-
def add(severity, message = nil, progname = nil, &block) #:nodoc:
|
64
|
-
if @split_logs
|
65
|
-
unless severity >= @stderr_logger.level
|
66
|
-
super(severity,message,progname,&block)
|
67
|
-
end
|
68
|
-
else
|
69
|
-
super(severity,message,progname,&block)
|
70
|
-
end
|
71
|
-
@stderr_logger.add(severity,message,progname,&block)
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
# A logger that logs error-type messages to a second device; useful
|
76
|
-
# for ensuring that error messages go to standard error. This should be
|
77
|
-
# pretty smart about doing the right thing. If both log devices are
|
78
|
-
# ttys, e.g. one is going to standard error and the other to the standard output,
|
79
|
-
# messages only appear once in the overall output stream. In other words,
|
80
|
-
# an ERROR logged will show up *only* in the standard error. If either
|
81
|
-
# log device is NOT a tty, then all messages go to +log_device+ and only
|
82
|
-
# errors go to +error_device+
|
83
|
-
#
|
84
|
-
# +log_device+:: device where all log messages should go, based on level
|
85
|
-
# +error_device+:: device where all error messages should go. By default, this is Logger::Severity::WARN
|
86
|
-
def initialize(log_device=$stdout,error_device=$stderr)
|
87
|
-
super(log_device)
|
88
|
-
@split_logs = log_device.tty? && error_device.tty?
|
89
|
-
self.level = Logger::Severity::INFO
|
90
|
-
@stderr_logger = Logger.new(error_device)
|
91
|
-
@stderr_logger.level = Logger::Severity::WARN
|
92
|
-
self.formatter = BLANK_FORMAT if log_device.tty?
|
93
|
-
@stderr_logger.formatter = BLANK_FORMAT if error_device.tty?
|
94
|
-
end
|
95
|
-
|
96
|
-
# Set the threshold for what messages go to the error device. Note that calling
|
97
|
-
# #level= will *not* affect the error logger
|
98
|
-
#
|
99
|
-
# +level+:: a constant from Logger::Severity for the level of messages that should go
|
100
|
-
# to the error logger
|
101
|
-
def error_level=(level)
|
102
|
-
@stderr_logger.level = level
|
103
|
-
end
|
104
|
-
|
105
|
-
# Overrides the formatter for the error logger. A future call to #formatter= will
|
106
|
-
# affect both, so the order of the calls matters.
|
107
|
-
#
|
108
|
-
# +formatter+:: Proc that handles the formatting, the same as for #formatter=
|
109
|
-
def error_formatter=(formatter)
|
110
|
-
@stderr_logger.formatter=formatter
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
end
|
data/lib/blazing/cli_logging.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Borrowed from: https://raw.github.com/davetron5000/methadone/master/lib/methadone/cli_logging.rb
|
3
|
-
#
|
4
|
-
|
5
|
-
require 'blazing/cli_logger'
|
6
|
-
|
7
|
-
module Blazing
|
8
|
-
# Provides easier access to a shared Methadone::CLILogger instance.
|
9
|
-
#
|
10
|
-
# Include this module into your class, and #logger provides access to a shared logger.
|
11
|
-
# This is handy if you want all of your clases to have access to the same logger, but
|
12
|
-
# don't want to (or aren't able to) pass it around to each class.
|
13
|
-
#
|
14
|
-
# This also provides methods for direct logging without going through the #logger
|
15
|
-
#
|
16
|
-
# === Example
|
17
|
-
#
|
18
|
-
# class MyClass
|
19
|
-
# include Methadone::CLILogger
|
20
|
-
#
|
21
|
-
# def doit
|
22
|
-
# debug("About to doit!")
|
23
|
-
# if results
|
24
|
-
# info("We did it!"
|
25
|
-
# else
|
26
|
-
# error("Something went wrong")
|
27
|
-
# end
|
28
|
-
# debug("Done doing it")
|
29
|
-
# end
|
30
|
-
# end
|
31
|
-
module CLILogging
|
32
|
-
# Access the shared logger. All classes that include this module
|
33
|
-
# will get the same logger via this method.
|
34
|
-
def logger
|
35
|
-
@@logger ||= Blazing::CLILogger.new
|
36
|
-
end
|
37
|
-
|
38
|
-
# Change the global logger that includers will use. Useful if you
|
39
|
-
# don't want the default configured logger.
|
40
|
-
#
|
41
|
-
# +new_logger+:: the new logger. May not be nil and should be a a logger of some kind
|
42
|
-
def logger=(new_logger)
|
43
|
-
raise ArgumentError,"Logger may not be nil" if new_logger.nil?
|
44
|
-
@@logger = new_logger
|
45
|
-
end
|
46
|
-
|
47
|
-
# pass-through to <tt>logger.debug(progname,&block)</tt>
|
48
|
-
def debug(progname = nil, &block); logger.debug(progname,&block); end
|
49
|
-
# pass-through to <tt>logger.info(progname,&block)</tt>
|
50
|
-
def info(progname = nil, &block); logger.info(progname,&block); end
|
51
|
-
# pass-through to <tt>logger.warn(progname,&block)</tt>
|
52
|
-
def warn(progname = nil, &block); logger.warn(progname,&block); end
|
53
|
-
# pass-through to <tt>logger.error(progname,&block)</tt>
|
54
|
-
def error(progname = nil, &block); logger.error(progname,&block); end
|
55
|
-
# pass-through to <tt>logger.fatal(progname,&block)</tt>
|
56
|
-
def fatal(progname = nil, &block); logger.fatal(progname,&block); end
|
57
|
-
end
|
58
|
-
end
|