simple-config 0.6.4 → 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: 7362e0c04d2109b0f576ebd13d4e2fe7f5637a54
4
- data.tar.gz: 5c58b5c41239e6c6d59fd4e04e8c3a5fb6f85dae
2
+ SHA256:
3
+ metadata.gz: 3f7ed9d6359d2460dc59bf8c847eb4b9731a9656c0fc2ac87d7103c65e7b786d
4
+ data.tar.gz: 59d4967df759f4f3930963d59357b870f0f53423fe5ecd6cc42d08f3b29ac98c
5
5
  SHA512:
6
- metadata.gz: 8e778ddf0533fd6f8ad6cfad12c0d59474368c3361b81ade03c130b86380a7da79776866081496cc7b3468d3ef187a3dde6b77d2d335aee94adcdb0a38a47379
7
- data.tar.gz: a9c6cf3ef3dedd82b6d35ab03ecd00423e04c576f31a420fff40974a0a3928246819af6ad2983218c15a04f579ec1d7d92011a289db6f1c5b19fa152ac9370f0
6
+ metadata.gz: 370f0e40b6b4f36ab45549312a180c6e86c4e8f7df3eea1db01468ac486afa6697550c04bf4e911ec287ca37605aedc45afd3c2eb879b93a1656de07b35cf697
7
+ data.tar.gz: accf6be123b22dd9c9b8bc8551f6a10a1a59d915e44417a96cda05020be5e7e45a65c6121223fc9027927bf064152020985c41f21a5cdcc388842bb52f4c6da2
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -8,9 +8,10 @@ require 'kvx'
8
8
  class SimpleConfig < Kvx
9
9
 
10
10
 
11
- def initialize(x, attributes: {}, debug: false)
11
+ def initialize(x, attributes: {}, auto_detect_type: true, debug: false)
12
12
 
13
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
@@ -27,8 +28,31 @@ class SimpleConfig < Kvx
27
28
  private
28
29
 
29
30
  def parse_to_h(s)
30
- super(s, header_pattern: %r(^<\?simple-?config\s*))
31
+ h = super(s, header_pattern: %r(^<\?simple-?config\s*))
32
+ @auto_detect_type ? scan2type(h) : h
31
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
32
56
 
33
57
 
34
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.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,27 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwNDA2MjIxMDA4WhcN
15
- MTkwNDA2MjIxMDA4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDajYa8
17
- 4GOU0da4gKMdFzvJTEYDzZiKwQYiI7FedKYaqvr8rQwb9eUXeyIR8Ib7pA1139x3
18
- +KO/V56PnCjK17qQZYn87nlPpghd65cmiTlHUamAeAj1j1Mzj50XYwKD9fwVQn/h
19
- uKS6dfEfxrCBqJaS2CzS3UzCN+TZ/7cBZkC7XPQqoGK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Y4Xzxy/sovrR6UvDyhE7KGZixws+0TaG9aV0zywG8FMP0SgDI7
33
+ WByV0I2LV5P2m9yLM1ydlktrx5xj/pkL9EDXq5Yxjf/aejBblfEITwIVSoS9XW59
34
+ MEaGWL8v3gZcWxNXE0TU1UyVrKSkOUMBnSCtQcV+Uq85XzNM16Bh7UgXrllY50Uf
35
+ Mzs6McLVLKfpmpQsVuAPGjmpZkmsEwtaMZNmkAcKL/6ocO2LqzGp92Ndx3NhaMGa
36
+ hlH4OINi4m+y+z0VAPAag4KQ
32
37
  -----END CERTIFICATE-----
33
- date: 2018-04-06 00:00:00.000000000 Z
38
+ date: 2020-07-06 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: kvx
@@ -38,20 +43,20 @@ dependencies:
38
43
  requirements:
39
44
  - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '0.7'
46
+ version: '0.9'
42
47
  - - ">="
43
48
  - !ruby/object:Gem::Version
44
- version: 0.7.0
49
+ version: 0.9.1
45
50
  type: :runtime
46
51
  prerelease: false
47
52
  version_requirements: !ruby/object:Gem::Requirement
48
53
  requirements:
49
54
  - - "~>"
50
55
  - !ruby/object:Gem::Version
51
- version: '0.7'
56
+ version: '0.9'
52
57
  - - ">="
53
58
  - !ruby/object:Gem::Version
54
- version: 0.7.0
59
+ version: 0.9.1
55
60
  description:
56
61
  email: james@jamesrobertson.eu
57
62
  executables: []
@@ -78,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
83
  - !ruby/object:Gem::Version
79
84
  version: '0'
80
85
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.6.13
86
+ rubygems_version: 3.0.3
83
87
  signing_key:
84
88
  specification_version: 4
85
89
  summary: Simple-config makes it convenient to read or write a config file as simple
metadata.gz.sig CHANGED
Binary file