ya2yaml 0.30 → 0.31
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -1
- data/lib/ya2yaml.rb +2 -0
- data/test/test.rb +15 -0
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Ya2YAML - An UTF8 safe YAML dumper
|
2
2
|
|
3
|
-
Project Contact: Akira FUNAI <
|
3
|
+
Project Contact: Akira FUNAI <akira -at- funai -dot- com>
|
4
4
|
|
5
5
|
Ya2YAML is "yet another to_yaml". It emits YAML document with complete UTF8 support (string/binary detection, "\u" escape sequences and Unicode specific line breaks). I hope someone might find it useful until Syck/RbYAML come out with UTF8/16 support.
|
6
6
|
|
@@ -67,6 +67,7 @@ A String which contains any non-UTF8 character will be regarded as "binary" and
|
|
67
67
|
:printable_with_syck => true,
|
68
68
|
:escape_b_specific => true,
|
69
69
|
:escape_as_utf8 => true
|
70
|
+
:preserve_order => true
|
70
71
|
)
|
71
72
|
|
72
73
|
# or simply set this for a safe roundtrip with Syck.
|
@@ -98,6 +99,10 @@ A String which contains any non-UTF8 character will be regarded as "binary" and
|
|
98
99
|
- default: false
|
99
100
|
- When set to true, Ya2YAML uses Ruby-like escape sequences in UTF8 code instead of "\uXXXX" style in UCS code. It also suppresses use of "\L" and "\P" (escape sequences for LS and PS).
|
100
101
|
|
102
|
+
- :preserve_order
|
103
|
+
- default: false
|
104
|
+
- When set to true, the order of keys in hashes will be the natural hash order rather than sorted alphabetically or explicitelly (usefull for syck/psych roundtrip and ruby >= 1.9.2)
|
105
|
+
|
101
106
|
- :syck_compatible
|
102
107
|
- default: false
|
103
108
|
- When set to true, These options are set to true at once. You have to set this to false when you set them individually.
|
data/lib/ya2yaml.rb
CHANGED
data/test/test.rb
CHANGED
@@ -137,6 +137,21 @@ class TC_Ya2YAML < Test::Unit::TestCase
|
|
137
137
|
}
|
138
138
|
end
|
139
139
|
|
140
|
+
def test_preserve_order
|
141
|
+
h = {}
|
142
|
+
h['a'] = 1
|
143
|
+
h['c'] = 3
|
144
|
+
h['b'] = 2
|
145
|
+
y = h.ya2yaml(
|
146
|
+
:preserve_order => true
|
147
|
+
)
|
148
|
+
assert_equal(
|
149
|
+
"--- \na: 1\nc: 3\nb: 2\n",
|
150
|
+
y,
|
151
|
+
'the natural hash order should be preserved'
|
152
|
+
)
|
153
|
+
end if RUBY_VERSION >= "1.9"
|
154
|
+
|
140
155
|
def test_normalize_line_breaks
|
141
156
|
[
|
142
157
|
["\n\n\n\n", "--- \"\\n\\n\\n\\n\"\n"],
|
metadata
CHANGED
@@ -4,15 +4,15 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
version: "0.
|
7
|
+
- 31
|
8
|
+
version: "0.31"
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Akira FUNAI
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain:
|
15
|
-
date:
|
15
|
+
date: 2012-02-20 00:00:00 +09:00
|
16
16
|
default_executable:
|
17
17
|
dependencies: []
|
18
18
|
|