midwire_common 0.1.17 → 0.1.18
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/CHANGELOG +5 -0
- data/README.md +1 -1
- data/lib/midwire_common.rb +6 -0
- data/lib/midwire_common/version.rb +1 -1
- data/lib/midwire_common/yaml_setting.rb +8 -3
- data/spec/lib/midwire_common/yaml_setting_spec.rb +13 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9306a1ed77900544a6c8850f1af1cac6967fc67a
|
4
|
+
data.tar.gz: 3e00284792d683b740ff9624e163933e98aa97f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80fbc07b6d5cdf717f22426e34cd4f85e94fe1720351f430ca71cc7e377553abf419310b5ede6c9a202628b148e6adc874810d2199b7c2415c67899b1edeeb92
|
7
|
+
data.tar.gz: 4c71ff2bb61e4ce92b2f85eac0a4fc3b0bbd58a978f20021fe3203f16353ef411a9793f034c1573cca119d739a39ef482c2702bc238c7006df4ee4de8a40b9a5
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
data/lib/midwire_common.rb
CHANGED
@@ -3,6 +3,7 @@ require 'yaml'
|
|
3
3
|
module MidwireCommon
|
4
4
|
class YamlSetting
|
5
5
|
attr_accessor :file
|
6
|
+
attr_reader :config
|
6
7
|
|
7
8
|
def initialize(file)
|
8
9
|
@file = file
|
@@ -14,18 +15,22 @@ module MidwireCommon
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def save
|
17
|
-
File.open(file, 'w') { |f| f.write(YAML.dump(
|
18
|
+
File.open(file, 'w') { |f| f.write(YAML.dump(config)) }
|
18
19
|
self
|
19
20
|
end
|
20
21
|
|
21
22
|
def [](key)
|
22
23
|
load
|
23
|
-
|
24
|
+
config[key]
|
24
25
|
end
|
25
26
|
|
26
27
|
def []=(key, value)
|
27
28
|
load
|
28
|
-
|
29
|
+
config[key] = value
|
30
|
+
end
|
31
|
+
|
32
|
+
def data
|
33
|
+
config
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe MidwireCommon::YamlSetting do
|
4
|
-
let(:root) {
|
4
|
+
let(:root) { Midwire.root }
|
5
5
|
let(:tmpdir) { File.join(root, 'tmp') }
|
6
6
|
let(:file) { File.join(tmpdir, 'bogus.yml') }
|
7
7
|
let(:setting) { YamlSetting.new(file) }
|
@@ -42,4 +42,16 @@ describe MidwireCommon::YamlSetting do
|
|
42
42
|
expect(setting[:test]).to eq('bogus')
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
context '.config' do
|
47
|
+
it 'returns the data hash' do
|
48
|
+
expect(setting.config[:test]).to eq(a: 1, b: 2, c: 3)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context '.data' do
|
53
|
+
it 'returns the data hash' do
|
54
|
+
expect(setting.data[:test]).to eq(a: 1, b: 2, c: 3)
|
55
|
+
end
|
56
|
+
end
|
45
57
|
end
|