psych 1.2.1 → 1.2.2.rc1
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.
- data/CHANGELOG.rdoc +6 -0
- data/Rakefile +6 -1
- data/lib/psych.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +4 -0
- data/lib/psych/visitors/yaml_tree.rb +29 -6
- data/test/psych/test_deprecated.rb +1 -1
- data/test/psych/test_string.rb +8 -0
- metadata +13 -9
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
Fri Sep 2 04:05:25 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
|
2
|
+
|
|
3
|
+
* ext/psych/lib/psych/visitors/yaml_tree.rb: emit strings tagged as
|
|
4
|
+
ascii-8bit as binary in YAML.
|
|
5
|
+
* test/psych/test_string.rb: corresponding test.
|
|
6
|
+
|
|
1
7
|
Thu Aug 25 06:11:35 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
|
2
8
|
|
|
3
9
|
* ext/psych/lib/psych/nodes/node.rb: default `to_yaml` encoding to be
|
data/Rakefile
CHANGED
|
@@ -13,7 +13,7 @@ require "rake/extensiontask"
|
|
|
13
13
|
|
|
14
14
|
Hoe.plugin :debugging, :doofus, :git, :gemspec
|
|
15
15
|
|
|
16
|
-
Hoe.spec 'psych' do
|
|
16
|
+
$hoe = Hoe.spec 'psych' do
|
|
17
17
|
developer 'Aaron Patterson', 'aaron@tenderlovemaking.com'
|
|
18
18
|
|
|
19
19
|
self.extra_rdoc_files = Dir['*.rdoc']
|
|
@@ -37,6 +37,11 @@ Hoe.add_include_dirs('.:lib/psych')
|
|
|
37
37
|
|
|
38
38
|
task :test => :compile
|
|
39
39
|
|
|
40
|
+
task :hack_spec do
|
|
41
|
+
$hoe.spec.extra_rdoc_files.clear
|
|
42
|
+
end
|
|
43
|
+
task 'core:spec' => [:hack_spec, 'gem:spec']
|
|
44
|
+
|
|
40
45
|
desc "merge psych in to ruby trunk"
|
|
41
46
|
namespace :merge do
|
|
42
47
|
basedir = File.expand_path File.dirname __FILE__
|
data/lib/psych.rb
CHANGED
|
@@ -214,12 +214,19 @@ module Psych
|
|
|
214
214
|
end
|
|
215
215
|
end
|
|
216
216
|
|
|
217
|
+
def binary? string
|
|
218
|
+
string.encoding == Encoding::ASCII_8BIT ||
|
|
219
|
+
string.index("\x00") ||
|
|
220
|
+
string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3
|
|
221
|
+
end
|
|
222
|
+
private :binary?
|
|
223
|
+
|
|
217
224
|
def visit_String o
|
|
218
225
|
plain = false
|
|
219
226
|
quote = false
|
|
220
227
|
style = Nodes::Scalar::ANY
|
|
221
228
|
|
|
222
|
-
if
|
|
229
|
+
if binary?(o)
|
|
223
230
|
str = [o].pack('m').chomp
|
|
224
231
|
tag = '!binary' # FIXME: change to below when syck is removed
|
|
225
232
|
#tag = 'tag:yaml.org,2002:binary'
|
|
@@ -304,11 +311,27 @@ module Psych
|
|
|
304
311
|
end
|
|
305
312
|
|
|
306
313
|
private
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
314
|
+
# '%:z' was no defined until 1.9.3
|
|
315
|
+
if RUBY_VERSION < '1.9.3'
|
|
316
|
+
def format_time time
|
|
317
|
+
formatted = time.strftime("%Y-%m-%d %H:%M:%S.%9N")
|
|
318
|
+
|
|
319
|
+
if time.utc?
|
|
320
|
+
formatted += " Z"
|
|
321
|
+
else
|
|
322
|
+
zone = time.strftime('%z')
|
|
323
|
+
formatted += " #{zone[0,3]}:#{zone[3,5]}"
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
formatted
|
|
327
|
+
end
|
|
328
|
+
else
|
|
329
|
+
def format_time time
|
|
330
|
+
if time.utc?
|
|
331
|
+
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
|
|
332
|
+
else
|
|
333
|
+
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
|
|
334
|
+
end
|
|
312
335
|
end
|
|
313
336
|
end
|
|
314
337
|
|
data/test/psych/test_string.rb
CHANGED
|
@@ -2,6 +2,14 @@ require 'psych/helper'
|
|
|
2
2
|
|
|
3
3
|
module Psych
|
|
4
4
|
class TestString < TestCase
|
|
5
|
+
def test_tagged_binary_should_be_dumped_as_binary
|
|
6
|
+
string = "hello world!"
|
|
7
|
+
string.force_encoding 'ascii-8bit'
|
|
8
|
+
yml = Psych.dump string
|
|
9
|
+
assert_match(/binary/, yml)
|
|
10
|
+
assert_equal string, Psych.load(yml)
|
|
11
|
+
end
|
|
12
|
+
|
|
5
13
|
def test_binary_string_null
|
|
6
14
|
string = "\x00"
|
|
7
15
|
yml = Psych.dump string
|
metadata
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: psych
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: 15424007
|
|
5
|
+
prerelease: 6
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 2
|
|
9
|
+
- 2
|
|
10
|
+
- rc
|
|
9
11
|
- 1
|
|
10
|
-
version: 1.2.
|
|
12
|
+
version: 1.2.2.rc1
|
|
11
13
|
platform: ruby
|
|
12
14
|
authors:
|
|
13
15
|
- Aaron Patterson
|
|
@@ -15,7 +17,7 @@ autorequire:
|
|
|
15
17
|
bindir: bin
|
|
16
18
|
cert_chain: []
|
|
17
19
|
|
|
18
|
-
date: 2011-
|
|
20
|
+
date: 2011-10-03 00:00:00 Z
|
|
19
21
|
dependencies:
|
|
20
22
|
- !ruby/object:Gem::Dependency
|
|
21
23
|
name: rake-compiler
|
|
@@ -176,16 +178,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
176
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
179
|
none: false
|
|
178
180
|
requirements:
|
|
179
|
-
- - "
|
|
181
|
+
- - ">"
|
|
180
182
|
- !ruby/object:Gem::Version
|
|
181
|
-
hash:
|
|
183
|
+
hash: 25
|
|
182
184
|
segments:
|
|
183
|
-
-
|
|
184
|
-
|
|
185
|
+
- 1
|
|
186
|
+
- 3
|
|
187
|
+
- 1
|
|
188
|
+
version: 1.3.1
|
|
185
189
|
requirements: []
|
|
186
190
|
|
|
187
191
|
rubyforge_project: psych
|
|
188
|
-
rubygems_version: 1.8.
|
|
192
|
+
rubygems_version: 1.8.10
|
|
189
193
|
signing_key:
|
|
190
194
|
specification_version: 3
|
|
191
195
|
summary: Psych is a YAML parser and emitter
|