producer-core 0.5.7 → 0.5.8

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +6 -3
  4. data/config/cucumber.yaml +2 -1
  5. data/features/cli/debug.feature +7 -1
  6. data/features/cli/dry_run.feature +5 -0
  7. data/features/cli/error_reporting.feature +1 -1
  8. data/features/cli/usage.feature +6 -10
  9. data/features/cli/verbose.feature +5 -0
  10. data/features/recipe/errors.feature +9 -0
  11. data/features/ssh/config.feature +1 -1
  12. data/features/steps/environment_steps.rb +3 -0
  13. data/lib/producer/core/action.rb +5 -7
  14. data/lib/producer/core/actions/file_append.rb +1 -1
  15. data/lib/producer/core/actions/file_writer.rb +1 -2
  16. data/lib/producer/core/actions/mkdir.rb +4 -4
  17. data/lib/producer/core/actions/shell_command.rb +1 -1
  18. data/lib/producer/core/actions/yaml_writer.rb +1 -2
  19. data/lib/producer/core/cli.rb +48 -37
  20. data/lib/producer/core/condition.rb +3 -3
  21. data/lib/producer/core/env.rb +5 -4
  22. data/lib/producer/core/error_formatter.rb +13 -14
  23. data/lib/producer/core/errors.rb +1 -0
  24. data/lib/producer/core/logger_formatter.rb +3 -4
  25. data/lib/producer/core/prompter.rb +4 -4
  26. data/lib/producer/core/recipe/file_evaluator.rb +3 -3
  27. data/lib/producer/core/recipe.rb +10 -10
  28. data/lib/producer/core/remote/environment.rb +1 -1
  29. data/lib/producer/core/remote/fs.rb +10 -10
  30. data/lib/producer/core/remote.rb +13 -7
  31. data/lib/producer/core/task.rb +15 -9
  32. data/lib/producer/core/template.rb +9 -10
  33. data/lib/producer/core/test.rb +1 -1
  34. data/lib/producer/core/testing/aruba_program_wrapper.rb +2 -2
  35. data/lib/producer/core/testing/cucumber/output_steps.rb +12 -0
  36. data/lib/producer/core/testing/cucumber/recipe_steps.rb +5 -5
  37. data/lib/producer/core/testing/cucumber/remote_steps.rb +8 -8
  38. data/lib/producer/core/testing/cucumber.rb +3 -3
  39. data/lib/producer/core/testing/mock_remote.rb +27 -25
  40. data/lib/producer/core/tests/condition_test.rb +1 -1
  41. data/lib/producer/core/tests/file_contains.rb +2 -3
  42. data/lib/producer/core/tests/file_eq.rb +1 -2
  43. data/lib/producer/core/tests/file_match.rb +1 -2
  44. data/lib/producer/core/tests/has_env.rb +3 -6
  45. data/lib/producer/core/tests/has_executable.rb +1 -1
  46. data/lib/producer/core/tests/shell_command_status.rb +1 -1
  47. data/lib/producer/core/version.rb +1 -1
  48. data/lib/producer/core/worker.rb +7 -7
  49. data/lib/producer/core.rb +0 -1
  50. data/producer-core.gemspec +2 -2
  51. data/spec/producer/core/cli_spec.rb +29 -4
  52. data/spec/producer/core/remote_spec.rb +9 -1
  53. data/spec/producer/core/testing/mock_remote_spec.rb +5 -4
  54. metadata +10 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f750e0a3e7e1507d6ae506e7a225d36013e32a46
4
- data.tar.gz: dd1936c1fca2cedd04e3526de0de5b6c0a20a540
3
+ metadata.gz: 928f078bd25c17856fcd95f5f95b1cf5f62cc2f6
4
+ data.tar.gz: 795822a79e878ed17e775216ecb75e4760739435
5
5
  SHA512:
6
- metadata.gz: 746ff40b2247ebaafe28ed7c1ce080a70bd079ae3ddb31fb90f38e49e19f2e9344218b0c5f1923eb392ac6f0e81b9c3bac08dbb03805abbcb6d42067965e7086
7
- data.tar.gz: cf618dde3593f0e0da83f4c3cdce8cef3896610bea5a42cfd5c5cc04aa4229b80ce15be530482449d716c7e0581b5bd38d2a6d475da57bef8da5520dc25e956e
6
+ metadata.gz: 537ca3e1729156f2ea60a7e9a7cf975a7fdc88b807670be525e49c7a56b6c7372adc7c5dacd0af18174ec96b9a8ecb46041d139f59f7132ab6f3dc3ba68ab911
7
+ data.tar.gz: b7a099e4ffb7438e8a02336fac5f36cd58960e29009946546bd7fbf47ea96fc15b5dc45e838f15214d0f090d0ac8172380fc746e4e0aeba1878e57b013b6d08c
data/README.md CHANGED
@@ -136,7 +136,7 @@ end
136
136
  Usage
137
137
  -----
138
138
 
139
- Usage: producer [options] [recipes]
139
+ Usage: producer [options] [recipes] [-- recipe_arguments...]
140
140
 
141
141
  options:
142
142
  -v, --verbose enable verbose mode
data/Rakefile CHANGED
@@ -5,12 +5,15 @@ task default: %i[features spec]
5
5
 
6
6
  Cucumber::Rake::Task.new(:features)
7
7
 
8
- Cucumber::Rake::Task.new(:features_no_sshd) do |t|
8
+ Cucumber::Rake::Task.new(:features_ci) do |t|
9
9
  t.instance_eval { @desc << ' excluding @ci_skip' }
10
10
  t.cucumber_opts = '--tags ~@ci_skip'
11
+ t.profile = 'quiet' if ENV.key? 'TRAVIS'
11
12
  end
12
13
 
13
- RSpec::Core::RakeTask.new(:spec)
14
+ RSpec::Core::RakeTask.new do |t|
15
+ t.rspec_opts = '--format progress' if ENV.key? 'TRAVIS'
16
+ end
14
17
 
15
18
  desc 'Run CI test suite'
16
- task ci: %i[features_no_sshd spec]
19
+ task ci: %i[features_ci spec]
data/config/cucumber.yaml CHANGED
@@ -1 +1,2 @@
1
- default: --require features/support --require features/steps
1
+ default: --require features/support --require features/steps --no-source
2
+ quiet: --format progress
@@ -3,7 +3,7 @@ Feature: CLI debug option
3
3
  Scenario: reports recipe errors with their cause
4
4
  Given a recipe with an error
5
5
  When I execute the recipe with option -d
6
- Then the output must match /\ARuntimeError:.*\n\ncause:\nRuntimeError:/
6
+ Then the output must match /\ARecipeEvaluationError:.*\n\ncause:\nRuntimeError:/
7
7
 
8
8
  Scenario: does not exclude anything from backtrace
9
9
  Given a recipe using a remote
@@ -11,3 +11,9 @@ Feature: CLI debug option
11
11
  Then the output must contain "producer"
12
12
  And the output must contain "net-ssh"
13
13
  And the output must contain ruby lib directory
14
+
15
+ Scenario: enables debug mode from the environment
16
+ Given a recipe with an error
17
+ And I set the environment variable "PRODUCER_DEBUG"
18
+ When I execute the recipe
19
+ Then the output must contain "producer"
@@ -15,3 +15,8 @@ Feature: CLI dry run option
15
15
  Scenario: prints a warning before any output
16
16
  When I successfully execute the recipe with option -n
17
17
  Then the output must match /\AWarning: running in dry run mode, actions will NOT be applied/
18
+
19
+ Scenario: enables dry run mode from the environment
20
+ Given I set the environment variable "PRODUCER_DRYRUN"
21
+ When I successfully execute the recipe
22
+ Then the output must contain "running in dry run"
@@ -4,7 +4,7 @@ Feature: CLI error reporting
4
4
  Given a recipe with an error
5
5
  When I execute the recipe
6
6
  Then the exit status must be 70
7
- And the output must match /\ARuntimeError: some error\n/
7
+ And the output must match /\ARecipeEvaluationError: some error\n/
8
8
 
9
9
  Scenario: reports errors with a backtrace
10
10
  Given a recipe with an error
@@ -4,14 +4,10 @@ Feature: CLI usage
4
4
  Scenario: prints the usage when an argument is missing
5
5
  When I run `producer`
6
6
  Then the exit status must be 64
7
- And the output must contain exactly:
8
- """
9
- Usage: producer [options] [recipes]
7
+ And the output must contain exactly the usage
10
8
 
11
- options:
12
- -v, --verbose enable verbose mode
13
- -d, --debug enable debug mode
14
- -n, --dry-run enable dry run mode
15
- -t, --target HOST target host
16
-
17
- """
9
+ @exec
10
+ Scenario: prints the usage when unknown option switch is given
11
+ When I run `producer --unknown-option`
12
+ Then the exit status must be 64
13
+ And the output must contain exactly the usage
@@ -41,3 +41,8 @@ Feature: CLI verbose option
41
41
  """
42
42
  When I successfully execute the recipe with option -v
43
43
  Then the output must match /action: .{,70}$/
44
+
45
+ Scenario: enables verbose mode from the environment
46
+ Given I set the environment variable "PRODUCER_VERBOSE"
47
+ When I successfully execute the recipe
48
+ Then the output must contain "Task"
@@ -0,0 +1,9 @@
1
+ Feature: recipe errors
2
+
3
+ Scenario: reports when remote target is invalid
4
+ Given a recipe with:
5
+ """
6
+ task(:some_task) { sh 'true' }
7
+ """
8
+ When I execute the recipe
9
+ Then the output must match /\ARemoteInvalidError:\s+\w+/
@@ -14,7 +14,7 @@ Feature: SSH settings
14
14
  When I successfully execute the recipe
15
15
  Then the output must contain my current login name
16
16
 
17
- @mocked_home_directory
17
+ @mocked-home-directory
18
18
  Scenario: uses configured SSH user name for a given host
19
19
  Given an SSH config with:
20
20
  """
@@ -0,0 +1,3 @@
1
+ Given /^I set the environment variable "([^"]+)"$/ do |variable|
2
+ set_environment_variable variable, 'yes'
3
+ end
@@ -9,7 +9,7 @@ module Producer
9
9
 
10
10
  attr_reader :env, :arguments, :options
11
11
 
12
- def initialize(env, *args, **options)
12
+ def initialize env, *args, **options
13
13
  @env = env
14
14
  @arguments = args
15
15
  @options = options
@@ -24,17 +24,15 @@ module Producer
24
24
  [name, inspect_arguments].join ' '
25
25
  end
26
26
 
27
-
28
- private
27
+ private
29
28
 
30
29
  def inspect_arguments
31
30
  @arguments.inspect[0, INSPECT_ARGUMENTS_SUM_LEN - name.length]
32
31
  end
33
32
 
34
- def check_arguments_size!(size)
35
- if arguments.compact.size != size
36
- fail ArgumentError, '`%s\' action requires %d arguments' % [name, size]
37
- end
33
+ def check_arguments_size! size
34
+ return if arguments.compact.size == size
35
+ fail ArgumentError, '`%s\' action requires %d arguments' % [name, size]
38
36
  end
39
37
  end
40
38
  end
@@ -16,7 +16,7 @@ module Producer
16
16
  end
17
17
 
18
18
  def combined_content
19
- original_content = fs.file_read(@path)
19
+ original_content = fs.file_read @path
20
20
 
21
21
  return @content unless original_content
22
22
  original_content + @content
@@ -18,8 +18,7 @@ module Producer
18
18
  fs.setstat @path, @options unless @options.empty?
19
19
  end
20
20
 
21
-
22
- private
21
+ private
23
22
 
24
23
  def arguments_size
25
24
  2
@@ -14,10 +14,10 @@ module Producer
14
14
  end
15
15
 
16
16
  def apply
17
- @path.descend do |p|
18
- next if fs.dir? p
19
- fs.mkdir p.to_s
20
- fs.setstat p.to_s, @options unless @options.empty?
17
+ @path.descend do |path|
18
+ next if fs.dir? path
19
+ fs.mkdir path.to_s
20
+ fs.setstat path.to_s, @options unless @options.empty?
21
21
  end
22
22
  end
23
23
  end
@@ -12,7 +12,7 @@ module Producer
12
12
  end
13
13
 
14
14
  def apply
15
- remote.execute(@command, output, error_output)
15
+ remote.execute @command, output, error_output
16
16
  end
17
17
  end
18
18
  end
@@ -11,8 +11,7 @@ module Producer
11
11
  'yaml_write'
12
12
  end
13
13
 
14
-
15
- private
14
+ private
16
15
 
17
16
  def arguments_size
18
17
  1
@@ -1,54 +1,63 @@
1
1
  module Producer
2
2
  module Core
3
3
  class CLI
4
- ArgumentError = Class.new(::ArgumentError)
4
+ ArgumentError = Class.new(ArgumentError)
5
5
 
6
- USAGE = "Usage: #{File.basename $0} [options] [recipes]".freeze
6
+ USAGE =
7
+ "Usage: #{File.basename $0} [options] [recipes] [-- recipe_argument...]"
8
+ .freeze
7
9
 
8
10
  EX_USAGE = 64
9
11
  EX_SOFTWARE = 70
10
12
 
11
13
  ARGUMENTS_SEPARATOR = '--'.freeze
12
14
 
15
+ ENV_VERBOSE_KEY = 'PRODUCER_VERBOSE'.freeze
16
+ ENV_DEBUG_KEY = 'PRODUCER_DEBUG'.freeze
17
+ ENV_DRYRUN_KEY = 'PRODUCER_DRYRUN'.freeze
18
+
13
19
  class << self
14
- def run!(arguments, stdin: $stdin, stdout: $stdout, stderr: $stderr)
15
- cli = new(arguments, stdin: stdin, stdout: stdout, stderr: stderr)
16
- begin
17
- cli.parse_arguments!
18
- cli.run
19
- rescue ArgumentError => e
20
- stderr.puts e.message
21
- exit EX_USAGE
22
- rescue StandardError => e
23
- ef = ErrorFormatter.new(
24
- debug: cli.env.debug?,
25
- force_cause: [RecipeEvaluationError]
26
- )
27
- stderr.puts ef.format e
28
- exit EX_SOFTWARE
29
- end
20
+ def run! arguments, stdin: $stdin, stdout: $stdout, stderr: $stderr
21
+ cli = new arguments, ENV, stdin: stdin, stdout: stdout, stderr: stderr
22
+ cli.parse_arguments!
23
+ cli.run
24
+ rescue ArgumentError => e
25
+ stderr.puts e.message
26
+ exit EX_USAGE
27
+ rescue StandardError => e
28
+ ef = ErrorFormatter.new(
29
+ debug: cli.env.debug?,
30
+ force_cause: [RecipeEvaluationError]
31
+ )
32
+ stderr.puts ef.format e
33
+ exit EX_SOFTWARE
30
34
  end
31
35
  end
32
36
 
33
37
  attr_reader :arguments, :stdin, :stdout, :stderr, :env
34
38
 
35
- def initialize(args, stdin: $stdin, stdout: $stdout, stderr: $stderr)
39
+ def initialize args, environment, stdin: $stdin, stdout: $stdout,
40
+ stderr: $stderr
36
41
  @arguments = args
37
42
  @stdin = stdin
38
43
  @stdout = stdout
39
44
  @stderr = stderr
40
45
  @env = build_env
46
+
47
+ configure_environment! environment
41
48
  end
42
49
 
43
50
  def parse_arguments!
44
51
  if @arguments.include? ARGUMENTS_SEPARATOR
45
52
  @arguments, @env.recipe_argv = split_arguments_lists @arguments
46
53
  end
47
- option_parser.parse!(@arguments)
54
+ option_parser.parse! @arguments
48
55
  fail ArgumentError, option_parser if @arguments.empty?
56
+ rescue OptionParser::InvalidOption
57
+ raise ArgumentError, option_parser
49
58
  end
50
59
 
51
- def run(worker: Worker.new(@env))
60
+ def run worker: Worker.new(@env)
52
61
  evaluate_recipes.each { |recipe| worker.process recipe.tasks }
53
62
  ensure
54
63
  @env.cleanup
@@ -58,17 +67,22 @@ module Producer
58
67
  @arguments.map { |e| Recipe::FileEvaluator.evaluate(e, @env) }
59
68
  end
60
69
 
61
-
62
- private
70
+ private
63
71
 
64
72
  def build_env
65
73
  Env.new(input: @stdin, output: @stdout, error_output: @stderr)
66
74
  end
67
75
 
68
- def split_arguments_lists(arguments)
76
+ def configure_environment! environment
77
+ @env.verbose = true if environment.key? ENV_VERBOSE_KEY
78
+ @env.debug = true if environment.key? ENV_DEBUG_KEY
79
+ @env.dry_run = true if environment.key? ENV_DRYRUN_KEY
80
+ end
81
+
82
+ def split_arguments_lists arguments
69
83
  arguments
70
84
  .chunk { |e| e == ARGUMENTS_SEPARATOR }
71
- .reject { |b, a| b }
85
+ .reject { |a, _| a }
72
86
  .map &:last
73
87
  end
74
88
 
@@ -78,23 +92,20 @@ module Producer
78
92
  opts.separator ''
79
93
  opts.separator 'options:'
80
94
 
81
- opts.on '-v', '--verbose', 'enable verbose mode' do |e|
82
- env.verbose = true
83
- end
84
-
85
- opts.on '-d', '--debug', 'enable debug mode' do |e|
86
- env.debug = true
87
- end
88
-
89
- opts.on '-n', '--dry-run', 'enable dry run mode' do |e|
90
- env.dry_run = true
91
- end
92
-
95
+ option_parser_add_boolean_options opts
93
96
  opts.on '-t', '--target HOST', 'target host' do |e|
94
97
  env.target = e
95
98
  end
96
99
  end
97
100
  end
101
+
102
+ def option_parser_add_boolean_options opts
103
+ { v: 'verbose', d: 'debug', n: 'dry run' }.each do |k, v|
104
+ opts.on "-#{k}", "--#{v.tr ' ', '-'}", "enable #{v} mode" do
105
+ env.send "#{v.tr ' ', '_'}=", true
106
+ end
107
+ end
108
+ end
98
109
  end
99
110
  end
100
111
  end
@@ -2,7 +2,7 @@ module Producer
2
2
  module Core
3
3
  class Condition
4
4
  class << self
5
- def define_test(keyword, test)
5
+ def define_test keyword, test
6
6
  {
7
7
  keyword => false,
8
8
  "no_#{keyword}" => true
@@ -19,7 +19,7 @@ module Producer
19
19
  end
20
20
  end
21
21
 
22
- def evaluate(env, *args, &block)
22
+ def evaluate env, *args, &block
23
23
  new.tap do |o|
24
24
  o.instance_eval { @env = env }
25
25
  return_value = o.instance_exec *args, &block
@@ -44,7 +44,7 @@ module Producer
44
44
 
45
45
  attr_reader :tests, :return_value
46
46
 
47
- def initialize(tests = [], return_value = nil)
47
+ def initialize tests = [], return_value = nil
48
48
  @tests = tests
49
49
  @return_value = return_value
50
50
  end
@@ -7,7 +7,8 @@ module Producer
7
7
  attr_reader :input, :output, :error_output, :registry, :logger
8
8
  attr_accessor :target, :verbose, :debug, :dry_run, :recipe_argv
9
9
 
10
- def initialize(input: $stdin, output: $stdout, error_output: $stderr, remote: nil, registry: {})
10
+ def initialize input: $stdin, output: $stdout, error_output: $stderr,
11
+ remote: nil, registry: {}
11
12
  @verbose = @debug = @dry_run = false
12
13
  @input = input
13
14
  @output = output
@@ -20,10 +21,10 @@ module Producer
20
21
  @remote ||= Remote.new(target)
21
22
  end
22
23
 
23
- def [](*args)
24
+ def [] *args
24
25
  @registry.fetch *args
25
26
  rescue KeyError
26
- fail RegistryKeyError, args.first.inspect
27
+ raise RegistryKeyError, args.first.inspect
27
28
  end
28
29
  alias get []
29
30
 
@@ -34,7 +35,7 @@ module Producer
34
35
  end
35
36
  end
36
37
 
37
- def log(message, severity = :info)
38
+ def log message, severity = :info
38
39
  logger.send severity, message
39
40
  end
40
41
 
@@ -8,7 +8,7 @@ module Producer
8
8
  /\/net-sftp/
9
9
  ].freeze
10
10
 
11
- def initialize(debug: false, force_cause: [])
11
+ def initialize debug: false, force_cause: []
12
12
  @debug = debug
13
13
  @force_cause = force_cause
14
14
  end
@@ -17,46 +17,45 @@ module Producer
17
17
  !!@debug
18
18
  end
19
19
 
20
- def format(exception)
21
- lines = format_exception exception, filter: !debug?
22
-
20
+ def format exception
23
21
  if debug? && exception.cause
22
+ lines = format_exception exception, filter: true
24
23
  lines << ''
25
24
  lines << 'cause:'
26
25
  lines << format_exception(exception.cause, filter: false)
26
+ else
27
+ lines = format_exception exception, filter: !debug?
27
28
  end
28
29
 
29
- lines.join("\n")
30
+ lines.join "\n"
30
31
  end
31
32
 
33
+ private
32
34
 
33
- private
34
-
35
- def format_exception(exception, filter: true)
35
+ def format_exception exception, filter: true
36
36
  [
37
37
  format_message(exception),
38
38
  *format_backtrace(exception.backtrace, filter: filter)
39
39
  ]
40
40
  end
41
41
 
42
- def format_message(exception)
43
- exception = exception.cause if @force_cause.include? exception.class
42
+ def format_message exception
44
43
  "#{exception.class.name.split('::').last}: #{exception.message}"
45
44
  end
46
45
 
47
- def format_backtrace(backtrace, filter: true)
46
+ def format_backtrace backtrace, filter: true
48
47
  backtrace = filter_backtrace backtrace if filter
49
48
  indent_backtrace backtrace
50
49
  end
51
50
 
52
- def filter_backtrace(backtrace)
51
+ def filter_backtrace backtrace
53
52
  backtrace.reject do |line|
54
53
  FILTERS.any? { |filter| line =~ filter }
55
54
  end
56
55
  end
57
56
 
58
- def indent_backtrace(backtrace)
59
- backtrace.map { |e| ' %s' % e }
57
+ def indent_backtrace backtrace
58
+ backtrace.map { |e| ' ' + e }
60
59
  end
61
60
  end
62
61
  end
@@ -8,5 +8,6 @@ module Producer
8
8
  RecipeEvaluationError = Class.new(RuntimeError)
9
9
  RemoteCommandExecutionError = Class.new(RuntimeError)
10
10
  RegistryKeyError = Class.new(RuntimeError)
11
+ RemoteInvalidError = Class.new(ArgumentError)
11
12
  end
12
13
  end
@@ -1,14 +1,13 @@
1
1
  module Producer
2
2
  module Core
3
3
  class LoggerFormatter < Logger::Formatter
4
- def call(severity, datetime, progname, message)
4
+ def call severity, _datetime, _progname, message
5
5
  prefix(severity) + message + "\n"
6
6
  end
7
7
 
8
+ private
8
9
 
9
- private
10
-
11
- def prefix(severity)
10
+ def prefix severity
12
11
  severity == 'WARN' ? 'Warning: ' : ''
13
12
  end
14
13
  end
@@ -3,14 +3,14 @@ module Producer
3
3
  class Prompter
4
4
  attr_reader :input, :output
5
5
 
6
- def initialize(input, output)
6
+ def initialize input, output
7
7
  @input = input
8
8
  @output = output
9
9
  end
10
10
 
11
- def prompt(question, choices)
12
- cs = choices.each_with_index.inject('') do |m, (c, i)|
13
- m += "#{i}: #{c.last}\n"
11
+ def prompt question, choices
12
+ cs = choices.each_with_index.inject '' do |m, (c, i)|
13
+ m + "#{i}: #{c.last}\n"
14
14
  end
15
15
  output.puts "#{question}\n#{cs}Choice:"
16
16
  choice = input.gets
@@ -3,12 +3,12 @@ module Producer
3
3
  class Recipe
4
4
  class FileEvaluator
5
5
  class << self
6
- def evaluate(file_path, env)
6
+ def evaluate file_path, env
7
7
  content = File.read(file_path)
8
8
  begin
9
9
  Recipe.new(env).tap { |o| o.instance_eval content, file_path }
10
- rescue Exception => e
11
- fail RecipeEvaluationError, e.message, [
10
+ rescue ::StandardError, ::ScriptError => e
11
+ raise RecipeEvaluationError, e.message, [
12
12
  '%s (recipe)' % file_path,
13
13
  *e.backtrace
14
14
  ]
@@ -2,7 +2,7 @@ module Producer
2
2
  module Core
3
3
  class Recipe
4
4
  class << self
5
- def define_macro(name, block)
5
+ def define_macro name, block
6
6
  [self, Task].each do |klass|
7
7
  klass.class_eval do
8
8
  define_method(name) { |*args| task name, *args, &block }
@@ -10,7 +10,7 @@ module Producer
10
10
  end
11
11
  end
12
12
 
13
- def compose_macro(name, macro, *base_args)
13
+ def compose_macro name, macro, *base_args
14
14
  [self, Task].each do |klass|
15
15
  klass.class_eval do
16
16
  define_method(name) { |*args| send macro, *(base_args + args) }
@@ -24,32 +24,32 @@ module Producer
24
24
  def_delegator :@env, :[], :get
25
25
  attr_reader :env, :tasks
26
26
 
27
- def initialize(env)
27
+ def initialize env
28
28
  @env = env
29
29
  @tasks = []
30
30
  end
31
31
 
32
- def source(filepath)
32
+ def source filepath
33
33
  instance_eval File.read("./#{filepath}.rb"), "#{filepath}.rb"
34
34
  end
35
35
 
36
- def target(hostname = nil)
36
+ def target hostname = nil
37
37
  if hostname then env.target ||= hostname else env.target end
38
38
  end
39
39
 
40
- def task(name, *args, &block)
40
+ def task name, *args, &block
41
41
  Task.evaluate(env, name, *args, &block).tap { |o| @tasks << o }
42
42
  end
43
43
 
44
- def macro(name, &block)
44
+ def macro name, &block
45
45
  self.class.class_eval { define_macro name, block }
46
46
  end
47
47
 
48
- def compose_macro(name, macro, *base_args)
49
- self.class.class_eval { compose_macro name, macro, *base_args}
48
+ def compose_macro name, macro, *base_args
49
+ self.class.class_eval { compose_macro name, macro, *base_args }
50
50
  end
51
51
 
52
- def test_macro(name, &block)
52
+ def test_macro name, &block
53
53
  Condition.define_test(name, block)
54
54
  end
55
55
  end
@@ -3,7 +3,7 @@ module Producer
3
3
  class Remote
4
4
  class Environment
5
5
  class << self
6
- def string_to_hash(str)
6
+ def string_to_hash str
7
7
  Hash[str.each_line.map { |l| l.chomp.split '=', 2 }]
8
8
  end
9
9
  end