itamae 1.1.24 → 1.1.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 415c20d30292ed0e272ed3cbf4ae265ee2e13a49
4
- data.tar.gz: a6084dba3f47e602a7563b8442193417c9ac2b1b
3
+ metadata.gz: 3c28cb6ce63cd01d6be927470128c5e21666a6ce
4
+ data.tar.gz: d9ab010148c396f5c176757ced0ab51ead30846b
5
5
  SHA512:
6
- metadata.gz: e9ae2c9df28f65efdf00a292015ff0267df8e642949a9c58bb15a777af7c01eb75fd6882b164579fcd907f860063908424b767dd45d2266af8ae840b9468cb7b
7
- data.tar.gz: 9871ff0e1ce3528f7f52563bf8037bb55716dce9b8cb5d66233f257ea9202531159a8a679fb4a89d8d72bf7d4d22a239d5d6377e0c678cba4214ec160ca24fbe
6
+ metadata.gz: c36b27f65ae8e7767fc66204dd0a4a6f845cf67ef70925a6f10bac5c227ea2d67ee28d9b9fe81a8d2c642be2a40dfa0ee3ed147a5a72e81d51eb11d2706f2699
7
+ data.tar.gz: 4b8541dca0a658732c6d38606fa6e393fd5557ed5111f016918646d7a2a810c8e918539f3c5e92e0dfe34efe9a0a8438c2fdc050c16656edddd176798b3142bb
data/README.md CHANGED
@@ -49,8 +49,7 @@ Further example is here: [spec/integration/recipes/default.rb](spec/integration/
49
49
 
50
50
  ## Documentations
51
51
 
52
- - http://itamae.kitchen/docs.html
53
- - https://github.com/ryotarai/itamae/wiki
52
+ - https://github.com/itamae-kitchen/itamae/wiki
54
53
 
55
54
  ## Run tests
56
55
 
@@ -68,7 +68,7 @@ module Itamae
68
68
  result = Specinfra::Runner.run_command(command)
69
69
  exit_status = result.exit_status
70
70
 
71
- Logger.formatter.indent do
71
+ Logger.formatter.with_indent do
72
72
  if exit_status == 0 || !options[:error]
73
73
  method = :debug
74
74
  message = "exited with #{exit_status}"
data/lib/itamae/logger.rb CHANGED
@@ -9,7 +9,7 @@ module Itamae
9
9
  attr_accessor :depth
10
10
  attr_accessor :color
11
11
 
12
- INDENT_LENGTH = 3
12
+ INDENT_LENGTH = 2
13
13
 
14
14
  def initialize(*args)
15
15
  super
@@ -26,19 +26,28 @@ module Itamae
26
26
  end
27
27
  end
28
28
 
29
- def indent
30
- @depth += 1
29
+ def with_indent
30
+ indent
31
31
  yield
32
32
  ensure
33
+ outdent
34
+ end
35
+
36
+ def indent
37
+ @depth += 1
38
+ end
39
+
40
+ def outdent
33
41
  @depth -= 1
42
+ @depth = 0 if @depth < 0
34
43
  end
35
44
 
36
45
  def color(code)
37
- @prev_color = @color
46
+ prev_color = @color
38
47
  @color = code
39
48
  yield
40
49
  ensure
41
- @color = @prev_color
50
+ @color = prev_color
42
51
  end
43
52
 
44
53
  private
data/lib/itamae/recipe.rb CHANGED
@@ -43,7 +43,7 @@ module Itamae
43
43
  def run(options = {})
44
44
  Logger.info "Recipe: #{@path}"
45
45
 
46
- Logger.formatter.indent do
46
+ Logger.formatter.with_indent do
47
47
  @children.run(options)
48
48
 
49
49
  @delayed_notifications.uniq do |notification|
@@ -116,26 +116,28 @@ module Itamae
116
116
  end
117
117
 
118
118
  def run(specific_action = nil, options = {})
119
- Logger.info "#{resource_type}[#{resource_name}]"
120
-
121
- Logger.formatter.indent do
122
- if do_not_run_because_of_only_if?
123
- Logger.info "Execution skipped because of only_if attribute"
124
- return
125
- elsif do_not_run_because_of_not_if?
126
- Logger.info "Execution skipped because of not_if attribute"
127
- return
128
- end
119
+ Logger.debug "#{resource_type}[#{resource_name}]"
129
120
 
130
- [specific_action || attributes.action].flatten.each do |action|
131
- run_action(action, options)
132
- end
121
+ Logger.formatter.indent if Logger.debug?
133
122
 
134
- verify unless options[:dry_run]
135
- notify(options) if updated?
123
+ if do_not_run_because_of_only_if?
124
+ Logger.debug "#{resource_type}[#{resource_name}] Execution skipped because of only_if attribute"
125
+ return
126
+ elsif do_not_run_because_of_not_if?
127
+ Logger.debug "#{resource_type}[#{resource_name}] Execution skipped because of not_if attribute"
128
+ return
136
129
  end
130
+
131
+ [specific_action || attributes.action].flatten.each do |action|
132
+ run_action(action, options)
133
+ end
134
+
135
+ verify unless options[:dry_run]
136
+ notify(options) if updated?
137
+
138
+ Logger.formatter.outdent if Logger.debug?
137
139
  rescue Backend::CommandExecutionError
138
- Logger.error "Failed."
140
+ Logger.error "#{resource_type}[#{resource_name}] Failed."
139
141
  exit 2
140
142
  end
141
143
 
@@ -164,27 +166,28 @@ module Itamae
164
166
 
165
167
  clear_current_attributes
166
168
 
167
- Logger.info "action: #{action}"
169
+ Logger.debug "#{resource_type}[#{resource_name}] action: #{action}"
168
170
 
169
171
  return if action == :nothing
170
172
 
171
- Logger.formatter.indent do
172
- Logger.debug "(in pre_action)"
173
- pre_action
174
-
175
- Logger.debug "(in set_current_attributes)"
176
- set_current_attributes
173
+ Logger.formatter.indent if Logger.debug?
174
+ Logger.debug "(in pre_action)"
175
+ pre_action
177
176
 
178
- Logger.debug "(in show_differences)"
179
- show_differences
177
+ Logger.debug "(in set_current_attributes)"
178
+ set_current_attributes
180
179
 
181
- unless options[:dry_run]
182
- public_send("action_#{action}".to_sym, options)
183
- end
180
+ Logger.debug "(in show_differences)"
181
+ show_differences
184
182
 
185
- updated! if different?
183
+ unless options[:dry_run]
184
+ public_send("action_#{action}".to_sym, options)
186
185
  end
187
186
 
187
+ updated! if different?
188
+
189
+ Logger.formatter.outdent if Logger.debug?
190
+
188
191
  @current_action = nil
189
192
  end
190
193
 
@@ -215,13 +218,13 @@ module Itamae
215
218
  # ignore
216
219
  elsif current_value.nil? && !value.nil?
217
220
  Logger.formatter.color :green do
218
- Logger.info "#{key} will be '#{value}'"
221
+ Logger.info "#{resource_type}[#{resource_name}] #{key} will be '#{value}'"
219
222
  end
220
223
  elsif current_value == value || value.nil?
221
- Logger.debug "#{key} will not change (current value is '#{current_value}')"
224
+ Logger.debug "#{resource_type}[#{resource_name}] #{key} will not change (current value is '#{current_value}')"
222
225
  else
223
226
  Logger.formatter.color :green do
224
- Logger.info "#{key} will change from '#{current_value}' to '#{value}'"
227
+ Logger.info "#{resource_type}[#{resource_name}] #{key} will change from '#{current_value}' to '#{value}'"
225
228
  end
226
229
  end
227
230
  end
@@ -359,7 +362,7 @@ module Itamae
359
362
  return if @verify_commands.empty?
360
363
 
361
364
  Logger.info "Verifying..."
362
- Logger.formatter.indent do
365
+ Logger.formatter.with_indent do
363
366
  @verify_commands.each do |command|
364
367
  run_command(command)
365
368
  end
@@ -1 +1 @@
1
- 1.1.24
1
+ 1.1.25
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.24
4
+ version: 1.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor