psych 2.0.15-java → 2.0.16-java

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: 21b5af8f236816605f77e809c7cb96a06661b2cc
4
- data.tar.gz: ba60b073e141a626e91637e12eb4f04055bc6ee5
3
+ metadata.gz: 6f4110ab7047d2c3994b5bf979138b0b8dbc1df8
4
+ data.tar.gz: bc958a3e425bc1725b46967c0c7bc1ebf02bcf02
5
5
  SHA512:
6
- metadata.gz: 50fd87911af4ff75d767ff02937fb71d6e12f44319a9d8b51aad18e59bf027d8bdfa532d1b8f80a3962940a7f5ca5d9c8d3f8a40c2f006dd09d822d5c6325cf9
7
- data.tar.gz: a32fab58e7ac81c80df6764f19ca5811a3081ed949126523cac5533a6c3e28970070cca571d57c65805a255459379a06338e667bdd7f8c549a5104bbd002b408
6
+ metadata.gz: 4b841b4ac9cb6d5455f34ee0ed82004bbb8d4c354a08fa8b2de478714b503b82d072847db6bb4ed9508e566ae23a27e6ab5c9f34925c542028a01a65174d3bad
7
+ data.tar.gz: 5c980e0ab8c7dbc86a695f55f868f47ab0b27ee7ed12494671de683588a7a0ed7aa02f8a7e6b1a79d9bab7f951a7edfb99821061e9316af60c8df82808bc3255
data/.travis.yml CHANGED
@@ -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
 
data/lib/psych.jar CHANGED
Binary file
data/lib/psych.rb CHANGED
@@ -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
 
data/test/psych/helper.rb CHANGED
@@ -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: java
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: jar-dependencies