psych 2.0.15 → 2.0.16

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: 9723896ce1c029250c40de2395d76fe4133285da
4
- data.tar.gz: 6dfe37723db8e821b8c82d656188c95331e7d800
3
+ metadata.gz: 7c037fcb7ef48f0f83b3b03427ad2ffdd96befdc
4
+ data.tar.gz: d51f7d29fc63de8aa3aa823e585d060595194347
5
5
  SHA512:
6
- metadata.gz: d5e5204545c105702e9f0ff93b608b2b804f06e512745c74b3db837088e24f1f356190e01234c7316563c11bf0114596398d5e8894db296e121d4d272ffbd7e9
7
- data.tar.gz: e95109b57bf2b48c6236818a4804ff48c68792c5ac11e62eea5ad9b963a72d2de525673a40a73f3659678ee2bf1ea8c606375bb93fccd396ae95d032bac2e8fe
6
+ metadata.gz: 03afdda5d3685773185c2064b6651ea66d64da1202b4e53966742fbcb72faa0bbcfa587e12e57b67eee3566bf91aaa082af110628bb6e453f9fc7ad7f2b740f7
7
+ data.tar.gz: a3a4acdd49e43956f05e639e2e0f926e883267fc1552dcb5ca686e557ad4992b0f00d01c780ef052510d831fcfa8af85e6133d290712ea960f3563ab4141dd9b
@@ -1,6 +1,4 @@
1
1
  rvm:
2
- - 1.9.2
3
- - 1.9.3
4
2
  - 2.0.0
5
3
  - 2.1.0
6
4
  - 2.2.0
@@ -13,4 +11,4 @@ before_script:
13
11
  script: rake test
14
12
  matrix:
15
13
  allow_failures:
16
- - rvm: rbx-2
14
+ - rvm: rbx-2
@@ -1,5 +1,12 @@
1
1
  #include <psych.h>
2
2
 
3
+ #if !defined(RARRAY_CONST_PTR)
4
+ #define RARRAY_CONST_PTR(s) (const VALUE *)RARRAY_PTR(s)
5
+ #endif
6
+ #if !defined(RARRAY_AREF)
7
+ #define RARRAY_AREF(a, i) RARRAY_CONST_PTR(a)[i]
8
+ #endif
9
+
3
10
  VALUE cPsychEmitter;
4
11
  static ID id_write;
5
12
  static ID id_line_width;
@@ -15,7 +22,11 @@ static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
15
22
  static int writer(void *ctx, unsigned char *buffer, size_t size)
16
23
  {
17
24
  VALUE io = (VALUE)ctx;
25
+ #ifdef HAVE_RUBY_ENCODING_H
26
+ VALUE str = rb_enc_str_new((const char *)buffer, (long)size, rb_utf8_encoding());
27
+ #else
18
28
  VALUE str = rb_str_new((const char *)buffer, (long)size);
29
+ #endif
19
30
  VALUE wrote = rb_funcall(io, id_write, 1, str);
20
31
  return (int)NUM2INT(wrote);
21
32
  }
@@ -155,7 +166,7 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
155
166
  }
156
167
 
157
168
  if(RTEST(tags)) {
158
- int i = 0;
169
+ long i = 0;
159
170
  #ifdef HAVE_RUBY_ENCODING_H
160
171
  rb_encoding * encoding = rb_utf8_encoding();
161
172
  #endif
@@ -166,7 +177,7 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
166
177
  tail = head;
167
178
 
168
179
  for(i = 0; i < RARRAY_LEN(tags); i++) {
169
- VALUE tuple = RARRAY_PTR(tags)[i];
180
+ VALUE tuple = RARRAY_AREF(tags, i);
170
181
  VALUE name;
171
182
  VALUE value;
172
183
 
@@ -176,8 +187,8 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
176
187
  xfree(head);
177
188
  rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
178
189
  }
179
- name = RARRAY_PTR(tuple)[0];
180
- value = RARRAY_PTR(tuple)[1];
190
+ name = RARRAY_AREF(tuple, 0);
191
+ value = RARRAY_AREF(tuple, 1);
181
192
  #ifdef HAVE_RUBY_ENCODING_H
182
193
  name = rb_str_export_to_enc(name, encoding);
183
194
  value = rb_str_export_to_enc(value, encoding);
@@ -2053,7 +2053,7 @@ yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
2053
2053
  else
2054
2054
  {
2055
2055
  yaml_parser_set_scanner_error(parser, "while scanning a directive",
2056
- start_mark, "found uknown directive name");
2056
+ start_mark, "found unknown directive name");
2057
2057
  goto error;
2058
2058
  }
2059
2059
 
@@ -223,7 +223,7 @@ require 'psych/class_loader'
223
223
 
224
224
  module Psych
225
225
  # The version is Psych you're using
226
- VERSION = '2.0.15'
226
+ VERSION = '2.0.16'
227
227
 
228
228
  # The version of libyaml Psych is using
229
229
  LIBYAML_VERSION = Psych.libyaml_version.join '.'
@@ -330,12 +330,13 @@ module Psych
330
330
  list
331
331
  end
332
332
 
333
+ SHOVEL = '<<'
333
334
  def revive_hash hash, o
334
335
  o.children.each_slice(2) { |k,v|
335
336
  key = accept(k)
336
337
  val = accept(v)
337
338
 
338
- if key == '<<' && k.tag != "tag:yaml.org,2002:str"
339
+ if key == SHOVEL && k.tag != "tag:yaml.org,2002:str"
339
340
  case v
340
341
  when Nodes::Alias, Nodes::Mapping
341
342
  begin
@@ -70,6 +70,14 @@ module Psych
70
70
  @ss = ss
71
71
  @options = options
72
72
  @line_width = options[:line_width]
73
+ if @line_width && @line_width < 0
74
+ if @line_width == -1
75
+ # Treat -1 as unlimited line-width, same as libyaml does.
76
+ @line_width = nil
77
+ else
78
+ fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.")
79
+ end
80
+ end
73
81
  @coders = []
74
82
 
75
83
  @dispatch_cache = Hash.new do |h,klass|
@@ -510,27 +518,11 @@ module Psych
510
518
  def dump_list o
511
519
  end
512
520
 
513
- # '%:z' was no defined until 1.9.3
514
- if RUBY_VERSION < '1.9.3'
515
- def format_time time
516
- formatted = time.strftime("%Y-%m-%d %H:%M:%S.%9N")
517
-
518
- if time.utc?
519
- formatted += " Z"
520
- else
521
- zone = time.strftime('%z')
522
- formatted += " #{zone[0,3]}:#{zone[3,5]}"
523
- end
524
-
525
- formatted
526
- end
527
- else
528
- def format_time time
529
- if time.utc?
530
- time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
531
- else
532
- time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
533
- end
521
+ def format_time time
522
+ if time.utc?
523
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
524
+ else
525
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
534
526
  end
535
527
  end
536
528
 
@@ -91,7 +91,7 @@ module Psych
91
91
  end
92
92
  end
93
93
 
94
- # backport so that tests will run on 1.9 and 2.0.0
94
+ # backport so that tests will run on 2.0.0
95
95
  unless Tempfile.respond_to? :create
96
96
  def Tempfile.create(basename, *rest)
97
97
  tmpfile = nil
@@ -249,6 +249,15 @@ module Psych
249
249
  assert_encodings @utf8, @handler.strings
250
250
  end
251
251
 
252
+ def test_dump_non_ascii_string_to_file
253
+ Tempfile.create(['utf8', 'yml'], :encoding => 'UTF-8') do |t|
254
+ h = {'one' => 'いち'}
255
+ Psych.dump(h, t)
256
+ t.close
257
+ assert_equal h, Psych.load_file(t.path)
258
+ end
259
+ end
260
+
252
261
  private
253
262
  def assert_encodings encoding, strings
254
263
  strings.each do |str|
@@ -8,7 +8,17 @@ class TestPsych < Psych::TestCase
8
8
  Psych.domain_types.clear
9
9
  end
10
10
 
11
- def test_line_width
11
+ def test_line_width_invalid
12
+ assert_raises(ArgumentError) { Psych.dump('x', { :line_width => -2 }) }
13
+ end
14
+
15
+ def test_line_width_no_limit
16
+ data = { 'a' => 'a b' * 50}
17
+ expected = "---\na: #{'a b' * 50}\n"
18
+ assert_equal(expected, Psych.dump(data, { :line_width => -1 }))
19
+ end
20
+
21
+ def test_line_width_limit
12
22
  yml = Psych.dump('123456 7', { :line_width => 5 })
13
23
  assert_match(/^\s*7/, yml)
14
24
  end
@@ -77,7 +77,6 @@ module Psych
77
77
  # end
78
78
 
79
79
  def test_key
80
- skip 'only on ruby 2.0.0' if RUBY_VERSION < '2.0.0'
81
80
  @yamldbm['a'] = 'b'
82
81
  @yamldbm['c'] = 'd'
83
82
  assert_equal 'a', @yamldbm.key('b')
@@ -166,16 +166,14 @@ description:
166
166
  assert_equal Complex(1,2), mapping.to_ruby
167
167
  end
168
168
 
169
- if RUBY_VERSION >= '1.9'
170
- def test_complex_string
171
- node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
172
- assert_equal Complex(3, 4), node.to_ruby
173
- end
169
+ def test_complex_string
170
+ node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
171
+ assert_equal Complex(3, 4), node.to_ruby
172
+ end
174
173
 
175
- def test_rational_string
176
- node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
177
- assert_equal Rational(1, 2), node.to_ruby
178
- end
174
+ def test_rational_string
175
+ node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
176
+ assert_equal Rational(1, 2), node.to_ruby
179
177
  end
180
178
 
181
179
  def test_range_string
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.15
4
+ version: 2.0.16
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-08-21 00:00:00.000000000 Z
11
+ date: 2015-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.13'
61
+ version: '3.14'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.13'
68
+ version: '3.14'
69
69
  description: |-
70
70
  Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
71
71
  for its YAML parsing and emitting capabilities. In addition to wrapping
@@ -82,7 +82,6 @@ extra_rdoc_files:
82
82
  - README.rdoc
83
83
  files:
84
84
  - ".autotest"
85
- - ".gemtest"
86
85
  - ".travis.yml"
87
86
  - CHANGELOG.rdoc
88
87
  - Manifest.txt
data/.gemtest DELETED
File without changes