rb-konfig 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/konfig/utils.rb +14 -1
- data/lib/konfig/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e6f3dd52871d34e92d8a03de6ec2fd4ea05d2393a168e25e3d0a8b7b1e8c05e
|
4
|
+
data.tar.gz: b69d8737c181ae24c43c9a4aee502f6af68fb2a1c290d5c8e090c36ad2a2d769
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63e9948892cd048da2602d3d7f0f2434164a9681b91c3f94e321f09ea05d84a3ad1ef03a69214c5fc869c9bb72d9f055a2ed85336f34ba29b03352591745a440
|
7
|
+
data.tar.gz: 80e7fd214685cd632f9ccb44eed8dd254c9ec07a1d607736d309cbb631dae00887cf4789497b67bde3ef9efa5293619ce6dec8472c1b3428a882ccc046d1a7e3
|
data/lib/konfig/utils.rb
CHANGED
@@ -12,6 +12,10 @@ module Konfig
|
|
12
12
|
lambda { |value| (["true", "false"].include?(value)) ? (value == "true") : NIL_VALUE }, # boolean
|
13
13
|
lambda { |value| (value == Konfig.configuration.nil_word && Konfig.configuration.allow_nil) ? nil : NIL_VALUE }, # nil value
|
14
14
|
lambda do |value|
|
15
|
+
value = value.strip
|
16
|
+
# on some platforms, JSON.parse returns value for integer and floats. This is incorrect https://www.json.org/
|
17
|
+
return NIL_VALUE if !value.start_with?("[") && !value.start_with?("{")
|
18
|
+
|
15
19
|
result = JSON.parse(value, { symbolize_names: true })
|
16
20
|
if result == nil && !Konfig.configuration.allow_nil
|
17
21
|
return NIL_VALUE
|
@@ -21,7 +25,10 @@ module Konfig
|
|
21
25
|
rescue
|
22
26
|
NIL_VALUE
|
23
27
|
end, # json
|
24
|
-
lambda
|
28
|
+
lambda do |value| # string. should always be the last one
|
29
|
+
# in case we have a string, clean it up. For example, quotes in strings should be escaped or will be removed
|
30
|
+
Konfig::Utils.remove_quotations(value)
|
31
|
+
end,
|
25
32
|
]
|
26
33
|
|
27
34
|
class Utils
|
@@ -35,5 +42,11 @@ module Konfig
|
|
35
42
|
|
36
43
|
raise UnsupportedValueType, "'#{value}' is unsupported type"
|
37
44
|
end
|
45
|
+
|
46
|
+
def self.remove_quotations(str)
|
47
|
+
str = str.slice(1..-1) if str.start_with?('"') || str.start_with?('\'')
|
48
|
+
str = str.slice(0..-2) if str.end_with?('"') || str.end_with?('\'')
|
49
|
+
return str
|
50
|
+
end
|
38
51
|
end
|
39
52
|
end
|
data/lib/konfig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-konfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khash Sajadi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|