cheffish 4.1.1 → 5.0.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: 18704ce9d93e9b7f2e0009aec7fae8796e7b890b
4
- data.tar.gz: 94d26ffa96ea4363482d9c76dd0b734a3b06c15e
3
+ metadata.gz: c319e55f4faad24ef6fb157b9fc9f903c47cc466
4
+ data.tar.gz: bf2cb3572b55f1805eedc069e2ee0ac10078aa91
5
5
  SHA512:
6
- metadata.gz: 750e6567aeb409b1f68d692d4a7f41b22592a0cfabd6d1081b43c44fa24a50fc37fc9a73be328e250815a53ac75c13478ebb6372b4c133b4308512c22eb47f90
7
- data.tar.gz: 21a7ce7717192db9bf36fc18ceccdf10e528fae29bf35417f751b0b88250e7dd33d5f0aed2c4cc13b1d3abd33df9ba132ccf8e06521611e105bdd1e29e16b24c
6
+ metadata.gz: 1e73940e8d05a661d28a8f9b616b1b7ffa07453b28ca60c0dd4af2968a609e0147d97eebfee0e513c9467c592af500dd19862ea6be0e00d7342551a5bc1fde41
7
+ data.tar.gz: 4731f43daf08d9943a46fd004145f4880f71e1ccc706dbad6512dfd795df2178912916f5e15d05364fa05737a678b7f22d47e9e9cb9046ab3ace93c16e334c76
@@ -1,8 +1,10 @@
1
+ require "chef/mash"
2
+
1
3
  module Cheffish
2
4
  class MergedConfig
3
5
  def initialize(*configs)
4
- @configs = configs
5
- @merge_arrays = {}
6
+ @configs = configs.map { |config| Chef::Mash.from_hash config }
7
+ @merge_arrays = Chef::Mash.new
6
8
  end
7
9
 
8
10
  include Enumerable
@@ -1,3 +1,3 @@
1
1
  module Cheffish
2
- VERSION = "4.1.1"
2
+ VERSION = "5.0.0"
3
3
  end
@@ -6,6 +6,24 @@ describe "merged_config" do
6
6
  Cheffish::MergedConfig.new({ :test => "val" })
7
7
  end
8
8
 
9
+ let(:collision) do
10
+ c1 = { :test1 => "c1.1", "test2" => "c1.2" }
11
+ c2 = { "test1" => "c2.1", "test3" => "c2.3" }
12
+ Cheffish::MergedConfig.new(c1, c2)
13
+ end
14
+
15
+ let(:config_mismatch) do
16
+ c1 = { :test => { :test => "val" } }
17
+ c2 = { :test => [2, 3, 4] }
18
+ Cheffish::MergedConfig.new(c1, c2)
19
+ end
20
+
21
+ let(:config_hashes) do
22
+ c1 = { :test => { :test => "val" } }
23
+ c2 = { :test => { :test2 => "val2" } }
24
+ Cheffish::MergedConfig.new(c1, c2)
25
+ end
26
+
9
27
  it "returns value in config" do
10
28
  expect(config.test).to eq("val")
11
29
  end
@@ -15,6 +33,28 @@ describe "merged_config" do
15
33
  end
16
34
 
17
35
  it "has an informative string representation" do
18
- expect("#{config}").to eq("{:test=>\"val\"}")
36
+ expect("#{config}").to eq("{\"test\"=>\"val\"}")
37
+ end
38
+
39
+ it "has indifferent str/sym access" do
40
+ expect(config["test"]).to eq("val")
41
+ end
42
+
43
+ it "respects precedence between the different configs" do
44
+ expect(collision["test1"]).to eq("c1.1")
45
+ expect(collision[:test1]).to eq("c1.1")
46
+ end
47
+
48
+ it "merges the configs" do
49
+ expect(collision[:test2]).to eq("c1.2")
50
+ expect(collision[:test3]).to eq("c2.3")
51
+ end
52
+
53
+ it "handle merged value type mismatch" do
54
+ expect(config_mismatch[:test]).to eq("test" => "val")
55
+ end
56
+
57
+ it "merges values when they're hashes" do
58
+ expect(config_hashes[:test].keys).to eq(%w{test test2})
19
59
  end
20
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheffish
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser