simple-config 0.6.1 → 0.7.1

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: c7d3adf1e66e7b72c2784d896c9c23e70cd805b6
4
- data.tar.gz: e9daa894c46c0dd1b1d725270594150cf2b20bc4
2
+ SHA256:
3
+ metadata.gz: ba6ef9849b7b1d1730cb9e94d51722ec5c022138468af71b093cfd6b3782a545
4
+ data.tar.gz: 916568cf979853cd2164f4aac8a82e364f54550535f3d0534ed0d31724e7a05c
5
5
  SHA512:
6
- metadata.gz: f7bbc43eaac5c7652096ff378f802c06d9df2c166fbfc79a8705441fa4fc87900033805dffdc75a13ffbe08f9fc535189669c4b7c1e1d11879809868e3290910
7
- data.tar.gz: 1cd42cc3872585c51c5012951b29912d29520ff8e22a13d83210bc5e5eadf610463cca5cf8ee5c86490408a8d65df36915e609b8002543ffc1e78cd9353a1a41
6
+ metadata.gz: '08c0ecc225a43e162ebbdd04933a4c83e0154dca71ec833c73dca7f4b0a9675d86a218a9ceab4fcdbe078a44acd133fa4fe5ab9a12c7ed56f97cd80154bf5f36'
7
+ data.tar.gz: 85d8b774825660ac5d3961d221a1ffb7e21082e96fbea8f849c8be1c93434a729a6af443f6d9e607b5eca2c25cbc6414444484fa94c448f0f639c3b1188c3ce3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -8,12 +8,15 @@ 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
+ @ignore_blank_lines = true
14
+ @auto_detect_type = auto_detect_type
15
+
13
16
  if x.is_a? SimpleConfig then
14
17
  @to_h = x.to_h
15
18
  elsif x
16
- super(x, attributes: attributes)
19
+ super(x, attributes: attributes, debug: debug)
17
20
  end
18
21
 
19
22
  @identifier = 'simple-config'
@@ -25,8 +28,33 @@ 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
+ puts 'v: ' + v.inspect if @debug
38
+
39
+ if v[/^\d+$/] and v.to_i.to_s.length == v.length then v.to_i
40
+ elsif v[/^\d+\.\d+$/] and v.to_f.to_s.length == v.length then v.to_f
41
+ elsif v.downcase[/^(?:true|false|on|off|yes|no)$/]
42
+ v.downcase[/^(?:true|on|yes)$/] ? true : false
43
+ elsif v[/^\#.*\#$/] then
44
+ Time.parse(v)
45
+ else
46
+ v
47
+ end
48
+
49
+ end
50
+
51
+ def scan2type(h)
52
+
53
+ h.each do |key, value|
54
+ next if value.is_a? Array
55
+ h[key] = value.is_a?(Hash) ? scan2type(value) : find_type(value)
56
+ end
30
57
 
58
+ end
31
59
 
32
- end
60
+ 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.1
4
+ version: 0.7.1
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
- 8ixkARkWAmV1MB4XDTE1MDkxOTIxMDgzM1oXDTE2MDkxODIxMDgzM1owSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEB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/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-09-19 00:00:00.000000000 Z
38
+ date: 2020-07-18 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: []
@@ -80,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
84
  version: '0'
81
85
  requirements: []
82
86
  rubyforge_project:
83
- rubygems_version: 2.4.8
87
+ rubygems_version: 2.7.10
84
88
  signing_key:
85
89
  specification_version: 4
86
90
  summary: Simple-config makes it convenient to read or write a config file as simple
metadata.gz.sig CHANGED
Binary file