json2properties 0.0.2 → 0.0.3
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 +4 -4
- data/bin/properties2json +0 -0
- data/lib/json2properties.rb +9 -3
- data/lib/json2properties_cli.rb +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 030e4ff931fa9a62d5264eed950a374de848f067
|
4
|
+
data.tar.gz: f76c1133f68400b65d7345ce86fa663384bd9b48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2850ac8c31a8d2ae30cdf3c52a50ab9ede955baffe7a550e0df2b1333f58fcac6b0fb0e5570ed53eacf24ea91e19940257d41960be06e8090971c557ec6ef6c
|
7
|
+
data.tar.gz: 75e23f5c0c0bc637908cd80cb9e81b6dc2f5be76a2837f05b647a8290e39a50ca2941bb53c97f1cdd8b38a62d4d5a2a9ce80862ff973ce032aff7e4379f24e75
|
data/bin/properties2json
CHANGED
File without changes
|
data/lib/json2properties.rb
CHANGED
@@ -12,10 +12,15 @@ class String
|
|
12
12
|
return true if self.is_i?
|
13
13
|
true if Float(self) rescue false
|
14
14
|
end
|
15
|
+
|
16
|
+
def is_numeric_leading_zero?
|
17
|
+
self[0].eql?("0") && self.length > 1
|
18
|
+
end
|
19
|
+
|
15
20
|
end
|
16
21
|
|
17
22
|
class Json2properties
|
18
|
-
VERSION = '0.0.
|
23
|
+
VERSION = '0.0.3'
|
19
24
|
SEPARATOR = '.'
|
20
25
|
|
21
26
|
def initialize
|
@@ -53,11 +58,11 @@ class Json2properties
|
|
53
58
|
part = parts[i]
|
54
59
|
next_part = parts[i+1]
|
55
60
|
|
56
|
-
part = part.to_i if part.is_i?
|
61
|
+
part = part.to_i if ( part.is_i? && !part.is_numeric_leading_zero? )
|
57
62
|
if tmp[part].nil?
|
58
63
|
if next_part.nil?
|
59
64
|
tmp[part] = fix_type(v)
|
60
|
-
elsif next_part.is_i?
|
65
|
+
elsif next_part.is_i? && !next_part.is_numeric_leading_zero?
|
61
66
|
tmp[part] = []
|
62
67
|
else
|
63
68
|
tmp[part] = {}
|
@@ -72,6 +77,7 @@ class Json2properties
|
|
72
77
|
private
|
73
78
|
|
74
79
|
def fix_type(v)
|
80
|
+
return v if v.is_numeric_leading_zero?
|
75
81
|
return v.to_i if v.is_i?
|
76
82
|
return v.to_f if v.is_numeric?
|
77
83
|
return true if v == "true"
|
data/lib/json2properties_cli.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json2properties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: java-properties
|