blazing 0.0.6 → 0.0.7
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/Gemfile +5 -3
- data/Gemfile.lock +27 -26
- data/README.md +3 -1
- data/Rakefile +3 -0
- data/lib/blazing.rb +3 -1
- data/lib/blazing/cli/base.rb +32 -14
- data/lib/blazing/cli/create.rb +11 -2
- data/lib/blazing/cli/hook.rb +7 -5
- data/lib/blazing/config.rb +7 -7
- data/lib/blazing/logger.rb +13 -106
- data/lib/blazing/recipe.rb +4 -11
- data/lib/blazing/recipes/bundler_recipe.rb +2 -0
- data/lib/blazing/recipes/rvm_recipe.rb +2 -0
- data/lib/blazing/remote.rb +50 -45
- data/lib/blazing/runner.rb +5 -0
- data/lib/blazing/target.rb +55 -23
- data/lib/blazing/version.rb +1 -1
- data/spec/blazing/cli/base_spec.rb +102 -0
- data/spec/blazing/cli/create_spec.rb +26 -0
- data/spec/blazing/cli/hook_spec.rb +16 -0
- data/spec/blazing/config_spec.rb +82 -0
- data/spec/blazing/logger_spec.rb +50 -0
- data/spec/blazing/recipe_spec.rb +13 -8
- data/spec/blazing/recipes/bundler_recipe_spec.rb +6 -0
- data/spec/blazing/recipes/passenger_recipe_spec.rb +6 -0
- data/spec/blazing/recipes/rvm_recipe_spec.rb +6 -0
- data/spec/blazing/remote_spec.rb +126 -3
- data/spec/blazing/runner_spec.rb +9 -0
- data/spec/blazing/target_spec.rb +110 -0
- data/spec/spec_helper.rb +7 -3
- data/spec/support/config.rb +0 -0
- metadata +25 -3
- data/index.html +0 -111
data/Gemfile
CHANGED
@@ -3,9 +3,11 @@ source "http://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in blazing.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
+
gem 'rake', '0.8.7'
|
6
7
|
gem 'rspec'
|
7
|
-
gem 'ruby-debug19'
|
8
|
-
gem '
|
8
|
+
gem 'ruby-debug19', :platforms => :ruby_19
|
9
|
+
gem 'ruby-debug', :platforms => :ruby_18
|
10
|
+
gem 'guard' , '0.4.0.rc'
|
9
11
|
gem 'guard-rspec'
|
10
12
|
gem 'growl'
|
11
|
-
gem 'simplecov', '>= 0.4.0', :require => false, :group => :test
|
13
|
+
gem 'simplecov', '>= 0.4.0', :require => false, :group => :test, :platforms => :ruby_19
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
blazing (0.0.
|
4
|
+
blazing (0.0.6)
|
5
5
|
activesupport (>= 3.0.5)
|
6
6
|
i18n
|
7
7
|
thor (>= 0.14.6)
|
@@ -9,35 +9,34 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (3.0.
|
12
|
+
activesupport (3.0.7)
|
13
13
|
archive-tar-minitar (0.5.2)
|
14
14
|
columnize (0.3.2)
|
15
|
-
configuration (1.2.0)
|
16
15
|
diff-lcs (1.1.2)
|
17
16
|
growl (1.0.3)
|
18
|
-
guard (0.
|
19
|
-
open_gem (~> 1.4.2)
|
17
|
+
guard (0.4.0.rc)
|
20
18
|
thor (~> 0.14.6)
|
21
|
-
guard-rspec (0.
|
19
|
+
guard-rspec (0.3.0)
|
22
20
|
guard (>= 0.2.2)
|
23
|
-
i18n (0.
|
24
|
-
|
25
|
-
|
26
|
-
rake (>= 0.8.1)
|
27
|
-
linecache19 (0.5.11)
|
21
|
+
i18n (0.6.0)
|
22
|
+
linecache (0.43)
|
23
|
+
linecache19 (0.5.12)
|
28
24
|
ruby_core_source (>= 0.1.4)
|
29
|
-
open_gem (1.4.2)
|
30
|
-
launchy (~> 0.3.5)
|
31
25
|
rake (0.8.7)
|
32
|
-
rspec (2.
|
33
|
-
rspec-core (~> 2.
|
34
|
-
rspec-expectations (~> 2.
|
35
|
-
rspec-mocks (~> 2.
|
36
|
-
rspec-core (2.
|
37
|
-
rspec-expectations (2.
|
26
|
+
rspec (2.5.0)
|
27
|
+
rspec-core (~> 2.5.0)
|
28
|
+
rspec-expectations (~> 2.5.0)
|
29
|
+
rspec-mocks (~> 2.5.0)
|
30
|
+
rspec-core (2.5.1)
|
31
|
+
rspec-expectations (2.5.0)
|
38
32
|
diff-lcs (~> 1.1.2)
|
39
|
-
rspec-mocks (2.
|
40
|
-
ruby-debug
|
33
|
+
rspec-mocks (2.5.0)
|
34
|
+
ruby-debug (0.10.4)
|
35
|
+
columnize (>= 0.1)
|
36
|
+
ruby-debug-base (~> 0.10.4.0)
|
37
|
+
ruby-debug-base (0.10.4)
|
38
|
+
linecache (>= 0.3)
|
39
|
+
ruby-debug-base19 (0.11.25)
|
41
40
|
columnize (>= 0.3.1)
|
42
41
|
linecache19 (>= 0.5.11)
|
43
42
|
ruby_core_source (>= 0.1.4)
|
@@ -45,11 +44,11 @@ GEM
|
|
45
44
|
columnize (>= 0.3.1)
|
46
45
|
linecache19 (>= 0.5.11)
|
47
46
|
ruby-debug-base19 (>= 0.11.19)
|
48
|
-
ruby_core_source (0.1.
|
47
|
+
ruby_core_source (0.1.5)
|
49
48
|
archive-tar-minitar (>= 0.5.2)
|
50
|
-
simplecov (0.4.
|
51
|
-
simplecov-html (~> 0.4.
|
52
|
-
simplecov-html (0.4.
|
49
|
+
simplecov (0.4.2)
|
50
|
+
simplecov-html (~> 0.4.4)
|
51
|
+
simplecov-html (0.4.4)
|
53
52
|
thor (0.14.6)
|
54
53
|
|
55
54
|
PLATFORMS
|
@@ -58,8 +57,10 @@ PLATFORMS
|
|
58
57
|
DEPENDENCIES
|
59
58
|
blazing!
|
60
59
|
growl
|
61
|
-
guard
|
60
|
+
guard (= 0.4.0.rc)
|
62
61
|
guard-rspec
|
62
|
+
rake (= 0.8.7)
|
63
63
|
rspec
|
64
|
+
ruby-debug
|
64
65
|
ruby-debug19
|
65
66
|
simplecov (>= 0.4.0)
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Blazing -- Fast and painless git push deploys
|
2
2
|
=============================================
|
3
3
|
|
4
|
+
[](http://travis-ci.org/effkay/blazing) (but still in alpha!)
|
5
|
+
|
4
6
|
## What
|
5
7
|
|
6
8
|
Blazing aims to be a fast and hassle free way to deploy web
|
@@ -21,7 +23,7 @@ Some design goals:
|
|
21
23
|
|
22
24
|
I initially started working on an extension to capistrano which would
|
23
25
|
cover most of my needs and the needs we had at [Screen
|
24
|
-
Concept](http://www.
|
26
|
+
Concept](http://www.screenconcept.ch). After a short while I noticed
|
25
27
|
that bolting more functionality on top of capistrano was just going to
|
26
28
|
be messy (and a PTA to maintain). We were alerady using tons of own recipes and customizations,
|
27
29
|
capistrano multistage, capistrano-ext, etc.
|
data/Rakefile
CHANGED
@@ -2,9 +2,12 @@ require 'bundler'
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
+
|
5
6
|
desc "Run specs"
|
6
7
|
RSpec::Core::RakeTask.new do |t|
|
7
8
|
# t.rspec_opts = %w(--colour --fail-fast --format nested)
|
8
9
|
t.rspec_opts = %w(--colour --format nested)
|
9
10
|
t.ruby_opts = %w(-w)
|
10
11
|
end
|
12
|
+
|
13
|
+
task :default => :spec
|
data/lib/blazing.rb
CHANGED
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
require 'thor/group'
|
3
3
|
require 'blazing'
|
4
4
|
require 'blazing/config'
|
5
|
+
require 'blazing/runner'
|
5
6
|
require 'blazing/logger'
|
6
7
|
require 'blazing/target'
|
7
8
|
require 'blazing/remote'
|
@@ -12,7 +13,8 @@ require 'blazing/cli/create'
|
|
12
13
|
require 'blazing/cli/hook'
|
13
14
|
|
14
15
|
module Blazing
|
16
|
+
|
15
17
|
DIRECTORY = 'config'
|
16
18
|
CONFIGURATION_FILE = 'config/blazing.rb'
|
17
|
-
|
19
|
+
|
18
20
|
end
|
data/lib/blazing/cli/base.rb
CHANGED
@@ -1,49 +1,67 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'blazing'
|
3
|
+
require 'blazing/logger'
|
4
|
+
require 'blazing/recipe'
|
5
|
+
|
6
|
+
require 'blazing/cli/create'
|
7
|
+
|
1
8
|
module Blazing
|
2
9
|
module CLI
|
3
10
|
class Base < Thor
|
4
11
|
|
12
|
+
def initialize(logger = Blazing::Logger.new)
|
13
|
+
@logger = logger
|
14
|
+
@config = Blazing::Config.load
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
5
18
|
desc 'init', 'prepare project for blazing deploys'
|
6
19
|
def init
|
7
|
-
Blazing::CLI::Create.new
|
20
|
+
@task ||= Blazing::CLI::Create.new
|
21
|
+
@task.invoke_all
|
8
22
|
end
|
9
23
|
|
10
24
|
desc 'setup TARGET_NAME', 'setup or update blazing on specified target and deploy'
|
11
25
|
def setup(target_name = nil)
|
12
|
-
|
13
|
-
target
|
14
|
-
LOGGER.info "setting up target #{target.name}"
|
26
|
+
target = @config.find_target(target_name)
|
27
|
+
@logger.log :info, "setting up target #{target.name}"
|
15
28
|
target.setup
|
16
29
|
|
17
30
|
# TODO: Abstract this into module and load it where we need it. Methods / actions should have
|
18
31
|
# a success and failure message
|
19
|
-
if
|
20
|
-
|
32
|
+
if exit_status == 0
|
33
|
+
@logger.log :success, "successfully set up target #{target.name}"
|
21
34
|
else
|
22
|
-
|
35
|
+
@logger.log :error, "failed setting up target #{target.name}"
|
23
36
|
end
|
24
37
|
end
|
25
38
|
|
26
39
|
desc 'deploy TARGET', 'deploy to TARGET'
|
27
40
|
def deploy(target_name = nil)
|
28
|
-
|
29
|
-
target
|
30
|
-
LOGGER.info "deploying target #{target.name}"
|
41
|
+
target = @config.find_target(target_name)
|
42
|
+
@logger.log :info, "deploying target #{target.name}"
|
31
43
|
target.deploy
|
32
44
|
|
33
|
-
if
|
34
|
-
|
45
|
+
if exit_status == 0
|
46
|
+
@logger.log :success, "successfully deployed target #{target.name}"
|
35
47
|
else
|
36
|
-
|
48
|
+
@logger.log :error, "failed deploying on target #{target.name}"
|
37
49
|
end
|
38
50
|
end
|
39
51
|
|
40
52
|
desc 'recipes', 'List available recipes'
|
41
53
|
def recipes
|
42
54
|
Blazing::Recipe.list.each do |recipe|
|
43
|
-
|
55
|
+
@logger.log :success, recipe.name
|
44
56
|
end
|
57
|
+
@logger.report
|
45
58
|
end
|
46
59
|
|
60
|
+
private
|
61
|
+
|
62
|
+
def exit_status
|
63
|
+
@exit_status || $?.exitstatus
|
64
|
+
end
|
47
65
|
end
|
48
66
|
end
|
49
67
|
end
|
data/lib/blazing/cli/create.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/group'
|
3
|
+
|
1
4
|
module Blazing
|
2
5
|
module CLI
|
3
6
|
class Create < Thor::Group
|
@@ -6,6 +9,11 @@ module Blazing
|
|
6
9
|
|
7
10
|
include Thor::Actions
|
8
11
|
|
12
|
+
def initialize(logger = Blazing::Logger.new)
|
13
|
+
@logger = logger
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
9
17
|
def self.source_root
|
10
18
|
File.dirname(__FILE__)
|
11
19
|
end
|
@@ -16,8 +24,9 @@ module Blazing
|
|
16
24
|
|
17
25
|
def create_config_file
|
18
26
|
template 'templates/blazing.tt', Blazing::CONFIGURATION_FILE
|
19
|
-
|
20
|
-
|
27
|
+
@logger.log :info, "Blazing config file has been created in #{Blazing::CONFIGURATION_FILE} with a default remote."
|
28
|
+
@logger.log :info, "Check the config and then setup your remote with blazing setup REMOTE"
|
29
|
+
@logger.report
|
21
30
|
end
|
22
31
|
|
23
32
|
end
|
data/lib/blazing/cli/hook.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
1
3
|
module Blazing
|
2
4
|
module CLI
|
3
5
|
class Hook < Thor
|
4
6
|
|
5
7
|
include Thor::Actions
|
6
8
|
|
7
|
-
def self.source_root
|
8
|
-
File.dirname(__FILE__)
|
9
|
-
end
|
10
|
-
|
11
9
|
argument :target
|
12
10
|
|
13
11
|
desc 'generate', 'generate post-receive hook from template'
|
14
12
|
def generate
|
15
13
|
template('templates/post-hook.tt', '/tmp/post-receive')
|
16
14
|
end
|
17
|
-
|
15
|
+
|
16
|
+
def self.source_root
|
17
|
+
File.dirname(__FILE__)
|
18
|
+
end
|
19
|
+
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/blazing/config.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
require 'blazing'
|
2
|
+
require 'blazing/target'
|
3
|
+
|
1
4
|
module Blazing
|
2
5
|
class Config
|
3
6
|
|
4
7
|
class << self
|
5
|
-
|
8
|
+
|
6
9
|
#
|
7
10
|
# Read the Configuration File
|
8
11
|
#
|
@@ -16,7 +19,6 @@ module Blazing
|
|
16
19
|
# Load configuration file and parse it
|
17
20
|
#
|
18
21
|
def load
|
19
|
-
# TODO: shorten with something like this: new.instance_eval(File.read(guardfile_path), guardfile_path, 1)
|
20
22
|
config = read do
|
21
23
|
instance_eval(File.read(Blazing::CONFIGURATION_FILE))
|
22
24
|
end
|
@@ -49,13 +51,11 @@ module Blazing
|
|
49
51
|
@recipes = []
|
50
52
|
end
|
51
53
|
|
52
|
-
def target(name, options = {}
|
53
|
-
# TODO: implement if needed: target_definition.call if target_definition
|
54
|
+
def target(name, options = {})
|
54
55
|
@targets << Blazing::Target.new(name, options)
|
55
56
|
end
|
56
57
|
|
57
|
-
def use(name, options = {}
|
58
|
-
#TODO: implement if needed: recipe_definition.call if recipe_definition
|
58
|
+
def use(name, options = {})
|
59
59
|
@recipes << Blazing::Recipe.new(name, options)
|
60
60
|
end
|
61
61
|
|
@@ -63,7 +63,7 @@ module Blazing
|
|
63
63
|
# Determines which target is picked, based on defaults and CLI argument
|
64
64
|
# If only one target is defined, it is the default one
|
65
65
|
#
|
66
|
-
def find_target(target_name)
|
66
|
+
def find_target(target_name = nil)
|
67
67
|
if target_name
|
68
68
|
target = targets.find {|target| target.name == target_name }
|
69
69
|
end
|
data/lib/blazing/logger.rb
CHANGED
@@ -3,122 +3,29 @@ module Blazing
|
|
3
3
|
|
4
4
|
LOG_LEVELS = [:info, :success, :warn, :error]
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(output = $stdout)
|
7
|
+
@output = output
|
8
8
|
end
|
9
9
|
|
10
10
|
def messages
|
11
11
|
@messages ||= []
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
14
|
+
def log(type, message)
|
15
|
+
if LOG_LEVELS.include? type
|
16
|
+
messages << Hash[:message => message, :type => type]
|
17
|
+
else
|
18
|
+
raise
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
puts
|
22
|
+
def report(type = nil)
|
23
|
+
if type
|
24
|
+
messages.select { |m| m[:type] == type }.each { |m| @output.puts m[:message] }
|
25
|
+
else
|
26
|
+
messages.each { |m| @output.puts m[:message] }
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
24
|
-
# def prefix
|
25
|
-
# '[BLAZING] *** '
|
26
|
-
# end
|
27
|
-
|
28
|
-
# def postfix
|
29
|
-
# ' ***'
|
30
|
-
# end
|
31
|
-
|
32
|
-
# def message(message, type)
|
33
|
-
# case type
|
34
|
-
# when :info
|
35
|
-
# puts prefix + message.blue + postfix
|
36
|
-
# when :success
|
37
|
-
# puts prefix + message.green + postfix
|
38
|
-
# when :warn
|
39
|
-
# puts prefix + message.yellow + postfix
|
40
|
-
# when :error
|
41
|
-
# puts prefix + message.red + postfix
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
|
45
30
|
end
|
46
31
|
end
|
47
|
-
|
48
|
-
class String
|
49
|
-
|
50
|
-
# 00 Turn off all attributes
|
51
|
-
# 01 Set bright mode
|
52
|
-
# 04 Set underline mode
|
53
|
-
# 05 Set blink mode
|
54
|
-
# 07 Exchange foreground and background colors
|
55
|
-
# 08 Hide text (foreground color would be the same as background)
|
56
|
-
# 30 Black text
|
57
|
-
# 31 Red text
|
58
|
-
# 32 Green text
|
59
|
-
# 33 Yellow text
|
60
|
-
# 34 Blue text
|
61
|
-
# 35 Magenta text
|
62
|
-
# 36 Cyan text
|
63
|
-
# 37 White text
|
64
|
-
# 39 Default text color
|
65
|
-
# 40 Black background
|
66
|
-
# 41 Red background
|
67
|
-
# 42 Green background
|
68
|
-
# 43 Yellow background
|
69
|
-
# 44 Blue background
|
70
|
-
# 45 Magenta background
|
71
|
-
# 46 Cyan background
|
72
|
-
# 47 White background
|
73
|
-
# 49 Default background col
|
74
|
-
|
75
|
-
def black
|
76
|
-
string = "\033[30m"
|
77
|
-
string << self
|
78
|
-
string << "\033[0m"
|
79
|
-
end
|
80
|
-
|
81
|
-
def red
|
82
|
-
string = "\033[31m"
|
83
|
-
string << self
|
84
|
-
string << "\033[0m"
|
85
|
-
end
|
86
|
-
|
87
|
-
def green
|
88
|
-
string = "\033[32m"
|
89
|
-
string << self
|
90
|
-
string << "\033[0m"
|
91
|
-
end
|
92
|
-
|
93
|
-
def yellow
|
94
|
-
string = "\033[33m"
|
95
|
-
string << self
|
96
|
-
string << "\033[0m"
|
97
|
-
end
|
98
|
-
|
99
|
-
def blue
|
100
|
-
string = "\033[34m"
|
101
|
-
string << self
|
102
|
-
string << "\033[0m"
|
103
|
-
end
|
104
|
-
|
105
|
-
def purple
|
106
|
-
string = "\033[35m"
|
107
|
-
string << self
|
108
|
-
string << "\033[0m"
|
109
|
-
end
|
110
|
-
|
111
|
-
def cyan
|
112
|
-
string = "\033[36m"
|
113
|
-
string << self
|
114
|
-
string << "\033[0m"
|
115
|
-
end
|
116
|
-
|
117
|
-
def white
|
118
|
-
string = "\033[37m"
|
119
|
-
string << self
|
120
|
-
string << "\033[0m"
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|