blazing 0.4.2 → 0.5.0

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +183 -0
  4. data/.travis.yml +8 -4
  5. data/CHANGELOG.md +7 -1
  6. data/Gemfile +1 -1
  7. data/Guardfile +6 -7
  8. data/README.md +30 -152
  9. data/Rakefile +5 -6
  10. data/bin/blazing +1 -2
  11. data/blazing.gemspec +17 -26
  12. data/lib/blazing.rb +2 -14
  13. data/lib/blazing/cli.rb +32 -39
  14. data/lib/blazing/commands.rb +18 -26
  15. data/lib/blazing/config.rb +21 -51
  16. data/lib/blazing/dsl.rb +37 -0
  17. data/lib/blazing/hook.rb +15 -11
  18. data/lib/blazing/logger.rb +13 -17
  19. data/lib/blazing/repository.rb +5 -1
  20. data/lib/blazing/shell.rb +5 -5
  21. data/lib/blazing/target.rb +3 -3
  22. data/lib/blazing/templates/config.erb +10 -45
  23. data/lib/blazing/templates/hook/base.erb +0 -3
  24. data/lib/blazing/templates/hook/bundler.erb +4 -3
  25. data/lib/blazing/templates/hook/env-scripts.erb +3 -3
  26. data/lib/blazing/templates/hook/rake.erb +0 -1
  27. data/lib/blazing/templates/hook/rvm.erb +3 -31
  28. data/lib/blazing/templates/hook/setup.erb +1 -1
  29. data/lib/blazing/version.rb +3 -0
  30. data/spec/blazing/cli_spec.rb +1 -11
  31. data/spec/blazing/commands_spec.rb +35 -65
  32. data/spec/blazing/config_spec.rb +22 -102
  33. data/spec/blazing/dsl_spec.rb +60 -0
  34. data/spec/blazing/hook_spec.rb +31 -82
  35. data/spec/blazing/integration/deployment_spec.rb +20 -22
  36. data/spec/blazing/integration/init_spec.rb +2 -4
  37. data/spec/blazing/integration/setup_spec.rb +30 -30
  38. data/spec/blazing/integration/update_spec.rb +35 -35
  39. data/spec/blazing/logger_spec.rb +0 -4
  40. data/spec/blazing/repository_spec.rb +8 -10
  41. data/spec/blazing/shell_spec.rb +2 -4
  42. data/spec/blazing/target_spec.rb +12 -13
  43. data/spec/spec_helper.rb +8 -12
  44. data/spec/support/dummy_config.rb +6 -0
  45. metadata +18 -35
  46. data/lib/blazing/dsl_setter.rb +0 -20
  47. data/lib/blazing/recipe.rb +0 -45
  48. data/lib/blazing/templates/hook/recipes.erb +0 -5
  49. data/spec/blazing/dsl_setter_spec.rb +0 -29
  50. data/spec/blazing/integration/list_spec.rb +0 -20
  51. data/spec/blazing/integration/recipes_spec.rb +0 -29
  52. data/spec/blazing/recipe_spec.rb +0 -42
@@ -1,20 +0,0 @@
1
- module Blazing::DSLSetter
2
-
3
- #
4
- # DSL Setter helper method
5
- #
6
- def dsl_setter(*names)
7
- names.each do |name|
8
- class_eval <<-EVAL
9
- def #{name}(value = nil)
10
- if value
11
- instance_variable_set("@#{name}", value)
12
- else
13
- instance_variable_get("@#{name}")
14
- end
15
- end
16
- EVAL
17
- end
18
- end
19
-
20
- end
@@ -1,45 +0,0 @@
1
- require 'blazing/logger'
2
- require 'active_support/inflector'
3
-
4
- class Blazing::Recipe
5
-
6
- include Blazing::Logger
7
-
8
- attr_reader :options
9
-
10
- def initialize(options = {})
11
- @options = options
12
- end
13
-
14
- def run(target_options = {})
15
- @options.merge! target_options
16
- end
17
-
18
- class << self
19
-
20
- def init_by_name(name, options = {})
21
- "Blazing::Recipe::#{name.to_s.camelize}".constantize.new(options)
22
- end
23
-
24
- def list
25
- load_recipes!
26
- descendants = []
27
- ObjectSpace.each_object(Class) do |k|
28
- descendants.unshift k if k < self
29
- end
30
- descendants
31
- end
32
-
33
- def load_recipes!
34
- gems = $:.select{|p| p.match /blazing-\w+(|-\d\.\d\.\d)\/lib/}.map { |r| r.scan(/blazing-\w+/)[0] }
35
- gems.each { |gem| require gem }
36
- rescue LoadError
37
- # Here because using blazing from git now produces a match like 'blazing-269ee17d65d1'
38
- end
39
-
40
- def pretty_list
41
- list.each { |r| puts r.to_s.demodulize.underscore }
42
- end
43
-
44
- end
45
- end
@@ -1,5 +0,0 @@
1
- <% unless @config.recipes.empty? %>
2
- echo "------> [blazing] Running recipes for <%= @target.name.to_s %>"
3
- bundle exec blazing recipes <%= @target.name.to_s %>
4
- <% end %>
5
-
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Blazing
4
-
5
- describe DSLSetter do
6
-
7
- let(:dummy) { class Dummy; extend DSLSetter; end }
8
- let(:dummy_instance) { Dummy.new }
9
-
10
- it 'it defines a dsl method named after each argument provided' do
11
- dummy.dsl_setter(:foo, :bar)
12
- dummy_instance.should respond_to :foo
13
- dummy_instance.should respond_to :bar
14
- end
15
-
16
- context 'the generated dsl method' do
17
- it 'sets an instance variable when provided with an argumnent' do
18
- dummy_instance.foo('something')
19
- dummy_instance.instance_variable_get(:@foo).should == 'something'
20
- end
21
-
22
- it 'returns the value of the istance variable when no argument is provided' do
23
- dummy_instance.instance_variable_set(:@foo, 'something')
24
- dummy_instance.foo.should == 'something'
25
- end
26
- end
27
- end
28
- end
29
-
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '$ blazing list' do
4
-
5
-
6
- before :each do
7
- setup_sandbox
8
- end
9
-
10
- after :each do
11
- teardown_sandbox
12
- end
13
-
14
- it 'prints a list of the available recipes' do
15
- class Blazing::Recipe::Dummy < Blazing::Recipe
16
- end
17
- capture(:stdout) { Blazing::Commands.new(:file => File.join(File.dirname(__FILE__), '../../support/empty_config.rb')).list }.should == "dummy\n"
18
- end
19
- end
20
-
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '$ blazing recipes' do
4
-
5
- before :each do
6
- setup_sandbox
7
- class Blazing::Recipe::Dummy < Blazing::Recipe
8
- def run(target_options={})
9
- puts 'dummy recipe was run'
10
- end
11
- end
12
- @dummy_recipe = Blazing::Recipe::Dummy.new
13
- @config = Blazing::Config.new
14
- @config.target :production, @production_url
15
- @config.instance_variable_set('@recipes', [@dummy_recipe])
16
- @cli = Blazing::CLI.new
17
- Blazing::Config.stub(:parse).and_return @config
18
- end
19
-
20
- after :each do
21
- teardown_sandbox
22
- end
23
-
24
- it 'runs the configured recipes' do
25
- output = capture(:stdout) { @cli.recipes(:production) }
26
- output.should == "dummy recipe was run\n"
27
- end
28
- end
29
-
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
- require 'blazing/recipe'
3
-
4
- describe Blazing::Recipe do
5
-
6
- describe '.init_by_name' do
7
- before :each do
8
- class Blazing::Recipe::Dummy < Blazing::Recipe
9
- def run(target_options = {})
10
- super target_options
11
- end
12
- end
13
- end
14
-
15
- it 'initializes the correct recipe' do
16
- Blazing::Recipe.init_by_name(:dummy).should be_a Blazing::Recipe::Dummy
17
- end
18
- end
19
-
20
- describe '.list' do
21
- it 'retunrs an array of the available recipe classes' do
22
- Blazing::Recipe.list.should include Blazing::Recipe::Dummy
23
- end
24
- end
25
-
26
- describe '#run' do
27
-
28
- before :each do
29
- @production_url = '/some/target'
30
- @dummy_recipe = Blazing::Recipe::Dummy.new(:some_option => 'global')
31
- @config = Blazing::Config.new
32
- @config.target(:production, @production_url, :some_option => 'target-specific')
33
- @config.instance_variable_set('@recipes', [@dummy_recipe])
34
- end
35
-
36
- it 'overrides global recipe options with target options' do
37
- @dummy_recipe.run(:some_option => 'target-specific')
38
- @dummy_recipe.instance_variable_get('@options')[:some_option].should == 'target-specific'
39
- end
40
- end
41
-
42
- end