itamae 1.4.5 → 1.5.0

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: a1702b011e6985d136ff6cd8d86d962a0ecb4c0a
4
- data.tar.gz: a6e3caf02febbc6229fc4762abe498626c734b6f
3
+ metadata.gz: 5824e615aa71ac1b33b444d24ef09a784ce481fe
4
+ data.tar.gz: 18ded54560fa8f2c95d94bdee351d33edfc53b06
5
5
  SHA512:
6
- metadata.gz: dfda34ba80a5c2f0bc1eaa7a8070c07387b44e9cfcea7d86ab5edc5dff9a06772a82f6f290d17191b3c35f6d42f179185a95183d1c31962034c2a69ec504ea28
7
- data.tar.gz: c558ee700af41b9fec212cffc761bc90859f4236e57583363fbd7ea8a4adb4e54884c467919a8896c515f34dcc64d53d987d9941e8e65617a74eff2d6972fc2e
6
+ metadata.gz: f04064f58c4b1ed7130dee98dd8d640562140e49b49de8f4cf098181fe628fd1eafa9ff6350ed3e3213d52f9b1a160133e6169c973a34a556b095bd3a29a540a
7
+ data.tar.gz: 7180ffdc7d22da2ba174d6c9985e8bf596ba458943e3483a4391af88a84da75ff6535e2627aebdcce58fb60b4b72305b8ff7f4fb8ff389f94400fa5e31b07697
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v1.5.0
2
+
3
+ Improvements
4
+
5
+ - [Make a logger injectable from outside of Itamae.](https://github.com/itamae-kitchen/itamae/pull/160)
6
+
1
7
  ## v1.4.5
2
8
 
3
9
  Improvements
@@ -417,4 +423,3 @@ Features
417
423
  Incompatible changes
418
424
 
419
425
  - `uid` and `gid` attributes of `user` resource accept only Integer. (https://github.com/ryotarai/itamae/pull/65)
420
-
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Itamae [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![wercker status](https://app.wercker.com/status/3e7be3b982d3671940a07e3ef45d9f5f/s/master "wercker status")](https://app.wercker.com/project/bykey/3e7be3b982d3671940a07e3ef45d9f5f) [![Slack](https://itamae-slackin.herokuapp.com/badge.svg)](https://itamae-slackin.herokuapp.com/)
1
+ # Itamae [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![wercker status](https://app.wercker.com/status/3e7be3b982d3671940a07e3ef45d9f5f/s/master "wercker status")](https://app.wercker.com/project/bykey/3e7be3b982d3671940a07e3ef45d9f5f) [![Slack](https://img.shields.io/badge/slack-join-blue.svg)](https://itamae-slackin.herokuapp.com/)
2
2
 
3
3
  Simple and lightweight configuration management tool inspired by Chef.
4
4
 
@@ -6,9 +6,9 @@ Simple and lightweight configuration management tool inspired by Chef.
6
6
 
7
7
  ## Concept
8
8
 
9
- - Chef-like DSL
9
+ - Chef-like DSL (but not compatible with Chef)
10
10
  - Simpler and lighter weight than Chef
11
- - Not compatible with Chef
11
+ - Only recipes
12
12
  - Idempotent
13
13
 
14
14
  ## Installation
@@ -19,9 +19,49 @@ $ gem install itamae
19
19
 
20
20
  ## Getting Started
21
21
 
22
- https://github.com/itamae-kitchen/itamae/wiki/Getting-Started
22
+ Create a recipe file as `recipe.rb`:
23
23
 
24
- ## Documentations
24
+ ```ruby
25
+ package 'nginx' do
26
+ action :install
27
+ end
28
+
29
+ service 'nginx' do
30
+ action [:enable, :start]
31
+ end
32
+ ```
33
+
34
+ And then excute `itamae` command to apply a recipe to a local machine.
35
+
36
+ ```
37
+ $ itamae local recipe.rb
38
+ INFO : Starting Itamae...
39
+ INFO : Recipe: /home/user/recipe.rb
40
+ INFO : package[nginx]
41
+ INFO : action: install
42
+ INFO : installed will change from 'false' to 'true'
43
+ INFO : service[nginx]
44
+ INFO : action: enable
45
+ INFO : action: start
46
+ ```
47
+
48
+ Or you can apply a recipe to a remote machine by `itamae ssh`.
49
+
50
+ ```
51
+ $ itamae ssh --host host001.example.jp recipe.rb
52
+ ```
53
+
54
+ You can also apply a recipe to Vagrant VM by `itamae ssh --vagrant`.
55
+
56
+ ```
57
+ $ itamae ssh --vagrant --host vm_name recipe.rb
58
+ ```
59
+
60
+ You can find further information to use Itamae on [Itamae Wiki](https://github.com/itamae-kitchen/itamae/wiki).
61
+
62
+ Enjoy!
63
+
64
+ ## Documentation
25
65
 
26
66
  https://github.com/itamae-kitchen/itamae/wiki
27
67
 
@@ -44,11 +44,11 @@ module Itamae
44
44
  options = {error: true}.merge(options)
45
45
 
46
46
  command = build_command(commands, options)
47
- Logger.debug "Executing `#{command}`..."
47
+ Itamae.logger.debug "Executing `#{command}`..."
48
48
 
49
49
  result = nil
50
50
 
51
- Logger.formatter.with_indent do
51
+ Itamae.logger.with_indent do
52
52
  reset_output_handler
53
53
  result = @backend.run_command(command)
54
54
  flush_output_handler_buffer
@@ -60,7 +60,7 @@ module Itamae
60
60
  method = :error
61
61
  message = "Command `#{command}` failed. (exit status: #{result.exit_status})"
62
62
 
63
- unless Logger.logger.level == ::Logger::DEBUG
63
+ unless Itamae.logger.level == ::Logger::DEBUG
64
64
  result.stdout.each_line do |l|
65
65
  log_output_line("stdout", l, :error)
66
66
  end
@@ -70,7 +70,7 @@ module Itamae
70
70
  end
71
71
  end
72
72
 
73
- Logger.public_send(method, message)
73
+ Itamae.logger.public_send(method, message)
74
74
  end
75
75
 
76
76
  if options[:error] && result.exit_status != 0
@@ -86,15 +86,15 @@ module Itamae
86
86
 
87
87
  def receive_file(src, dst = nil)
88
88
  if dst
89
- Logger.debug "Receiving a file from '#{src}' to '#{dst}'..."
89
+ Itamae.logger.debug "Receiving a file from '#{src}' to '#{dst}'..."
90
90
  else
91
- Logger.debug "Receiving a file from '#{src}'..."
91
+ Itamae.logger.debug "Receiving a file from '#{src}'..."
92
92
  end
93
93
  @backend.receive_file(src, dst)
94
94
  end
95
95
 
96
96
  def send_file(src, dst)
97
- Logger.debug "Sending a file from '#{src}' to '#{dst}'..."
97
+ Itamae.logger.debug "Sending a file from '#{src}' to '#{dst}'..."
98
98
  unless ::File.exist?(src)
99
99
  raise SourceNotExistError, "The file '#{src}' doesn't exist."
100
100
  end
@@ -105,7 +105,7 @@ module Itamae
105
105
  end
106
106
 
107
107
  def send_directory(src, dst)
108
- Logger.debug "Sending a directory from '#{src}' to '#{dst}'..."
108
+ Itamae.logger.debug "Sending a directory from '#{src}' to '#{dst}'..."
109
109
  unless ::File.exist?(src)
110
110
  raise SourceNotExistError, "The directory '#{src}' doesn't exist."
111
111
  end
@@ -157,7 +157,7 @@ module Itamae
157
157
 
158
158
  def log_output_line(output_name, line, severity = :debug)
159
159
  line = line.gsub(/[[:cntrl:]]/, '')
160
- Logger.public_send(severity, "#{output_name} | #{line}")
160
+ Itamae.logger.public_send(severity, "#{output_name} | #{line}")
161
161
  end
162
162
 
163
163
  def build_command(commands, options)
@@ -245,7 +245,7 @@ module Itamae
245
245
  class Docker < Base
246
246
  def finalize
247
247
  image = @backend.commit_container
248
- Logger.info "Image created: #{image.id}"
248
+ Itamae.logger.info "Image created: #{image.id}"
249
249
  end
250
250
 
251
251
  private
@@ -253,12 +253,12 @@ module Itamae
253
253
  begin
254
254
  require 'docker'
255
255
  rescue LoadError
256
- Logger.fatal "To use docker backend, please install 'docker-api' gem"
256
+ Itamae.logger.fatal "To use docker backend, please install 'docker-api' gem"
257
257
  end
258
258
 
259
259
  # TODO: Move to Specinfra?
260
260
  Excon.defaults[:ssl_verify_peer] = @options[:tls_verify_peer]
261
- ::Docker.logger = Logger
261
+ ::Docker.logger = Itamae.logger
262
262
 
263
263
  Specinfra::Backend::Docker.new(
264
264
  docker_image: @options[:image],
data/lib/itamae/cli.rb CHANGED
@@ -10,8 +10,8 @@ module Itamae
10
10
  opts = Config.new(opts).load
11
11
  super(args, opts, config)
12
12
 
13
- Itamae::Logger.level = ::Logger.const_get(options[:log_level].upcase)
14
- Itamae::Logger.formatter.colored = options[:color]
13
+ Itamae.logger.level = ::Logger.const_get(options[:log_level].upcase)
14
+ Itamae.logger.formatter.colored = options[:color]
15
15
  end
16
16
 
17
17
  def self.define_exec_options
data/lib/itamae/logger.rb CHANGED
@@ -4,28 +4,7 @@ require 'ansi/code'
4
4
 
5
5
  module Itamae
6
6
  module Logger
7
- class Formatter
8
- attr_accessor :colored
9
- attr_accessor :depth
10
- attr_accessor :color
11
-
12
- INDENT_LENGTH = 2
13
-
14
- def initialize(*args)
15
- super
16
-
17
- @depth = 0
18
- end
19
-
20
- def call(severity, datetime, progname, msg)
21
- log = "%s : %s%s\n" % ["%5s" % severity, ' ' * INDENT_LENGTH * depth , msg2str(msg)]
22
- if colored
23
- colorize(log, severity)
24
- else
25
- log
26
- end
27
- end
28
-
7
+ module IndentHelper
29
8
  def with_indent
30
9
  indent
31
10
  yield
@@ -42,12 +21,42 @@ module Itamae
42
21
  end
43
22
 
44
23
  def indent
45
- @depth += 1
24
+ self.indent_depth += 1
46
25
  end
47
26
 
48
27
  def outdent
49
- @depth -= 1
50
- @depth = 0 if @depth < 0
28
+ self.indent_depth -= 1
29
+ self.indent_depth = 0 if self.indent_depth < 0
30
+ end
31
+
32
+ def indent_depth
33
+ @indent_depth ||= 0
34
+ end
35
+
36
+ def indent_depth=(val)
37
+ @indent_depth = val
38
+ end
39
+
40
+ %w!debug info warn error fatal unknown!.each do |level|
41
+ module_eval(<<-EOC, __FILE__, __LINE__ + 1)
42
+ def #{level}(msg)
43
+ super(" " * indent_depth + msg)
44
+ end
45
+ EOC
46
+ end
47
+ end
48
+
49
+ class Formatter
50
+ attr_accessor :colored
51
+ attr_accessor :color
52
+
53
+ def call(severity, datetime, progname, msg)
54
+ log = "%s : %s\n" % ["%5s" % severity, msg2str(msg)]
55
+ if colored
56
+ colorize(log, severity)
57
+ else
58
+ log
59
+ end
51
60
  end
52
61
 
53
62
  def color(code)
@@ -89,37 +98,19 @@ module Itamae
89
98
  ANSI.public_send(color_code) { str }
90
99
  end
91
100
  end
101
+ end
92
102
 
93
- class << self
94
- def logger
95
- @logger ||= create_logger
96
- end
97
-
98
- def log_device
99
- @log_device || $stdout
100
- end
101
-
102
- def log_device=(value)
103
- @log_device = value
104
- @logger = create_logger
105
- end
106
-
107
- private
108
-
109
- def create_logger
110
- ::Logger.new(log_device).tap do |logger|
111
- logger.formatter = Formatter.new
112
- end
113
- end
103
+ @logger = ::Logger.new($stdout).tap do |l|
104
+ l.formatter = Itamae::Logger::Formatter.new
105
+ end.extend(Itamae::Logger::IndentHelper)
114
106
 
115
- def respond_to_missing?(method, include_private = false)
116
- logger.respond_to?(method)
117
- end
107
+ class << self
108
+ def logger
109
+ @logger
110
+ end
118
111
 
119
- def method_missing(method, *args, &block)
120
- logger.public_send(method, *args, &block)
121
- end
112
+ def logger=(l)
113
+ @logger = l.extend(Itamae::Logger::IndentHelper)
122
114
  end
123
115
  end
124
116
  end
125
-
data/lib/itamae/node.rb CHANGED
@@ -34,7 +34,7 @@ module Itamae
34
34
  errors = Schash::Validator.new(&block).validate(@mash)
35
35
  unless errors.empty?
36
36
  errors.each do |error|
37
- Logger.error "'#{error.position.join('->')}' #{error.message}"
37
+ Itamae.logger.error "'#{error.position.join('->')}' #{error.message}"
38
38
  end
39
39
  raise ValidationError
40
40
  end
@@ -32,7 +32,7 @@ module Itamae
32
32
 
33
33
  def validate!
34
34
  unless [:delay, :delayed, :immediately].include?(timing)
35
- Logger.error "'#{timing}' is not valid notification timing. (Valid option is delayed or immediately)"
35
+ Itamae.logger.error "'#{timing}' is not valid notification timing. (Valid option is delayed or immediately)"
36
36
  abort
37
37
  end
38
38
  end
data/lib/itamae/recipe.rb CHANGED
@@ -49,7 +49,7 @@ module Itamae
49
49
  def run(options = {})
50
50
  show_banner
51
51
 
52
- Logger.formatter.with_indent do
52
+ Itamae.logger.with_indent do
53
53
  @children.run(options)
54
54
  run_delayed_notifications(options)
55
55
  end
@@ -68,7 +68,7 @@ module Itamae
68
68
  end
69
69
 
70
70
  def show_banner
71
- Logger.info "Recipe: #{@path}"
71
+ Itamae.logger.info "Recipe: #{@path}"
72
72
  end
73
73
 
74
74
  class EvalContext
@@ -118,7 +118,7 @@ module Itamae
118
118
  end
119
119
 
120
120
  if runner.children.find_recipe_by_path(path)
121
- Logger.debug "Recipe, #{path}, is skipped because it is already included"
121
+ Itamae.logger.debug "Recipe, #{path}, is skipped because it is already included"
122
122
  return
123
123
  end
124
124
 
@@ -151,7 +151,7 @@ module Itamae
151
151
  private
152
152
 
153
153
  def show_banner
154
- Logger.debug "#{@definition.resource_type}[#{@definition.resource_name}]"
154
+ Itamae.logger.debug "#{@definition.resource_type}[#{@definition.resource_name}]"
155
155
  end
156
156
  end
157
157
  end
@@ -42,7 +42,7 @@ module Itamae
42
42
  def define_resource(name, klass)
43
43
  class_name = to_camel_case(name.to_s)
44
44
  if Resource.const_defined?(class_name)
45
- Logger.warn "Redefine class. (#{class_name})"
45
+ Itamae.logger.warn "Redefine class. (#{class_name})"
46
46
  return
47
47
  end
48
48
 
@@ -121,14 +121,14 @@ module Itamae
121
121
  end
122
122
 
123
123
  def run(specific_action = nil, options = {})
124
- Logger.debug "#{resource_type}[#{resource_name}]"
124
+ Itamae.logger.debug "#{resource_type}[#{resource_name}]"
125
125
 
126
- Logger.formatter.with_indent_if(Logger.debug?) do
126
+ Itamae.logger.with_indent_if(Itamae.logger.debug?) do
127
127
  if do_not_run_because_of_only_if?
128
- Logger.debug "#{resource_type}[#{resource_name}] Execution skipped because of only_if attribute"
128
+ Itamae.logger.debug "#{resource_type}[#{resource_name}] Execution skipped because of only_if attribute"
129
129
  return
130
130
  elsif do_not_run_because_of_not_if?
131
- Logger.debug "#{resource_type}[#{resource_name}] Execution skipped because of not_if attribute"
131
+ Itamae.logger.debug "#{resource_type}[#{resource_name}] Execution skipped because of not_if attribute"
132
132
  return
133
133
  end
134
134
 
@@ -142,7 +142,7 @@ module Itamae
142
142
 
143
143
  @updated = false
144
144
  rescue Backend::CommandExecutionError
145
- Logger.error "#{resource_type}[#{resource_name}] Failed."
145
+ Itamae.logger.error "#{resource_type}[#{resource_name}] Failed."
146
146
  exit 2
147
147
  end
148
148
 
@@ -172,24 +172,24 @@ module Itamae
172
172
 
173
173
  clear_current_attributes
174
174
 
175
- Logger.debug "#{resource_type}[#{resource_name}] action: #{action}"
175
+ Itamae.logger.debug "#{resource_type}[#{resource_name}] action: #{action}"
176
176
 
177
177
  return if action == :nothing
178
178
 
179
- Logger.formatter.with_indent_if(Logger.debug?) do
180
- Logger.debug "(in pre_action)"
179
+ Itamae.logger.with_indent_if(Itamae.logger.debug?) do
180
+ Itamae.logger.debug "(in pre_action)"
181
181
  pre_action
182
182
 
183
- Logger.debug "(in set_current_attributes)"
183
+ Itamae.logger.debug "(in set_current_attributes)"
184
184
  set_current_attributes
185
185
 
186
- Logger.debug "(in show_differences)"
186
+ Itamae.logger.debug "(in show_differences)"
187
187
  show_differences
188
188
 
189
189
  method_name = "action_#{action}"
190
190
  if options[:dry_run]
191
191
  unless respond_to?(method_name)
192
- Logger.error "action #{action.inspect} is unavailable"
192
+ Itamae.logger.error "action #{action.inspect} is unavailable"
193
193
  end
194
194
  else
195
195
  public_send(method_name, options)
@@ -228,14 +228,14 @@ module Itamae
228
228
  if current_value.nil? && value.nil?
229
229
  # ignore
230
230
  elsif current_value.nil? && !value.nil?
231
- Logger.formatter.color :green do
232
- Logger.info "#{resource_type}[#{resource_name}] #{key} will be '#{value}'"
231
+ Itamae.logger.formatter.color :green do
232
+ Itamae.logger.info "#{resource_type}[#{resource_name}] #{key} will be '#{value}'"
233
233
  end
234
234
  elsif current_value == value || value.nil?
235
- Logger.debug "#{resource_type}[#{resource_name}] #{key} will not change (current value is '#{current_value}')"
235
+ Itamae.logger.debug "#{resource_type}[#{resource_name}] #{key} will not change (current value is '#{current_value}')"
236
236
  else
237
- Logger.formatter.color :green do
238
- Logger.info "#{resource_type}[#{resource_name}] #{key} will change from '#{current_value}' to '#{value}'"
237
+ Itamae.logger.formatter.color :green do
238
+ Itamae.logger.info "#{resource_type}[#{resource_name}] #{key} will change from '#{current_value}' to '#{value}'"
239
239
  end
240
240
  end
241
241
  end
@@ -319,7 +319,7 @@ module Itamae
319
319
  end
320
320
 
321
321
  def updated!
322
- Logger.debug "This resource is updated."
322
+ Itamae.logger.debug "This resource is updated."
323
323
  @updated = true
324
324
  end
325
325
 
@@ -337,10 +337,10 @@ module Itamae
337
337
  message << " (immediately)"
338
338
  end
339
339
 
340
- Logger.info message
340
+ Itamae.logger.info message
341
341
 
342
342
  if notification.instance_of?(Subscription)
343
- Logger.info "(because it subscribes this resource)"
343
+ Itamae.logger.info "(because it subscribes this resource)"
344
344
  end
345
345
 
346
346
  if notification.delayed?
@@ -354,8 +354,8 @@ module Itamae
354
354
  def verify
355
355
  return if @verify_commands.empty?
356
356
 
357
- Logger.info "Verifying..."
358
- Logger.formatter.with_indent do
357
+ Itamae.logger.info "Verifying..."
358
+ Itamae.logger.with_indent do
359
359
  @verify_commands.each do |command|
360
360
  run_command(command)
361
361
  end
@@ -364,4 +364,3 @@ module Itamae
364
364
  end
365
365
  end
366
366
  end
367
-
@@ -110,9 +110,9 @@ module Itamae
110
110
  diff = run_command(["diff", "-u", attributes.path, @temppath], error: false)
111
111
  if diff.exit_status == 0
112
112
  # no change
113
- Logger.debug "file content will not change"
113
+ Itamae.logger.debug "file content will not change"
114
114
  else
115
- Logger.info "diff:"
115
+ Itamae.logger.info "diff:"
116
116
  diff.stdout.each_line do |line|
117
117
  color = if line.start_with?('+')
118
118
  :green
@@ -121,8 +121,8 @@ module Itamae
121
121
  else
122
122
  :clear
123
123
  end
124
- Logger.formatter.color(color) do
125
- Logger.info line.chomp
124
+ Itamae.logger.formatter.color(color) do
125
+ Itamae.logger.info line.chomp
126
126
  end
127
127
  end
128
128
  end
@@ -44,11 +44,11 @@ module Itamae
44
44
  diff = run_command(["diff", "-u", attributes.path, @temppath], error: false)
45
45
  if diff.exit_status == 0
46
46
  # no change
47
- Logger.debug "directory content will not change"
47
+ Itamae.logger.debug "directory content will not change"
48
48
  else
49
- Logger.info "diff:"
49
+ Itamae.logger.info "diff:"
50
50
  diff.stdout.each_line do |line|
51
- Logger.info "#{line.strip}"
51
+ Itamae.logger.info "#{line.strip}"
52
52
  end
53
53
  end
54
54
  end
@@ -27,7 +27,7 @@ module Itamae
27
27
  source_file_exts.each do |ext|
28
28
  path = ::File.join(@recipe.dir, source_file_dir, "#{dirs[i..-1].join("/")}#{ext}")
29
29
  if ::File.exist?(path)
30
- Logger.debug "#{path} is used as a source file."
30
+ Itamae.logger.debug "#{path} is used as a source file."
31
31
  return path
32
32
  else
33
33
  searched_paths << path
data/lib/itamae/runner.rb CHANGED
@@ -6,14 +6,14 @@ module Itamae
6
6
  class Runner
7
7
  class << self
8
8
  def run(recipe_files, backend_type, options)
9
- Logger.info "Starting Itamae..."
9
+ Itamae.logger.info "Starting Itamae..."
10
10
 
11
11
  backend = Backend.create(backend_type, options)
12
12
  runner = self.new(backend, options)
13
13
  runner.load_recipes(recipe_files)
14
14
 
15
15
  if dot_file = options[:dot]
16
- Logger.info "Writing dependency graph in DOT to #{dot_file}..."
16
+ Itamae.logger.info "Writing dependency graph in DOT to #{dot_file}..."
17
17
  open(dot_file, 'w') do |f|
18
18
  f.write(runner.children.deps_in_dot)
19
19
  end
@@ -61,23 +61,23 @@ module Itamae
61
61
  if @options[:ohai]
62
62
  unless @backend.run_command("which ohai", error: false).exit_status == 0
63
63
  # install Ohai
64
- Logger.info "Installing Chef package... (to use Ohai)"
64
+ Itamae.logger.info "Installing Chef package... (to use Ohai)"
65
65
  @backend.run_command("curl -L https://www.opscode.com/chef/install.sh | bash")
66
66
  end
67
67
 
68
- Logger.info "Loading node data via ohai..."
68
+ Itamae.logger.info "Loading node data via ohai..."
69
69
  hash.merge!(JSON.parse(@backend.run_command("ohai").stdout))
70
70
  end
71
71
 
72
72
  if @options[:node_json]
73
73
  path = File.expand_path(@options[:node_json])
74
- Logger.info "Loading node data from #{path}..."
74
+ Itamae.logger.info "Loading node data from #{path}..."
75
75
  hash.merge!(JSON.load(open(path)))
76
76
  end
77
77
 
78
78
  if @options[:node_yaml]
79
79
  path = File.expand_path(@options[:node_yaml])
80
- Logger.info "Loading node data from #{path}..."
80
+ Itamae.logger.info "Loading node data from #{path}..."
81
81
  hash.merge!(YAML.load(open(path)))
82
82
  end
83
83
 
@@ -1 +1 @@
1
- 1.4.5
1
+ 1.5.0
@@ -204,7 +204,7 @@ end
204
204
 
205
205
  local_ruby_block "greeting" do
206
206
  block do
207
- Itamae::Logger.info "板前"
207
+ Itamae.logger.info "板前"
208
208
  end
209
209
  end
210
210
 
@@ -124,7 +124,7 @@ describe TestResource do
124
124
  context 'with dry_run' do
125
125
  context 'when specified action is unavailable' do
126
126
  it 'logs error' do
127
- expect(Itamae::Logger).to receive(:error).with(/action :name is unavailable/)
127
+ expect(Itamae.logger).to receive(:error).with(/action :name is unavailable/)
128
128
  subject.run(nil, dry_run: true)
129
129
  end
130
130
  end
@@ -19,6 +19,5 @@ RSpec.configure do |config|
19
19
  config.raise_errors_for_deprecations!
20
20
  end
21
21
 
22
- Itamae::Logger.log_device = StringIO.new
22
+ Itamae.logger = ::Logger.new(StringIO.new)
23
23
  Specinfra.configuration.error_on_missing_backend_type = false
24
-
data/wercker.yml CHANGED
@@ -7,7 +7,7 @@ build:
7
7
  steps:
8
8
  # Uncomment this to force RVM to use a specific Ruby version
9
9
  - rvm-use:
10
- version: 2.1.4
10
+ version: 2.2.3
11
11
 
12
12
  - script:
13
13
  name: update bundler
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.4.5
4
+ version: 1.5.0
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-08-18 00:00:00.000000000 Z
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -249,7 +249,6 @@ files:
249
249
  - spec/integration/spec_helper.rb
250
250
  - spec/unit/lib/itamae/backend_spec.rb
251
251
  - spec/unit/lib/itamae/config_spec.rb
252
- - spec/unit/lib/itamae/logger_spec.rb
253
252
  - spec/unit/lib/itamae/node_spec.rb
254
253
  - spec/unit/lib/itamae/recipe_spec.rb
255
254
  - spec/unit/lib/itamae/resource/base_spec.rb
@@ -298,7 +297,6 @@ test_files:
298
297
  - spec/integration/spec_helper.rb
299
298
  - spec/unit/lib/itamae/backend_spec.rb
300
299
  - spec/unit/lib/itamae/config_spec.rb
301
- - spec/unit/lib/itamae/logger_spec.rb
302
300
  - spec/unit/lib/itamae/node_spec.rb
303
301
  - spec/unit/lib/itamae/recipe_spec.rb
304
302
  - spec/unit/lib/itamae/resource/base_spec.rb
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Itamae
4
- describe Logger do
5
- let(:io) { StringIO.new }
6
-
7
- before do
8
- Logger.log_device = io
9
- end
10
-
11
- [:fatal, :error, :warn, :info, :debug].each do |level|
12
- describe "##{level}" do
13
- it "puts #{level} log" do
14
- Logger.public_send(level, "CONTENT")
15
- expect(io.string).to include('CONTENT')
16
- end
17
- end
18
- end
19
- end
20
- end