psych 2.0.0 → 2.0.1

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: a515327ad24888eda25dad4eefcc3120c27851c4
4
- data.tar.gz: 4397401188b23a9103f30c61cd3b91a2eeddac41
3
+ metadata.gz: 18ab569c52dd4c717aa67c3752008efba6f68f9d
4
+ data.tar.gz: 5de13cdc481633c56eb2e1dfb9067f9922d6ad30
5
5
  SHA512:
6
- metadata.gz: 32f49d5585211df26e9d06a25dae306376c24a30d68d3184e79adf34082773790d785e46302c4ea17bc73f2b11ca049ca9403c0334b55941417989702ee46621
7
- data.tar.gz: 3e1c6bb1ab901c77209b400f9f6e8b193de2cb58bb8b7cceee1cbf51b6381565232f25b3f1ff51621479eed3013d7a207e89ffdb6232d698330365664530cfa1
6
+ metadata.gz: 681a0bef521a162525b1b72e538bac13373857f4e2677cf4909fc6f8e90b740b5fb3abaee0f1a480b8db48d18d7d3793141f248fd48acbe78d64747da0784a0c
7
+ data.tar.gz: e1281e00a69f1faeaeb15543baf7b588d955b8f2b64915752d4c5ad180d5630da46839c883efd468ba02651d7db882c36f38537ae43d05ae1d2ffa4c864de66e
@@ -1,7 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
- - ruby-head
4
+ - 2.0.0
5
5
  before_script:
6
6
  - gem install isolate
7
7
  - gem install hoe
@@ -1,3 +1,25 @@
1
+ Fri Sep 6 02:37:22 2013 Aaron Patterson <aaron@tenderlovemaking.com>
2
+
3
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: use double quotes when
4
+ strings start with special characters.
5
+ [Fixes GH-157] https://github.com/tenderlove/psych/issues/157
6
+
7
+ * test/psych/test_string.rb: test for change.
8
+
9
+ Thu Aug 29 02:40:45 2013 Aaron Patterson <aaron@tenderlovemaking.com>
10
+
11
+ * ext/psych/lib/psych/scalar_scanner.rb: invalid floats should be
12
+ treated as strings.
13
+ [Fixes GH-156] https://github.com/tenderlove/psych/issues/156
14
+
15
+ * test/psych/test_string.rb: test for change
16
+
17
+ Sat Jul 6 04:49:38 2013 Aaron Patterson <aaron@tenderlovemaking.com>
18
+
19
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: register time objects so
20
+ they are referenced as ids during output.
21
+ * test/psych/test_date_time.rb: corresponding test.
22
+
1
23
  Wed May 15 02:22:16 2013 Aaron Patterson <aaron@tenderlovemaking.com>
2
24
 
3
25
  * ext/psych/lib/psych.rb: Adding Psych.safe_load for loading a user
@@ -1089,7 +1089,7 @@ typedef struct yaml_parser_s {
1089
1089
  yaml_error_type_t error;
1090
1090
  /** Error description. */
1091
1091
  const char *problem;
1092
- /** The byte about which the problem occured. */
1092
+ /** The byte about which the problem occurred. */
1093
1093
  size_t problem_offset;
1094
1094
  /** The problematic value (@c -1 is none). */
1095
1095
  int problem_value;
@@ -41,7 +41,7 @@ require 'psych/handlers/document_stream'
41
41
  # Psych provides a range of interfaces for parsing a YAML document ranging from
42
42
  # low level to high level, depending on your parsing needs. At the lowest
43
43
  # level, is an event based parser. Mid level is access to the raw YAML AST,
44
- # and at the highest level is the ability to unmarshal YAML to ruby objects.
44
+ # and at the highest level is the ability to unmarshal YAML to Ruby objects.
45
45
  #
46
46
  # == YAML Emitting
47
47
  #
@@ -172,7 +172,7 @@ require 'psych/handlers/document_stream'
172
172
  #
173
173
  # The lowest level parser should be used when the YAML input is already known,
174
174
  # and the developer does not want to pay the price of building an AST or
175
- # automatic detection and conversion to ruby objects. See Psych::Parser for
175
+ # automatic detection and conversion to Ruby objects. See Psych::Parser for
176
176
  # more information on using the event based parser.
177
177
  #
178
178
  # ==== Reading to Psych::Nodes::Stream structure
@@ -200,7 +200,7 @@ require 'psych/handlers/document_stream'
200
200
  # document. This interface should be used when document format is known in
201
201
  # advance or speed is a concern. See Psych::Emitter for more information.
202
202
  #
203
- # ==== Writing to a ruby structure
203
+ # ==== Writing to a Ruby structure
204
204
  #
205
205
  # Psych.parser.parse("--- a") # => #<Psych::Parser>
206
206
  #
@@ -216,7 +216,7 @@ require 'psych/handlers/document_stream'
216
216
 
217
217
  module Psych
218
218
  # The version is Psych you're using
219
- VERSION = '2.0.0'
219
+ VERSION = '2.0.1'
220
220
 
221
221
  # The version of libyaml Psych is using
222
222
  LIBYAML_VERSION = Psych.libyaml_version.join '.'
@@ -433,7 +433,7 @@ module Psych
433
433
 
434
434
  ###
435
435
  # Load multiple documents given in +yaml+. Returns the parsed documents
436
- # as a list. If a block is given, each document will be converted to ruby
436
+ # as a list. If a block is given, each document will be converted to Ruby
437
437
  # and passed to the block during parsing
438
438
  #
439
439
  # Example:
@@ -458,7 +458,7 @@ module Psych
458
458
 
459
459
  ###
460
460
  # Load the document contained in +filename+. Returns the yaml contained in
461
- # +filename+ as a ruby object
461
+ # +filename+ as a Ruby object
462
462
  def self.load_file filename
463
463
  File.open(filename, 'r:bom|utf-8') { |f| self.load f, filename }
464
464
  end
@@ -28,7 +28,7 @@ module Psych
28
28
  @class_loader = class_loader
29
29
  end
30
30
 
31
- # Tokenize +string+ returning the ruby object
31
+ # Tokenize +string+ returning the Ruby object
32
32
  def tokenize string
33
33
  return nil if string.empty?
34
34
  return string if @string_cache.key?(string)
@@ -95,7 +95,7 @@ module Psych
95
95
  end
96
96
  i
97
97
  when FLOAT
98
- if string == '.'
98
+ if string =~ /\A[-+]?\.\Z/
99
99
  @string_cache[string] = true
100
100
  string
101
101
  else
@@ -9,7 +9,7 @@ end
9
9
  module Psych
10
10
  module Visitors
11
11
  ###
12
- # This class walks a YAML AST, converting each node to ruby
12
+ # This class walks a YAML AST, converting each node to Ruby
13
13
  class ToRuby < Psych::Visitors::Visitor
14
14
  def self.create
15
15
  class_loader = ClassLoader.new
@@ -5,7 +5,7 @@ require 'psych/class_loader'
5
5
  module Psych
6
6
  module Visitors
7
7
  ###
8
- # YAMLTree builds a YAML ast given a ruby object. For example:
8
+ # YAMLTree builds a YAML ast given a Ruby object. For example:
9
9
  #
10
10
  # builder = Psych::Visitors::YAMLTree.new
11
11
  # builder << { :foo => 'bar' }
@@ -47,6 +47,15 @@ module Psych
47
47
  new(emitter, ss, options)
48
48
  end
49
49
 
50
+ def self.new emitter = nil, ss = nil, options = nil
51
+ return super if emitter && ss && options
52
+
53
+ if $VERBOSE
54
+ warn "This API is deprecated, please pass an emitter, scalar scanner, and options or call #{self}.create() (#{caller.first})"
55
+ end
56
+ create emitter, ss
57
+ end
58
+
50
59
  def initialize emitter, ss, options
51
60
  super()
52
61
  @started = false
@@ -207,7 +216,7 @@ module Psych
207
216
 
208
217
  def visit_Time o
209
218
  formatted = format_time o
210
- @emitter.scalar formatted, nil, nil, true, false, Nodes::Scalar::ANY
219
+ register o, @emitter.scalar(formatted, nil, nil, true, false, Nodes::Scalar::ANY)
211
220
  end
212
221
 
213
222
  def visit_Rational o
@@ -279,6 +288,8 @@ module Psych
279
288
  quote = false
280
289
  elsif o =~ /\n/
281
290
  style = Nodes::Scalar::LITERAL
291
+ elsif o =~ /^\W/
292
+ style = Nodes::Scalar::DOUBLE_QUOTED
282
293
  else
283
294
  unless String === @ss.tokenize(o)
284
295
  style = Nodes::Scalar::SINGLE_QUOTED
@@ -83,3 +83,32 @@ module Psych
83
83
  end
84
84
  end
85
85
  end
86
+
87
+ # backport so that tests will run on 1.9 and 2.0.0
88
+ unless Tempfile.respond_to? :create
89
+ def Tempfile.create(basename, *rest)
90
+ tmpfile = nil
91
+ Dir::Tmpname.create(basename, *rest) do |tmpname, n, opts|
92
+ mode = File::RDWR|File::CREAT|File::EXCL
93
+ perm = 0600
94
+ if opts
95
+ mode |= opts.delete(:mode) || 0
96
+ opts[:perm] = perm
97
+ perm = nil
98
+ else
99
+ opts = perm
100
+ end
101
+ tmpfile = File.open(tmpname, mode, opts)
102
+ end
103
+ if block_given?
104
+ begin
105
+ yield tmpfile
106
+ ensure
107
+ tmpfile.close if !tmpfile.closed?
108
+ File.unlink tmpfile
109
+ end
110
+ else
111
+ tmpfile
112
+ end
113
+ end
114
+ end
@@ -13,5 +13,13 @@ module Psych
13
13
  dt = DateTime.now
14
14
  assert_cycle dt
15
15
  end
16
+
17
+ def test_alias_with_time
18
+ t = Time.now
19
+ h = {:a => t, :b => t}
20
+ yaml = Psych.dump h
21
+ assert_match('&', yaml)
22
+ assert_match('*', yaml)
23
+ end
16
24
  end
17
25
  end
@@ -15,6 +15,16 @@ module Psych
15
15
  end
16
16
  end
17
17
 
18
+ def test_doublequotes_when_there_is_a_single
19
+ yaml = Psych.dump "@123'abc"
20
+ assert_match(/---\s*"/, yaml)
21
+ end
22
+
23
+ def test_dash_dot
24
+ assert_cycle '-.'
25
+ assert_cycle '+.'
26
+ end
27
+
18
28
  def test_string_subclass_with_anchor
19
29
  y = Psych.load <<-eoyml
20
30
  ---
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psych
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2013-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake-compiler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.4.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hoe
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.6'
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
54
  version: '3.6'
55
55
  description: |-
@@ -67,8 +67,8 @@ extra_rdoc_files:
67
67
  - Manifest.txt
68
68
  - README.rdoc
69
69
  files:
70
- - .autotest
71
- - .travis.yml
70
+ - ".autotest"
71
+ - ".travis.yml"
72
72
  - CHANGELOG.rdoc
73
73
  - Manifest.txt
74
74
  - README.rdoc
@@ -180,24 +180,24 @@ files:
180
180
  - test/psych/visitors/test_emitter.rb
181
181
  - test/psych/visitors/test_to_ruby.rb
182
182
  - test/psych/visitors/test_yaml_tree.rb
183
- - .gemtest
183
+ - ".gemtest"
184
184
  homepage: http://github.com/tenderlove/psych
185
185
  licenses: []
186
186
  metadata: {}
187
187
  post_install_message:
188
188
  rdoc_options:
189
- - --main
189
+ - "--main"
190
190
  - README.rdoc
191
191
  require_paths:
192
192
  - lib
193
193
  required_ruby_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - '>='
195
+ - - ">="
196
196
  - !ruby/object:Gem::Version
197
197
  version: 1.9.2
198
198
  required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - '>='
200
+ - - ">="
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []