simple-config 0.1.14 → 0.1.15

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: 0492daf736ff882d31e285804ece0592efdac1ad
4
- data.tar.gz: af6faec1a9e0f20432092982a0eec071fa16c222
3
+ metadata.gz: e0a418d339e417f8c95585efe631cb4265212f06
4
+ data.tar.gz: 7345dcbd253cb6bc0eed62d011c7c56b3b11464f
5
5
  SHA512:
6
- metadata.gz: d371bf7bec4871a215947400b928d2f6e2f41cf675e9f651c4071b4808c9e0700c16297e456f5b46c25b9509fb0b8eeaba28080a776dcbf448b657d8c71e8837
7
- data.tar.gz: 44f587e8207ed22d28c49951761bc585940c76c6fca6405f52263ccd6d5459ad19eeb62c86c9856704fd840530f27fb718094644f944e5a8166b0ab68c527422
6
+ metadata.gz: 5283216c3b1a99a6fc59a46b94d2658a6e262aa5c546e5821789da8f4a93f964503787f2693bb8e9c4d90cd69231bc588722805842726ba8528df153d1ca8f78
7
+ data.tar.gz: e6674d2575184f34058b9e8d0cca37fd0cbd08e7fe9e11eaadf6c2fcc1ca6e6df751de80e13b3780df19129eedac848957607b8f5e201b55ff4723e53ffe001b
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/simple-config.rb CHANGED
@@ -33,21 +33,34 @@ class SimpleConfig
33
33
 
34
34
  def pretty_print(a, indent='')
35
35
 
36
- a.map {|x| x.is_a?(String) ? x : pretty_print(x, indent + ' ')}\
36
+ a.map {|x| (x.is_a?(String) or x.nil?) ? x.to_s : pretty_print(x, indent + ' ')}\
37
37
  .join("\n" + indent)
38
38
  end
39
39
 
40
40
 
41
41
  def scan_to_h(txt)
42
+
43
+ raw_a = LineTree.new(txt.gsub(/(^-*$)|(#.*)/,'').strip).to_a
44
+
45
+ # if there are any orphan lines which aren't nested underneath a
46
+ # label, they will be fixed using the following statement
47
+
48
+ a = raw_a.chunk {|x| x[0][/^\w+:|.*/]}.inject([]) do |r,y|
49
+ if r.last and !y.first[/\w+:/] then
50
+ r.last << y.last[-1]
51
+ else
52
+ r << y.last[-1]
53
+ end
54
+ r
55
+ end
42
56
 
43
- raw_a = LineTree.new(txt.gsub(/(^-*$)|(#.*)/,'').strip).to_a
44
57
 
45
- @to_h = raw_a.inject({}) do |r, line|
58
+ @to_h = a.inject({}) do |r, line|
46
59
 
47
60
  s = line.shift
48
61
 
49
62
  if line.any? then
50
-
63
+
51
64
  r2 = if line[0][0][/^\w+: /] then
52
65
 
53
66
  scan_to_h(line.join("\n"))
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  GOyi72Dr1XTvfW8Vje543EzUeJP4EjrtsoS0tbx5hs2J8Ey8zv39aU4aNyM1h0Fv
32
32
  1BzvTQ2PY7IAEQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-11-22 00:00:00.000000000 Z
34
+ date: 2014-12-27 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: line-tree
metadata.gz.sig CHANGED
Binary file