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
data/Rakefile CHANGED
@@ -7,16 +7,15 @@ include Rake::DSL
7
7
 
8
8
  Bundler::GemHelper.install_tasks
9
9
 
10
- desc "Run specs"
10
+ desc 'Run specs'
11
11
  RSpec::Core::RakeTask.new do |t|
12
- # t.rspec_opts = %w(--colour --fail-fast --format nested)
13
- t.rspec_opts = %w(--colour --format nested)
12
+ t.rspec_opts = %w(--colour --fail-fast)
14
13
  t.ruby_opts = %w(-w)
15
14
  end
16
15
 
17
16
  Rake::RDocTask.new do |rd|
18
- rd.main = "README.rdoc"
19
- rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
17
+ rd.main = 'README.rdoc'
18
+ rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
20
19
  end
21
20
 
22
- task :default => [:spec]
21
+ task default: [:spec]
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path('../lib/', File.dirname(__FILE__))
2
3
 
3
- require 'blazing'
4
4
  require 'blazing/cli'
5
-
6
5
  Blazing::CLI.start
@@ -1,43 +1,34 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'blazing/version'
3
4
 
4
5
  Gem::Specification.new do |s|
5
- s.name = "blazing"
6
-
7
- #
8
- # TODO: Remove Config.repository in 0.3
9
- #
10
- s.version = '0.4.2'
11
-
12
- s.authors = ["Felipe Kaufmann"]
13
- s.email = ["felipekaufmann@gmail.com"]
14
- s.homepage = "https://github.com/effkay/blazing"
15
- s.summary = %q{git push deployment helper}
16
- s.description = %q{painless git push deployments for everyone}
17
- s.rubyforge_project = "blazing"
6
+ s.name = 'blazing'
7
+ s.version = ::Blazing::VERSION
8
+ s.authors = ['Felipe Kaufmann', 'Alexander Adam']
9
+ s.email = ['felipekaufmann@gmail.com']
10
+ s.homepage = 'https://github.com/effkay/blazing'
11
+ s.summary = 'git push deployment helper'
12
+ s.description = 'painless git push deployments for everyone'
13
+ s.rubyforge_project = 'blazing'
18
14
  s.files = `git ls-files`.split("\n")
19
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
- s.require_paths = ["lib"]
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
+ s.require_path = 'lib'
18
+ s.required_ruby_version = '>= 2.0.0'
22
19
 
23
- # specify any dependencies here; for example:
24
- # s.add_development_dependency "rspec"
25
- # s.add_runtime_dependency "rest-client"
26
20
  s.add_development_dependency('rdoc')
27
- s.add_development_dependency('rake','~> 0.9.2')
28
- s.add_development_dependency('rspec')
21
+ s.add_development_dependency('rake', '~> 0.9.2')
22
+ s.add_development_dependency('rspec', '>= 3.0')
29
23
  s.add_development_dependency('guard')
30
24
  s.add_development_dependency('guard-rspec')
31
25
  s.add_development_dependency('ruby_gntp')
32
26
  s.add_development_dependency('rb-fsevent')
33
27
  s.add_development_dependency('pry')
34
28
  s.add_development_dependency('pimpmychangelog')
29
+ s.add_development_dependency('rubocop')
35
30
 
36
31
  s.add_dependency('grit')
37
- s.add_dependency('logging', '~> 1.8')
32
+ s.add_dependency('logging')
38
33
  s.add_dependency('thor')
39
-
40
- # TODO: Get rid of those, just used for guessing recipe names etc in lib/recipes.rb
41
- s.add_dependency "activesupport"
42
- s.add_dependency "i18n"
43
34
  end
@@ -1,19 +1,7 @@
1
- require "blazing/logger"
1
+ require_relative 'blazing/config'
2
2
 
3
3
  module Blazing
4
-
5
- autoload :CLI, 'blazing/cli'
6
- autoload :Config, 'blazing/config'
7
- autoload :DSLSetter, 'blazing/dsl_setter'
8
- autoload :Recipe, 'blazing/recipe'
9
- autoload :COmmands, 'blazing/commands'
10
- autoload :Shell, 'blazing/shell'
11
- autoload :Target, 'blazing/target'
12
- autoload :Hook, 'blazing/hook'
13
- autoload :Repository, 'blazing/repository'
14
-
15
- TEMPLATE_ROOT = File.expand_path(File.dirname(__FILE__) + File.join('/', 'blazing', 'templates'))
4
+ TEMPLATE_ROOT = File.expand_path(File.join(File.dirname(__FILE__), 'blazing/templates'))
16
5
  DEFAULT_CONFIG_LOCATION = 'config/blazing.rb'
17
6
  TMP_HOOK = '/tmp/post-receive'
18
-
19
7
  end
@@ -1,78 +1,71 @@
1
1
  require 'thor'
2
- require 'blazing/commands'
2
+ require_relative 'commands'
3
+ require_relative 'version'
3
4
 
4
5
  module Blazing
5
6
  class CLI < Thor
6
-
7
7
  default_task :help
8
8
 
9
- desc 'init', 'Generate a blazing config file'
10
-
11
9
  #
12
10
  # Bootstrap blazing by creating a sample config file
13
11
  #
12
+ desc 'init', 'Generate a sample blazing config file'
13
+
14
14
  def init
15
15
  Blazing::Commands.run(:init)
16
16
  end
17
17
 
18
+ #
19
+ # Setup a target to be deployed with blazing
20
+ #
18
21
  desc 'setup [TARGET]', 'Setup local and remote repository/repositories for deployment'
19
22
 
20
23
  method_option :file,
21
- :type => :string,
22
- :aliases => '-f',
23
- :banner => 'Specify a configuration file'
24
+ type: :string,
25
+ aliases: '-f',
26
+ banner: 'Specify a configuration file'
24
27
 
25
- #
26
- # Setup a target to be deployed with blazing
27
- #
28
28
  def setup(target_name = nil)
29
- Blazing::Commands.run(:setup, :target_name => target_name, :options => options)
29
+ Blazing::Commands.run(:setup, target_name: target_name, cli_options: options)
30
30
  end
31
31
 
32
- desc 'update [TARGET]', 'Re-Generate and uplaod hook based on current configuration'
33
-
34
- method_option :file,
35
- :type => :string,
36
- :aliases => '-f',
37
- :banner => 'Specify a configuration file'
38
-
39
32
  #
40
33
  # Update the target hook so it matches the settings in the config
41
34
  #
35
+ desc 'update [TARGET]', 'Re-Generate and upload hook based on current configuration'
36
+
37
+ method_option :file,
38
+ type: :string,
39
+ aliases: '-f',
40
+ banner: 'Specify a configuration file'
41
+
42
42
  def update(target_name = nil)
43
- Blazing::Commands.run(:update, :target_name => target_name, :options => options)
43
+ Blazing::Commands.run(:update, target_name: target_name, cli_options: options)
44
44
  end
45
45
 
46
- desc 'recipes [TARGET]', 'Run the recipes for the given target'
47
-
48
46
  #
49
- # Run the configured blazing recipes (used on remote machien)
47
+ # SSH to the server and cd into the app directory. Of course it also sets the appropriate RAILS_ENV
50
48
  #
51
- def recipes(target_name)
52
- Blazing::Commands.run(:recipes, :target_name => target_name, :options => options)
53
- end
54
-
55
- desc 'goto [TARGET]', 'Open a shell for specified target'
49
+ desc 'goto [TARGET]', 'Open ssh session on target. Use -c to specify a command to be run'
56
50
 
57
51
  method_option :run,
58
- :type => :string,
59
- :aliases => '-c',
60
- :banner => 'Specify a command'
52
+ type: :string,
53
+ aliases: '-c',
54
+ banner: 'Specify a command'
61
55
 
62
- #
63
- # SSH to the server and cd into the app directory. Of course it also sets the appropriate RAILS_ENV
64
- #
65
56
  def goto(target_name)
66
- Blazing::Commands.run(:goto, :target_name => target_name, :options => options)
57
+ Blazing::Commands.run(:goto, target_name: target_name, cli_options: options)
67
58
  end
68
59
 
69
- desc 'list', 'List available recipes'
70
-
71
60
  #
72
- # List the available blazing recipes
61
+ # Show blazing version
73
62
  #
74
- def list
75
- Blazing::Commands.run(:list)
63
+ desc 'version', 'Show the blazing version'
64
+
65
+ map %w(-v --version) => :version
66
+
67
+ def version
68
+ puts "blazing version #{::Blazing::VERSION}"
76
69
  end
77
70
  end
78
71
  end
@@ -1,49 +1,46 @@
1
1
  require 'erb'
2
+ require 'blazing'
3
+ require_relative 'config'
2
4
 
3
5
  module Blazing
4
6
  class Commands
5
-
6
- include Logger
7
+ include Blazing::Logger
7
8
 
8
9
  class << self
9
10
  def run(command, options = {})
10
- self.new(options.merge({ :command => command })).send(command)
11
+ new(options.merge(command: command)).send(command)
11
12
  end
12
13
  end
13
14
 
14
15
  def initialize(options = {})
15
- warn 'The :default Target option has been deprecated and will be ignored' if options.has_key?(:default)
16
- @cli_options = options[:options] # that stinks! TODO: clean up options handling.
16
+ warn 'The :default Target option has been deprecated and will be ignored' if options.key?(:default)
17
+ @cli_options = options[:cli_options]
17
18
  @target_name = options[:target_name]
18
19
  @config_file = options[:file]
19
20
  @command = options[:command]
20
21
  @targets = []
21
22
 
22
- if command_requires_config?
23
- @config ||= Config.parse(@config_file)
24
- @targets = determine_targets
25
- error 'no target given or found' if @targets.empty?
26
- end
23
+ return unless command_requires_config?
24
+
25
+ @config ||= Blazing::Config.parse(@config_file)
26
+ @targets = determine_targets
27
+ error 'no target given or found' if @targets.empty?
27
28
  end
28
29
 
29
30
  def init
30
31
  info "Creating an example config file in #{Blazing::DEFAULT_CONFIG_LOCATION}"
31
- info "Customize it to your needs"
32
+ info 'Customize it to your needs'
32
33
  create_config_directory
33
34
  write_config_file
34
35
  end
35
36
 
36
37
  def setup
37
- @targets.each { |target| target.setup }
38
+ @targets.each(&:setup)
38
39
  update
39
40
  end
40
41
 
41
42
  def update
42
- @targets.each { |target| target.update }
43
- end
44
-
45
- def recipes
46
- @config.recipes.each { |recipe| recipe.run({:target_name => @target_name}) }
43
+ @targets.each(&:update)
47
44
  end
48
45
 
49
46
  def goto
@@ -57,19 +54,15 @@ module Blazing
57
54
  end
58
55
  end
59
56
 
60
- def list
61
- Blazing::Recipe.pretty_list
62
- end
63
-
64
57
  private
65
58
 
66
59
  def create_config_directory
67
- Dir.mkdir 'config' unless File.exists? 'config'
60
+ Dir.mkdir 'config' unless File.exist? 'config'
68
61
  end
69
62
 
70
63
  def write_config_file
71
64
  config = ERB.new(File.read("#{Blazing::TEMPLATE_ROOT}/config.erb")).result
72
- File.open(Blazing::DEFAULT_CONFIG_LOCATION,"wb") { |f| f.puts config }
65
+ File.open(Blazing::DEFAULT_CONFIG_LOCATION, 'wb') { |f| f.puts config }
73
66
  end
74
67
 
75
68
  def determine_targets
@@ -77,14 +70,13 @@ module Blazing
77
70
  @config.targets
78
71
  else
79
72
  targets = []
80
- targets << @config.find_target(@target_name)
73
+ targets << @config.target(@target_name)
81
74
  targets.compact
82
75
  end
83
76
  end
84
77
 
85
78
  def command_requires_config?
86
- [:setup, :update, :recipes, :goto].include? @command
79
+ [:setup, :update, :goto].include? @command
87
80
  end
88
81
  end
89
82
  end
90
-
@@ -1,60 +1,30 @@
1
- require 'blazing/target'
2
- require 'blazing/recipe'
3
- require 'blazing/dsl_setter'
1
+ require_relative 'dsl'
2
+ require_relative 'logger'
4
3
 
5
- class Blazing::Config
4
+ module Blazing
5
+ class Config
6
+ include Blazing::Logger
6
7
 
7
- extend Blazing::DSLSetter
8
- include Blazing::Logger
8
+ attr_reader :file
9
+ attr_accessor :targets, :rake_task, :env_script
9
10
 
10
- attr_reader :file
11
- attr_accessor :targets, :recipes
12
- dsl_setter :rvm, :env_scripts
13
- alias :rvm_scripts :env_scripts
14
-
15
- class << self
16
- def parse(configuration_file = nil)
17
- Blazing::Recipe.load_recipes!
18
- config = self.new(configuration_file)
19
- config.instance_eval(File.read(config.file))
20
-
21
- config
11
+ def initialize(configuration_file = nil)
12
+ @file = configuration_file || Blazing::DEFAULT_CONFIG_LOCATION
13
+ @targets = []
14
+ @rake_task = nil
15
+ @env_script = nil
22
16
  end
23
- end
24
-
25
- def initialize(configuration_file = nil)
26
- @file = configuration_file || Blazing::DEFAULT_CONFIG_LOCATION
27
- @targets = []
28
- @recipes = []
29
- end
30
-
31
- def target(name, location, options = {})
32
- raise "Name already taken" if targets.find { |t| t.name == name }
33
- targets << Blazing::Target.new(name, location, self, options)
34
- end
35
-
36
- def recipe(name, options = {})
37
- @recipes << Blazing::Recipe.init_by_name(name, options)
38
- end
39
-
40
- def rake(task_name, env = nil)
41
- @rake = { :task => task_name }
42
- @rake[:env] = env if env
43
- end
44
-
45
- def repository(*args)
46
- warn 'Ther repository DSL method has been deprecated and is no longer used. This method will be removed in Version 0.3'
47
- end
48
17
 
49
- def default_target
50
- if @targets.size == 1
51
- @targets.first
18
+ class << self
19
+ def parse(configuration_file = nil)
20
+ config = new(configuration_file)
21
+ Blazing::DSL.new(config).instance_eval(File.read(config.file))
22
+ config
23
+ end
52
24
  end
53
- end
54
25
 
55
- # TODO: Spec it!
56
- def find_target(target_name)
57
- targets.find { |t| t.name.to_s == target_name.to_s }
26
+ def target(target_name)
27
+ targets.find { |t| t.name.to_s == target_name.to_s }
28
+ end
58
29
  end
59
-
60
30
  end
@@ -0,0 +1,37 @@
1
+ require_relative 'target'
2
+
3
+ module Blazing
4
+ class DSL
5
+ attr_accessor :config
6
+
7
+ def initialize(config)
8
+ @config = config
9
+ end
10
+
11
+ def target(name, location, options = {})
12
+ raise 'Name already taken' if config.targets.find { |t| t.name == name }
13
+
14
+ config.targets << Blazing::Target.new(name, location, config, options)
15
+ end
16
+
17
+ def rake(task_name)
18
+ config.rake_task = task_name
19
+ end
20
+
21
+ def env_script(path)
22
+ config.env_script = path
23
+ end
24
+
25
+ def rvm_scripts(_args)
26
+ warn 'rvm_scripts in config has been deprecated and no longer works. Use env_script!'
27
+ end
28
+
29
+ def rvm(_args)
30
+ warn 'you can not set the rvm ruby with the blazing DSL anymore. Use rake tasks!'
31
+ end
32
+
33
+ def recipes(_args)
34
+ warn 'recipes have been removed from blazing!'
35
+ end
36
+ end
37
+ end