simple-config 0.6.0 → 0.7.0

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
- SHA1:
3
- metadata.gz: 23c29bab5b256f56259d7f4396c9b09f4404c335
4
- data.tar.gz: 966a5807b1906431261264dd000ecf7f80ff85c4
2
+ SHA256:
3
+ metadata.gz: 3f7ed9d6359d2460dc59bf8c847eb4b9731a9656c0fc2ac87d7103c65e7b786d
4
+ data.tar.gz: 59d4967df759f4f3930963d59357b870f0f53423fe5ecd6cc42d08f3b29ac98c
5
5
  SHA512:
6
- metadata.gz: 9b8f869ca27091cf89691b42e182eb7ac04317506d63072fc3b99207ebe0bee8816044b34359f2b35a24ba75d60df3c790193e773e2e875cab5a886af1e9df62
7
- data.tar.gz: 0976053bf5a997d46a0e48c8b65dd1c20b6c5b614dda2d054d416ce7c1943bef6f4c3521e37eeadfbab843e714cf2eaf166e2e3ba4e1a868c96430b48abe4da4
6
+ metadata.gz: 370f0e40b6b4f36ab45549312a180c6e86c4e8f7df3eea1db01468ac486afa6697550c04bf4e911ec287ca37605aedc45afd3c2eb879b93a1656de07b35cf697
7
+ data.tar.gz: accf6be123b22dd9c9b8bc8551f6a10a1a59d915e44417a96cda05020be5e7e45a65c6121223fc9027927bf064152020985c41f21a5cdcc388842bb52f4c6da2
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -8,16 +8,19 @@ require 'kvx'
8
8
  class SimpleConfig < Kvx
9
9
 
10
10
 
11
- def initialize(x, attributes: {})
11
+ def initialize(x, attributes: {}, auto_detect_type: true, debug: false)
12
12
 
13
- @identifier = 'simple-config'
13
+ @ignore_blank_lines = true
14
+ @auto_detect_type = auto_detect_type
14
15
 
15
16
  if x.is_a? SimpleConfig then
16
17
  @to_h = x.to_h
17
18
  elsif x
18
- super(x, attributes: attributes)
19
+ super(x, attributes: attributes, debug: debug)
19
20
  end
20
21
 
22
+ @identifier = 'simple-config'
23
+
21
24
  end
22
25
 
23
26
  alias write to_s
@@ -25,8 +28,31 @@ class SimpleConfig < Kvx
25
28
  private
26
29
 
27
30
  def parse_to_h(s)
28
- super(s, header_pattern: %r(^<\?simple-?config ))
31
+ h = super(s, header_pattern: %r(^<\?simple-?config\s*))
32
+ @auto_detect_type ? scan2type(h) : h
29
33
  end
34
+
35
+ def find_type(v)
36
+
37
+ if v[/^\d+$/] and v.to_i.to_s.length == v.length then v.to_i
38
+ elsif v[/^\d+\.\d+$/] and v.to_f.to_s.length == v.length then v.to_f
39
+ elsif v.downcase[/^(?:true|false|on|off|yes|no)$/]
40
+ v.downcase[/^(?:true|on|yes)$/] ? true : false
41
+ elsif v[/^\#.*\#$/] then
42
+ Time.parse(v)
43
+ else
44
+ v
45
+ end
46
+
47
+ end
48
+
49
+ def scan2type(h)
50
+
51
+ h.each do |key, value|
52
+ h[key] = value.is_a?(Hash) ? scan2type(value) : find_type(value)
53
+ end
54
+
55
+ end
30
56
 
31
57
 
32
- end
58
+ 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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE0MDkwODIwNDQwOFoXDTE1MDkwODIwNDQwOFowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
-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gw5dbDUiSHIhFkuZde/ZkWEBwH0
30
+ 1Tw/ZArr5TtosT1RmAFnJSZsJUOqPkuucaPlEtJb8ZNIu0kKYVsKkGuTbKp0ZC4d
31
+ CGiVpUdRG5p0evxNErXIeBNwm2Snh/mqUIifB/jWRXkbuJWX1HnuDlZRsVpkL8JJ
32
+ CztkCAu5TcE9+oY4Xzxy/sovrR6UvDyhE7KGZixws+0TaG9aV0zywG8FMP0SgDI7
33
+ WByV0I2LV5P2m9yLM1ydlktrx5xj/pkL9EDXq5Yxjf/aejBblfEITwIVSoS9XW59
34
+ MEaGWL8v3gZcWxNXE0TU1UyVrKSkOUMBnSCtQcV+Uq85XzNM16Bh7UgXrllY50Uf
35
+ Mzs6McLVLKfpmpQsVuAPGjmpZkmsEwtaMZNmkAcKL/6ocO2LqzGp92Ndx3NhaMGa
36
+ hlH4OINi4m+y+z0VAPAag4KQ
33
37
  -----END CERTIFICATE-----
34
- date: 2015-04-28 00:00:00.000000000 Z
38
+ date: 2020-07-06 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: kvx
@@ -39,22 +43,22 @@ dependencies:
39
43
  requirements:
40
44
  - - "~>"
41
45
  - !ruby/object:Gem::Version
42
- version: '0.2'
46
+ version: '0.9'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 0.2.0
49
+ version: 0.9.1
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
49
53
  requirements:
50
54
  - - "~>"
51
55
  - !ruby/object:Gem::Version
52
- version: '0.2'
56
+ version: '0.9'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 0.2.0
59
+ version: 0.9.1
56
60
  description:
57
- email: james@r0bertson.co.uk
61
+ email: james@jamesrobertson.eu
58
62
  executables: []
59
63
  extensions: []
60
64
  extra_rdoc_files: []
@@ -79,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
83
  - !ruby/object:Gem::Version
80
84
  version: '0'
81
85
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.4.6
86
+ rubygems_version: 3.0.3
84
87
  signing_key:
85
88
  specification_version: 4
86
89
  summary: Simple-config makes it convenient to read or write a config file as simple
metadata.gz.sig CHANGED
Binary file