blazing 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  *.DS_Store
6
6
  tags
7
7
  .idea
8
+ coverage
data/.rvmrc ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2-p180@blazing"
8
+
9
+ #
10
+ # First we attempt to load the desired environment directly from the environment
11
+ # file. This is very fast and efficicent compared to running through the entire
12
+ # CLI and selector. If you want feedback on which environment was used then
13
+ # insert the word 'use' after --create as this triggers verbose mode.
14
+ #
15
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
16
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
17
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
18
+
19
+ [[ -s ".rvm/hooks/after_use" ]] && . ".rvm/hooks/after_use"
20
+ else
21
+ # If the environment file has not yet been created, use the RVM CLI to select.
22
+ rvm --create "$environment_id"
23
+ fi
24
+
25
+ #
26
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
27
+ # it be automatically loaded. Uncomment the following and adjust the filename if
28
+ # necessary.
29
+ #
30
+ # filename=".gems"
31
+ # if [[ -s "$filename" ]] ; then
32
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
33
+ # fi
34
+
35
+ #
36
+ # If you use bundler and would like to run bundle each time you enter the
37
+ # directory, you can uncomment the following code.
38
+ #
39
+ # # Ensure that Bundler is installed. Install it if it is not.
40
+ # if ! command -v bundle >/dev/null; then
41
+ # printf "The rubygem 'bundler' is not installed. Installing it now.\n"
42
+ # gem install bundler
43
+ # fi
44
+ #
45
+ # # Bundle while reducing excess noise.
46
+ # printf "Bundling your gems. This may take a few minutes on a fresh clone.\n"
47
+ # bundle | grep -v '^Using ' | grep -v ' is complete' | sed '/^$/d'
48
+ #
49
+
data/Gemfile CHANGED
@@ -5,3 +5,7 @@ gemspec
5
5
 
6
6
  gem 'rspec'
7
7
  gem 'ruby-debug19'
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'growl'
11
+ gem 'simplecov', '>= 0.4.0', :require => false, :group => :test
@@ -1,17 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blazing (0.0.1)
4
+ blazing (0.0.4)
5
+ activesupport (>= 3.0.5)
6
+ i18n
5
7
  thor (>= 0.14.6)
6
8
 
7
9
  GEM
8
10
  remote: http://rubygems.org/
9
11
  specs:
12
+ activesupport (3.0.5)
10
13
  archive-tar-minitar (0.5.2)
11
14
  columnize (0.3.2)
15
+ configuration (1.2.0)
12
16
  diff-lcs (1.1.2)
17
+ growl (1.0.3)
18
+ guard (0.3.0)
19
+ open_gem (~> 1.4.2)
20
+ thor (~> 0.14.6)
21
+ guard-rspec (0.2.0)
22
+ guard (>= 0.2.2)
23
+ i18n (0.5.0)
24
+ launchy (0.3.7)
25
+ configuration (>= 0.0.5)
26
+ rake (>= 0.8.1)
13
27
  linecache19 (0.5.11)
14
28
  ruby_core_source (>= 0.1.4)
29
+ open_gem (1.4.2)
30
+ launchy (~> 0.3.5)
31
+ rake (0.8.7)
15
32
  rspec (2.4.0)
16
33
  rspec-core (~> 2.4.0)
17
34
  rspec-expectations (~> 2.4.0)
@@ -30,6 +47,9 @@ GEM
30
47
  ruby-debug-base19 (>= 0.11.19)
31
48
  ruby_core_source (0.1.4)
32
49
  archive-tar-minitar (>= 0.5.2)
50
+ simplecov (0.4.1)
51
+ simplecov-html (~> 0.4.3)
52
+ simplecov-html (0.4.3)
33
53
  thor (0.14.6)
34
54
 
35
55
  PLATFORMS
@@ -37,6 +57,9 @@ PLATFORMS
37
57
 
38
58
  DEPENDENCIES
39
59
  blazing!
60
+ growl
61
+ guard
62
+ guard-rspec
40
63
  rspec
41
64
  ruby-debug19
42
- thor (>= 0.14.6)
65
+ simplecov (>= 0.4.0)
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2, :cli => "--colour --fail-fast --format nested" do
5
+ watch(%r{^spec/.+_spec\.rb})
6
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch(%r{^lib/blazing/(.+)\.rb}) { |m| "spec/blazing/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { "spec" }
9
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Felipe Kaufmann
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.md CHANGED
@@ -1,65 +1,114 @@
1
- Yet another deployment utility
2
- ==============================
1
+ Blazing -- Fast and painless git push deploys
2
+ =============================================
3
3
 
4
- **WARNING: This gem is in early development. Use at your own risk.**
4
+ ## What
5
5
 
6
- But why? Well, Capistrano was bloated for our use-cases, to much stuff bolted on. Inploy looked really interesting, but does not have multistage support from what I could tell. So I did what any reasonable developer would do and befell to the "Not Invented here syndrome".
6
+ Blazing aims to be a fast and hassle free way to deploy web
7
+ applications. It may work for other frameworks, but it is mainly
8
+ designed to deploy Ruby on Rails and Rack based applications, as well as
9
+ static sites.
7
10
 
8
- Top Design goals, ideas:
9
- ------------------------
10
-
11
- * deploy is just a push to another remote. all that must be done is triggered by pre and post receveie git hooks.
12
- * initial setup done by ruby script
13
- * extensible recipe system, so you can plug in and out what you need and easily roll your own recipes
11
+ Some design goals:
14
12
 
15
- Usage
16
- =====
13
+ * A deploy is just a git push to another remote. All that must be done afterwards is triggered by pre and post receveie git hooks.
14
+ * initial setup done by ruby script, so unexerpienced users do not
15
+ have to fiddle with the git config files
16
+ * clean API for writing your own recipes, no messy rake file jungles
17
+ * DRY, clean and minimal configuration file
18
+ * blazing fast!
17
19
 
18
- Setup a project with
20
+ ## Why
19
21
 
20
- blazing init
22
+ I initially started working on an extension to capistrano which would
23
+ cover most of my needs and the needs we had at [Screen
24
+ Concept](http://www.screencocnept.ch). After a short while I noticed
25
+ that bolting more functionality on top of capistrano was just going to
26
+ be messy (and a PTA to maintain). We were alerady using tons of own recipes and customizations,
27
+ capistrano multistage, capistrano-ext, etc.
21
28
 
22
- Then edit your config/blazing.rb file.
29
+ I had a look at what others were doing and after a round of trying
30
+ around and not getting what I wanted, I started this.
23
31
 
24
- If you are ready to do your first deploy, run
32
+ ### Inspiration & Alternatives
25
33
 
26
- blazing setup <target_name>
34
+ I looked at [Inploy](https://github.com/dcrec1/inploy) and [Vlad](https://github.com/seattlerb/vlad) after having used [Capistrano](https://github.com/capistrano/capistrano) for several
35
+ years. Then got inspired by defunkt's
36
+ [blog post](https://github.com/blog/470-deployment-script-spring-cleaning) about deployment script spring cleaning. Other's doing a similar thing with git push deployments are Mislav's [git-deploy](https://github.com/mislav/git-deploy) and [pushand](https://github.com/remi/pushand.git) by remi.
27
37
 
28
- Afterwards you can just deploy with
38
+ ## Installation & Setup
29
39
 
30
- blazing deploy <target_name>
40
+ Run `blazing init` in your project's root, this will create the necessary files to use and configure blazing.
31
41
 
32
- Or just use
42
+ ## Configuration & Blazing DSL
33
43
 
34
- git push <target_name>
44
+ The blazing config file features a DSL similar to capistrano or other
45
+ such systems.
35
46
 
36
- which does basically the same
47
+ Examples:
37
48
 
38
- Roadmap
39
- =======
49
+ repository 'git@github.com:someones/repository.git'
40
50
 
41
- You have guessed it, and the version number does not lie. This is all in early development. So here's my little roadmap, aka the backlog:
51
+ use [:rvm, :bundler, :whenever]
42
52
 
43
- * recipe extension system
44
- * disable colored log output
45
- * cleanup logging
46
- * sync fs recipes
47
- * sync db recipes for
48
- * mysql
49
- * postgres
50
- * mongodb
51
- * redis
53
+ target :stagigng, :deploy_to => 'user@hostname:/path/to/target', :default => true
54
+ target :production, :deploy_to => 'user@somehostname:/path/to/target'
52
55
 
53
- * hoptoad notifier
54
- * maintenance page recipe
55
- * rollback recipe/feature
56
- * rvm recipe
57
- * bundler recipe
58
- * whenever recipe
59
- * coffescript recipe
60
- * sass recipe
61
- * passenger recipe
62
- * unicorn recipe
63
- * apache recipe
64
- * nginx recipe
65
- * nanoc deploy
56
+ ...
57
+
58
+ ## Deploying
59
+
60
+ blazing deploy <target_name>
61
+
62
+ Or, if everyting is already set up on the remote etc. you can acutally
63
+ just do a git push to your target name.
64
+
65
+ ## Development
66
+
67
+ Report Issues/Questions/Feature requests on [GitHub
68
+ Issues](http://github.com/effkay/blazing/issues)
69
+
70
+ ### Extending / Fixing Blazing itself
71
+
72
+ Pull requests are very welcome as long as they are well tested. Please
73
+ create a topic branch for every separate change you intend to make.
74
+
75
+ ### Developing Blazing Extensions
76
+
77
+ **(Still work in progress and not a stable API yet)**
78
+
79
+ Example:
80
+
81
+ class SomeFunkyRecipe < Blazing::Recipe
82
+
83
+ def self.run
84
+ # do something
85
+ end
86
+
87
+ end
88
+
89
+ ## Authors
90
+
91
+ [Felipe Kaufmann](http://github.com/effkay)
92
+
93
+ ## License
94
+
95
+ Copyright (c) 2011 Felipe Kaufmann
96
+
97
+ Permission is hereby granted, free of charge, to any person obtaining
98
+ a copy of this software and associated documentation files (the
99
+ "Software"), to deal in the Software without restriction, including
100
+ without limitation the rights to use, copy, modify, merge, publish,
101
+ distribute, sublicense, and/or sell copies of the Software, and to
102
+ permit persons to whom the Software is furnished to do so, subject to
103
+ the following conditions:
104
+
105
+ The above copyright notice and this permission notice shall be
106
+ included in all copies or substantial portions of the Software.
107
+
108
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
109
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
110
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
111
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
112
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
113
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
114
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new do |t|
7
+ # t.rspec_opts = %w(--colour --fail-fast --format nested)
8
+ t.rspec_opts = %w(--colour --format nested)
9
+ t.ruby_opts = %w(-w)
10
+ end
@@ -18,4 +18,8 @@ Gem::Specification.new do |s|
18
18
 
19
19
  # TODO: better to use ~ ?
20
20
  s.add_dependency "thor", ">= 0.14.6"
21
+
22
+ # TODO: Get rid of those, just used for guessing recipe names etc in lib/recipes.rb
23
+ s.add_dependency "activesupport", ">= 3.0.5"
24
+ s.add_dependency "i18n"
21
25
  end
@@ -0,0 +1,111 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+
6
+ <title>effkay/blazing @ GitHub</title>
7
+
8
+ <style type="text/css">
9
+ body {
10
+ margin-top: 1.0em;
11
+ background-color: #e7600d;
12
+ font-family: Helvetica, Arial, FreeSans, san-serif;
13
+ color: #ffffff;
14
+ }
15
+ #container {
16
+ margin: 0 auto;
17
+ width: 700px;
18
+ }
19
+ h1 { font-size: 3.8em; color: #189ff2; margin-bottom: 3px; }
20
+ h1 .small { font-size: 0.4em; }
21
+ h1 a { text-decoration: none }
22
+ h2 { font-size: 1.5em; color: #189ff2; }
23
+ h3 { text-align: center; color: #189ff2; }
24
+ a { color: #189ff2; }
25
+ .description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
26
+ .download { float: right; }
27
+ pre { background: #000; color: #fff; padding: 15px;}
28
+ hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
29
+ .footer { text-align:center; padding-top:30px; font-style: italic; }
30
+ </style>
31
+ </head>
32
+
33
+ <body>
34
+ <a href="http://github.com/effkay/blazing"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
35
+
36
+ <div id="container">
37
+
38
+ <div class="download">
39
+ <a href="http://github.com/effkay/blazing/zipball/master">
40
+ <img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a>
41
+ <a href="http://github.com/effkay/blazing/tarball/master">
42
+ <img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a>
43
+ </div>
44
+
45
+ <h1><a href="http://github.com/effkay/blazing">blazing</a>
46
+ <span class="small">by <a href="http://github.com/effkay">effkay</a></span></h1>
47
+
48
+ <div class="description">
49
+ git push deployments
50
+ </div>
51
+
52
+ <p>blahblahmainproject text</p><h2>Dependencies</h2>
53
+ <p>heregoesdependencies</p>
54
+ <h2>Install</h2>
55
+ <p>heregoesinstallinstructions</p>
56
+ <h2>License</h2>
57
+ <p>Copyright (c) 2011 Felipe Kaufmann
58
+
59
+ Permission is hereby granted, free of charge, to any person obtaining
60
+ a copy of this software and associated documentation files (the
61
+ "Software"), to deal in the Software without restriction, including
62
+ without limitation the rights to use, copy, modify, merge, publish,
63
+ distribute, sublicense, and/or sell copies of the Software, and to
64
+ permit persons to whom the Software is furnished to do so, subject to
65
+ the following conditions:
66
+
67
+ The above copyright notice and this permission notice shall be
68
+ included in all copies or substantial portions of the Software.
69
+
70
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
71
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
72
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
73
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
74
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
75
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
76
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77
+ </p>
78
+ <h2>Authors</h2>
79
+ <p>Felipe Kaufmann (felipekaufmann@gmail.com)
80
+ <h2>Contact</h2>
81
+ <p>Felipe Kaufmann (felipekaufmann@gmail.com)
82
+
83
+
84
+ <h2>Download</h2>
85
+ <p>
86
+ You can download this project in either
87
+ <a href="http://github.com/effkay/blazing/zipball/master">zip</a> or
88
+ <a href="http://github.com/effkay/blazing/tarball/master">tar</a> formats.
89
+ </p>
90
+ <p>You can also clone the project with <a href="http://git-scm.com">Git</a>
91
+ by running:
92
+ <pre>$ git clone git://github.com/effkay/blazing</pre>
93
+ </p>
94
+
95
+ <div class="footer">
96
+ get the source code on GitHub : <a href="http://github.com/effkay/blazing">effkay/blazing</a>
97
+ </div>
98
+
99
+ </div>
100
+
101
+ <script type="text/javascript">
102
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
103
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
104
+ </script>
105
+ <script type="text/javascript">
106
+ try {
107
+ var pageTracker = _gat._getTracker("UA-757870-3");
108
+ pageTracker._trackPageview();
109
+ } catch(err) {}</script>
110
+ </body>
111
+ </html>
@@ -1,19 +1,18 @@
1
1
  require 'thor'
2
2
  require 'thor/group'
3
3
  require 'blazing'
4
- require 'blazing/cli/base'
5
-
6
4
  require 'blazing/config'
7
5
  require 'blazing/logger'
8
6
  require 'blazing/target'
9
7
  require 'blazing/remote'
10
8
  require 'blazing/recipe'
11
9
  require 'blazing/object'
10
+ require 'blazing/cli/base'
12
11
  require 'blazing/cli/create'
13
12
  require 'blazing/cli/hook'
14
13
 
15
14
  module Blazing
16
15
  DIRECTORY = 'config'
17
16
  CONFIGURATION_FILE = 'config/blazing.rb'
18
- LOGGER = Blazing::Logger.new
17
+ LOGGER ||= Blazing::Logger.new
19
18
  end
@@ -2,9 +2,6 @@ module Blazing
2
2
  module CLI
3
3
  class Base < Thor
4
4
 
5
- #
6
- # Configure blazing in current working dir
7
- #
8
5
  desc 'init', 'prepare project for blazing deploys'
9
6
  def init
10
7
  target = ask "Deployment Target: (ie username@host:/path/to/app)"
@@ -14,13 +11,10 @@ module Blazing
14
11
  else
15
12
  repository = ask "Repository URL: (ie username@host:/path/to/app)"
16
13
  end
17
-
14
+
18
15
  Blazing::CLI::Create.new([repository, target]).invoke_all
19
16
  end
20
17
 
21
- #
22
- # Setup target for deployment
23
- #
24
18
  desc 'setup TARGET_NAME', 'setup or update blazing on specified target and deploy'
25
19
  def setup(target_name = nil)
26
20
  config = Blazing::Config.load
@@ -37,9 +31,6 @@ module Blazing
37
31
  end
38
32
  end
39
33
 
40
- #
41
- # Deploy to target
42
- #
43
34
  desc 'deploy TARGET', 'deploy to TARGET'
44
35
  def deploy(target_name = nil)
45
36
  config = Blazing::Config.load
@@ -52,7 +43,13 @@ module Blazing
52
43
  else
53
44
  LOGGER.error "failed deploying on target #{target.name}"
54
45
  end
46
+ end
55
47
 
48
+ desc 'recipes', 'List available recipes'
49
+ def recipes
50
+ Blazing::Recipe.list.each do |recipe|
51
+ puts recipe.name
52
+ end
56
53
  end
57
54
 
58
55
  end
@@ -7,7 +7,7 @@ module Blazing
7
7
  include Thor::Actions
8
8
 
9
9
  argument :repository
10
- argument :remote
10
+ argument :target
11
11
 
12
12
  def self.source_root
13
13
  File.dirname(__FILE__)
@@ -25,4 +25,4 @@ module Blazing
25
25
 
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -1,36 +1,47 @@
1
1
  module Blazing
2
2
  class Logger
3
-
4
- @@use_color = true
5
- # TODO: implement non colored output, allow to pass option from commandline
6
3
 
7
- [:info, :success, :warn, :error].each do |type|
8
- define_method type do |message|
9
- message(message, type)
10
- end
4
+ LOG_LEVELS = [:info, :success, :warn, :error]
5
+
6
+ def initialize(use_color = false)
7
+ @use_color = use_color
11
8
  end
12
9
 
13
- def prefix
14
- "[".red + "BLAZING".yellow + "] ".red + '*** '
10
+ def messages
11
+ @messages ||= []
15
12
  end
16
13
 
17
- def postfix
18
- ' ***'
14
+ def puts(message, type)
15
+ messages << Hash[:message => message, :type => type]
19
16
  end
20
17
 
21
- def message(message, type)
22
- case type
23
- when :info
24
- puts prefix + message.blue + postfix
25
- when :success
26
- puts prefix + message.green + postfix
27
- when :warn
28
- puts prefix + message.yellow + postfix
29
- when :error
30
- puts prefix + message.red + postfix
31
- end
18
+ LOG_LEVELS.each do |type|
19
+ define_method type do |message|
20
+ puts(message, type)
21
+ end
32
22
  end
33
23
 
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
+
34
45
  end
35
46
  end
36
47
 
@@ -1,6 +1,11 @@
1
+ require 'active_support/inflector'
2
+ require 'blazing'
3
+
1
4
  module Blazing
2
5
  class Recipe
3
6
 
7
+ # TODO: provide hooks for recipe to use bundle exec
8
+
4
9
  attr_accessor :name, :options
5
10
 
6
11
  def initialize(name, options = {})
@@ -8,23 +13,60 @@ module Blazing
8
13
  @options = options
9
14
  end
10
15
 
11
- end
12
- end
16
+ def run
17
+ recipe_class.run if recipe_class
18
+ end
19
+
20
+ def recipe_class
21
+ ('Blazing::' + (@name.to_s + '_recipe').camelize).constantize
22
+ rescue NameError
23
+ Blazing::LOGGER.error "unable to load #{@name} recipe"
24
+ return nil
25
+ end
26
+
27
+ def fail
28
+ raise 'NOT IMPLEMENTED'
29
+ # TODO: implement meaningful default behaviour!
30
+ end
31
+
32
+ def success
33
+ raise 'NOT IMPLEMENTED'
34
+ # TODO: implement meaningful default behaviour!
35
+ end
13
36
 
14
- # TODO: recipes as gems: blazing_hoptoad, blazing_rpm etc.
15
- # TODO: provide setup, run and use methods and ability to override the whole recipe
16
- # TODO: Must be callable from global namespace and from remote block
17
-
18
- # TODO: make it easy to keep recipe externally and use git submodule
19
- #
20
- # TODO: later, make it possible to keep recipe and setup of all projects in
21
- # a central repo:
22
- #
23
- # /recipes
24
- # /projects/
25
- # " " someproject.rb
26
- # " " anotherpoject.rb
27
- #
28
- #
29
- # ????
37
+ class << self
30
38
 
39
+ def load_builtin_recipes
40
+ dir = File.join(File.dirname(__FILE__), "/recipes")
41
+ $LOAD_PATH.unshift(dir)
42
+ Dir[File.join(dir, "*.rb")].each { |file| load File.basename(file) }
43
+ end
44
+
45
+ def load_gem_recipes
46
+ #TODO: Implement
47
+ end
48
+
49
+ def load_local_recipes
50
+ #TODO: Implement
51
+ end
52
+
53
+ #
54
+ # Return the list of available recipes based
55
+ # on class hierarchy
56
+ #
57
+ def list
58
+ descendants = []
59
+
60
+ load_builtin_recipes
61
+
62
+ ObjectSpace.each_object(Class) do |k|
63
+ descendants.unshift k if k < self
64
+ end
65
+ descendants.uniq!
66
+ descendants
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,14 @@
1
+ module Blazing
2
+
3
+ class BundlerRecipe < Blazing::Recipe
4
+ def self.run
5
+ puts 'buhuuuuuu, running bundler!'
6
+ success
7
+ end
8
+
9
+ def self.success
10
+ puts 'yay, ran Bundler successfully!!!!!!'
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,15 @@
1
+ module Blazing
2
+
3
+ class RvmRecipe < Blazing::Recipe
4
+
5
+ def self.run
6
+ puts 'buhuuuuuu, running rvm!'
7
+ success
8
+ end
9
+
10
+ def self.success
11
+ puts 'yay, ran rvm successfully!!!!!!'
12
+ end
13
+ end
14
+
15
+ end
@@ -1,15 +1,44 @@
1
1
  module Blazing
2
2
  class Remote
3
-
4
- # TODO: RVM
5
- # TODO: Bundler
6
- # TODO: Check if post-hook and blazing versions match
7
-
8
3
  class << self
9
4
 
10
- def post_receive(target)
5
+ def post_receive(target_name)
11
6
  set_git_dir
12
- reset_head
7
+ target = config.find_target(target_name)
8
+
9
+ # TODO: Check if post-hook and blazing versions match before doing anything
10
+
11
+ if target.recipes.blank?
12
+ target.recipes = config.recipes
13
+ end
14
+
15
+ # TODO: looks stupid. shorter way to do it?
16
+ use_rvm = target.recipes.find { |recipe| recipe.name == 'rvm' }
17
+ target.recipes.delete_if { |recipe| recipe.name == 'rvm' }
18
+
19
+ Blazing::Recipe.load_builtin_recipes
20
+
21
+ if use_rvm
22
+ use_rvm.run
23
+ end
24
+
25
+ if gemfile_present?
26
+ # TODO: Bundler setup or something
27
+ end
28
+
29
+ target.recipes.each do |recipe|
30
+ recipe.run
31
+ end
32
+
33
+ reset_head!
34
+ end
35
+
36
+ def post_setup(target_name)
37
+ # TODO: needed?
38
+ end
39
+
40
+ def gemfile_present?
41
+ File.exists? 'Gemfile'
13
42
  end
14
43
 
15
44
  def set_git_dir
@@ -19,25 +48,15 @@ module Blazing
19
48
  end
20
49
  end
21
50
 
22
- def reset_head
51
+ def reset_head!
23
52
  system 'git reset --hard HEAD'
24
53
  end
25
54
 
55
+ def config
56
+ Blazing::Config.load
57
+ end
58
+
26
59
  end
27
60
 
28
61
  end
29
62
  end
30
-
31
- # if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
32
- # begin
33
- # rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
34
- # rvm_lib_path = File.join(rvm_path, 'lib')
35
- # $LOAD_PATH.unshift rvm_lib_path
36
- # require 'rvm'
37
- # RVM.use_from_path! File.dirname(File.dirname(__FILE__))
38
- # rescue LoadError
39
- # # RVM is unavailable at this point.
40
- # raise "RVM ruby lib is currently unavailable."
41
- # end
42
- # end
43
-
@@ -1,7 +1,7 @@
1
1
  module Blazing
2
- class Target < Config
2
+ class Target
3
3
 
4
- attr_accessor :name
4
+ attr_accessor :name, :recipes
5
5
 
6
6
  @@configuration_options = [:deploy_to, :host, :user, :path, :default]
7
7
 
@@ -26,11 +26,6 @@ module Blazing
26
26
  end
27
27
 
28
28
  def setup
29
-
30
- # TODO: Log some output?
31
- # TODO: install post-receive hook and make it executable
32
-
33
- config = Blazing::Config.load
34
29
  clone_command = "if [ -e #{path} ]; then \
35
30
  echo 'directory exists already'; else \
36
31
  git clone #{config.repository} #{path} && cd #{path} && git config receive.denyCurrentBranch ignore; fi"
@@ -47,5 +42,9 @@ module Blazing
47
42
  system "git push #{name}"
48
43
  end
49
44
 
45
+ def config
46
+ Blazing::Config.load
47
+ end
48
+
50
49
  end
51
50
  end
@@ -1,3 +1,3 @@
1
1
  module Blazing
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+ require 'blazing/recipe'
3
+
4
+ describe Blazing::Recipe do
5
+
6
+ context 'initializer' do
7
+
8
+ it 'takes a string as name parameter' do
9
+ recipe = Blazing::Recipe.new('some_recipe')
10
+ recipe.name.should == 'some_recipe'
11
+ end
12
+
13
+ it 'takes a symbol as name parameter and converts it to a string' do
14
+ recipe = Blazing::Recipe.new(:some_recipe)
15
+ recipe.name.should == 'some_recipe'
16
+ end
17
+
18
+ it 'accepts options' do
19
+ recipe = Blazing::Recipe.new(:some_recipe, :an_option => 'yeah')
20
+ recipe.options[:an_option].should == 'yeah'
21
+ end
22
+
23
+ end
24
+
25
+ context 'recipe discovery' do
26
+
27
+ it 'before loading them, no recipes are known' do
28
+ lambda { Blazing::RvmRecipe }.should raise_error NameError
29
+ end
30
+
31
+ it 'can discover available recipes' do
32
+ recipes = Blazing::Recipe.list
33
+ recipes.should be_all { |recipe| recipe.superclass.should == Blazing::Recipe }
34
+ recipes.each { |r| Blazing.send(:remove_const, r.name.to_s.gsub(/^.*::/, '')) }
35
+ end
36
+
37
+ end
38
+
39
+ context 'running recipes' do
40
+
41
+ # before :each do
42
+ # @logger = double('logger').as_null_object
43
+ # end
44
+
45
+ it 'delegate running a recipe to the recipe implementation' do
46
+ Blazing::Recipe.load_builtin_recipes
47
+ Blazing::RvmRecipe.should_receive(:run)
48
+ Blazing::Recipe.new(:rvm).run
49
+ end
50
+
51
+ it 'construct the correct classname to use from recie name' do
52
+ Blazing::Recipe.new(:rvm).recipe_class.should == Blazing::RvmRecipe
53
+ end
54
+
55
+ it 'raise an error when a recipe has no run method defined' do
56
+ class Blazing::BlahRecipe < Blazing::Recipe; end
57
+ lambda { Blazing::Recipe.new(:blah).run }.should raise_error NoMethodError
58
+ end
59
+
60
+ context 'unknown recipe' do
61
+
62
+ before :all do
63
+ @unknown_recipe_name = :undefined
64
+ end
65
+
66
+ it 'does not crash when a recipe can not be loaded' do
67
+ lambda { Blazing::Recipe.new(@unknown_recipe_name).run }.should_not raise_error
68
+ end
69
+
70
+ it 'logs an error when a recipe cant be loaded' do
71
+ Blazing::LOGGER.should_receive(:error) # TODO: how should one do this?? .with("unable to laod #{@unknown_recipe_name} recipe")
72
+ Blazing::Recipe.new(:undefined).run
73
+ end
74
+
75
+ end
76
+ end
77
+
78
+
79
+ context 'builtin recipes' do
80
+
81
+ it 'include an rvm recipe' do
82
+ lambda { Blazing::RvmRecipe }.should_not raise_error NameError
83
+ end
84
+
85
+ it 'include a bundler recipe' do
86
+ lambda { Blazing::BundlerRecipe }.should_not raise_error NameError
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'blazing/remote'
3
+
4
+ describe Blazing::Remote do
5
+
6
+ context 'post_receive method' do
7
+ it 'set the gid dir to .git if it is not already' do
8
+ pending 'dont know how to spec this yet'
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,4 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "/spec/"
4
+ end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blazing
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 4
9
- version: 0.0.4
4
+ prerelease:
5
+ version: 0.0.5
10
6
  platform: ruby
11
7
  authors:
12
8
  - Felipe Kaufmann
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-02-01 00:00:00 +01:00
13
+ date: 2011-04-12 00:00:00 +02:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,13 +21,31 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 14
31
- - 6
32
24
  version: 0.14.6
33
25
  type: :runtime
34
26
  version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 3.0.5
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: i18n
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id003
35
49
  description: git push deployent utility, ready to be extended by your own recipes
36
50
  email:
37
51
  - felipekaufmann@gmail.com
@@ -43,12 +57,16 @@ extra_rdoc_files: []
43
57
 
44
58
  files:
45
59
  - .gitignore
60
+ - .rvmrc
46
61
  - Gemfile
47
62
  - Gemfile.lock
63
+ - Guardfile
64
+ - MIT-LICENCE
48
65
  - README.md
49
66
  - Rakefile
50
67
  - bin/blazing
51
68
  - blazing.gemspec
69
+ - index.html
52
70
  - lib/blazing.rb
53
71
  - lib/blazing/cli/base.rb
54
72
  - lib/blazing/cli/create.rb
@@ -60,9 +78,14 @@ files:
60
78
  - lib/blazing/logger.rb
61
79
  - lib/blazing/object.rb
62
80
  - lib/blazing/recipe.rb
81
+ - lib/blazing/recipes/bundler_recipe.rb
82
+ - lib/blazing/recipes/rvm_recipe.rb
63
83
  - lib/blazing/remote.rb
64
84
  - lib/blazing/target.rb
65
85
  - lib/blazing/version.rb
86
+ - spec/blazing/recipe_spec.rb
87
+ - spec/blazing/remote_spec.rb
88
+ - spec/spec_helper.rb
66
89
  has_rdoc: true
67
90
  homepage: https://github.com/effkay/blazing
68
91
  licenses: []
@@ -77,23 +100,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
100
  requirements:
78
101
  - - ">="
79
102
  - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
103
  version: "0"
83
104
  required_rubygems_version: !ruby/object:Gem::Requirement
84
105
  none: false
85
106
  requirements:
86
107
  - - ">="
87
108
  - !ruby/object:Gem::Version
88
- segments:
89
- - 0
90
109
  version: "0"
91
110
  requirements: []
92
111
 
93
112
  rubyforge_project:
94
- rubygems_version: 1.3.7
113
+ rubygems_version: 1.6.2
95
114
  signing_key:
96
115
  specification_version: 3
97
116
  summary: blazing fast deployment
98
- test_files: []
99
-
117
+ test_files:
118
+ - spec/blazing/recipe_spec.rb
119
+ - spec/blazing/remote_spec.rb
120
+ - spec/spec_helper.rb