midwire_common 0.1.17 → 0.1.18

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: 70e04bafc57480ef9e1be8a862de1884dbdb49e9
4
- data.tar.gz: e9d8fdae68ba0a603013973be8ed0ba435fe47a0
3
+ metadata.gz: 9306a1ed77900544a6c8850f1af1cac6967fc67a
4
+ data.tar.gz: 3e00284792d683b740ff9624e163933e98aa97f3
5
5
  SHA512:
6
- metadata.gz: 78c9f3ca123983e09bd591b41340eb101be591c6c5eb0b715a3ba36a49c65278af66f60dd3230cd3ce784233b688c3f0c2fc900c6a247e4055f7a0966c7a9786
7
- data.tar.gz: 6b85526806618d3d4959790a879f69ba8854baa82056aa57111d5308b6bc52f6e1605ea96de78bdd3a0b645e5c634a32a2675b888607553ee04fef9e3cff1778
6
+ metadata.gz: 80fbc07b6d5cdf717f22426e34cd4f85e94fe1720351f430ca71cc7e377553abf419310b5ede6c9a202628b148e6adc874810d2199b7c2415c67899b1edeeb92
7
+ data.tar.gz: 4c71ff2bb61e4ce92b2f85eac0a4fc3b0bbd58a978f20021fe3203f16353ef411a9793f034c1573cca119d739a39ef482c2702bc238c7006df4ee4de8a40b9a5
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ *0.1.18* (February 01, 2016)
2
+
3
+ * Add 'data' method for YamlSetting
4
+ * Also add 'root' method for the module.
5
+
1
6
  *0.1.17* (February 01, 2016)
2
7
 
3
8
  * Fix some redundant self references in string.rb
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Midwire Common Gem
2
2
 
3
- **Version: 0.1.17**
3
+ **Version: 0.1.18**
4
4
 
5
5
  A handy, light-weight Ruby library for Midwire development
6
6
 
@@ -2,5 +2,11 @@ require 'pathname'
2
2
  require 'midwire_common/version'
3
3
 
4
4
  module Midwire
5
+ class << self
6
+ def root
7
+ Pathname.new(File.dirname(__FILE__)).parent
8
+ end
9
+ end
10
+
5
11
  autoload :RakeHelper, 'midwire_common/rake_helper'
6
12
  end
@@ -1,6 +1,6 @@
1
1
  original_verbosity = $VERBOSE
2
2
  $VERBOSE = nil
3
3
  module MidwireCommon
4
- VERSION = '0.1.17'
4
+ VERSION = '0.1.18'
5
5
  end
6
6
  $VERBOSE = original_verbosity
@@ -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(@config)) }
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
- @config[key]
24
+ config[key]
24
25
  end
25
26
 
26
27
  def []=(key, value)
27
28
  load
28
- @config[key] = value
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) { Pathname.new(File.dirname(__FILE__)).parent.parent.parent }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midwire_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Blackburn