itamae 1.2.2 → 1.2.3

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: bee2953f7e53e6c977a24568b6f1ef50b2209f40
4
- data.tar.gz: 2b8e4200cbcbf4f2106185355e240ba2c9798863
3
+ metadata.gz: f7fa94c40f407b231be9ce95914243185fc593d1
4
+ data.tar.gz: 9dc1fa0303e5300ebb4742ec6f0265764af39ac8
5
5
  SHA512:
6
- metadata.gz: 73481813d9a2e6d6ed1033e787dc8e0392a6b47c1e68de5df4af6b43e76b6bd0a67e9095c826aa51b9cd74e62cbb08767f41210f55ddfa8e088996f58c339963
7
- data.tar.gz: a1627a795d970cbfb2eba039bb13a5d33141c5209a1a75d967b549937e1db0bba7b03199e02f5758d0326be534d1758ee7673a4516e3f652c12a34742c2623a8
6
+ metadata.gz: 50781d5b380946cfe7647780a245e94929ae8c0c1af8cfa6435621b900af04cf5be62fc04fd2b0249343bceb97f26f026cd424afa509743c6da388bb2bb18e11
7
+ data.tar.gz: d1c88a9ec88b590af6c40dc4681b26ec09fd26e57c64cf20edb84fa9f01064a443911f9b799d8959eeb6c8dfe287c7ec96b9b9351d7c4448e397b8e630e120aa
@@ -1,3 +1,13 @@
1
+ ## v1.2.2
2
+
3
+ Improvements
4
+
5
+ - Refactor Backend and Runner class for multi backends.
6
+
7
+ ## v1.2.1
8
+
9
+ (yanked)
10
+
1
11
  ## v1.2.0
2
12
 
3
13
  Feature
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_runtime_dependency "thor"
21
- spec.add_runtime_dependency "specinfra", [">= 2.24.1", "< 3.0.0"]
21
+ spec.add_runtime_dependency "specinfra", [">= 2.24.2", "< 3.0.0"]
22
22
  spec.add_runtime_dependency "hashie"
23
23
  spec.add_runtime_dependency "ansi"
24
24
  spec.add_runtime_dependency "schash", "~> 0.1.0"
@@ -2,6 +2,8 @@ require 'specinfra'
2
2
  require 'singleton'
3
3
  require 'io/console'
4
4
 
5
+ Specinfra.configuration.error_on_missing_backend_type = true
6
+
5
7
  module Specinfra
6
8
  module Configuration
7
9
  def self.sudo_password
@@ -157,10 +159,9 @@ module Itamae
157
159
 
158
160
  if @options[:vagrant]
159
161
  config = Tempfile.new('', Dir.tmpdir)
160
- hostname = opts[:host] || 'default'
162
+ hostname = opts[:host_name] || 'default'
161
163
  `vagrant ssh-config #{hostname} > #{config.path}`
162
164
  opts.merge!(Net::SSH::Config.for(hostname, [config.path]))
163
- opts[:host] = opts.delete(:host_name)
164
165
  end
165
166
 
166
167
  if @options[:ask_password]
@@ -4,36 +4,34 @@ require 'json'
4
4
  require 'schash'
5
5
 
6
6
  module Itamae
7
- class Node < Hashie::Mash
7
+ class Node
8
8
  ValidationError = Class.new(StandardError)
9
9
 
10
- def initialize(initial_hash, backend = nil)
11
- super(initial_hash)
10
+ attr_reader :mash
11
+
12
+ def initialize(hash, backend)
13
+ @mash = Hashie::Mash.new(hash)
12
14
  @backend = backend
13
15
  end
14
16
 
15
17
  def reverse_merge(other_hash)
16
- Hashie::Mash.new(other_hash).merge(self)
18
+ self.class.new(_reverse_merge(other_hash), @backend)
17
19
  end
18
20
 
19
21
  def reverse_merge!(other_hash)
20
- self.replace(reverse_merge(other_hash))
22
+ @mash.replace(_reverse_merge(other_hash))
21
23
  end
22
24
 
23
25
  def [](key)
24
- val = super(key)
25
- if val.nil?
26
- begin
27
- val = @backend.host_inventory[key]
28
- rescue NotImplementedError, NameError
29
- val = nil
30
- end
26
+ if @mash.has_key?(key)
27
+ @mash[key]
28
+ else
29
+ fetch_inventory_value(key)
31
30
  end
32
- val
33
31
  end
34
32
 
35
33
  def validate!(&block)
36
- errors = Schash::Validator.new(&block).validate(self)
34
+ errors = Schash::Validator.new(&block).validate(@mash)
37
35
  unless errors.empty?
38
36
  errors.each do |error|
39
37
  Logger.error "'#{error.position.join('->')}' #{error.message}"
@@ -41,6 +39,31 @@ module Itamae
41
39
  raise ValidationError
42
40
  end
43
41
  end
42
+
43
+ private
44
+
45
+ def _reverse_merge(other_hash)
46
+ Hashie::Mash.new(other_hash).merge(@mash)
47
+ end
48
+
49
+ def method_missing(method, *args)
50
+ if @mash.respond_to?(method)
51
+ return @mash.public_send(method, *args)
52
+ elsif args.empty? && value = fetch_inventory_value(method)
53
+ return value
54
+ end
55
+
56
+ super
57
+ end
58
+
59
+ def respond_to?(method, priv = false)
60
+ @mash.respond_to?(method, priv) || super
61
+ end
62
+
63
+ def fetch_inventory_value(key)
64
+ @backend.host_inventory[key]
65
+ rescue NotImplementedError, NameError
66
+ nil
67
+ end
44
68
  end
45
69
  end
46
-
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.3
@@ -7,7 +7,7 @@ module Itamae
7
7
  it "merges a hash but the method receiver's value will be preferred" do
8
8
  a = described_class.new({a: :b, c: :d}, backend)
9
9
  expected = described_class.new({a: :b, c: :d, e: :f}, backend)
10
- expect(a.reverse_merge(a: :c, e: :f)).to eq(expected)
10
+ expect(a.reverse_merge(a: :c, e: :f).mash).to eq(expected.mash)
11
11
  end
12
12
  end
13
13
  end
@@ -19,4 +19,5 @@ RSpec.configure do |config|
19
19
  end
20
20
 
21
21
  Itamae::Logger.log_device = StringIO.new
22
+ Specinfra.configuration.error_on_missing_backend_type = false
22
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.24.1
33
+ version: 2.24.2
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: 3.0.0
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 2.24.1
43
+ version: 2.24.2
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 3.0.0