psych 1.3.2 → 1.3.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.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,34 @@
1
+ Fri May 18 01:28:21 2012 Aaron Patterson <aaron@tenderlovemaking.com>
2
+
3
+ * ext/psych/parser.c (transcode_string): fix encoding index names.
4
+ Thanks markizko for reporting.
5
+
6
+ Wed May 16 05:11:29 2012 Aaron Patterson <aaron@tenderlovemaking.com>
7
+
8
+ * ext/psych/lib/psych/visitors/to_ruby.rb: fix a bug with string
9
+ subclass dumping and loading.
10
+
11
+ * test/psych/test_array.rb: pertinent tests
12
+
13
+ * test/psych/test_string.rb: ditto
14
+
15
+ Wed May 16 01:31:21 2012 Aaron Patterson <aaron@tenderlovemaking.com>
16
+
17
+ * ext/psych/lib/psych/visitors/to_ruby.rb: convert omap tagged maps to
18
+ Psych::Omap objects rather than hashes. [Bug #6425]
19
+
20
+ * test/psych/test_omap.rb: pertinent test.
21
+
22
+ Wed May 16 01:15:45 2012 Aaron Patterson <aaron@tenderlovemaking.com>
23
+
24
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: keep a reference to
25
+ custom coders so that GC does not impact dumped yaml reference ids.
26
+
27
+ Mon Apr 30 04:43:53 2012 Aaron Patterson <aaron@tenderlovemaking.com>
28
+
29
+ * ext/psych/lib/psych/json/yaml_events.rb: implicit styles should not
30
+ be changeable for JSON events.
31
+
1
32
  Sat Apr 7 02:07:00 2012 Aaron Patterson <aaron@tenderlovemaking.com>
2
33
 
3
34
  * ext/psych/parser.c: fall back to any encoding if the external
data/ext/psych/parser.c CHANGED
@@ -79,8 +79,8 @@ static VALUE make_exception(yaml_parser_t * parser, VALUE path)
79
79
  static VALUE transcode_string(VALUE src, int * parser_encoding)
80
80
  {
81
81
  int utf8 = rb_utf8_encindex();
82
- int utf16le = rb_enc_find_index("UTF16_LE");
83
- int utf16be = rb_enc_find_index("UTF16_BE");
82
+ int utf16le = rb_enc_find_index("UTF-16LE");
83
+ int utf16be = rb_enc_find_index("UTF-16BE");
84
84
  int source_encoding = rb_enc_get_index(src);
85
85
 
86
86
  if (source_encoding == utf8) {
data/lib/psych.rb CHANGED
@@ -93,7 +93,7 @@ require 'psych/handlers/document_stream'
93
93
 
94
94
  module Psych
95
95
  # The version is Psych you're using
96
- VERSION = '1.3.2'
96
+ VERSION = '1.3.3'
97
97
 
98
98
  # The version of libyaml Psych is using
99
99
  LIBYAML_VERSION = Psych.libyaml_version.join '.'
@@ -10,11 +10,11 @@ module Psych
10
10
  end
11
11
 
12
12
  def start_mapping anchor, tag, implicit, style
13
- super(anchor, nil, implicit, Nodes::Mapping::FLOW)
13
+ super(anchor, nil, true, Nodes::Mapping::FLOW)
14
14
  end
15
15
 
16
16
  def start_sequence anchor, tag, implicit, style
17
- super(anchor, nil, implicit, Nodes::Sequence::FLOW)
17
+ super(anchor, nil, true, Nodes::Sequence::FLOW)
18
18
  end
19
19
 
20
20
  def scalar value, anchor, tag, plain, quoted, style
@@ -147,8 +147,7 @@ module Psych
147
147
  string = members.delete 'str'
148
148
 
149
149
  if klass
150
- string = klass.allocate
151
- string.replace string
150
+ string = klass.allocate.replace string
152
151
  end
153
152
 
154
153
  init_with(string, members.map { |k,v| [k.to_s.sub(/^@/, ''),v] }, o)
@@ -222,6 +221,13 @@ module Psych
222
221
  when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
223
222
  revive_hash resolve_class($1).new, o
224
223
 
224
+ when '!omap', 'tag:yaml.org,2002:omap'
225
+ map = register(o, Psych::Omap.new)
226
+ o.children.each_slice(2) do |l,r|
227
+ map[accept(l)] = accept r
228
+ end
229
+ map
230
+
225
231
  else
226
232
  revive_hash({}, o)
227
233
  end
@@ -20,6 +20,7 @@ module Psych
20
20
  @st = {}
21
21
  @ss = ss
22
22
  @options = options
23
+ @coders = []
23
24
 
24
25
  @dispatch_cache = Hash.new do |h,klass|
25
26
  method = "visit_#{(klass.name || '').split('::').join('_')}"
@@ -406,6 +407,7 @@ module Psych
406
407
  end
407
408
 
408
409
  def dump_coder o
410
+ @coders << o
409
411
  tag = Psych.dump_tags[o.class]
410
412
  unless tag
411
413
  klass = o.class == Object ? nil : o.class.name
@@ -14,6 +14,16 @@ module Psych
14
14
  @list = [{ :a => 'b' }, 'foo']
15
15
  end
16
16
 
17
+ def test_another_subclass_with_attributes
18
+ y = Y.new.tap {|y| y.val = 1}
19
+ y << "foo" << "bar"
20
+ y = Psych.load Psych.dump y
21
+
22
+ assert_equal %w{foo bar}, y
23
+ assert_equal Y, y.class
24
+ assert_equal 1, y.val
25
+ end
26
+
17
27
  def test_subclass
18
28
  yaml = Psych.dump X.new
19
29
  assert_match X.name, yaml
@@ -2,6 +2,13 @@ require 'psych/helper'
2
2
 
3
3
  module Psych
4
4
  class TestOmap < TestCase
5
+ def test_parse_as_map
6
+ o = Psych.load "--- !!omap\na: 1\nb: 2"
7
+ assert_kind_of Psych::Omap, o
8
+ assert_equal 1, o['a']
9
+ assert_equal 2, o['b']
10
+ end
11
+
5
12
  def test_self_referential
6
13
  map = Psych::Omap.new
7
14
  map['foo'] = 'bar'
@@ -32,6 +32,13 @@ module Psych
32
32
  @handler.parser = @parser
33
33
  end
34
34
 
35
+ def test_ast_roundtrip
36
+ parser = Psych.parser
37
+ parser.parse('null')
38
+ ast = parser.handler.root
39
+ assert_match(/^null/, ast.yaml)
40
+ end
41
+
35
42
  def test_exception_memory_leak
36
43
  yaml = <<-eoyaml
37
44
  %YAML 1.1
@@ -9,6 +9,13 @@ module Psych
9
9
  attr_accessor :val
10
10
  end
11
11
 
12
+ def test_another_subclass_with_attributes
13
+ y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1}
14
+ assert_equal "foo", y
15
+ assert_equal Y, y.class
16
+ assert_equal 1, y.val
17
+ end
18
+
12
19
  def test_backwards_with_syck
13
20
  x = Psych.load "--- !str:#{X.name} foo\n\n"
14
21
  assert_equal X, x.class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psych
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,41 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-07 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rake-compiler
16
- requirement: &70210793685840 !ruby/object:Gem::Requirement
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.4.1
21
+ version: '3.10'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70210793685840
25
- - !ruby/object:Gem::Dependency
26
- name: rdoc
27
- requirement: &70210793685400 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
28
25
  none: false
29
26
  requirements:
30
27
  - - ~>
31
28
  - !ruby/object:Gem::Version
32
29
  version: '3.10'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake-compiler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.4.1
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70210793685400
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.4.1
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: hoe
38
- requirement: &70210793709520 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
42
52
  - !ruby/object:Gem::Version
43
- version: '2.13'
53
+ version: '3.0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70210793709520
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
47
62
  description: ! 'Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
48
63
 
49
64
  for its YAML parsing and emitting capabilities. In addition to wrapping
@@ -57,8 +72,8 @@ executables: []
57
72
  extensions:
58
73
  - ext/psych/extconf.rb
59
74
  extra_rdoc_files:
60
- - Manifest.txt
61
75
  - CHANGELOG.rdoc
76
+ - Manifest.txt
62
77
  - README.rdoc
63
78
  files:
64
79
  - .autotest
@@ -178,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
193
  version: '0'
179
194
  requirements: []
180
195
  rubyforge_project: psych
181
- rubygems_version: 1.8.17
196
+ rubygems_version: 1.8.23
182
197
  signing_key:
183
198
  specification_version: 3
184
199
  summary: Psych is a YAML parser and emitter