simple-config 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/simple-config.rb +46 -12
- metadata +33 -25
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a97c9005bf678e8a459dcbe845bc31126def3a17
|
4
|
+
data.tar.gz: 3eb5ec3dd8ed8be990ca2780a0e2b1d7d5df90f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c97cf4ae4f67be93506335b04b16956c25da41d84aca2a7327dec5d1b1cc59355837d78d92b55676a68f1d4d831a89e90dae99fad3875a8149cca9038d9ad9ab
|
7
|
+
data.tar.gz: 6d71f3c284926189843faadddd6ecbe2f5dfae726ab398d0059e17356c5a6ca5c9f44ded28319bb8acb74a4df549d63e5cc9e2178038bcbb23cff31f271c989d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/simple-config.rb
CHANGED
@@ -5,24 +5,58 @@
|
|
5
5
|
require 'line-tree'
|
6
6
|
|
7
7
|
class SimpleConfig
|
8
|
+
|
9
|
+
attr_reader :to_h, :to_s
|
10
|
+
|
11
|
+
def initialize(x=nil)
|
12
|
+
m = {:String => :scan_to_h, :Hash => :scan_to_s}
|
13
|
+
method(m[x.class.to_s.to_sym]).call(x) if x
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse(t=nil)
|
17
|
+
scan_to_h(t || @to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def write(h=nil)
|
21
|
+
scan_to_s h || @to_h
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
8
25
|
|
9
|
-
def
|
10
|
-
|
11
|
-
raw_a = LineTree.new(txt.gsub(
|
26
|
+
def scan_to_h(txt)
|
27
|
+
|
28
|
+
raw_a = LineTree.new(txt.gsub(/(^-*$)|(#.*)/,'').strip).to_a
|
12
29
|
|
13
30
|
a = raw_a.map do |line|
|
14
31
|
|
15
|
-
s = line.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
32
|
+
s = line.shift
|
33
|
+
|
34
|
+
if line.any? then
|
35
|
+
r = scan_to_h(line.join("\n"))
|
36
|
+
[s[/[^:]+/].to_sym, r]
|
37
|
+
else
|
38
|
+
value, name = s.split(':',2).reverse
|
39
|
+
name ||= 'description'
|
40
|
+
|
41
|
+
[name.to_sym, value.to_s.strip]
|
42
|
+
end
|
20
43
|
|
21
44
|
end
|
22
45
|
|
23
|
-
Hash[a]
|
24
|
-
end
|
25
|
-
|
26
|
-
def
|
46
|
+
@to_h = Hash[a]
|
47
|
+
end
|
48
|
+
|
49
|
+
def scan_to_s(h, indent='')
|
50
|
+
|
51
|
+
a = h.inject([]) do |r, x|
|
52
|
+
if x.last.is_a? Hash then
|
53
|
+
r << x.first.to_s + ":\n" + scan_to_s(x.last, ' ')
|
54
|
+
else
|
55
|
+
r << "%s%s: %s" % [indent, *x]
|
56
|
+
end
|
57
|
+
end
|
27
58
|
|
59
|
+
@to_s = a.join("\n")
|
60
|
+
end
|
61
|
+
|
28
62
|
end
|
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.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,41 +10,49 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0Z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dov8vMZNPqVC/zppZSyJ0yRPUswyZxKIfNzyKxf/INZALOTPmanEf8pkkIgrlBcC
|
28
|
+
CH1voFZjIeCcQHvC8ETkBME9v1KYXHTDKeRoI4L1HGHGovbg/CbzLPivTQiuQYp3
|
29
|
+
mRUkt0MKSiotFMyhrvxDV6vb/RMp5YmHry2vJVyEsl+1AhiHziQQttJasQf5ZTQq
|
30
|
+
4AZY8Ma1hAC/K2Jh4ATkIaxDITR/DiZtF7bIFIBEauHynPnxSBz+HFp3nvQjhEie
|
31
|
+
GOyi72Dr1XTvfW8Vje543EzUeJP4EjrtsoS0tbx5hs2J8Ey8zv39aU4aNyM1h0Fv
|
32
|
+
1BzvTQ2PY7IAEQ==
|
31
33
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
34
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
33
35
|
dependencies:
|
34
36
|
- !ruby/object:Gem::Dependency
|
35
37
|
name: line-tree
|
36
38
|
requirement: !ruby/object:Gem::Requirement
|
37
39
|
requirements:
|
38
|
-
- -
|
40
|
+
- - "~>"
|
39
41
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
42
|
+
version: '0.3'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.3.17
|
41
46
|
type: :runtime
|
42
47
|
prerelease: false
|
43
48
|
version_requirements: !ruby/object:Gem::Requirement
|
44
49
|
requirements:
|
45
|
-
- -
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.3'
|
53
|
+
- - ">="
|
46
54
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
55
|
+
version: 0.3.17
|
48
56
|
description:
|
49
57
|
email: james@r0bertson.co.uk
|
50
58
|
executables: []
|
@@ -62,17 +70,17 @@ require_paths:
|
|
62
70
|
- lib
|
63
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
72
|
requirements:
|
65
|
-
- -
|
73
|
+
- - ">="
|
66
74
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
75
|
+
version: 2.1.2
|
68
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
77
|
requirements:
|
70
|
-
- -
|
78
|
+
- - ">="
|
71
79
|
- !ruby/object:Gem::Version
|
72
80
|
version: '0'
|
73
81
|
requirements: []
|
74
82
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.2.2
|
76
84
|
signing_key:
|
77
85
|
specification_version: 4
|
78
86
|
summary: simple-config
|
metadata.gz.sig
CHANGED
Binary file
|