psych 2.0.12 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38ed899f0b22c57d8a653dfb84f54a92d9c51ccd
4
- data.tar.gz: b9fe79097035b8594dff79dacb4c85e55451be5f
3
+ metadata.gz: 98ff80d57bc20b6d84ee24df83966f0feebfbe3f
4
+ data.tar.gz: afa7e8005ce6e5ce2867e4c3d06793d94c2af627
5
5
  SHA512:
6
- metadata.gz: 705e8c7667b4a841aab3a868a3a77cb5e55eb0e6a3d76c1169eba8244ab8b5307c83f85d5fa546f4fdbbdf62ee1a82d2336a30a17443556875ffa8b29fd60bfc
7
- data.tar.gz: 76f6c273cd9a0570fc64c1f0e789f907cb3ceeeabe6764549713a59fbbf06d83953afa4fcb53b6ca9527c724778b459b4bfac3310eb6e8ebe342b15e8589678e
6
+ metadata.gz: d219a2267fdb9c6471a9e27e18242e572bcbf259207d78b4a8948dd812fc1da23bde5b24850e099961c4d0384a71d2bb2177c02b8131d771d8c726924ec693f0
7
+ data.tar.gz: 0ae5569645a513442d8f7859b2ab3154a42c8fc728ec9a82f6a40971554eab5907338032352522755cc59666d13f58d42304f71aaacd6f86b5fc9c7c3f4f9dc9
@@ -1,3 +1,17 @@
1
+ Fri Feb 6 17:47:05 2015 Aaron Patterson <aaron@tenderlovemaking.com>
2
+
3
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: register nodes when
4
+ dumping objects with custom coders. [ruby-core:66215] [Bug #10496]
5
+
6
+ * test/psych/test_coder.rb: test for fix
7
+
8
+ Fri Feb 6 16:58:31 2015 Aaron Patterson <aaron@tenderlovemaking.com>
9
+
10
+ * ext/psych/lib/psych/visitors/to_ruby.rb: fix support for regular
11
+ expressions with newlines. tenderlove/psych#222
12
+
13
+ * test/psych/test_yaml.rb: test for change.
14
+
1
15
  Thu Jan 29 02:34:27 2015 Aaron Patterson <aaron@tenderlovemaking.com>
2
16
 
3
17
  * ext/psych/lib/psych/visitors/to_ruby.rb: fix parsing hashes with
@@ -1105,13 +1105,6 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
1105
1105
  int required = (!parser->flow_level
1106
1106
  && parser->indent == (ptrdiff_t)parser->mark.column);
1107
1107
 
1108
- /*
1109
- * A simple key is required only when it is the first token in the current
1110
- * line. Therefore it is always allowed. But we add a check anyway.
1111
- */
1112
-
1113
- assert(parser->simple_key_allowed || !required); /* Impossible. */
1114
-
1115
1108
  /*
1116
1109
  * If the current position may start a simple key, save it.
1117
1110
  */
@@ -217,7 +217,7 @@ require 'psych/class_loader'
217
217
 
218
218
  module Psych
219
219
  # The version is Psych you're using
220
- VERSION = '2.0.12'
220
+ VERSION = '2.0.13'
221
221
 
222
222
  # The version of libyaml Psych is using
223
223
  LIBYAML_VERSION = Psych.libyaml_version.join '.'
@@ -32,7 +32,7 @@ module Psych
32
32
  return result if @domain_types.empty? || !target.tag
33
33
 
34
34
  key = target.tag.sub(/^[!\/]*/, '').sub(/(,\d+)\//, '\1:')
35
- key = "tag:#{key}" unless key =~ /^(tag:|x-private)/
35
+ key = "tag:#{key}" unless key =~ /^(?:tag:|x-private)/
36
36
 
37
37
  if @domain_types.key? key
38
38
  value, block = @domain_types[key]
@@ -89,7 +89,7 @@ module Psych
89
89
  Float(@ss.tokenize(o.value))
90
90
  when "!ruby/regexp"
91
91
  klass = class_loader.regexp
92
- o.value =~ /^\/(.*)\/([mixn]*)$/
92
+ o.value =~ /^\/(.*)\/([mixn]*)$/m
93
93
  source = $1
94
94
  options = 0
95
95
  lang = nil
@@ -21,6 +21,7 @@ module Psych
21
21
  end
22
22
 
23
23
  def register target, node
24
+ return unless target.respond_to? :object_id
24
25
  @targets << target
25
26
  @obj_to_node[target.object_id] = node
26
27
  end
@@ -566,10 +567,10 @@ module Psych
566
567
 
567
568
  c = Psych::Coder.new(tag)
568
569
  o.encode_with(c)
569
- emit_coder c
570
+ emit_coder c, o
570
571
  end
571
572
 
572
- def emit_coder c
573
+ def emit_coder c, o
573
574
  case c.type
574
575
  when :scalar
575
576
  @emitter.scalar c.scalar, nil, c.tag, c.tag.nil?, false, Nodes::Scalar::ANY
@@ -580,7 +581,7 @@ module Psych
580
581
  end
581
582
  @emitter.end_sequence
582
583
  when :map
583
- @emitter.start_mapping nil, c.tag, c.implicit, c.style
584
+ register o, @emitter.start_mapping(nil, c.tag, c.implicit, c.style)
584
585
  c.map.each do |k,v|
585
586
  accept k
586
587
  accept v
@@ -5,7 +5,13 @@ require 'date'
5
5
  require 'psych'
6
6
 
7
7
  module Psych
8
- class TestCase < MiniTest::Unit::TestCase
8
+ superclass = if defined?(Minitest::Test)
9
+ Minitest::Test
10
+ else
11
+ MiniTest::Unit::TestCase
12
+ end
13
+
14
+ class TestCase < superclass
9
15
  def self.suppress_warning
10
16
  verbose, $VERBOSE = $VERBOSE, nil
11
17
  yield
@@ -95,6 +95,28 @@ module Psych
95
95
  end
96
96
  end
97
97
 
98
+ class Referential
99
+ attr_reader :a
100
+
101
+ def initialize
102
+ @a = self
103
+ end
104
+
105
+ def encode_with(c)
106
+ c['a'] = @a
107
+ end
108
+
109
+ def init_with(c)
110
+ @a = c['a']
111
+ end
112
+ end
113
+
114
+ def test_self_referential
115
+ x = Referential.new
116
+ copy = Psych.load Psych.dump x
117
+ assert_equal copy, copy.a
118
+ end
119
+
98
120
  def test_represent_with_object
99
121
  thing = Psych.load(Psych.dump(RepresentWithObject.new))
100
122
  assert_equal 20, thing
@@ -1,7 +1,7 @@
1
1
  require_relative 'helper'
2
2
 
3
3
  module Psych
4
- class TestToYamlProperties < MiniTest::Unit::TestCase
4
+ class TestToYamlProperties < Psych::TestCase
5
5
  class Foo
6
6
  attr_accessor :a, :b, :c
7
7
  def initialize
@@ -27,6 +27,10 @@ class Psych_Unit_Tests < Psych::TestCase
27
27
  assert_match "2010-10-10 00:00:00.000000000 Z", yaml
28
28
  end
29
29
 
30
+ def test_multiline_regexp
31
+ assert_cycle(Regexp.new("foo\nbar"))
32
+ end
33
+
30
34
  # [ruby-core:34969]
31
35
  def test_regexp_with_n
32
36
  assert_cycle(Regexp.new('',0,'n'))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psych
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.12
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc