kungfuig 0.7.2 → 0.7.5
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/lib/kungfuig.rb +15 -11
- data/lib/kungfuig/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f916d00ad175d459be94cde9664bd5ef813983f5
|
|
4
|
+
data.tar.gz: 6d2e2630943cbb354eb2ebd11e3b3d0f307fa839
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3afbfeb420ef1a7d9f44cdd203e87bef98193ca2c01ec8221169203d76266f9dd8acad29cfc73e4d60f04ff42f4c283f824bad31db694dac3985da36e0ddd9fc
|
|
7
|
+
data.tar.gz: 6e34a2c86f900be9326583e0f0621bcc8d360a66361dce17a6bb2c89f63e61491b70c06544366fc8e0c80e5d6ada180015c227363f5c58fa6a4fd7d3e7de6930
|
data/lib/kungfuig.rb
CHANGED
|
@@ -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
|
-
|
|
32
|
+
raise ArgumentError, "#{__callee__} expects valid YAML configuration file. “#{hos.inspect}” contains invalid syntax."
|
|
33
33
|
rescue Psych::SyntaxError
|
|
34
|
-
|
|
34
|
+
raise ArgumentError, "#{__callee__} expects valid YAML configuration string. Got:\n#{hos.inspect}"
|
|
35
35
|
rescue
|
|
36
|
-
|
|
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
|
|
59
|
+
def __options__
|
|
60
60
|
@options ||= Hashie::Mash.new
|
|
61
61
|
end
|
|
62
|
-
private :
|
|
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
|
|
79
|
+
candidate && candidate.inject(options) do |memo, k|
|
|
76
80
|
memo.public_send(k.to_s) unless memo.nil?
|
|
77
81
|
end
|
|
78
|
-
end.
|
|
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(
|
|
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
|
-
|
|
111
|
+
__options__.deep_merge! Kungfuig.load_stuff hos
|
|
108
112
|
end
|
|
109
113
|
private :merge_hash_or_string!
|
|
110
114
|
end
|
data/lib/kungfuig/version.rb
CHANGED
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.
|
|
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-
|
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hashie
|