rb-konfig 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e89ed135a36c5a070a8e02df06a30aea4f3dc3e24582b276a634a485968b30da
4
- data.tar.gz: c2a805cc1c9265ed33200ef6f2e0f31fd087db940125d83569c095886d865bc3
3
+ metadata.gz: 8e6f3dd52871d34e92d8a03de6ec2fd4ea05d2393a168e25e3d0a8b7b1e8c05e
4
+ data.tar.gz: b69d8737c181ae24c43c9a4aee502f6af68fb2a1c290d5c8e090c36ad2a2d769
5
5
  SHA512:
6
- metadata.gz: 32d1ea060492c8066e02671471b8bd6075601dfe99aa04a25b14eda9c4b7356d8ab88eda3bd8481b345f5ac6592c4b7e73f36cdf658ab7fa60ba8b849775f5fb
7
- data.tar.gz: 40a42dad3ab16867caf1bd1f85d3ff86620710c64b3e76e864d68c777c1dada0d29b4879b12ae0fa74f23cd5b721837ba60af7df6d2d50de0689a1a3c1b211e3
6
+ metadata.gz: 63e9948892cd048da2602d3d7f0f2434164a9681b91c3f94e321f09ea05d84a3ad1ef03a69214c5fc869c9bb72d9f055a2ed85336f34ba29b03352591745a440
7
+ data.tar.gz: 80e7fd214685cd632f9ccb44eed8dd254c9ec07a1d607736d309cbb631dae00887cf4789497b67bde3ef9efa5293619ce6dec8472c1b3428a882ccc046d1a7e3
@@ -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 { |value| value }, # string. should always be the last one
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
@@ -1,3 +1,3 @@
1
1
  module Konfig
2
- VERSION ||= "0.1.4"
2
+ VERSION ||= "0.1.5"
3
3
  end
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
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-08-23 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport