rubysl-yaml 0.0.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/.travis.yml +7 -0
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/lib/rubysl/yaml.rb +2 -0
- data/lib/rubysl/yaml/version.rb +5 -0
- data/lib/rubysl/yaml/yaml.rb +440 -0
- data/lib/yaml.rb +1 -0
- data/lib/yaml/baseemitter.rb +247 -0
- data/lib/yaml/basenode.rb +216 -0
- data/lib/yaml/constants.rb +45 -0
- data/lib/yaml/dbm.rb +111 -0
- data/lib/yaml/encoding.rb +33 -0
- data/lib/yaml/error.rb +34 -0
- data/lib/yaml/loader.rb +14 -0
- data/lib/yaml/rubytypes.rb +409 -0
- data/lib/yaml/store.rb +43 -0
- data/lib/yaml/stream.rb +40 -0
- data/lib/yaml/stringio.rb +83 -0
- data/lib/yaml/syck.rb +44 -0
- data/lib/yaml/tag.rb +91 -0
- data/lib/yaml/types.rb +192 -0
- data/lib/yaml/yamlnode.rb +54 -0
- data/lib/yaml/ypath.rb +52 -0
- data/rubysl-yaml.gemspec +19 -17
- data/spec/add_builtin_type_spec.rb +1 -0
- data/spec/add_domain_type_spec.rb +1 -0
- data/spec/add_private_type_spec.rb +1 -0
- data/spec/add_ruby_type_spec.rb +1 -0
- data/spec/detect_implicit_spec.rb +1 -0
- data/spec/dump_spec.rb +35 -0
- data/spec/dump_stream_spec.rb +13 -0
- data/spec/each_document_spec.rb +9 -0
- data/spec/each_node_spec.rb +1 -0
- data/spec/emitter_spec.rb +1 -0
- data/spec/fixtures/common.rb +10 -0
- data/spec/fixtures/example_class.rb +5 -0
- data/spec/fixtures/strings.rb +36 -0
- data/spec/fixtures/test_yaml.yml +2 -0
- data/spec/generic_parser_spec.rb +1 -0
- data/spec/load_documents_spec.rb +7 -0
- data/spec/load_file_spec.rb +12 -0
- data/spec/load_spec.rb +111 -0
- data/spec/load_stream_spec.rb +1 -0
- data/spec/object_maker_spec.rb +1 -0
- data/spec/parse_documents_spec.rb +1 -0
- data/spec/parse_file_spec.rb +9 -0
- data/spec/parse_spec.rb +21 -0
- data/spec/parser_spec.rb +1 -0
- data/spec/quick_emit_spec.rb +1 -0
- data/spec/read_type_class_spec.rb +1 -0
- data/spec/shared/each_document.rb +18 -0
- data/spec/tag_class_spec.rb +9 -0
- data/spec/tagged_classes_spec.rb +9 -0
- data/spec/tagurize_spec.rb +8 -0
- data/spec/to_yaml_spec.rb +97 -0
- data/spec/transfer_spec.rb +1 -0
- data/spec/try_implicit_spec.rb +1 -0
- metadata +163 -88
- data/lib/rubysl-yaml.rb +0 -7
- data/lib/rubysl-yaml/version.rb +0 -5
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
2
|
+
|
3
|
+
describe "YAML#parse_file" do
|
4
|
+
quarantine! do
|
5
|
+
it "returns a YAML::Syck::Map object after parsing a YAML file" do
|
6
|
+
YAML.parse_file($test_parse_file).should be_kind_of(YAML::Syck::Map)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/spec/parse_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
2
|
+
|
3
|
+
describe "YAML#parse with an empty string" do
|
4
|
+
it "returns false" do
|
5
|
+
YAML.parse('').should be_false
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "YAML#parse" do
|
10
|
+
before :each do
|
11
|
+
@string_yaml = "foo".to_yaml
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns the value from the object" do
|
15
|
+
if YAML.to_s == "Psych"
|
16
|
+
YAML.parse(@string_yaml).to_ruby.should == "foo"
|
17
|
+
else
|
18
|
+
YAML.parse(@string_yaml).value.should == "foo"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/parser_spec.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe :yaml_each_document, :shared => true do
|
2
|
+
it "calls the block on each succesive document" do
|
3
|
+
documents = []
|
4
|
+
YAML.send(@method, $multidocument) do |doc|
|
5
|
+
documents << doc
|
6
|
+
end
|
7
|
+
documents.should == [["Mark McGwire", "Sammy Sosa", "Ken Griffey"],
|
8
|
+
["Chicago Cubs", "St Louis Cardinals"]]
|
9
|
+
end
|
10
|
+
|
11
|
+
it "works on files" do
|
12
|
+
File.open($test_parse_file, "r") do |file|
|
13
|
+
YAML.send(@method, file) do |doc|
|
14
|
+
doc.should == {"project"=>{"name"=>"RubySpec"}}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
2
|
+
|
3
|
+
ruby_version_is "" ... "2.0" do
|
4
|
+
describe "YAML.tagged_classes" do
|
5
|
+
it "returns a complete dictionary of taguris paired with classes" do
|
6
|
+
YAML.tagged_classes["tag:yaml.org,2002:int"].should == Integer
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
2
|
+
require File.expand_path('../fixtures/example_class', __FILE__)
|
3
|
+
|
4
|
+
describe "Object#to_yaml" do
|
5
|
+
|
6
|
+
it "returns the YAML representation of an Array object" do
|
7
|
+
%w( 30 ruby maz irb 99 ).to_yaml.gsub("'", '"').should match_yaml("--- \n- \"30\"\n- ruby\n- maz\n- irb\n- \"99\"\n")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns the YAML representation of a Hash object" do
|
11
|
+
{ "a" => "b"}.to_yaml.should match_yaml("--- \na: b\n")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns the YAML representation of a Class object" do
|
15
|
+
FooBar.new("baz").to_yaml.should match_yaml("--- !ruby/object:FooBar\nname: baz\n")
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns the YAML representation of a Date object" do
|
20
|
+
Date.parse('1997/12/30').to_yaml.should match_yaml("--- 1997-12-30\n")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns the YAML representation of a FalseClass" do
|
24
|
+
false_klass = false
|
25
|
+
false_klass.should be_kind_of(FalseClass)
|
26
|
+
false_klass.to_yaml.should match_yaml("--- false\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns the YAML representation of a Float object" do
|
30
|
+
float = 1.2
|
31
|
+
float.should be_kind_of(Float)
|
32
|
+
float.to_yaml.should match_yaml("--- 1.2\n")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns the YAML representation of an Integer object" do
|
36
|
+
int = 20
|
37
|
+
int.should be_kind_of(Integer)
|
38
|
+
int.to_yaml.should match_yaml("--- 20\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns the YAML representation of a NilClass object" do
|
42
|
+
nil_klass = nil
|
43
|
+
nil_klass.should be_kind_of(NilClass)
|
44
|
+
nil_klass.to_yaml.should match_yaml("--- \n")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns the YAML represenation of a RegExp object" do
|
48
|
+
Regexp.new('^a-z+:\\s+\w+').to_yaml.should match_yaml("--- !ruby/regexp /^a-z+:\\s+\\w+/\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "returns the YAML representation of a String object" do
|
52
|
+
"I love Ruby".to_yaml.should match_yaml("--- I love Ruby\n")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns the YAML representation of a Struct object" do
|
56
|
+
Person = Struct.new(:name, :gender)
|
57
|
+
Person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct:Person\nname: Jane\ngender: female\n")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns the YAML representation of a Symbol object" do
|
61
|
+
:symbol.to_yaml.should match_yaml("--- :symbol\n")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns the YAML representation of a Time object" do
|
65
|
+
Time.utc(2000,"jan",1,20,15,1).to_yaml.sub(/\.0+/, "").should match_yaml("--- 2000-01-01 20:15:01 Z\n")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns the YAML representation of a TrueClass" do
|
69
|
+
true_klass = true
|
70
|
+
true_klass.should be_kind_of(TrueClass)
|
71
|
+
true_klass.to_yaml.should match_yaml("--- true\n")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns the YAML representation of a Error object" do
|
75
|
+
StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\n")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns the YAML representation for Range objects" do
|
79
|
+
yaml = Range.new(1,3).to_yaml
|
80
|
+
yaml.include?("!ruby/range").should be_true
|
81
|
+
yaml.include?("begin: 1").should be_true
|
82
|
+
yaml.include?("end: 3").should be_true
|
83
|
+
yaml.include?("excl: false").should be_true
|
84
|
+
end
|
85
|
+
|
86
|
+
it "returns the YAML representation of numeric constants" do
|
87
|
+
nan_value.to_yaml.downcase.should match_yaml("--- .nan\n")
|
88
|
+
infinity_value.to_yaml.downcase.should match_yaml("--- .inf\n")
|
89
|
+
(-infinity_value).to_yaml.downcase.should match_yaml("--- -.inf\n")
|
90
|
+
(0.0).to_yaml.should match_yaml("--- 0.0\n")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns the YAML representation of an array of hashes" do
|
94
|
+
players = [{"a" => "b"}, {"b" => "c"}]
|
95
|
+
players.to_yaml.should match_yaml("--- \n- a: b\n- b: c\n")
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../fixtures/common', __FILE__)
|
metadata
CHANGED
@@ -1,118 +1,193 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-yaml
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Brian Shirai
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubysl-syck
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
26
17
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
version: "1.0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
33
20
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rake
|
37
21
|
prerelease: false
|
38
|
-
|
39
|
-
|
40
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
41
24
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
48
34
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: mspec
|
52
35
|
prerelease: false
|
53
|
-
|
54
|
-
|
55
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
56
38
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
63
48
|
type: :development
|
64
|
-
|
65
|
-
|
66
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.5'
|
69
|
+
description: Ruby standard library YAML.
|
70
|
+
email:
|
67
71
|
- brixen@gmail.com
|
68
72
|
executables: []
|
69
|
-
|
70
73
|
extensions: []
|
71
|
-
|
72
74
|
extra_rdoc_files: []
|
73
|
-
|
74
|
-
files:
|
75
|
+
files:
|
75
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
76
78
|
- Gemfile
|
77
79
|
- LICENSE
|
78
80
|
- README.md
|
79
81
|
- Rakefile
|
80
|
-
- lib/rubysl
|
81
|
-
- lib/rubysl
|
82
|
+
- lib/rubysl/yaml.rb
|
83
|
+
- lib/rubysl/yaml/version.rb
|
84
|
+
- lib/rubysl/yaml/yaml.rb
|
85
|
+
- lib/yaml.rb
|
86
|
+
- lib/yaml/baseemitter.rb
|
87
|
+
- lib/yaml/basenode.rb
|
88
|
+
- lib/yaml/constants.rb
|
89
|
+
- lib/yaml/dbm.rb
|
90
|
+
- lib/yaml/encoding.rb
|
91
|
+
- lib/yaml/error.rb
|
92
|
+
- lib/yaml/loader.rb
|
93
|
+
- lib/yaml/rubytypes.rb
|
94
|
+
- lib/yaml/store.rb
|
95
|
+
- lib/yaml/stream.rb
|
96
|
+
- lib/yaml/stringio.rb
|
97
|
+
- lib/yaml/syck.rb
|
98
|
+
- lib/yaml/tag.rb
|
99
|
+
- lib/yaml/types.rb
|
100
|
+
- lib/yaml/yamlnode.rb
|
101
|
+
- lib/yaml/ypath.rb
|
82
102
|
- rubysl-yaml.gemspec
|
83
|
-
|
84
|
-
|
85
|
-
|
103
|
+
- spec/add_builtin_type_spec.rb
|
104
|
+
- spec/add_domain_type_spec.rb
|
105
|
+
- spec/add_private_type_spec.rb
|
106
|
+
- spec/add_ruby_type_spec.rb
|
107
|
+
- spec/detect_implicit_spec.rb
|
108
|
+
- spec/dump_spec.rb
|
109
|
+
- spec/dump_stream_spec.rb
|
110
|
+
- spec/each_document_spec.rb
|
111
|
+
- spec/each_node_spec.rb
|
112
|
+
- spec/emitter_spec.rb
|
113
|
+
- spec/fixtures/common.rb
|
114
|
+
- spec/fixtures/example_class.rb
|
115
|
+
- spec/fixtures/strings.rb
|
116
|
+
- spec/fixtures/test_yaml.yml
|
117
|
+
- spec/generic_parser_spec.rb
|
118
|
+
- spec/load_documents_spec.rb
|
119
|
+
- spec/load_file_spec.rb
|
120
|
+
- spec/load_spec.rb
|
121
|
+
- spec/load_stream_spec.rb
|
122
|
+
- spec/object_maker_spec.rb
|
123
|
+
- spec/parse_documents_spec.rb
|
124
|
+
- spec/parse_file_spec.rb
|
125
|
+
- spec/parse_spec.rb
|
126
|
+
- spec/parser_spec.rb
|
127
|
+
- spec/quick_emit_spec.rb
|
128
|
+
- spec/read_type_class_spec.rb
|
129
|
+
- spec/shared/each_document.rb
|
130
|
+
- spec/tag_class_spec.rb
|
131
|
+
- spec/tagged_classes_spec.rb
|
132
|
+
- spec/tagurize_spec.rb
|
133
|
+
- spec/to_yaml_spec.rb
|
134
|
+
- spec/transfer_spec.rb
|
135
|
+
- spec/try_implicit_spec.rb
|
136
|
+
homepage: https://github.com/rubysl/rubysl-yaml
|
137
|
+
licenses:
|
138
|
+
- BSD
|
139
|
+
metadata: {}
|
86
140
|
post_install_message:
|
87
141
|
rdoc_options: []
|
88
|
-
|
89
|
-
require_paths:
|
142
|
+
require_paths:
|
90
143
|
- lib
|
91
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
none: false
|
102
|
-
requirements:
|
103
|
-
- - ">="
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
hash: 2002549777813010636
|
106
|
-
segments:
|
107
|
-
- 0
|
108
|
-
version: "0"
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
109
154
|
requirements: []
|
110
|
-
|
111
155
|
rubyforge_project:
|
112
|
-
rubygems_version:
|
156
|
+
rubygems_version: 2.0.7
|
113
157
|
signing_key:
|
114
|
-
specification_version:
|
115
|
-
summary: Ruby
|
116
|
-
test_files:
|
117
|
-
|
118
|
-
|
158
|
+
specification_version: 4
|
159
|
+
summary: Ruby standard library YAML.
|
160
|
+
test_files:
|
161
|
+
- spec/add_builtin_type_spec.rb
|
162
|
+
- spec/add_domain_type_spec.rb
|
163
|
+
- spec/add_private_type_spec.rb
|
164
|
+
- spec/add_ruby_type_spec.rb
|
165
|
+
- spec/detect_implicit_spec.rb
|
166
|
+
- spec/dump_spec.rb
|
167
|
+
- spec/dump_stream_spec.rb
|
168
|
+
- spec/each_document_spec.rb
|
169
|
+
- spec/each_node_spec.rb
|
170
|
+
- spec/emitter_spec.rb
|
171
|
+
- spec/fixtures/common.rb
|
172
|
+
- spec/fixtures/example_class.rb
|
173
|
+
- spec/fixtures/strings.rb
|
174
|
+
- spec/fixtures/test_yaml.yml
|
175
|
+
- spec/generic_parser_spec.rb
|
176
|
+
- spec/load_documents_spec.rb
|
177
|
+
- spec/load_file_spec.rb
|
178
|
+
- spec/load_spec.rb
|
179
|
+
- spec/load_stream_spec.rb
|
180
|
+
- spec/object_maker_spec.rb
|
181
|
+
- spec/parse_documents_spec.rb
|
182
|
+
- spec/parse_file_spec.rb
|
183
|
+
- spec/parse_spec.rb
|
184
|
+
- spec/parser_spec.rb
|
185
|
+
- spec/quick_emit_spec.rb
|
186
|
+
- spec/read_type_class_spec.rb
|
187
|
+
- spec/shared/each_document.rb
|
188
|
+
- spec/tag_class_spec.rb
|
189
|
+
- spec/tagged_classes_spec.rb
|
190
|
+
- spec/tagurize_spec.rb
|
191
|
+
- spec/to_yaml_spec.rb
|
192
|
+
- spec/transfer_spec.rb
|
193
|
+
- spec/try_implicit_spec.rb
|