blazing 0.0.9 → 0.0.10

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 CHANGED
@@ -11,3 +11,4 @@ gem 'guard' , '0.4.0.rc'
11
11
  gem 'guard-rspec'
12
12
  gem 'growl'
13
13
  gem 'simplecov', '>= 0.4.0', :require => false, :group => :test, :platforms => :ruby_19
14
+ gem 'rb-fsevent'
@@ -1,18 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blazing (0.0.8)
4
+ blazing (0.0.10)
5
5
  activesupport (>= 3.0.5)
6
+ grit
6
7
  i18n
7
8
  thor (>= 0.14.6)
8
9
 
9
10
  GEM
10
11
  remote: http://rubygems.org/
11
12
  specs:
12
- activesupport (3.0.7)
13
+ activesupport (3.0.9)
13
14
  archive-tar-minitar (0.5.2)
14
15
  columnize (0.3.2)
15
16
  diff-lcs (1.1.2)
17
+ grit (2.4.1)
18
+ diff-lcs (~> 1.1)
19
+ mime-types (~> 1.15)
16
20
  growl (1.0.3)
17
21
  guard (0.4.0.rc)
18
22
  thor (~> 0.14.6)
@@ -22,7 +26,9 @@ GEM
22
26
  linecache (0.43)
23
27
  linecache19 (0.5.12)
24
28
  ruby_core_source (>= 0.1.4)
29
+ mime-types (1.16)
25
30
  rake (0.8.7)
31
+ rb-fsevent (0.4.0)
26
32
  rspec (2.5.0)
27
33
  rspec-core (~> 2.5.0)
28
34
  rspec-expectations (~> 2.5.0)
@@ -60,6 +66,7 @@ DEPENDENCIES
60
66
  guard (= 0.4.0.rc)
61
67
  guard-rspec
62
68
  rake (= 0.8.7)
69
+ rb-fsevent
63
70
  rspec
64
71
  ruby-debug
65
72
  ruby-debug19
data/README.md CHANGED
@@ -48,18 +48,22 @@ such systems.
48
48
 
49
49
  Examples:
50
50
 
51
- repository 'git@github.com:someones/repository.git'
51
+ ```ruby
52
+ repository 'git@github.com:someones/repository.git'
52
53
 
53
- use [:rvm, :bundler, :whenever]
54
+ use [:bundler, :whenever]
55
+ use :rvm, :rvm_string => 'ree@production'
54
56
 
55
- target :stagigng, :deploy_to => 'user@hostname:/path/to/target', :default => true
56
- target :production, :deploy_to => 'user@somehostname:/path/to/target'
57
-
58
- ...
57
+ target :stagigng, :deploy_to => 'user@hostname:/path/to/target', :default => true
58
+ target :production, :deploy_to => 'user@somehostname:/path/to/target'
59
+ ...
60
+ ```
59
61
 
60
62
  ## Deploying
61
63
 
62
- blazing deploy <target_name>
64
+ ```bash
65
+ blazing deploy <target_name>
66
+ ```
63
67
 
64
68
  Or, if everyting is already set up on the remote etc. you can acutally
65
69
  just do a git push to your target name.
@@ -80,13 +84,15 @@ create a topic branch for every separate change you intend to make.
80
84
 
81
85
  Example:
82
86
 
83
- class SomeFunkyRecipe < Blazing::Recipe
87
+ ```ruby
88
+ class SomeFunkyRecipe < Blazing::Recipe
84
89
 
85
- def self.run
86
- # do something
87
- end
90
+ def self.run
91
+ # do something
92
+ end
88
93
 
89
- end
94
+ end
95
+ ```
90
96
 
91
97
  ## Authors
92
98
 
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+ Bundler.setup
3
4
 
4
5
  require 'rspec/core/rake_task'
5
6
 
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ Bundler.setup
4
+
3
5
  require 'thor'
4
6
  require 'thor/group'
5
7
  require 'blazing'
@@ -22,4 +22,5 @@ Gem::Specification.new do |s|
22
22
  # TODO: Get rid of those, just used for guessing recipe names etc in lib/recipes.rb
23
23
  s.add_dependency "activesupport", ">= 3.0.5"
24
24
  s.add_dependency "i18n"
25
+ s.add_dependency "grit"
25
26
  end
@@ -1,18 +1,34 @@
1
+ require 'grit'
2
+
1
3
  module Blazing
2
4
  module Base
3
5
 
6
+ def config
7
+ @config ||= Blazing::Config.load
8
+ end
9
+
4
10
  def log(type, message)
5
11
  @logger ||= Blazing::Logger.new
6
12
  @logger.log(type, message)
7
13
  end
8
14
 
9
- def config
10
- @config ||= Blazing::Config.load
11
- end
12
-
13
15
  def report
14
16
  @logger.report
15
17
  end
16
18
 
19
+ #
20
+ # Helper that wraps exitstatus of cli stuff
21
+ #
22
+ def exit_status
23
+ @exit_status || $?.exitstatus
24
+ end
25
+
26
+ #
27
+ # Try to read the default remote
28
+ #
29
+ def repository_url
30
+ Grit::Repo.new(Dir.pwd).config['remote.origin.url'] || 'user@host:/some/path'
31
+ end
32
+
17
33
  end
18
34
  end
@@ -1,4 +1,5 @@
1
1
  require 'thor'
2
+ require 'grit'
2
3
  require 'blazing'
3
4
  require 'blazing/logger'
4
5
  require 'blazing/base'
@@ -13,7 +14,7 @@ module Blazing
13
14
 
14
15
  desc 'init', 'prepare project for blazing deploys'
15
16
  def init
16
- @task ||= Blazing::CLI::Create.new
17
+ @task ||= Blazing::CLI::Create.new([repository_url])
17
18
  @task.invoke_all
18
19
  end
19
20
 
@@ -53,8 +54,7 @@ module Blazing
53
54
  report
54
55
  end
55
56
 
56
- #TODO: move post_recevie and rvm somewhere else, they must only be called by the
57
- # post-receive hook and not visible to user
57
+ #TODO: move post_recevie and rvm somewhere else, they must only be called by the post-receive hook and not visible to user
58
58
 
59
59
  desc 'post_receive', 'trigger the post-receive actions'
60
60
  def post_receive(target_name = nil)
@@ -68,12 +68,6 @@ module Blazing
68
68
  log :info, Blazing::Remote.new(target.name).use_rvm?
69
69
  report
70
70
  end
71
-
72
- private
73
-
74
- def exit_status
75
- @exit_status || $?.exitstatus
76
- end
77
71
  end
78
72
  end
79
73
  end
@@ -8,6 +8,8 @@ module Blazing
8
8
 
9
9
  desc 'create a blazing config file'
10
10
 
11
+ argument :repository
12
+
11
13
  include Thor::Actions
12
14
  include Blazing::Base
13
15
 
@@ -25,7 +27,6 @@ module Blazing
25
27
  log :info, "Check the config and then setup your remote with blazing setup REMOTE"
26
28
  report
27
29
  end
28
-
29
30
  end
30
31
  end
31
32
  end
@@ -2,6 +2,6 @@
2
2
  # blazing config file -- generated on <%= Time.now %>
3
3
  #
4
4
 
5
- repository 'username@host:path/to/your/repository.git'
5
+ repository '<%= repository %>'
6
6
 
7
7
  target :default, :deploy_to => 'username@host:path/to/deploy'
@@ -12,14 +12,15 @@ module Blazing
12
12
  def read(&block)
13
13
  config = Blazing::Config.new
14
14
  config.instance_eval(&block)
15
- return config
15
+
16
+ config
16
17
  end
17
18
 
18
19
  #
19
20
  # Load configuration file and parse it
20
21
  #
21
22
  def load
22
- config = read do
23
+ read do
23
24
  instance_eval(File.read(Blazing::CONFIGURATION_FILE))
24
25
  end
25
26
  end
@@ -6,24 +6,29 @@ module Blazing
6
6
 
7
7
  attr_accessor :name, :recipes
8
8
 
9
- AVAILABLE_SETTINGS = [:deploy_to, :host, :user, :path, :default]
9
+ AVAILABLE_SETTINGS = [:deploy_to, :host, :user, :path, :default, :branch]
10
10
 
11
11
  def initialize(name, options = {})
12
12
  @name = name.to_s
13
13
  @logger = options[:_logger] ||= Blazing::Logger.new
14
14
  @runner = options[:_runner] ||= Blazing::Runner.new
15
15
  @hook = options[:_hook] ||= Blazing::CLI::Hook
16
- create_accesors(options)
16
+ create_accessors(options)
17
17
  end
18
18
 
19
19
  def setup
20
+ # TODO: Use a Wrapper to Net::SSH
21
+ #
20
22
  clone_repository
23
+ checkout_correct_branch if @branch
21
24
  add_target_as_remote
22
25
  setup_post_receive_hook
23
26
  end
24
27
 
25
28
  def deploy
26
- @runner.run "git push #{name}"
29
+ deploy_command = "git push #{name}"
30
+ deploy_command += " #{@branch}:#{@branch}" if @branch
31
+ @runner.run deploy_command
27
32
  end
28
33
 
29
34
  def config
@@ -31,7 +36,7 @@ module Blazing
31
36
  @_config.load
32
37
  end
33
38
 
34
- def create_accesors(options)
39
+ def create_accessors(options)
35
40
  assign_settings(options)
36
41
  parse_deploy_to_string unless @deploy_to.blank?
37
42
  ensure_mandatory_settings
@@ -64,6 +69,10 @@ module Blazing
64
69
  git clone #{config.repository} #{@path} && cd #{@path} && git config receive.denyCurrentBranch ignore; fi"
65
70
  end
66
71
 
72
+ def checkout_correct_branch
73
+ @runner.run "ssh #{@user}@#{@host} 'cd #{@path} && git checkout #{@branch}'" if @branch
74
+ end
75
+
67
76
  def clone_repository
68
77
  @runner.run "ssh #{@user}@#{@host} '#{clone_command}'"
69
78
  end
@@ -1,3 +1,3 @@
1
1
  module Blazing
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -6,7 +6,7 @@ describe Blazing::CLI::Create do
6
6
 
7
7
  before :each do
8
8
  @logger = double('logger', :log => nil, :report => nil)
9
- @config_generator = Blazing::CLI::Create.new
9
+ @config_generator = Blazing::CLI::Create.new(['repository_url'])
10
10
  @config_generator.instance_variable_set('@logger', @logger)
11
11
  end
12
12
 
@@ -66,25 +66,6 @@ describe Blazing::Target do
66
66
  end
67
67
  end
68
68
 
69
- describe '#config' do
70
- it 'delegates to Blazing::Config.load' do
71
- blazing_config = double
72
- target = Blazing::Target.new('somename', @options)
73
- target.instance_variable_set("@_config", blazing_config)
74
- blazing_config.should_receive(:load)
75
- target.config
76
- end
77
- end
78
-
79
-
80
- describe '#deploy' do
81
- it 'uses git push to deploy to the target' do
82
- target = Blazing::Target.new('somename', @options)
83
- @runner.should_receive(:run).with(/git push somename/)
84
- target.deploy
85
- end
86
- end
87
-
88
69
  describe '#setup' do
89
70
  before :each do
90
71
  blazing_config = double('config', :load => Blazing::Config.new)
@@ -106,5 +87,36 @@ describe Blazing::Target do
106
87
  @target.should_receive(:setup_post_receive_hook)
107
88
  @target.setup
108
89
  end
90
+
91
+ it 'checks out the correct branch if a branch is specified' do
92
+ @target.branch = 'test'
93
+ @target.should_receive(:checkout_correct_branch)
94
+ @target.setup
95
+ end
96
+ end
97
+
98
+ describe '#deploy' do
99
+ it 'uses git push to deploy to the target' do
100
+ target = Blazing::Target.new('somename', @options)
101
+ @runner.should_receive(:run).with(/git push somename/)
102
+ target.deploy
103
+ end
104
+
105
+ it 'pushes the correct branch when one is configured' do
106
+ target = Blazing::Target.new('somename', @options)
107
+ target.branch = 'somebranch'
108
+ @runner.should_receive(:run).with(/git push somename somebranch:somebranch/)
109
+ target.deploy
110
+ end
111
+ end
112
+
113
+ describe '#config' do
114
+ it 'delegates to Blazing::Config.load' do
115
+ blazing_config = double
116
+ target = Blazing::Target.new('somename', @options)
117
+ target.instance_variable_set("@_config", blazing_config)
118
+ blazing_config.should_receive(:load)
119
+ target.config
120
+ end
109
121
  end
110
122
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: blazing
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.9
5
+ version: 0.0.10
6
6
  platform: ruby
7
7
  authors:
8
8
  - Felipe Kaufmann
@@ -10,12 +10,10 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-09 00:00:00 +02:00
14
- default_executable:
13
+ date: 2011-07-15 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: thor
18
- prerelease: false
19
17
  requirement: &id001 !ruby/object:Gem::Requirement
20
18
  none: false
21
19
  requirements:
@@ -23,10 +21,10 @@ dependencies:
23
21
  - !ruby/object:Gem::Version
24
22
  version: 0.14.6
25
23
  type: :runtime
24
+ prerelease: false
26
25
  version_requirements: *id001
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: activesupport
29
- prerelease: false
30
28
  requirement: &id002 !ruby/object:Gem::Requirement
31
29
  none: false
32
30
  requirements:
@@ -34,10 +32,10 @@ dependencies:
34
32
  - !ruby/object:Gem::Version
35
33
  version: 3.0.5
36
34
  type: :runtime
35
+ prerelease: false
37
36
  version_requirements: *id002
38
37
  - !ruby/object:Gem::Dependency
39
38
  name: i18n
40
- prerelease: false
41
39
  requirement: &id003 !ruby/object:Gem::Requirement
42
40
  none: false
43
41
  requirements:
@@ -45,7 +43,19 @@ dependencies:
45
43
  - !ruby/object:Gem::Version
46
44
  version: "0"
47
45
  type: :runtime
46
+ prerelease: false
48
47
  version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: grit
50
+ requirement: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: *id004
49
59
  description: git push deployent utility, ready to be extended by your own recipes
50
60
  email:
51
61
  - felipekaufmann@gmail.com
@@ -100,7 +110,6 @@ files:
100
110
  - spec/blazing/target_spec.rb
101
111
  - spec/spec_helper.rb
102
112
  - spec/support/config.rb
103
- has_rdoc: true
104
113
  homepage: https://github.com/effkay/blazing
105
114
  licenses: []
106
115
 
@@ -114,17 +123,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
123
  requirements:
115
124
  - - ">="
116
125
  - !ruby/object:Gem::Version
126
+ hash: 1710367293229875195
127
+ segments:
128
+ - 0
117
129
  version: "0"
118
130
  required_rubygems_version: !ruby/object:Gem::Requirement
119
131
  none: false
120
132
  requirements:
121
133
  - - ">="
122
134
  - !ruby/object:Gem::Version
135
+ hash: 1710367293229875195
136
+ segments:
137
+ - 0
123
138
  version: "0"
124
139
  requirements: []
125
140
 
126
141
  rubyforge_project:
127
- rubygems_version: 1.6.2
142
+ rubygems_version: 1.7.2
128
143
  signing_key:
129
144
  specification_version: 3
130
145
  summary: blazing fast deployment