psych 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.autotest +18 -0
  2. data/.gemtest +0 -0
  3. data/CHANGELOG.rdoc +3 -0
  4. data/Manifest.txt +87 -0
  5. data/README.rdoc +50 -0
  6. data/Rakefile +66 -0
  7. data/ext/psych/emitter.c +517 -0
  8. data/ext/psych/emitter.h +8 -0
  9. data/ext/psych/extconf.rb +22 -0
  10. data/ext/psych/parser.c +384 -0
  11. data/ext/psych/parser.h +6 -0
  12. data/ext/psych/psych.c +34 -0
  13. data/ext/psych/psych.h +20 -0
  14. data/ext/psych/to_ruby.c +41 -0
  15. data/ext/psych/to_ruby.h +8 -0
  16. data/ext/psych/yaml_tree.c +24 -0
  17. data/ext/psych/yaml_tree.h +8 -0
  18. data/lib/psych.rb +263 -0
  19. data/lib/psych/coder.rb +94 -0
  20. data/lib/psych/core_ext.rb +39 -0
  21. data/lib/psych/deprecated.rb +82 -0
  22. data/lib/psych/handler.rb +221 -0
  23. data/lib/psych/json.rb +6 -0
  24. data/lib/psych/json/ruby_events.rb +19 -0
  25. data/lib/psych/json/stream.rb +15 -0
  26. data/lib/psych/json/tree_builder.rb +12 -0
  27. data/lib/psych/json/yaml_events.rb +29 -0
  28. data/lib/psych/nodes.rb +77 -0
  29. data/lib/psych/nodes/alias.rb +18 -0
  30. data/lib/psych/nodes/document.rb +60 -0
  31. data/lib/psych/nodes/mapping.rb +56 -0
  32. data/lib/psych/nodes/node.rb +52 -0
  33. data/lib/psych/nodes/scalar.rb +67 -0
  34. data/lib/psych/nodes/sequence.rb +81 -0
  35. data/lib/psych/nodes/stream.rb +37 -0
  36. data/lib/psych/omap.rb +4 -0
  37. data/lib/psych/parser.rb +47 -0
  38. data/lib/psych/scalar_scanner.rb +105 -0
  39. data/lib/psych/set.rb +4 -0
  40. data/lib/psych/stream.rb +36 -0
  41. data/lib/psych/streaming.rb +22 -0
  42. data/lib/psych/tree_builder.rb +94 -0
  43. data/lib/psych/visitors.rb +6 -0
  44. data/lib/psych/visitors/depth_first.rb +26 -0
  45. data/lib/psych/visitors/emitter.rb +44 -0
  46. data/lib/psych/visitors/json_tree.rb +21 -0
  47. data/lib/psych/visitors/to_ruby.rb +267 -0
  48. data/lib/psych/visitors/visitor.rb +19 -0
  49. data/lib/psych/visitors/yaml_tree.rb +373 -0
  50. data/test/psych/helper.rb +63 -0
  51. data/test/psych/json/test_stream.rb +109 -0
  52. data/test/psych/nodes/test_enumerable.rb +43 -0
  53. data/test/psych/test_alias_and_anchor.rb +26 -0
  54. data/test/psych/test_array.rb +19 -0
  55. data/test/psych/test_boolean.rb +36 -0
  56. data/test/psych/test_class.rb +17 -0
  57. data/test/psych/test_coder.rb +184 -0
  58. data/test/psych/test_date_time.rb +17 -0
  59. data/test/psych/test_deprecated.rb +210 -0
  60. data/test/psych/test_document.rb +46 -0
  61. data/test/psych/test_emitter.rb +94 -0
  62. data/test/psych/test_encoding.rb +179 -0
  63. data/test/psych/test_engine_manager.rb +57 -0
  64. data/test/psych/test_exception.rb +39 -0
  65. data/test/psych/test_hash.rb +30 -0
  66. data/test/psych/test_json_tree.rb +65 -0
  67. data/test/psych/test_merge_keys.rb +72 -0
  68. data/test/psych/test_nil.rb +18 -0
  69. data/test/psych/test_null.rb +19 -0
  70. data/test/psych/test_object.rb +27 -0
  71. data/test/psych/test_omap.rb +68 -0
  72. data/test/psych/test_parser.rb +297 -0
  73. data/test/psych/test_psych.rb +168 -0
  74. data/test/psych/test_scalar.rb +11 -0
  75. data/test/psych/test_scalar_scanner.rb +69 -0
  76. data/test/psych/test_serialize_subclasses.rb +38 -0
  77. data/test/psych/test_set.rb +49 -0
  78. data/test/psych/test_stream.rb +49 -0
  79. data/test/psych/test_string.rb +49 -0
  80. data/test/psych/test_struct.rb +51 -0
  81. data/test/psych/test_symbol.rb +17 -0
  82. data/test/psych/test_to_yaml_properties.rb +63 -0
  83. data/test/psych/test_tree_builder.rb +79 -0
  84. data/test/psych/test_yaml.rb +1256 -0
  85. data/test/psych/visitors/test_depth_first.rb +49 -0
  86. data/test/psych/visitors/test_emitter.rb +144 -0
  87. data/test/psych/visitors/test_to_ruby.rb +325 -0
  88. data/test/psych/visitors/test_yaml_tree.rb +155 -0
  89. metadata +232 -0
@@ -0,0 +1,155 @@
1
+ require 'psych/helper'
2
+
3
+ module Psych
4
+ module Visitors
5
+ class TestYAMLTree < TestCase
6
+ def setup
7
+ super
8
+ @v = Visitors::YAMLTree.new
9
+ end
10
+
11
+ def test_binary_formatting
12
+ gif = "GIF89a\f\x00\f\x00\x84\x00\x00\xFF\xFF\xF7\xF5\xF5\xEE\xE9\xE9\xE5fff\x00\x00\x00\xE7\xE7\xE7^^^\xF3\xF3\xED\x8E\x8E\x8E\xE0\xE0\xE0\x9F\x9F\x9F\x93\x93\x93\xA7\xA7\xA7\x9E\x9E\x9Eiiiccc\xA3\xA3\xA3\x84\x84\x84\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9!\xFE\x0EMade with GIMP\x00,\x00\x00\x00\x00\f\x00\f\x00\x00\x05, \x8E\x810\x9E\xE3@\x14\xE8i\x10\xC4\xD1\x8A\b\x1C\xCF\x80M$z\xEF\xFF0\x85p\xB8\xB01f\r\e\xCE\x01\xC3\x01\x1E\x10' \x82\n\x01\x00;"
13
+ @v << gif
14
+ scalar = @v.tree.children.first.children.first
15
+ assert_equal Psych::Nodes::Scalar::LITERAL, scalar.style
16
+ end
17
+
18
+ def test_object_has_no_class
19
+ yaml = Psych.dump(Object.new)
20
+ assert(Psych.dump(Object.new) !~ /Object/, yaml)
21
+ end
22
+
23
+ def test_struct_const
24
+ foo = Struct.new("Foo", :bar)
25
+ assert_cycle foo.new('bar')
26
+ Struct.instance_eval { remove_const(:Foo) }
27
+ end
28
+
29
+ A = Struct.new(:foo)
30
+
31
+ def test_struct
32
+ assert_cycle A.new('bar')
33
+ end
34
+
35
+ def test_struct_anon
36
+ s = Struct.new(:foo).new('bar')
37
+ obj = Psych.load(Psych.dump(s))
38
+ assert_equal s.foo, obj.foo
39
+ end
40
+
41
+ def test_override_method
42
+ s = Struct.new(:method).new('override')
43
+ obj = Psych.load(Psych.dump(s))
44
+ assert_equal s.method, obj.method
45
+ end
46
+
47
+ def test_exception
48
+ ex = Exception.new 'foo'
49
+ loaded = Psych.load(Psych.dump(ex))
50
+
51
+ assert_equal ex.message, loaded.message
52
+ assert_equal ex.class, loaded.class
53
+ end
54
+
55
+ def test_regexp
56
+ assert_cycle(/foo/)
57
+ assert_cycle(/foo/i)
58
+ assert_cycle(/foo/mx)
59
+ end
60
+
61
+ def test_time
62
+ t = Time.now
63
+ assert_equal t, Psych.load(Psych.dump(t))
64
+ end
65
+
66
+ def test_date
67
+ date = Date.strptime('2002-12-14', '%Y-%m-%d')
68
+ assert_cycle date
69
+ end
70
+
71
+ def test_rational
72
+ assert_cycle Rational(1,2)
73
+ end
74
+
75
+ def test_complex
76
+ assert_cycle Complex(1,2)
77
+ end
78
+
79
+ def test_scalar
80
+ assert_cycle 'foo'
81
+ assert_cycle ':foo'
82
+ assert_cycle ''
83
+ assert_cycle ':'
84
+ end
85
+
86
+ def test_boolean
87
+ assert_cycle true
88
+ assert_cycle 'true'
89
+ assert_cycle false
90
+ assert_cycle 'false'
91
+ end
92
+
93
+ def test_range_inclusive
94
+ assert_cycle 1..2
95
+ end
96
+
97
+ def test_range_exclusive
98
+ assert_cycle 1...2
99
+ end
100
+
101
+ def test_anon_class
102
+ assert_raises(TypeError) do
103
+ @v.accept Class.new
104
+ end
105
+
106
+ assert_raises(TypeError) do
107
+ Psych.dump(Class.new)
108
+ end
109
+ end
110
+
111
+ def test_hash
112
+ assert_cycle('a' => 'b')
113
+ end
114
+
115
+ def test_list
116
+ assert_cycle(%w{ a b })
117
+ assert_cycle([1, 2.2])
118
+ end
119
+
120
+ def test_symbol
121
+ assert_cycle :foo
122
+ end
123
+
124
+ def test_int
125
+ assert_cycle 1
126
+ assert_cycle(-1)
127
+ assert_cycle '1'
128
+ assert_cycle '-1'
129
+ end
130
+
131
+ def test_float
132
+ assert_cycle 1.2
133
+ assert_cycle '1.2'
134
+
135
+ assert Psych.load(Psych.dump(0.0 / 0.0)).nan?
136
+ assert_equal 1, Psych.load(Psych.dump(1 / 0.0)).infinite?
137
+ assert_equal(-1, Psych.load(Psych.dump(-1 / 0.0)).infinite?)
138
+ end
139
+
140
+ # http://yaml.org/type/null.html
141
+ def test_nil
142
+ assert_cycle nil
143
+ assert_equal nil, Psych.load('null')
144
+ assert_equal nil, Psych.load('Null')
145
+ assert_equal nil, Psych.load('NULL')
146
+ assert_equal nil, Psych.load('~')
147
+ assert_equal({'foo' => nil}, Psych.load('foo: '))
148
+
149
+ assert_cycle 'null'
150
+ assert_cycle 'nUll'
151
+ assert_cycle '~'
152
+ end
153
+ end
154
+ end
155
+ end
metadata ADDED
@@ -0,0 +1,232 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: psych
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Aaron Patterson
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-30 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rake-compiler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 0
32
+ - 4
33
+ - 1
34
+ version: 0.4.1
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: hoe
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 41
46
+ segments:
47
+ - 2
48
+ - 9
49
+ - 1
50
+ version: 2.9.1
51
+ type: :development
52
+ version_requirements: *id002
53
+ description: |-
54
+ Psych is a YAML parser and emitter. Psych leverages libyaml[http://libyaml.org]
55
+ for it's YAML parsing and emitting capabilities. In addition to wrapping
56
+ libyaml, Psych also knows how to serialize and de-serialize most Ruby objects
57
+ to and from the YAML format.
58
+ email:
59
+ - aaronp@rubyforge.org
60
+ executables: []
61
+
62
+ extensions:
63
+ - ext/psych/extconf.rb
64
+ extra_rdoc_files:
65
+ - Manifest.txt
66
+ - CHANGELOG.rdoc
67
+ - README.rdoc
68
+ files:
69
+ - .autotest
70
+ - CHANGELOG.rdoc
71
+ - Manifest.txt
72
+ - README.rdoc
73
+ - Rakefile
74
+ - ext/psych/emitter.c
75
+ - ext/psych/emitter.h
76
+ - ext/psych/extconf.rb
77
+ - ext/psych/parser.c
78
+ - ext/psych/parser.h
79
+ - ext/psych/psych.c
80
+ - ext/psych/psych.h
81
+ - ext/psych/to_ruby.c
82
+ - ext/psych/to_ruby.h
83
+ - ext/psych/yaml_tree.c
84
+ - ext/psych/yaml_tree.h
85
+ - lib/psych.rb
86
+ - lib/psych/coder.rb
87
+ - lib/psych/core_ext.rb
88
+ - lib/psych/deprecated.rb
89
+ - lib/psych/handler.rb
90
+ - lib/psych/json.rb
91
+ - lib/psych/json/ruby_events.rb
92
+ - lib/psych/json/stream.rb
93
+ - lib/psych/json/tree_builder.rb
94
+ - lib/psych/json/yaml_events.rb
95
+ - lib/psych/nodes.rb
96
+ - lib/psych/nodes/alias.rb
97
+ - lib/psych/nodes/document.rb
98
+ - lib/psych/nodes/mapping.rb
99
+ - lib/psych/nodes/node.rb
100
+ - lib/psych/nodes/scalar.rb
101
+ - lib/psych/nodes/sequence.rb
102
+ - lib/psych/nodes/stream.rb
103
+ - lib/psych/omap.rb
104
+ - lib/psych/parser.rb
105
+ - lib/psych/scalar_scanner.rb
106
+ - lib/psych/set.rb
107
+ - lib/psych/stream.rb
108
+ - lib/psych/streaming.rb
109
+ - lib/psych/tree_builder.rb
110
+ - lib/psych/visitors.rb
111
+ - lib/psych/visitors/depth_first.rb
112
+ - lib/psych/visitors/emitter.rb
113
+ - lib/psych/visitors/json_tree.rb
114
+ - lib/psych/visitors/to_ruby.rb
115
+ - lib/psych/visitors/visitor.rb
116
+ - lib/psych/visitors/yaml_tree.rb
117
+ - test/psych/helper.rb
118
+ - test/psych/json/test_stream.rb
119
+ - test/psych/nodes/test_enumerable.rb
120
+ - test/psych/test_alias_and_anchor.rb
121
+ - test/psych/test_array.rb
122
+ - test/psych/test_boolean.rb
123
+ - test/psych/test_class.rb
124
+ - test/psych/test_coder.rb
125
+ - test/psych/test_date_time.rb
126
+ - test/psych/test_deprecated.rb
127
+ - test/psych/test_document.rb
128
+ - test/psych/test_emitter.rb
129
+ - test/psych/test_encoding.rb
130
+ - test/psych/test_engine_manager.rb
131
+ - test/psych/test_exception.rb
132
+ - test/psych/test_hash.rb
133
+ - test/psych/test_json_tree.rb
134
+ - test/psych/test_merge_keys.rb
135
+ - test/psych/test_nil.rb
136
+ - test/psych/test_null.rb
137
+ - test/psych/test_object.rb
138
+ - test/psych/test_omap.rb
139
+ - test/psych/test_parser.rb
140
+ - test/psych/test_psych.rb
141
+ - test/psych/test_scalar.rb
142
+ - test/psych/test_scalar_scanner.rb
143
+ - test/psych/test_serialize_subclasses.rb
144
+ - test/psych/test_set.rb
145
+ - test/psych/test_stream.rb
146
+ - test/psych/test_string.rb
147
+ - test/psych/test_struct.rb
148
+ - test/psych/test_symbol.rb
149
+ - test/psych/test_to_yaml_properties.rb
150
+ - test/psych/test_tree_builder.rb
151
+ - test/psych/test_yaml.rb
152
+ - test/psych/visitors/test_depth_first.rb
153
+ - test/psych/visitors/test_emitter.rb
154
+ - test/psych/visitors/test_to_ruby.rb
155
+ - test/psych/visitors/test_yaml_tree.rb
156
+ - .gemtest
157
+ has_rdoc: true
158
+ homepage: http://github.com/tenderlove/psych
159
+ licenses: []
160
+
161
+ post_install_message:
162
+ rdoc_options:
163
+ - --main
164
+ - README.rdoc
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ hash: 55
173
+ segments:
174
+ - 1
175
+ - 9
176
+ - 2
177
+ version: 1.9.2
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ hash: 3
184
+ segments:
185
+ - 0
186
+ version: "0"
187
+ requirements: []
188
+
189
+ rubyforge_project: psych
190
+ rubygems_version: 1.6.1
191
+ signing_key:
192
+ specification_version: 3
193
+ summary: Psych is a YAML parser and emitter
194
+ test_files:
195
+ - test/psych/json/test_stream.rb
196
+ - test/psych/nodes/test_enumerable.rb
197
+ - test/psych/test_alias_and_anchor.rb
198
+ - test/psych/test_array.rb
199
+ - test/psych/test_boolean.rb
200
+ - test/psych/test_class.rb
201
+ - test/psych/test_coder.rb
202
+ - test/psych/test_date_time.rb
203
+ - test/psych/test_deprecated.rb
204
+ - test/psych/test_document.rb
205
+ - test/psych/test_emitter.rb
206
+ - test/psych/test_encoding.rb
207
+ - test/psych/test_engine_manager.rb
208
+ - test/psych/test_exception.rb
209
+ - test/psych/test_hash.rb
210
+ - test/psych/test_json_tree.rb
211
+ - test/psych/test_merge_keys.rb
212
+ - test/psych/test_nil.rb
213
+ - test/psych/test_null.rb
214
+ - test/psych/test_object.rb
215
+ - test/psych/test_omap.rb
216
+ - test/psych/test_parser.rb
217
+ - test/psych/test_psych.rb
218
+ - test/psych/test_scalar.rb
219
+ - test/psych/test_scalar_scanner.rb
220
+ - test/psych/test_serialize_subclasses.rb
221
+ - test/psych/test_set.rb
222
+ - test/psych/test_stream.rb
223
+ - test/psych/test_string.rb
224
+ - test/psych/test_struct.rb
225
+ - test/psych/test_symbol.rb
226
+ - test/psych/test_to_yaml_properties.rb
227
+ - test/psych/test_tree_builder.rb
228
+ - test/psych/test_yaml.rb
229
+ - test/psych/visitors/test_depth_first.rb
230
+ - test/psych/visitors/test_emitter.rb
231
+ - test/psych/visitors/test_to_ruby.rb
232
+ - test/psych/visitors/test_yaml_tree.rb