kungfuig 0.7.2 → 0.7.5

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: cc430df3b6cfe95416a9954f8a70af80cb28192a
4
- data.tar.gz: ca05a19e089810361ed88492c3d65ca256365a42
3
+ metadata.gz: f916d00ad175d459be94cde9664bd5ef813983f5
4
+ data.tar.gz: 6d2e2630943cbb354eb2ebd11e3b3d0f307fa839
5
5
  SHA512:
6
- metadata.gz: 4c91b9e77ef5988557eb0f2a3cde047eeec3d83448d42d02a8b65e31885582918512a13e31bebf7c2807578dce855fc29b31ae43131e8c6919fdce057717b582
7
- data.tar.gz: d3a55b372986ee6128b29aa33ac7ad2c8bdb6a4322384ea0bdd586efebeaa3da60a5a42272232706d89c098570cbe92f234474c09e202fddda51bb4327372859
6
+ metadata.gz: 3afbfeb420ef1a7d9f44cdd203e87bef98193ca2c01ec8221169203d76266f9dd8acad29cfc73e4d60f04ff42f4c283f824bad31db694dac3985da36e0ddd9fc
7
+ data.tar.gz: 6e34a2c86f900be9326583e0f0621bcc8d360a66361dce17a6bb2c89f63e61491b70c06544366fc8e0c80e5d6ada180015c227363f5c58fa6a4fd7d3e7de6930
@@ -29,11 +29,11 @@ module Kungfuig
29
29
  begin
30
30
  File.exist?(hos) ? Hashie::Mash.load(hos) : Hashie::Mash.new(YAML.load(hos))
31
31
  rescue ArgumentError
32
- fail ArgumentError, "#{__callee__} expects valid YAML configuration file. “#{hos.inspect}” contains invalid syntax."
32
+ raise ArgumentError, "#{__callee__} expects valid YAML configuration file. “#{hos.inspect}” contains invalid syntax."
33
33
  rescue Psych::SyntaxError
34
- fail ArgumentError, "#{__callee__} expects valid YAML configuration string. Got:\n#{hos.inspect}"
34
+ raise ArgumentError, "#{__callee__} expects valid YAML configuration string. Got:\n#{hos.inspect}"
35
35
  rescue
36
- fail ArgumentError, "#{__callee__} expects valid YAML configuration string (misspelled file name?). Got:\n#{hos.inspect}"
36
+ raise ArgumentError, "#{__callee__} expects valid YAML configuration string (misspelled file name?). Got:\n#{hos.inspect}"
37
37
  end
38
38
  when ->(h) { h.respond_to?(:to_hash) } then Hashie::Mash.new(h.to_hash)
39
39
  else
@@ -56,10 +56,14 @@ module Kungfuig
56
56
 
57
57
  # Options getter
58
58
  # @return [Hashie::Mash] options
59
- def options
59
+ def __options__
60
60
  @options ||= Hashie::Mash.new
61
61
  end
62
- private :options
62
+ private :__options__
63
+
64
+ def options
65
+ __options__.dup
66
+ end
63
67
 
64
68
  # Accepts:
65
69
  # option :foo, :bar, 'baz'
@@ -67,15 +71,15 @@ module Kungfuig
67
71
  # option 'foo.bar.baz'
68
72
  # option 'foo::bar::baz'
69
73
  def option *keys
70
- key = keys.join('.').gsub(/::/, '.').split('.')
74
+ key = keys.map(&:to_s).join('.').gsub(/::/, '.').split('.')
71
75
 
72
76
  MX.synchronize {
73
77
  # options.foo!.bar!.baz!
74
78
  [key, key[1..-1]].map do |candidate|
75
- candidate.inject(options.dup) do |memo, k|
79
+ candidate && candidate.inject(options) do |memo, k|
76
80
  memo.public_send(k.to_s) unless memo.nil?
77
81
  end
78
- end.detect { |e| e }
82
+ end.compact.first
79
83
  }
80
84
  end
81
85
 
@@ -84,12 +88,12 @@ module Kungfuig
84
88
  # option! 'foo.bar.baz', value
85
89
  # option! 'foo::bar::baz', value
86
90
  def option! keys, value
87
- key = (keys.is_a?(Array) ? keys.join('.') : keys).gsub(/::/, '.').split('.')
91
+ key = (keys.is_a?(Array) ? keys.join('.') : keys.to_s).gsub(/::/, '.').split('.')
88
92
  last = key.pop
89
93
 
90
94
  MX.synchronize {
91
95
  # options.foo!.bar!.baz! = value
92
- build = key.inject(options) do |memo, k|
96
+ build = key.inject(__options__) do |memo, k|
93
97
  memo.public_send("#{k}!")
94
98
  end
95
99
  build[last] = value
@@ -104,7 +108,7 @@ module Kungfuig
104
108
  # mash or string (when string, should be either valid YAML file name or
105
109
  # string with valid YAML)
106
110
  def merge_hash_or_string! hos
107
- options.deep_merge! Kungfuig.load_stuff hos
111
+ __options__.deep_merge! Kungfuig.load_stuff hos
108
112
  end
109
113
  private :merge_hash_or_string!
110
114
  end
@@ -1,3 +1,3 @@
1
1
  module Kungfuig
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kungfuig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kantox LTD
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie