itamae 1.1.7 → 1.1.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +1 -0
- data/lib/itamae/logger.rb +26 -13
- data/lib/itamae/recipe.rb +6 -0
- data/lib/itamae/resource/base.rb +7 -5
- data/lib/itamae/version.txt +1 -1
- data/spec/integration/default_spec.rb +4 -0
- data/spec/integration/recipes/redefine.rb +20 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d44fdcac91acf929fbf94754542e1521a8528b67
|
4
|
+
data.tar.gz: 17770615b03da709e699397bddffe2556f01a9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20e405c5105a2b00d04e20669c4304a73ad21ea6490876dcc4321eb8ef5f837f0f488cb2b2aaef8b36cf5d13b2551920d5b0da88750299cec071ded07a18e4a6
|
7
|
+
data.tar.gz: 0e0761e611fda6e8fef0ddbbfa23b1f3a13bb9a2a02d0cf13e91b0f372545dbc812ac6af7b8e0484723946ef54cae57678d871a34883aa7c58b4c167643e925a
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Itamae [](http://badge.fury.io/rb/itamae) [](https://codeclimate.com/github/ryotarai/itamae) [](http://badge.fury.io/rb/itamae) [](https://codeclimate.com/github/ryotarai/itamae) [](https://app.wercker.com/project/bykey/3e7be3b982d3671940a07e3ef45d9f5f) [](https://gitter.im/itamae-kitchen/itamae?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
2
2
|
|
3
3
|
Simple and lightweight configuration management tool inspired by Chef.
|
4
4
|
|
data/Rakefile
CHANGED
data/lib/itamae/logger.rb
CHANGED
@@ -7,6 +7,7 @@ module Itamae
|
|
7
7
|
class Formatter
|
8
8
|
attr_accessor :colored
|
9
9
|
attr_accessor :depth
|
10
|
+
attr_accessor :color
|
10
11
|
|
11
12
|
INDENT_LENGTH = 3
|
12
13
|
|
@@ -19,7 +20,7 @@ module Itamae
|
|
19
20
|
def call(severity, datetime, progname, msg)
|
20
21
|
log = "%s : %s%s\n" % ["%5s" % severity, ' ' * INDENT_LENGTH * depth , msg2str(msg)]
|
21
22
|
if colored
|
22
|
-
|
23
|
+
colorize(log, severity)
|
23
24
|
else
|
24
25
|
log
|
25
26
|
end
|
@@ -32,6 +33,14 @@ module Itamae
|
|
32
33
|
@depth -= 1
|
33
34
|
end
|
34
35
|
|
36
|
+
def color(code)
|
37
|
+
@prev_color = @color
|
38
|
+
@color = code
|
39
|
+
yield
|
40
|
+
ensure
|
41
|
+
@color = @prev_color
|
42
|
+
end
|
43
|
+
|
35
44
|
private
|
36
45
|
def msg2str(msg)
|
37
46
|
case msg
|
@@ -45,17 +54,21 @@ module Itamae
|
|
45
54
|
end
|
46
55
|
end
|
47
56
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def colorize(str, severity)
|
58
|
+
if @color
|
59
|
+
color_code = @color
|
60
|
+
else
|
61
|
+
color_code = case severity
|
62
|
+
when "INFO"
|
63
|
+
:clear
|
64
|
+
when "WARN"
|
65
|
+
:magenta
|
66
|
+
when "ERROR"
|
67
|
+
:red
|
68
|
+
else
|
69
|
+
:clear
|
70
|
+
end
|
71
|
+
end
|
59
72
|
ANSI.public_send(color_code) { str }
|
60
73
|
end
|
61
74
|
end
|
@@ -73,7 +86,7 @@ module Itamae
|
|
73
86
|
@log_device = value
|
74
87
|
@logger = create_logger
|
75
88
|
end
|
76
|
-
|
89
|
+
|
77
90
|
private
|
78
91
|
|
79
92
|
def create_logger
|
data/lib/itamae/recipe.rb
CHANGED
@@ -80,6 +80,12 @@ module Itamae
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def define(name, params = {}, &block)
|
83
|
+
class_name = Resource.get_resource_class_name(name)
|
84
|
+
if Resource.const_defined?(class_name)
|
85
|
+
Logger.warn "Redefine class. (#{class_name})"
|
86
|
+
return
|
87
|
+
end
|
88
|
+
|
83
89
|
Resource.const_set(
|
84
90
|
Resource.get_resource_class_name(name),
|
85
91
|
Definition.create_class(name, params, &block)
|
data/lib/itamae/resource/base.rb
CHANGED
@@ -205,11 +205,15 @@ module Itamae
|
|
205
205
|
if current_value.nil? && value.nil?
|
206
206
|
# ignore
|
207
207
|
elsif current_value.nil? && !value.nil?
|
208
|
-
Logger.
|
208
|
+
Logger.formatter.color :green do
|
209
|
+
Logger.info "#{key} will be '#{value}'"
|
210
|
+
end
|
209
211
|
elsif current_value == value || value.nil?
|
210
212
|
Logger.debug "#{key} will not change (current value is '#{current_value}')"
|
211
213
|
else
|
212
|
-
Logger.
|
214
|
+
Logger.formatter.color :green do
|
215
|
+
Logger.info "#{key} will change from '#{current_value}' to '#{value}'"
|
216
|
+
end
|
213
217
|
end
|
214
218
|
end
|
215
219
|
end
|
@@ -310,9 +314,7 @@ module Itamae
|
|
310
314
|
end
|
311
315
|
|
312
316
|
def updated!
|
313
|
-
|
314
|
-
Logger.debug "This resource is updated."
|
315
|
-
end
|
317
|
+
Logger.debug "This resource is updated."
|
316
318
|
@updated = true
|
317
319
|
end
|
318
320
|
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.8
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# spec/integration/recipes/redefine.rb
|
2
|
+
define :echo_hello, version: nil do
|
3
|
+
file "put file in redefine.rb" do
|
4
|
+
action :create
|
5
|
+
path "/tmp/created_in_redefine"
|
6
|
+
content 'first'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Duplicated definitions
|
11
|
+
define :echo_hello, version: nil do
|
12
|
+
file "put file in redefine.rb" do
|
13
|
+
action :create
|
14
|
+
path "/tmp/created_in_redefine"
|
15
|
+
content 'second'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Execute
|
20
|
+
echo_hello "execute echo_hello!"
|
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.
|
4
|
+
version: 1.1.8
|
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-02-
|
11
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- spec/integration/recipes/hello.txt
|
191
191
|
- spec/integration/recipes/included.rb
|
192
192
|
- spec/integration/recipes/node.json
|
193
|
+
- spec/integration/recipes/redefine.rb
|
193
194
|
- spec/integration/spec_helper.rb
|
194
195
|
- spec/unit/lib/itamae/config_spec.rb
|
195
196
|
- spec/unit/lib/itamae/logger_spec.rb
|
@@ -233,6 +234,7 @@ test_files:
|
|
233
234
|
- spec/integration/recipes/hello.txt
|
234
235
|
- spec/integration/recipes/included.rb
|
235
236
|
- spec/integration/recipes/node.json
|
237
|
+
- spec/integration/recipes/redefine.rb
|
236
238
|
- spec/integration/spec_helper.rb
|
237
239
|
- spec/unit/lib/itamae/config_spec.rb
|
238
240
|
- spec/unit/lib/itamae/logger_spec.rb
|