immosquare-yaml 1.0.3 → 1.0.4
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/lib/immosquare-yaml/version.rb +1 -1
- data/lib/immosquare-yaml.rb +13 -2
- 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: 18474159a026b7caf6296f284339cd69fc74e3d413cc80135d527873a92db43d
|
|
4
|
+
data.tar.gz: a4e7b2e8193dde12dc218a055e6dd857dfdd5255f70ffdebe38568943ee5ffd0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3895b71e4cee8091551f0ec75a9e95ecdc4a622c89778dac4bdee06d0abf66146021904b583e4baede6a9f12716532f51669d71355298579ce245561641e55fd
|
|
7
|
+
data.tar.gz: bd33415993538752b14b6c18919c984a5964efc2b800161871393d382908bb25949bcd7445780db51fa66b1786ac3c7a2214ee2ccf74253dc645d7b3a4b33bdd
|
data/lib/immosquare-yaml.rb
CHANGED
|
@@ -272,7 +272,8 @@ module ImmosquareYaml
|
|
|
272
272
|
##
|
|
273
273
|
## On quote si la valeur contient des caractères qui auraient
|
|
274
274
|
## un sens YAML particulier en plain (": ", " #", début par un
|
|
275
|
-
## caractère spécial, fin par ":",
|
|
275
|
+
## caractère spécial, fin par ":", espace en bord) ou si Psych
|
|
276
|
+
## lui attribuerait un type implicite différent de String.
|
|
276
277
|
##============================================================##
|
|
277
278
|
def format_scalar_value(value)
|
|
278
279
|
value = value.to_s
|
|
@@ -298,7 +299,8 @@ module ImmosquareYaml
|
|
|
298
299
|
value.end_with?(":") ||
|
|
299
300
|
RESERVED_KEYS.include?(value) ||
|
|
300
301
|
value.start_with?(SPACE) ||
|
|
301
|
-
value.end_with?(SPACE)
|
|
302
|
+
value.end_with?(SPACE) ||
|
|
303
|
+
psych_implicitly_types?(value)
|
|
302
304
|
|
|
303
305
|
return value if !need_quotes
|
|
304
306
|
|
|
@@ -318,6 +320,15 @@ module ImmosquareYaml
|
|
|
318
320
|
end
|
|
319
321
|
end
|
|
320
322
|
|
|
323
|
+
##============================================================##
|
|
324
|
+
## Détecte les scalaires plain que Psych convertirait en nombre,
|
|
325
|
+
## valeur nulle, date ou heure lors du chargement YAML.
|
|
326
|
+
##============================================================##
|
|
327
|
+
def psych_implicitly_types?(value)
|
|
328
|
+
scanner = Psych::ScalarScanner.new(Psych::ClassLoader.new, :parse_symbols => false)
|
|
329
|
+
!scanner.tokenize(value).is_a?(String)
|
|
330
|
+
end
|
|
331
|
+
|
|
321
332
|
##============================================================##
|
|
322
333
|
## Échappe une string pour la sérialiser en YAML double-quoted.
|
|
323
334
|
## On gère \, ", \t et \n. Les newlines réels n'arrivent pas
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: immosquare-yaml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- immosquare
|
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
62
|
version: '0'
|
|
63
63
|
requirements: []
|
|
64
|
-
rubygems_version: 4.0.
|
|
64
|
+
rubygems_version: 4.0.20
|
|
65
65
|
specification_version: 4
|
|
66
66
|
summary: A YAML parser optimized for translation files.
|
|
67
67
|
test_files: []
|