blazing 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
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 'guard'
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blazing (0.0.4)
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.5)
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.3.0)
19
- open_gem (~> 1.4.2)
17
+ guard (0.4.0.rc)
20
18
  thor (~> 0.14.6)
21
- guard-rspec (0.2.0)
19
+ guard-rspec (0.3.0)
22
20
  guard (>= 0.2.2)
23
- i18n (0.5.0)
24
- launchy (0.3.7)
25
- configuration (>= 0.0.5)
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.4.0)
33
- rspec-core (~> 2.4.0)
34
- rspec-expectations (~> 2.4.0)
35
- rspec-mocks (~> 2.4.0)
36
- rspec-core (2.4.0)
37
- rspec-expectations (2.4.0)
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.4.0)
40
- ruby-debug-base19 (0.11.24)
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.4)
47
+ ruby_core_source (0.1.5)
49
48
  archive-tar-minitar (>= 0.5.2)
50
- simplecov (0.4.1)
51
- simplecov-html (~> 0.4.3)
52
- simplecov-html (0.4.3)
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
+ [![Build Status](http://travis-ci.org/effkay/blazing.png)](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.screencocnept.ch). After a short while I noticed
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
@@ -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
- LOGGER ||= Blazing::Logger.new
19
+
18
20
  end
@@ -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.invoke_all
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
- config = Blazing::Config.load
13
- target = config.find_target(target_name)
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 $?.exitstatus == 0
20
- LOGGER.success "successfully set up target #{target.name}"
32
+ if exit_status == 0
33
+ @logger.log :success, "successfully set up target #{target.name}"
21
34
  else
22
- LOGGER.error "failed setting up target #{target.name}"
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
- config = Blazing::Config.load
29
- target = config.find_target(target_name)
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 $?.exitstatus == 0
34
- LOGGER.success "successfully deployed target #{target.name}"
45
+ if exit_status == 0
46
+ @logger.log :success, "successfully deployed target #{target.name}"
35
47
  else
36
- LOGGER.error "failed deploying on target #{target.name}"
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
- puts recipe.name
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
@@ -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
- say "Blazing config file has been created in #{Blazing::CONFIGURATION_FILE} with a default remote."
20
- say "Check the config and then setup your remote with blazing setup REMOTE"
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
@@ -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
@@ -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 = {}, &target_definition)
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 = {}, &recipe_definition)
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
@@ -3,122 +3,29 @@ module Blazing
3
3
 
4
4
  LOG_LEVELS = [:info, :success, :warn, :error]
5
5
 
6
- def initialize(use_color = false)
7
- @use_color = use_color
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 puts(message, type)
15
- messages << Hash[:message => message, :type => type]
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
- LOG_LEVELS.each do |type|
19
- define_method type do |message|
20
- puts(message, type)
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
-