psych 2.0.5 → 2.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70e18407966f1c51b40310189546fd35c97055da
4
- data.tar.gz: 90878220005cb871ac09a83f5adc238fdf4485d1
3
+ metadata.gz: e91f848f788c5da3599afe0e778bc171cc12bc04
4
+ data.tar.gz: c134efc70bfb872c283ae9feba311993eaa0ce33
5
5
  SHA512:
6
- metadata.gz: fc9beff6914abbf499b6c93986e2fb9cae11053e76349dd238f455edee78d8b57ff296f09095a485154f6aee4fe3af982bdccd3436a57021fdd2750aa53a02a2
7
- data.tar.gz: 75ae858c3fe0f2a98de8047f3ff79c0e9cf60c134dacedc93d8c897cd2d4c8bd4d301f0001b1537f51f85de5b08817ec3ca15607f05a07677dfc895c3b2bc966
6
+ metadata.gz: 42d1532a925bb1dc75cb64f67671b69c444ef67ccabbd649176b82d3da09c6c791bc65ddbd75dc3c8a9a23e075458f11c883d8c3902c5189ac32e404c0ce03b8
7
+ data.tar.gz: a8fc0522e9ffb4cb98065efd400129a32a8990d90c7c957acf0811285c5ef7fa3e36c540756e4ea399dcef6f6088a8f8f6d6e8c26efdf2f1a6cf5612d7f71b9c
@@ -1,3 +1,45 @@
1
+ Sat Aug 30 06:39:48 2014 Aaron Patterson <aaron@tenderlovemaking.com>
2
+
3
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: fix NameError dumping and
4
+ loading. Fixes GH #85. Thanks @brentdax for the patch!
5
+ * test/psych/test_exception.rb: test for fix
6
+
7
+ Sat Aug 30 06:23:40 2014 Aaron Patterson <aaron@tenderlovemaking.com>
8
+
9
+ * ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that
10
+ look like integers but have a newline. Fixes GH #189
11
+ * test/psych/test_string.rb: test for fix
12
+
13
+ Sat Aug 30 06:10:39 2014 Aaron Patterson <aaron@tenderlovemaking.com>
14
+
15
+ * ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash
16
+ should merge the hash in to the parent.
17
+ * test/psych/test_merge_keys.rb: test for change. Fixes GH #202
18
+
19
+ Sat Aug 30 06:00:26 2014 Aaron Patterson <aaron@tenderlovemaking.com>
20
+
21
+ * ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings
22
+ should not be treated as merge keys.
23
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: hashes with keys
24
+ containing "<<" should roundtrip.
25
+ * test/psych/test_merge_keys.rb: test for change. Fixes GH #203
26
+
27
+ Wed Aug 6 03:41:21 2014 Aaron Patterson <aaron@tenderlovemaking.com>
28
+
29
+ * ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for
30
+ hashes emitted by Syck. Github #198
31
+ * test/psych/test_hash.rb: test for change.
32
+
33
+ Fri Jun 6 07:41:41 2014 Aaron Patterson <aaron@tenderlovemaking.com>
34
+
35
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: dump empty symbols with a
36
+ tag so that they can be parsed on input. [Bug #9873] [ruby-core:62825]
37
+ * test/psych/test_symbol.rb: test for change
38
+
39
+ Sun May 25 11:35:41 2014 Zachary Scott <e@zzak.io>
40
+
41
+ * test/psych/*: YAML::ENGINE was removed in [Bug #8344]
42
+
1
43
  2014-03-27 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
2
44
 
3
45
  * ext/psych/yaml/scanner.c: merge libyaml 0.1.6
@@ -79,7 +79,6 @@ test/psych/test_deprecated.rb
79
79
  test/psych/test_document.rb
80
80
  test/psych/test_emitter.rb
81
81
  test/psych/test_encoding.rb
82
- test/psych/test_engine_manager.rb
83
82
  test/psych/test_exception.rb
84
83
  test/psych/test_hash.rb
85
84
  test/psych/test_json_tree.rb
@@ -21,7 +21,7 @@ require 'psych/class_loader'
21
21
  #
22
22
  # Psych is a YAML parser and emitter.
23
23
  # Psych leverages libyaml [Home page: http://pyyaml.org/wiki/LibYAML]
24
- # or [Git repo: https://github.com/zerotao/libyaml] for its YAML parsing
24
+ # or [HG repo: https://bitbucket.org/xi/libyaml] for its YAML parsing
25
25
  # and emitting capabilities. In addition to wrapping libyaml, Psych also
26
26
  # knows how to serialize and de-serialize most Ruby objects to and from
27
27
  # the YAML format.
@@ -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.5'
220
+ VERSION = '2.0.6'
221
221
 
222
222
  # The version of libyaml Psych is using
223
223
  LIBYAML_VERSION = Psych.libyaml_version.join '.'
@@ -37,7 +37,7 @@ module Psych
37
37
  case string
38
38
  # Check for a String type, being careful not to get caught by hash keys, hex values, and
39
39
  # special floats (e.g., -.inf).
40
- when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/
40
+ when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/, /\n/
41
41
  if string.length > 5
42
42
  @string_cache[string] = true
43
43
  return string
@@ -201,6 +201,8 @@ module Psych
201
201
  class_loader.rational
202
202
  h = Hash[*o.children.map { |c| accept c }]
203
203
  register o, Rational(h['numerator'], h['denominator'])
204
+ elsif name == 'Hash'
205
+ revive_hash(register(o, {}), o)
204
206
  else
205
207
  obj = revive((resolve_class(name) || class_loader.object), o)
206
208
  obj
@@ -303,9 +305,9 @@ module Psych
303
305
  key = accept(k)
304
306
  val = accept(v)
305
307
 
306
- if key == '<<'
308
+ if key == '<<' && k.tag != "tag:yaml.org,2002:str"
307
309
  case v
308
- when Nodes::Alias
310
+ when Nodes::Alias, Nodes::Mapping
309
311
  begin
310
312
  hash.merge! val
311
313
  rescue TypeError
@@ -16,10 +16,12 @@ module Psych
16
16
  def initialize
17
17
  @obj_to_id = {}
18
18
  @obj_to_node = {}
19
+ @targets = []
19
20
  @counter = 0
20
21
  end
21
22
 
22
23
  def register target, node
24
+ @targets << target
23
25
  @obj_to_node[target.object_id] = node
24
26
  end
25
27
 
@@ -209,6 +211,25 @@ module Psych
209
211
  @emitter.end_mapping
210
212
  end
211
213
 
214
+ def visit_NameError o
215
+ tag = ['!ruby/exception', o.class.name].join ':'
216
+
217
+ @emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
218
+
219
+ {
220
+ 'message' => o.message.to_s,
221
+ 'backtrace' => private_iv_get(o, 'backtrace'),
222
+ }.each do |k,v|
223
+ next unless v
224
+ @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
225
+ accept v
226
+ end
227
+
228
+ dump_ivars o
229
+
230
+ @emitter.end_mapping
231
+ end
232
+
212
233
  def visit_Regexp o
213
234
  register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
214
235
  end
@@ -289,6 +310,11 @@ module Psych
289
310
  quote = false
290
311
  elsif o =~ /\n/
291
312
  style = Nodes::Scalar::LITERAL
313
+ elsif o == '<<'
314
+ style = Nodes::Scalar::SINGLE_QUOTED
315
+ tag = 'tag:yaml.org,2002:str'
316
+ plain = false
317
+ quote = false
292
318
  elsif o =~ /^\W[^"]*$/
293
319
  style = Nodes::Scalar::DOUBLE_QUOTED
294
320
  else
@@ -378,7 +404,11 @@ module Psych
378
404
  end
379
405
 
380
406
  def visit_Symbol o
381
- @emitter.scalar ":#{o}", nil, nil, true, false, Nodes::Scalar::ANY
407
+ if o.empty?
408
+ @emitter.scalar "", nil, '!ruby/symbol', false, false, Nodes::Scalar::ANY
409
+ else
410
+ @emitter.scalar ":#{o}", nil, nil, true, false, Nodes::Scalar::ANY
411
+ end
382
412
  end
383
413
 
384
414
  private
@@ -16,6 +16,12 @@ module Psych
16
16
  @wups = Wups.new
17
17
  end
18
18
 
19
+ def test_naming_exception
20
+ err = String.xxx rescue $!
21
+ new_err = Psych.load(Psych.dump(err))
22
+ assert_equal err.message, new_err.message
23
+ end
24
+
19
25
  def test_load_takes_file
20
26
  ex = assert_raises(Psych::SyntaxError) do
21
27
  Psych.load '--- `'
@@ -10,6 +10,11 @@ module Psych
10
10
  @hash = { :a => 'b' }
11
11
  end
12
12
 
13
+ def test_load_with_class_syck_compatibility
14
+ hash = Psych.load "--- !ruby/object:Hash\n:user_id: 7\n:username: Lucas\n"
15
+ assert_equal({ user_id: 7, username: 'Lucas'}, hash)
16
+ end
17
+
13
18
  def test_empty_subclass
14
19
  assert_match "!ruby/hash:#{X}", Psych.dump(X.new)
15
20
  x = Psych.load Psych.dump X.new
@@ -6,6 +6,36 @@ module Psych
6
6
  attr_reader :bar
7
7
  end
8
8
 
9
+ def test_merge_key_with_bare_hash
10
+ doc = Psych.load <<-eodoc
11
+ map:
12
+ <<:
13
+ hello: world
14
+ eodoc
15
+ hash = { "map" => { "hello" => "world" } }
16
+ assert_equal hash, doc
17
+ end
18
+
19
+ def test_roundtrip_with_chevron_key
20
+ h = {}
21
+ v = { 'a' => h, '<<' => h }
22
+ assert_cycle v
23
+ end
24
+
25
+ def test_explicit_string
26
+ doc = Psych.load <<-eoyml
27
+ a: &me { hello: world }
28
+ b: { !!str '<<': *me }
29
+ eoyml
30
+ expected = {
31
+ "a" => { "hello" => "world" },
32
+ "b" => {
33
+ "<<" => { "hello" => "world" }
34
+ }
35
+ }
36
+ assert_equal expected, doc
37
+ end
38
+
9
39
  def test_mergekey_with_object
10
40
  s = <<-eoyml
11
41
  foo: &foo
@@ -15,6 +15,10 @@ module Psych
15
15
  end
16
16
  end
17
17
 
18
+ def test_string_with_newline
19
+ assert_equal "1\n2", Psych.load("--- ! '1\n\n 2'\n")
20
+ end
21
+
18
22
  def test_no_doublequotes_with_special_characters
19
23
  assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"')
20
24
  end
@@ -2,6 +2,14 @@ require_relative 'helper'
2
2
 
3
3
  module Psych
4
4
  class TestSymbol < TestCase
5
+ def test_cycle_empty
6
+ assert_cycle :''
7
+ end
8
+
9
+ def test_cycle_colon
10
+ assert_cycle :':'
11
+ end
12
+
5
13
  def test_cycle
6
14
  assert_cycle :a
7
15
  end
@@ -1,5 +1,3 @@
1
- # -*- coding: UTF-8 -*-
2
-
3
1
  require_relative 'helper'
4
2
  require 'tmpdir'
5
3
 
@@ -13,7 +11,6 @@ module Psych
13
11
 
14
12
  class YAMLDBMTest < TestCase
15
13
  def setup
16
- @engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
17
14
  @dir = Dir.mktmpdir("rubytest-file")
18
15
  File.chown(-1, Process.gid, @dir)
19
16
  @yamldbm_file = make_tmp_filename("yamldbm")
@@ -21,7 +18,6 @@ module Psych
21
18
  end
22
19
 
23
20
  def teardown
24
- YAML::ENGINE.yamler = @engine
25
21
  @yamldbm.clear
26
22
  @yamldbm.close
27
23
  FileUtils.remove_entry_secure @dir
@@ -7,7 +7,6 @@ module Psych
7
7
 
8
8
  class YAMLStoreTest < TestCase
9
9
  def setup
10
- @engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
11
10
  @dir = Dir.mktmpdir("rubytest-file")
12
11
  File.chown(-1, Process.gid, @dir)
13
12
  @yamlstore_file = make_tmp_filename("yamlstore")
@@ -15,7 +14,6 @@ module Psych
15
14
  end
16
15
 
17
16
  def teardown
18
- YAML::ENGINE.yamler = @engine
19
17
  FileUtils.remove_entry_secure @dir
20
18
  end
21
19
 
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.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.8'
47
+ version: '3.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.8'
54
+ version: '3.12'
55
55
  description: |-
56
56
  Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
57
57
  for its YAML parsing and emitting capabilities. In addition to wrapping
@@ -149,7 +149,6 @@ files:
149
149
  - test/psych/test_document.rb
150
150
  - test/psych/test_emitter.rb
151
151
  - test/psych/test_encoding.rb
152
- - test/psych/test_engine_manager.rb
153
152
  - test/psych/test_exception.rb
154
153
  - test/psych/test_hash.rb
155
154
  - test/psych/test_json_tree.rb
@@ -202,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
201
  - !ruby/object:Gem::Version
203
202
  version: '0'
204
203
  requirements: []
205
- rubyforge_project: psych
204
+ rubyforge_project:
206
205
  rubygems_version: 2.2.2
207
206
  signing_key:
208
207
  specification_version: 4
@@ -221,7 +220,6 @@ test_files:
221
220
  - test/psych/test_document.rb
222
221
  - test/psych/test_emitter.rb
223
222
  - test/psych/test_encoding.rb
224
- - test/psych/test_engine_manager.rb
225
223
  - test/psych/test_exception.rb
226
224
  - test/psych/test_hash.rb
227
225
  - test/psych/test_json_tree.rb
@@ -1,47 +0,0 @@
1
- require_relative 'helper'
2
- require 'yaml'
3
-
4
- module Psych
5
- class TestEngineManager < TestCase
6
- def test_bad_engine
7
- assert_raises(ArgumentError) do
8
- YAML::ENGINE.yamler = 'foooo'
9
- end
10
- end
11
-
12
- def test_set_psych
13
- YAML::ENGINE.yamler = 'psych'
14
- assert_equal Psych, YAML
15
- assert_equal 'psych', YAML::ENGINE.yamler
16
- end
17
-
18
- A = Struct.new(:name)
19
-
20
- def test_dump_types
21
- YAML::ENGINE.yamler = 'psych'
22
-
23
- assert_to_yaml ::Object.new
24
- assert_to_yaml Time.now
25
- assert_to_yaml Date.today
26
- assert_to_yaml('a' => 'b')
27
- assert_to_yaml A.new('foo')
28
- assert_to_yaml %w{a b}
29
- assert_to_yaml Exception.new('foo')
30
- assert_to_yaml "hello!"
31
- assert_to_yaml :fooo
32
- assert_to_yaml(1..10)
33
- assert_to_yaml(/hello!~/)
34
- assert_to_yaml 1
35
- assert_to_yaml 1.2
36
- assert_to_yaml Rational(1, 2)
37
- assert_to_yaml Complex(1, 2)
38
- assert_to_yaml true
39
- assert_to_yaml false
40
- assert_to_yaml nil
41
- end
42
-
43
- def assert_to_yaml obj
44
- assert obj.to_yaml, "#{obj.class} to_yaml works"
45
- end
46
- end
47
- end