simple-config 0.6.3 → 0.7.2

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: d5c926c6081e357160f4a5ab1f7301b395356122
4
- data.tar.gz: 18c747c9ae8d89356f6150750d985ffc2d0129f3
2
+ SHA256:
3
+ metadata.gz: f31bf5d219d6041190571af4825c8b6453c961ed5a564d91ed44ba1d51c98bfc
4
+ data.tar.gz: 24dff310f8873c6d7981cc73c190d7b35f1034b40e86cb04e5db3807a27638ee
5
5
  SHA512:
6
- metadata.gz: 82cad0c65c255097a905e8ab463f0b2cb2bb81571c435c25272e5952ab674ed62f6d22961573798270c77db0f18a4b464719d95dd4876cf52ff75c00414436ee
7
- data.tar.gz: e702df5a3dac99f3f093e7cf879ffcc0bf759d759a8eedf83c32a949d183d0419f373de48d6c268da5638c8313ddc76c895a387586fc643c0dbb82451f3d388d
6
+ metadata.gz: c58ce83f8700841ee34bf89d2858a6abba6c4d6869c70600f76c7d7d6ed113cfd3b3266472a54e91740881dbee843ce68e5ea0203d30ed39b6291c9f832431f8
7
+ data.tar.gz: 6395327c2c0e08afd2ec5b0900cd16510ab43789ddc5a7524d0d4fdeb2c9e2f7e18c5f57089a8e9c3a51be8231c5d1cf122ada990b88fb8160d5234becaf4881
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/simple-config.rb CHANGED
@@ -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\s*))
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
60
  end
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.6.3
4
+ version: 0.7.2
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
- 8ixkARkWAmV1MB4XDTE3MDYwNzEyNDgzNloXDTE4MDYwNzEyNDgzNlowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvc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ZKAX0uDL0bQoAuabbCSBavJQOeCT
30
+ Xn0goovz1d2GsDD+bNfgaQyvf0uL3f2a0UFglbecmxO39juGLZ54Uy4QZGqFYSUr
31
+ sEaGnqQ2sF4OXf80mDb/dhFxFFuwp5TX4JW8Cg5C3WOK2WjLtqW4ZQjkrQ3fvh+f
32
+ 9rnMcDdbmwI6D/JtrPOa31KlV+7sUF+/0yxZYoJ/yrUjN4JGAhkDhS4uy0SBVf+C
33
+ 26boO9olCrL1Z2Cv6g5b9Kwx4vZgmE6CnOOI3mmgTY74hyWmLndcqZimAyxK8y9r
34
+ dNJgQLjSfRLjYbrZvgt+hknDO75KO285NBcq62fZUsIpYda9pw32B2uMXmA585jH
35
+ 7fTseCWoJ+htGaGmF2XGa4vzno4Hrx46xtH5bMZXjJrZI5kAQ3q/rrwGTRAlhKXN
36
+ ohnGnEdpQlxOgeVD510QNHR5
33
37
  -----END CERTIFICATE-----
34
- date: 2017-06-07 00:00:00.000000000 Z
38
+ date: 2022-01-26 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: '1.0'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 0.2.0
49
+ version: 1.0.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: '1.0'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 0.2.0
59
+ version: 1.0.1
56
60
  description:
57
- email: james@jamesrobertson.eu
61
+ email: digital.robertson@gmail.com
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.6.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