kwalify 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +232 -0
- data/MIT-LICENSE +20 -0
- data/README.txt +16 -19
- data/bin/kwalify +3 -3
- data/contrib/inline-require +6 -4
- data/contrib/kwalify +3719 -2427
- data/doc-api/classes/CommandOptionError.html +17 -17
- data/doc-api/classes/CommandOptionParser.html +63 -63
- data/doc-api/classes/Kwalify.html +29 -7
- data/doc-api/classes/Kwalify/AssertionError.html +9 -9
- data/doc-api/classes/Kwalify/BaseError.html +72 -71
- data/doc-api/classes/Kwalify/BaseParser.html +461 -0
- data/doc-api/classes/Kwalify/CommandOptionError.html +11 -11
- data/doc-api/classes/Kwalify/ErrorHelper.html +51 -46
- data/doc-api/classes/Kwalify/HashInterface.html +13 -135
- data/doc-api/classes/Kwalify/Json.html +105 -0
- data/doc-api/classes/Kwalify/Main.html +129 -126
- data/doc-api/classes/Kwalify/MetaValidator.html +248 -232
- data/doc-api/classes/Kwalify/Parser.html +12 -12
- data/doc-api/classes/Kwalify/PlainYamlParser.html +166 -163
- data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +11 -11
- data/doc-api/classes/Kwalify/Rule.html +152 -130
- data/doc-api/classes/Kwalify/SchemaError.html +10 -10
- data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
- data/doc-api/classes/Kwalify/Types.html +26 -25
- data/doc-api/classes/Kwalify/Util.html +389 -0
- data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
- data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
- data/doc-api/classes/Kwalify/ValidationError.html +10 -10
- data/doc-api/classes/Kwalify/Validator.html +153 -86
- data/doc-api/classes/Kwalify/Yaml.html +181 -0
- data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
- data/doc-api/classes/Kwalify/YamlParser.html +190 -183
- data/doc-api/classes/Kwalify/YamlSyntaxError.html +8 -57
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +17 -22
- data/doc-api/files/kwalify/errors_rb.html +2 -2
- data/doc-api/files/kwalify/main_rb.html +4 -3
- data/doc-api/files/kwalify/messages_rb.html +2 -2
- data/doc-api/files/kwalify/meta-validator_rb.html +3 -3
- data/doc-api/files/kwalify/{util/yaml-helper_rb.html → parser/base_rb.html} +8 -6
- data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
- data/doc-api/files/kwalify/rule_rb.html +2 -2
- data/doc-api/files/kwalify/types_rb.html +2 -2
- data/doc-api/files/kwalify/util/assert-text-equal_rb.html +2 -2
- data/doc-api/files/kwalify/util/hash-interface_rb.html +9 -2
- data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
- data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
- data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
- data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
- data/doc-api/files/kwalify/util_rb.html +107 -0
- data/doc-api/files/kwalify/validator_rb.html +2 -2
- data/doc-api/files/kwalify/yaml-parser_rb.html +2 -2
- data/doc-api/files/kwalify_rb.html +3 -2
- data/doc-api/fr_class_index.html +8 -1
- data/doc-api/fr_file_index.html +5 -1
- data/doc-api/fr_method_index.html +128 -69
- data/doc/img/fig01.png +0 -0
- data/doc/users-guide.html +882 -717
- data/examples/address-book/address-book.schema.yaml +2 -2
- data/examples/data-binding/BABEL.data.yaml +63 -0
- data/examples/data-binding/BABEL.schema.yaml +31 -0
- data/examples/data-binding/Makefile +8 -0
- data/examples/data-binding/Rakefile +13 -0
- data/examples/data-binding/main.rb +27 -0
- data/examples/invoice/invoice.schema.yaml +3 -3
- data/examples/tapkit/tapkit.schema.yaml +2 -2
- data/lib/kwalify.rb +41 -4
- data/lib/kwalify/errors.rb +118 -96
- data/lib/kwalify/kwalify.schema.yaml +58 -0
- data/lib/kwalify/main.rb +384 -377
- data/lib/kwalify/messages.rb +41 -27
- data/lib/kwalify/meta-validator.rb +251 -331
- data/lib/kwalify/parser/base.rb +127 -0
- data/lib/kwalify/parser/yaml.rb +837 -0
- data/lib/kwalify/rule.rb +545 -487
- data/lib/kwalify/templates/genclass-java.eruby +189 -162
- data/lib/kwalify/templates/genclass-php.eruby +104 -0
- data/lib/kwalify/templates/genclass-ruby.eruby +95 -66
- data/lib/kwalify/types.rb +107 -106
- data/lib/kwalify/util.rb +157 -0
- data/lib/kwalify/util/assert-text-equal.rb +33 -31
- data/lib/kwalify/util/hash-interface.rb +11 -30
- data/lib/kwalify/util/hashlike.rb +51 -0
- data/lib/kwalify/util/option-parser.rb +144 -144
- data/lib/kwalify/util/ordered-hash.rb +57 -0
- data/lib/kwalify/util/testcase-helper.rb +3 -3
- data/lib/kwalify/validator.rb +267 -212
- data/lib/kwalify/yaml-parser.rb +822 -768
- data/setup.rb +861 -607
- data/test/Rookbook.yaml +10 -0
- data/test/{tmp.dir/Context.java → data/users-guide/AddressBook.java.expected} +11 -11
- data/test/data/users-guide/BABEL.data.yaml +24 -0
- data/test/data/users-guide/BABEL.schema.yaml +30 -0
- data/test/data/users-guide/ExampleAddressBook.java +47 -0
- data/test/{tmp.dir/Group.java → data/users-guide/Group.java.expected} +2 -11
- data/test/data/users-guide/Person.java.expected +44 -0
- data/test/data/users-guide/address_book.rb +52 -0
- data/test/data/users-guide/address_book.schema.yaml +28 -0
- data/test/data/users-guide/address_book.yaml +27 -0
- data/test/data/users-guide/answers-schema.yaml +12 -0
- data/test/data/users-guide/answers-validator.rb +52 -0
- data/test/data/users-guide/babel_genclass.result +26 -0
- data/test/data/users-guide/config.schema.yaml +7 -0
- data/test/data/users-guide/config.yaml +4 -0
- data/test/{tmp.dir/silent1.document → data/users-guide/document01a.yaml} +0 -0
- data/test/data/users-guide/document01b.yaml +3 -0
- data/test/data/users-guide/document02a.yaml +4 -0
- data/test/data/users-guide/document02b.yaml +4 -0
- data/test/data/users-guide/document03a.yaml +6 -0
- data/test/data/users-guide/document03b.yaml +6 -0
- data/test/data/users-guide/document04a.yaml +9 -0
- data/test/data/users-guide/document04b.yaml +9 -0
- data/test/data/users-guide/document05a.yaml +11 -0
- data/test/data/users-guide/document05b.yaml +12 -0
- data/test/data/users-guide/document06a.yaml +15 -0
- data/test/data/users-guide/document06b.yaml +16 -0
- data/test/data/users-guide/document07a.yaml +9 -0
- data/test/data/users-guide/document07b.yaml +7 -0
- data/test/data/users-guide/document12a.json +10 -0
- data/test/data/users-guide/document12b.json +6 -0
- data/test/data/users-guide/document13a.yaml +17 -0
- data/test/data/users-guide/document14a.yaml +3 -0
- data/test/data/users-guide/document14b.yaml +3 -0
- data/test/data/users-guide/document15a.yaml +6 -0
- data/test/data/users-guide/document15b.yaml +5 -0
- data/test/data/users-guide/example_address_book.rb +10 -0
- data/test/data/users-guide/example_address_book_java.result +32 -0
- data/test/data/users-guide/example_address_book_ruby.result +31 -0
- data/test/data/users-guide/genclass_java.result +4 -0
- data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
- data/test/data/users-guide/howto-validation.rb +25 -0
- data/test/data/users-guide/howto3.rb +6 -0
- data/test/data/users-guide/howto3.result +5 -0
- data/test/data/users-guide/howto3.yaml +8 -0
- data/test/data/users-guide/howto5_databinding.result +111 -0
- data/test/data/users-guide/invalid01.result +3 -0
- data/test/data/users-guide/invalid02.result +5 -0
- data/test/data/users-guide/invalid03.result +5 -0
- data/test/data/users-guide/invalid04.result +4 -0
- data/test/data/users-guide/invalid05.result +11 -0
- data/test/data/users-guide/invalid06.result +4 -0
- data/test/data/users-guide/invalid07.result +3 -0
- data/test/data/users-guide/invalid08.result +3 -0
- data/test/data/users-guide/invalid12.json +8 -0
- data/test/data/users-guide/invalid14.result +4 -0
- data/test/data/users-guide/invalid15.result +4 -0
- data/test/data/users-guide/loadbabel.rb +27 -0
- data/test/data/users-guide/loadconfig.rb +15 -0
- data/test/data/users-guide/loadconfig.result +2 -0
- data/test/data/users-guide/models.rb +22 -0
- data/test/data/users-guide/option_ha.result +6 -0
- data/test/data/users-guide/option_ha_genclass_java.result +7 -0
- data/test/{tmp.dir/meta1.schema → data/users-guide/schema01.yaml} +0 -0
- data/test/data/users-guide/schema02.yaml +12 -0
- data/test/data/users-guide/schema03.yaml +9 -0
- data/test/data/users-guide/schema04.yaml +20 -0
- data/test/data/users-guide/schema05.yaml +29 -0
- data/test/data/users-guide/schema06.yaml +11 -0
- data/test/data/users-guide/schema12.json +12 -0
- data/test/data/users-guide/schema13.yaml +13 -0
- data/test/data/users-guide/schema14.yaml +5 -0
- data/test/data/users-guide/schema15.yaml +21 -0
- data/test/data/users-guide/valid01.result +2 -0
- data/test/data/users-guide/valid02.result +2 -0
- data/test/data/users-guide/valid03.result +2 -0
- data/test/data/users-guide/valid04.result +2 -0
- data/test/data/users-guide/valid05.result +2 -0
- data/test/data/users-guide/valid06.result +2 -0
- data/test/data/users-guide/valid07.result +2 -0
- data/test/data/users-guide/valid08.result +2 -0
- data/test/data/users-guide/valid12.result +2 -0
- data/test/data/users-guide/valid13.result +2 -0
- data/test/data/users-guide/valid14.result +2 -0
- data/test/data/users-guide/valid15.result +2 -0
- data/test/data/users-guide/validate08.rb +37 -0
- data/test/test-action.rb +78 -0
- data/test/test-action.yaml +738 -0
- data/test/test-databinding.rb +80 -0
- data/test/test-databinding.yaml +301 -0
- data/test/test-main.rb +129 -150
- data/test/test-main.yaml +126 -321
- data/test/test-metavalidator.rb +47 -47
- data/test/test-metavalidator.yaml +77 -21
- data/test/test-parser-yaml.rb +57 -0
- data/test/test-parser-yaml.yaml +1749 -0
- data/test/test-rule.rb +14 -15
- data/test/test-rule.yaml +6 -3
- data/test/test-users-guide.rb +75 -0
- data/test/test-validator.rb +77 -52
- data/test/test-validator.yaml +168 -6
- data/test/test-yaml-parser.rb +47 -0
- data/test/{test-yamlparser.yaml → test-yaml-parser.yaml} +159 -52
- data/test/test.rb +37 -21
- metadata +136 -37
- data/COPYING +0 -340
- data/ChangeLog +0 -70
- data/doc-api/classes/YamlHelper.html +0 -259
- data/lib/kwalify/util/yaml-helper.rb +0 -82
- data/test/test-yamlparser.rb +0 -58
- data/test/tmp.dir/User.java +0 -43
- data/test/tmp.dir/action1.document +0 -18
- data/test/tmp.dir/action1.schema +0 -32
- data/test/tmp.dir/action2.document +0 -18
- data/test/tmp.dir/action2.schema +0 -32
- data/test/tmp.dir/emacs.document +0 -6
- data/test/tmp.dir/emacs.schema +0 -6
- data/test/tmp.dir/meta1.document +0 -0
- data/test/tmp.dir/meta2.document +0 -0
- data/test/tmp.dir/meta2.schema +0 -3
- data/test/tmp.dir/silent1.schema +0 -3
- data/test/tmp.dir/silent2.document +0 -7
- data/test/tmp.dir/silent2.schema +0 -3
- data/test/tmp.dir/stream.invalid +0 -8
- data/test/tmp.dir/stream.schema +0 -3
- data/test/tmp.dir/stream.valid +0 -8
- data/test/tmp.dir/untabify.document +0 -5
- data/test/tmp.dir/untabify.schema +0 -10
- data/todo.txt +0 -34
@@ -0,0 +1,1538 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Kwalify::Yaml::Parser</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Kwalify::Yaml::Parser</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/kwalify/parser/yaml_rb.html">
|
59
|
+
kwalify/parser/yaml.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="../BaseParser.html">
|
69
|
+
Kwalify::BaseParser
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
YAML parser with validator
|
86
|
+
</p>
|
87
|
+
<p>
|
88
|
+
ex.
|
89
|
+
</p>
|
90
|
+
<pre>
|
91
|
+
schema = YAML.load_file('schema.yaml')
|
92
|
+
require 'kwalify'
|
93
|
+
validator = Kwalify::Validator.new(schema)
|
94
|
+
parser = Kwalify::Yaml::Parser.new(validator) # validator is optional
|
95
|
+
#parser.preceding_alias = true # optional
|
96
|
+
#parser.data_binding = true # optional
|
97
|
+
ydoc = parser.parse_file('data.yaml')
|
98
|
+
errors = parser.errors
|
99
|
+
if errors && !errors.empty?
|
100
|
+
errors.each do |e|
|
101
|
+
puts "line=#{e.linenum}, path=#{e.path}, mesg=#{e.message}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
</pre>
|
105
|
+
|
106
|
+
</div>
|
107
|
+
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div id="method-list">
|
112
|
+
<h3 class="section-bar">Methods</h3>
|
113
|
+
|
114
|
+
<div class="name-list">
|
115
|
+
<a href="#M000071">_getclass</a>
|
116
|
+
<a href="#M000042">_set_error_info</a>
|
117
|
+
<a href="#M000057">_validate_map_value</a>
|
118
|
+
<a href="#M000069">add_to_seq</a>
|
119
|
+
<a href="#M000067">create_mapping</a>
|
120
|
+
<a href="#M000068">create_scalar</a>
|
121
|
+
<a href="#M000066">create_sequence</a>
|
122
|
+
<a href="#M000044">document_start?</a>
|
123
|
+
<a href="#M000046">has_next?</a>
|
124
|
+
<a href="#M000072">location</a>
|
125
|
+
<a href="#M000040">new</a>
|
126
|
+
<a href="#M000047">parse</a>
|
127
|
+
<a href="#M000053">parse_alias</a>
|
128
|
+
<a href="#M000052">parse_anchor</a>
|
129
|
+
<a href="#M000058">parse_block_map</a>
|
130
|
+
<a href="#M000059">parse_block_scalar</a>
|
131
|
+
<a href="#M000056">parse_block_seq</a>
|
132
|
+
<a href="#M000060">parse_block_text</a>
|
133
|
+
<a href="#M000055">parse_block_value</a>
|
134
|
+
<a href="#M000051">parse_documents</a>
|
135
|
+
<a href="#M000048">parse_file</a>
|
136
|
+
<a href="#M000063">parse_flow_map</a>
|
137
|
+
<a href="#M000064">parse_flow_scalar</a>
|
138
|
+
<a href="#M000062">parse_flow_seq</a>
|
139
|
+
<a href="#M000061">parse_flow_value</a>
|
140
|
+
<a href="#M000049">parse_next</a>
|
141
|
+
<a href="#M000050">parse_stream</a>
|
142
|
+
<a href="#M000070">put_to_map</a>
|
143
|
+
<a href="#M000041">reset_parser</a>
|
144
|
+
<a href="#M000054">resolve_preceding_aliases</a>
|
145
|
+
<a href="#M000073">set_errors_linenum</a>
|
146
|
+
<a href="#M000043">skip_spaces_and_comments</a>
|
147
|
+
<a href="#M000045">stream_end?</a>
|
148
|
+
<a href="#M000065">to_scalar</a>
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
</div>
|
153
|
+
|
154
|
+
|
155
|
+
<!-- if includes -->
|
156
|
+
|
157
|
+
<div id="section">
|
158
|
+
|
159
|
+
|
160
|
+
<div id="constants-list">
|
161
|
+
<h3 class="section-bar">Constants</h3>
|
162
|
+
|
163
|
+
<div class="name-list">
|
164
|
+
<table summary="Constants">
|
165
|
+
<tr class="top-aligned-row context-row">
|
166
|
+
<td class="context-item-name">PRECEDING_ALIAS_PLACEHOLDER</td>
|
167
|
+
<td>=</td>
|
168
|
+
<td class="context-item-value">Object.new # :nodoc:</td>
|
169
|
+
</tr>
|
170
|
+
</table>
|
171
|
+
</div>
|
172
|
+
</div>
|
173
|
+
|
174
|
+
<div id="aliases-list">
|
175
|
+
<h3 class="section-bar">External Aliases</h3>
|
176
|
+
|
177
|
+
<div class="name-list">
|
178
|
+
<table summary="aliases">
|
179
|
+
<tr class="top-aligned-row context-row">
|
180
|
+
<td class="context-item-name">reset</td>
|
181
|
+
<td>-></td>
|
182
|
+
<td class="context-item-value">reset_scanner</td>
|
183
|
+
</tr>
|
184
|
+
</table>
|
185
|
+
</div>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
|
189
|
+
<div id="attribute-list">
|
190
|
+
<h3 class="section-bar">Attributes</h3>
|
191
|
+
|
192
|
+
<div class="name-list">
|
193
|
+
<table>
|
194
|
+
<tr class="top-aligned-row context-row">
|
195
|
+
<td class="context-item-name">data_binding</td>
|
196
|
+
<td class="context-item-value"> [RW] </td>
|
197
|
+
<td class="context-item-desc"></td>
|
198
|
+
</tr>
|
199
|
+
<tr class="top-aligned-row context-row">
|
200
|
+
<td class="context-item-name">errors</td>
|
201
|
+
<td class="context-item-value"> [R] </td>
|
202
|
+
<td class="context-item-desc"></td>
|
203
|
+
</tr>
|
204
|
+
<tr class="top-aligned-row context-row">
|
205
|
+
<td class="context-item-name">mapping_class</td>
|
206
|
+
<td class="context-item-value"> [RW] </td>
|
207
|
+
<td class="context-item-desc"></td>
|
208
|
+
</tr>
|
209
|
+
<tr class="top-aligned-row context-row">
|
210
|
+
<td class="context-item-name">preceding_alias</td>
|
211
|
+
<td class="context-item-value"> [RW] </td>
|
212
|
+
<td class="context-item-desc"></td>
|
213
|
+
</tr>
|
214
|
+
<tr class="top-aligned-row context-row">
|
215
|
+
<td class="context-item-name">sequence_class</td>
|
216
|
+
<td class="context-item-value"> [RW] </td>
|
217
|
+
<td class="context-item-desc"></td>
|
218
|
+
</tr>
|
219
|
+
<tr class="top-aligned-row context-row">
|
220
|
+
<td class="context-item-name">validator</td>
|
221
|
+
<td class="context-item-value"> [RW] </td>
|
222
|
+
<td class="context-item-desc"></td>
|
223
|
+
</tr>
|
224
|
+
</table>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
<!-- if method_list -->
|
231
|
+
<div id="methods">
|
232
|
+
<h3 class="section-bar">Public Class methods</h3>
|
233
|
+
|
234
|
+
<div id="method-M000040" class="method-detail">
|
235
|
+
<a name="M000040"></a>
|
236
|
+
|
237
|
+
<div class="method-heading">
|
238
|
+
<a href="#M000040" class="method-signature">
|
239
|
+
<span class="method-name">new</span><span class="method-args">(validator=nil, properties={})</span>
|
240
|
+
</a>
|
241
|
+
</div>
|
242
|
+
|
243
|
+
<div class="method-description">
|
244
|
+
<p><a class="source-toggle" href="#"
|
245
|
+
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
246
|
+
<div class="method-source-code" id="M000040-source">
|
247
|
+
<pre>
|
248
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 46</span>
|
249
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">validator</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">properties</span>={})
|
250
|
+
<span class="ruby-ivar">@validator</span> = <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">Validator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">validator</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">validator</span>
|
251
|
+
<span class="ruby-ivar">@data_binding</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:data_binding</span>] <span class="ruby-comment cmt"># enable data binding or not</span>
|
252
|
+
<span class="ruby-ivar">@preceding_alias</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:preceding_alias</span>] <span class="ruby-comment cmt"># allow preceding alias or not</span>
|
253
|
+
<span class="ruby-ivar">@sequence_class</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:sequence_class</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Array</span>
|
254
|
+
<span class="ruby-ivar">@mapping_class</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:mapping_class</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Hash</span>
|
255
|
+
<span class="ruby-keyword kw">end</span>
|
256
|
+
</pre>
|
257
|
+
</div>
|
258
|
+
</div>
|
259
|
+
</div>
|
260
|
+
|
261
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
262
|
+
|
263
|
+
<div id="method-M000042" class="method-detail">
|
264
|
+
<a name="M000042"></a>
|
265
|
+
|
266
|
+
<div class="method-heading">
|
267
|
+
<a href="#M000042" class="method-signature">
|
268
|
+
<span class="method-name">_set_error_info</span><span class="method-args">(linenum=@linenum, column=@column) {|| ...}</span>
|
269
|
+
</a>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
<div class="method-description">
|
273
|
+
<p>
|
274
|
+
def _validate_error(message, path, linenum=@linenum, column=@column)
|
275
|
+
</p>
|
276
|
+
<pre>
|
277
|
+
#message = _build_message(message_key)
|
278
|
+
error = _error(ValidationError, message.to_s, path, linenum, column)
|
279
|
+
@errors << error
|
280
|
+
</pre>
|
281
|
+
<p>
|
282
|
+
end private :_validate_error
|
283
|
+
</p>
|
284
|
+
<p><a class="source-toggle" href="#"
|
285
|
+
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
286
|
+
<div class="method-source-code" id="M000042-source">
|
287
|
+
<pre>
|
288
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 90</span>
|
289
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">linenum</span>=<span class="ruby-ivar">@linenum</span>, <span class="ruby-identifier">column</span>=<span class="ruby-ivar">@column</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
290
|
+
<span class="ruby-identifier">len</span> = <span class="ruby-ivar">@errors</span>.<span class="ruby-identifier">length</span>
|
291
|
+
<span class="ruby-keyword kw">yield</span>
|
292
|
+
<span class="ruby-identifier">n</span> = <span class="ruby-ivar">@errors</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">len</span>
|
293
|
+
(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
294
|
+
<span class="ruby-identifier">error</span> = <span class="ruby-ivar">@errors</span>[<span class="ruby-operator">-</span><span class="ruby-identifier">i</span>]
|
295
|
+
<span class="ruby-identifier">error</span>.<span class="ruby-identifier">linenum</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">linenum</span>
|
296
|
+
<span class="ruby-identifier">error</span>.<span class="ruby-identifier">column</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">column</span>
|
297
|
+
<span class="ruby-identifier">error</span>.<span class="ruby-identifier">filename</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@filename</span>
|
298
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
299
|
+
<span class="ruby-keyword kw">end</span>
|
300
|
+
</pre>
|
301
|
+
</div>
|
302
|
+
</div>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
<div id="method-M000057" class="method-detail">
|
306
|
+
<a name="M000057"></a>
|
307
|
+
|
308
|
+
<div class="method-heading">
|
309
|
+
<a href="#M000057" class="method-signature">
|
310
|
+
<span class="method-name">_validate_map_value</span><span class="method-args">(map, map_rule, rule, path, uniq_table, key, val,</span>
|
311
|
+
</a>
|
312
|
+
</div>
|
313
|
+
|
314
|
+
<div class="method-description">
|
315
|
+
<p><a class="source-toggle" href="#"
|
316
|
+
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
317
|
+
<div class="method-source-code" id="M000057-source">
|
318
|
+
<pre>
|
319
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 404</span>
|
320
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_validate_map_value</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">map_rule</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span>, <span class="ruby-comment cmt">#*V</span>
|
321
|
+
<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-comment cmt">#*V</span>
|
322
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">map_rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rule</span> <span class="ruby-comment cmt">#*V</span>
|
323
|
+
<span class="ruby-comment cmt">#_validate_error("unknown mapping key.", path) #*V</span>
|
324
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
325
|
+
<span class="ruby-identifier">error</span> = <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">ErrorHelper</span>.<span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:key_undefined</span>, <span class="ruby-comment cmt">#*V</span>
|
326
|
+
<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">map</span>, [<span class="ruby-node">"#{key}:"</span>]) <span class="ruby-comment cmt">#*V</span>
|
327
|
+
<span class="ruby-ivar">@errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">error</span> <span class="ruby-comment cmt">#*V</span>
|
328
|
+
<span class="ruby-comment cmt">#error.linenum = _linenum #*V</span>
|
329
|
+
<span class="ruby-comment cmt">#error.column = _column #*V</span>
|
330
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt">#*V</span>
|
331
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt">#*V</span>
|
332
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
333
|
+
<span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">val</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-ivar">@errors</span>, <span class="ruby-ivar">@done</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-keyword kw">false</span>) <span class="ruby-comment cmt">#*V</span>
|
334
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">equal?</span>(<span class="ruby-constant">PRECEDING_ALIAS_PLACEHOLDER</span>) <span class="ruby-comment cmt">#*V</span>
|
335
|
+
<span class="ruby-keyword kw">end</span>
|
336
|
+
</pre>
|
337
|
+
</div>
|
338
|
+
</div>
|
339
|
+
</div>
|
340
|
+
|
341
|
+
<div id="method-M000044" class="method-detail">
|
342
|
+
<a name="M000044"></a>
|
343
|
+
|
344
|
+
<div class="method-heading">
|
345
|
+
<a href="#M000044" class="method-signature">
|
346
|
+
<span class="method-name">document_start?</span><span class="method-args">()</span>
|
347
|
+
</a>
|
348
|
+
</div>
|
349
|
+
|
350
|
+
<div class="method-description">
|
351
|
+
<p><a class="source-toggle" href="#"
|
352
|
+
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
|
353
|
+
<div class="method-source-code" id="M000044-source">
|
354
|
+
<pre>
|
355
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 112</span>
|
356
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">document_start?</span>()
|
357
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/---\s/</span>) <span class="ruby-operator">&&</span> <span class="ruby-ivar">@column</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
358
|
+
<span class="ruby-keyword kw">end</span>
|
359
|
+
</pre>
|
360
|
+
</div>
|
361
|
+
</div>
|
362
|
+
</div>
|
363
|
+
|
364
|
+
<div id="method-M000046" class="method-detail">
|
365
|
+
<a name="M000046"></a>
|
366
|
+
|
367
|
+
<div class="method-heading">
|
368
|
+
<a href="#M000046" class="method-signature">
|
369
|
+
<span class="method-name">has_next?</span><span class="method-args">()</span>
|
370
|
+
</a>
|
371
|
+
</div>
|
372
|
+
|
373
|
+
<div class="method-description">
|
374
|
+
<p><a class="source-toggle" href="#"
|
375
|
+
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
376
|
+
<div class="method-source-code" id="M000046-source">
|
377
|
+
<pre>
|
378
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 122</span>
|
379
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_next?</span>()
|
380
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">eos?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">stream_end?</span>)
|
381
|
+
<span class="ruby-keyword kw">end</span>
|
382
|
+
</pre>
|
383
|
+
</div>
|
384
|
+
</div>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
<div id="method-M000072" class="method-detail">
|
388
|
+
<a name="M000072"></a>
|
389
|
+
|
390
|
+
<div class="method-heading">
|
391
|
+
<a href="#M000072" class="method-signature">
|
392
|
+
<span class="method-name">location</span><span class="method-args">(path)</span>
|
393
|
+
</a>
|
394
|
+
</div>
|
395
|
+
|
396
|
+
<div class="method-description">
|
397
|
+
<p><a class="source-toggle" href="#"
|
398
|
+
onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
|
399
|
+
<div class="method-source-code" id="M000072-source">
|
400
|
+
<pre>
|
401
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 791</span>
|
402
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">location</span>(<span class="ruby-identifier">path</span>)
|
403
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'/'</span>
|
404
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@location_table</span>[<span class="ruby-value">-1</span>] <span class="ruby-comment cmt"># return value is [linenum, column]</span>
|
405
|
+
<span class="ruby-keyword kw">end</span>
|
406
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
407
|
+
<span class="ruby-identifier">items</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to_scalar</span>(<span class="ruby-identifier">item</span>) }
|
408
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
|
409
|
+
<span class="ruby-identifier">items</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to_scalar</span>(<span class="ruby-identifier">item</span>) }
|
410
|
+
<span class="ruby-identifier">items</span>.<span class="ruby-identifier">shift</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?/</span> <span class="ruby-comment cmt"># delete empty string on head</span>
|
411
|
+
<span class="ruby-keyword kw">else</span>
|
412
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"path should be Array or String."</span>)
|
413
|
+
<span class="ruby-keyword kw">end</span>
|
414
|
+
<span class="ruby-identifier">last_item</span> = <span class="ruby-identifier">items</span>.<span class="ruby-identifier">pop</span>()
|
415
|
+
<span class="ruby-identifier">c</span> = <span class="ruby-ivar">@doc</span> <span class="ruby-comment cmt"># collection</span>
|
416
|
+
<span class="ruby-identifier">items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
|
417
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
418
|
+
<span class="ruby-identifier">c</span> = <span class="ruby-identifier">c</span>[<span class="ruby-identifier">item</span>.<span class="ruby-identifier">to_i</span>]
|
419
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
420
|
+
<span class="ruby-identifier">c</span> = <span class="ruby-identifier">c</span>[<span class="ruby-identifier">item</span>]
|
421
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">table</span> = <span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">__id__</span>]) <span class="ruby-operator">&&</span> <span class="ruby-identifier">table</span>[<span class="ruby-identifier">:classobj</span>]
|
422
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">item</span>)
|
423
|
+
<span class="ruby-identifier">c</span> = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">item</span>)
|
424
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">"[]="</span>)
|
425
|
+
<span class="ruby-identifier">c</span> = <span class="ruby-identifier">c</span>[<span class="ruby-identifier">item</span>]
|
426
|
+
<span class="ruby-keyword kw">else</span>
|
427
|
+
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">false</span>
|
428
|
+
<span class="ruby-keyword kw">end</span>
|
429
|
+
<span class="ruby-keyword kw">else</span>
|
430
|
+
<span class="ruby-comment cmt">#assert false</span>
|
431
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{path.inspect}: invalid path."</span>)
|
432
|
+
<span class="ruby-keyword kw">end</span>
|
433
|
+
<span class="ruby-keyword kw">end</span>
|
434
|
+
<span class="ruby-identifier">collection</span> = <span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">__id__</span>]
|
435
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">collection</span>.<span class="ruby-identifier">nil?</span>
|
436
|
+
<span class="ruby-identifier">index</span> = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">last_item</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">last_item</span>
|
437
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">collection</span>[<span class="ruby-identifier">index</span>] <span class="ruby-comment cmt"># return value is [linenum, column]</span>
|
438
|
+
<span class="ruby-keyword kw">end</span>
|
439
|
+
</pre>
|
440
|
+
</div>
|
441
|
+
</div>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
<div id="method-M000047" class="method-detail">
|
445
|
+
<a name="M000047"></a>
|
446
|
+
|
447
|
+
<div class="method-heading">
|
448
|
+
<a href="#M000047" class="method-signature">
|
449
|
+
<span class="method-name">parse</span><span class="method-args">(input=nil, opts={})</span>
|
450
|
+
</a>
|
451
|
+
</div>
|
452
|
+
|
453
|
+
<div class="method-description">
|
454
|
+
<p><a class="source-toggle" href="#"
|
455
|
+
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
456
|
+
<div class="method-source-code" id="M000047-source">
|
457
|
+
<pre>
|
458
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 127</span>
|
459
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">input</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">opts</span>={})
|
460
|
+
<span class="ruby-identifier">reset_scanner</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:filename</span>], <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:untabify</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">input</span>
|
461
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parse_next</span>()
|
462
|
+
<span class="ruby-keyword kw">end</span>
|
463
|
+
</pre>
|
464
|
+
</div>
|
465
|
+
</div>
|
466
|
+
</div>
|
467
|
+
|
468
|
+
<div id="method-M000053" class="method-detail">
|
469
|
+
<a name="M000053"></a>
|
470
|
+
|
471
|
+
<div class="method-heading">
|
472
|
+
<a href="#M000053" class="method-signature">
|
473
|
+
<span class="method-name">parse_alias</span><span class="method-args">(rule, path, uniq_table, container)</span>
|
474
|
+
</a>
|
475
|
+
</div>
|
476
|
+
|
477
|
+
<div class="method-description">
|
478
|
+
<p><a class="source-toggle" href="#"
|
479
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
480
|
+
<div class="method-source-code" id="M000053-source">
|
481
|
+
<pre>
|
482
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 198</span>
|
483
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_alias</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
484
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">1</span>)
|
485
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@anchors</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">name</span>)
|
486
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>]
|
487
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@preceding_alias</span>
|
488
|
+
<span class="ruby-ivar">@preceding_aliases</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">name</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span>, <span class="ruby-identifier">container</span>,
|
489
|
+
<span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>]
|
490
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-constant">PRECEDING_ALIAS_PLACEHOLDER</span>
|
491
|
+
<span class="ruby-keyword kw">else</span>
|
492
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-node">"*#{name}: anchor not found."</span>, <span class="ruby-identifier">path</span>,
|
493
|
+
<span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
|
494
|
+
<span class="ruby-keyword kw">end</span>
|
495
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
496
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
|
497
|
+
<span class="ruby-keyword kw">end</span>
|
498
|
+
</pre>
|
499
|
+
</div>
|
500
|
+
</div>
|
501
|
+
</div>
|
502
|
+
|
503
|
+
<div id="method-M000052" class="method-detail">
|
504
|
+
<a name="M000052"></a>
|
505
|
+
|
506
|
+
<div class="method-heading">
|
507
|
+
<a href="#M000052" class="method-signature">
|
508
|
+
<span class="method-name">parse_anchor</span><span class="method-args">(rule, path, uniq_table, container)</span>
|
509
|
+
</a>
|
510
|
+
</div>
|
511
|
+
|
512
|
+
<div class="method-description">
|
513
|
+
<p><a class="source-toggle" href="#"
|
514
|
+
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
515
|
+
<div class="method-source-code" id="M000052-source">
|
516
|
+
<pre>
|
517
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 187</span>
|
518
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_anchor</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
519
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">1</span>)
|
520
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@anchors</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">name</span>)
|
521
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-node">"&#{name}: anchor duplicated."</span>, <span class="ruby-identifier">path</span>,
|
522
|
+
<span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">length</span>)
|
523
|
+
<span class="ruby-keyword kw">end</span>
|
524
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
525
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">name</span>
|
526
|
+
<span class="ruby-keyword kw">end</span>
|
527
|
+
</pre>
|
528
|
+
</div>
|
529
|
+
</div>
|
530
|
+
</div>
|
531
|
+
|
532
|
+
<div id="method-M000058" class="method-detail">
|
533
|
+
<a name="M000058"></a>
|
534
|
+
|
535
|
+
<div class="method-heading">
|
536
|
+
<a href="#M000058" class="method-signature">
|
537
|
+
<span class="method-name">parse_block_map</span><span class="method-args">(map, map_rule, path, uniq_table)</span>
|
538
|
+
</a>
|
539
|
+
</div>
|
540
|
+
|
541
|
+
<div class="method-description">
|
542
|
+
<p><a class="source-toggle" href="#"
|
543
|
+
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
|
544
|
+
<div class="method-source-code" id="M000058-source">
|
545
|
+
<pre>
|
546
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 422</span>
|
547
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_block_map</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">map_rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
548
|
+
<span class="ruby-identifier">_start_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
549
|
+
<span class="ruby-identifier">_start_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
550
|
+
<span class="ruby-identifier">level</span> = <span class="ruby-ivar">@column</span>
|
551
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">push</span>(<span class="ruby-keyword kw">nil</span>)
|
552
|
+
<span class="ruby-identifier">is_merged</span> = <span class="ruby-keyword kw">false</span>
|
553
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
554
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
555
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
556
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">level</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@column</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">scan</span>(<span class="ruby-constant">MAPKEY_PATTERN</span>)
|
557
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">1</span>)
|
558
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>() <span class="ruby-comment cmt">#*V</span>
|
559
|
+
<span class="ruby-identifier">_linenum2</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
560
|
+
<span class="ruby-identifier">_column2</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
561
|
+
<span class="ruby-identifier">is_merged</span> = <span class="ruby-identifier">_parse_map_value</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">map_rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">level</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">is_merged</span>,
|
562
|
+
<span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>, <span class="ruby-identifier">_linenum2</span>, <span class="ruby-identifier">_column2</span>)
|
563
|
+
<span class="ruby-comment cmt">#skip_spaces_and_comments()</span>
|
564
|
+
<span class="ruby-keyword kw">end</span>
|
565
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">pop</span>()
|
566
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_start_linenum</span>, <span class="ruby-identifier">_start_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
567
|
+
<span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">_validate_mapping_required_keys</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">map_rule</span>, <span class="ruby-comment cmt">#*V</span>
|
568
|
+
<span class="ruby-identifier">path</span>, <span class="ruby-ivar">@errors</span>) <span class="ruby-comment cmt">#*V</span>
|
569
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">map_rule</span> <span class="ruby-comment cmt">#*V</span>
|
570
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">map</span>
|
571
|
+
<span class="ruby-keyword kw">end</span>
|
572
|
+
</pre>
|
573
|
+
</div>
|
574
|
+
</div>
|
575
|
+
</div>
|
576
|
+
|
577
|
+
<div id="method-M000059" class="method-detail">
|
578
|
+
<a name="M000059"></a>
|
579
|
+
|
580
|
+
<div class="method-heading">
|
581
|
+
<a href="#M000059" class="method-signature">
|
582
|
+
<span class="method-name">parse_block_scalar</span><span class="method-args">(rule, path, uniq_table)</span>
|
583
|
+
</a>
|
584
|
+
</div>
|
585
|
+
|
586
|
+
<div class="method-description">
|
587
|
+
<p><a class="source-toggle" href="#"
|
588
|
+
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
|
589
|
+
<div class="method-source-code" id="M000059-source">
|
590
|
+
<pre>
|
591
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 459</span>
|
592
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_block_scalar</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
593
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
594
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
595
|
+
<span class="ruby-identifier">ch</span> = <span class="ruby-identifier">peep</span>(<span class="ruby-value">1</span>)
|
596
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ch</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'"'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">ch</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"'"</span>
|
597
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">scan_string</span>()
|
598
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/[ \t]*(?:\#.*)?$/</span>)
|
599
|
+
<span class="ruby-keyword kw">else</span>
|
600
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/(.*?)[ \t]*(?:\#.*)?$/</span>)
|
601
|
+
<span class="ruby-comment cmt">#str.rstrip!</span>
|
602
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">to_scalar</span>(<span class="ruby-identifier">group</span>(<span class="ruby-value">1</span>))
|
603
|
+
<span class="ruby-keyword kw">end</span>
|
604
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">create_scalar</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-comment cmt">#*V</span>
|
605
|
+
<span class="ruby-comment cmt">#_set_error_info(_linenum, _column) do #*V</span>
|
606
|
+
<span class="ruby-comment cmt"># @validator._validate_unique(val, rule, path, @errors, uniq_table) #*V</span>
|
607
|
+
<span class="ruby-comment cmt">#end if uniq_table #*V</span>
|
608
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
609
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
|
610
|
+
<span class="ruby-keyword kw">end</span>
|
611
|
+
</pre>
|
612
|
+
</div>
|
613
|
+
</div>
|
614
|
+
</div>
|
615
|
+
|
616
|
+
<div id="method-M000056" class="method-detail">
|
617
|
+
<a name="M000056"></a>
|
618
|
+
|
619
|
+
<div class="method-heading">
|
620
|
+
<a href="#M000056" class="method-signature">
|
621
|
+
<span class="method-name">parse_block_seq</span><span class="method-args">(seq, seq_rule, path, uniq_table)</span>
|
622
|
+
</a>
|
623
|
+
</div>
|
624
|
+
|
625
|
+
<div class="method-description">
|
626
|
+
<p><a class="source-toggle" href="#"
|
627
|
+
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
628
|
+
<div class="method-source-code" id="M000056-source">
|
629
|
+
<pre>
|
630
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 307</span>
|
631
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_block_seq</span>(<span class="ruby-identifier">seq</span>, <span class="ruby-identifier">seq_rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
632
|
+
<span class="ruby-identifier">level</span> = <span class="ruby-ivar">@column</span>
|
633
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-identifier">seq_rule</span> <span class="ruby-value">? </span><span class="ruby-identifier">seq_rule</span>.<span class="ruby-identifier">sequence</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
634
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">push</span>(<span class="ruby-keyword kw">nil</span>)
|
635
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
|
636
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
637
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
638
|
+
<span class="ruby-identifier">uniq_table</span> = <span class="ruby-identifier">rule</span> <span class="ruby-value">? </span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">_uniqueness_check_table</span>() <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
639
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">level</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@column</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/-\s+/</span>)
|
640
|
+
<span class="ruby-identifier">path</span>[<span class="ruby-value">-1</span>] = <span class="ruby-identifier">i</span>
|
641
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>() <span class="ruby-comment cmt">#*V</span>
|
642
|
+
<span class="ruby-identifier">_linenum2</span> = <span class="ruby-ivar">@linenum</span>
|
643
|
+
<span class="ruby-identifier">_column2</span> = <span class="ruby-ivar">@column</span>
|
644
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">parse_block_value</span>(<span class="ruby-identifier">level</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">seq</span>)
|
645
|
+
<span class="ruby-identifier">add_to_seq</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">seq</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">_linenum2</span>, <span class="ruby-identifier">_column2</span>) <span class="ruby-comment cmt"># seq << val</span>
|
646
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
647
|
+
<span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">val</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-ivar">@errors</span>, <span class="ruby-ivar">@done</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-keyword kw">false</span>) <span class="ruby-comment cmt">#*V</span>
|
648
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">equal?</span>(<span class="ruby-constant">PRECEDING_ALIAS_PLACEHOLDER</span>) <span class="ruby-comment cmt">#*V</span>
|
649
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
650
|
+
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
651
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
652
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
653
|
+
<span class="ruby-keyword kw">end</span>
|
654
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">pop</span>()
|
655
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">seq</span>
|
656
|
+
<span class="ruby-keyword kw">end</span>
|
657
|
+
</pre>
|
658
|
+
</div>
|
659
|
+
</div>
|
660
|
+
</div>
|
661
|
+
|
662
|
+
<div id="method-M000060" class="method-detail">
|
663
|
+
<a name="M000060"></a>
|
664
|
+
|
665
|
+
<div class="method-heading">
|
666
|
+
<a href="#M000060" class="method-signature">
|
667
|
+
<span class="method-name">parse_block_text</span><span class="method-args">(column, rule, path, uniq_table)</span>
|
668
|
+
</a>
|
669
|
+
</div>
|
670
|
+
|
671
|
+
<div class="method-description">
|
672
|
+
<p><a class="source-toggle" href="#"
|
673
|
+
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
|
674
|
+
<div class="method-source-code" id="M000060-source">
|
675
|
+
<pre>
|
676
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 480</span>
|
677
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_block_text</span>(<span class="ruby-identifier">column</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
678
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
679
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
680
|
+
<span class="ruby-identifier">indicator</span> = <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/[|>]/</span>)
|
681
|
+
<span class="ruby-identifier">chomping</span> = <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/[-+]/</span>)
|
682
|
+
<span class="ruby-identifier">num</span> = <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\d+/</span>)
|
683
|
+
<span class="ruby-identifier">indent</span> = <span class="ruby-identifier">num</span> <span class="ruby-value">? </span><span class="ruby-identifier">column</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">num</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
684
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/[ \t]*(.*?)(\#.*)?\r?\n/</span>) <span class="ruby-comment cmt"># /[ \t]*(\#.*)?\r?\n/</span>
|
685
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-value str">"Syntax Error (line break or comment are expected)"</span>, <span class="ruby-identifier">path</span>)
|
686
|
+
<span class="ruby-keyword kw">end</span>
|
687
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">1</span>)
|
688
|
+
<span class="ruby-identifier">is_folded</span> = <span class="ruby-keyword kw">false</span>
|
689
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/( *)(.*?)(\r?\n)/</span>)
|
690
|
+
<span class="ruby-identifier">spaces</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">1</span>)
|
691
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">2</span>)
|
692
|
+
<span class="ruby-identifier">nl</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">3</span>)
|
693
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">indent</span>.<span class="ruby-identifier">nil?</span>
|
694
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">spaces</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">column</span>
|
695
|
+
<span class="ruby-identifier">indent</span> = <span class="ruby-identifier">spaces</span>.<span class="ruby-identifier">length</span>
|
696
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
697
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">nl</span>
|
698
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/.*?\n/</span>)
|
699
|
+
<span class="ruby-keyword kw">next</span>
|
700
|
+
<span class="ruby-keyword kw">else</span>
|
701
|
+
<span class="ruby-ivar">@diagnostic</span> = <span class="ruby-value str">'text indent in block text may be shorter than that of first line or specified column.'</span>
|
702
|
+
<span class="ruby-keyword kw">break</span>
|
703
|
+
<span class="ruby-keyword kw">end</span>
|
704
|
+
<span class="ruby-keyword kw">else</span>
|
705
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">spaces</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">indent</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
706
|
+
<span class="ruby-ivar">@diagnostic</span> = <span class="ruby-value str">'text indent in block text may be shorter than that of first line or specified column.'</span>
|
707
|
+
<span class="ruby-keyword kw">break</span>
|
708
|
+
<span class="ruby-keyword kw">end</span>
|
709
|
+
<span class="ruby-keyword kw">end</span>
|
710
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/.*?\n/</span>)
|
711
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">indicator</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'|'</span>
|
712
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">spaces</span>[<span class="ruby-identifier">indent</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">spaces</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">indent</span>
|
713
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">text</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">nl</span>
|
714
|
+
<span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># indicator == '>'</span>
|
715
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">spaces</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">indent</span>
|
716
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/\r?\n((\r?\n)+)\z/</span>, <span class="ruby-value str">'\1'</span>)
|
717
|
+
<span class="ruby-keyword kw">nil</span>
|
718
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">is_folded</span>
|
719
|
+
<span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/\r?\n\z/</span>, <span class="ruby-value str">' '</span>)
|
720
|
+
<span class="ruby-keyword kw">end</span>
|
721
|
+
<span class="ruby-comment cmt">#s.sub!(/\r?\n\z/, '') if !s.sub!(/\r?\n(\r?\n)+\z/, '\1') && is_folded</span>
|
722
|
+
<span class="ruby-identifier">is_folded</span> = <span class="ruby-keyword kw">true</span>
|
723
|
+
<span class="ruby-keyword kw">else</span>
|
724
|
+
<span class="ruby-identifier">is_folded</span> = <span class="ruby-keyword kw">false</span>
|
725
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">spaces</span>[<span class="ruby-identifier">indent</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">spaces</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-identifier">indent</span>
|
726
|
+
<span class="ruby-keyword kw">end</span>
|
727
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">text</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">nl</span>
|
728
|
+
<span class="ruby-keyword kw">end</span>
|
729
|
+
<span class="ruby-keyword kw">end</span>
|
730
|
+
<span class="ruby-comment cmt">## chomping</span>
|
731
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">chomping</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'+'</span>
|
732
|
+
<span class="ruby-keyword kw">nil</span>
|
733
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">chomping</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'-'</span>
|
734
|
+
<span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/(\r?\n)+\z/</span>, <span class="ruby-value str">''</span>)
|
735
|
+
<span class="ruby-keyword kw">else</span>
|
736
|
+
<span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/(\r?\n)(\r?\n)+\z/</span>, <span class="ruby-value str">'\1'</span>)
|
737
|
+
<span class="ruby-keyword kw">end</span>
|
738
|
+
<span class="ruby-comment cmt">#</span>
|
739
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
740
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">s</span>
|
741
|
+
<span class="ruby-comment cmt">#_set_error_info(_linenum, _column) do #*V</span>
|
742
|
+
<span class="ruby-comment cmt"># @validator._validate_unique(val, rule, path, @errors, uniq_table) #*V</span>
|
743
|
+
<span class="ruby-comment cmt">#end if uniq_table #*V</span>
|
744
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
|
745
|
+
<span class="ruby-keyword kw">end</span>
|
746
|
+
</pre>
|
747
|
+
</div>
|
748
|
+
</div>
|
749
|
+
</div>
|
750
|
+
|
751
|
+
<div id="method-M000055" class="method-detail">
|
752
|
+
<a name="M000055"></a>
|
753
|
+
|
754
|
+
<div class="method-heading">
|
755
|
+
<a href="#M000055" class="method-signature">
|
756
|
+
<span class="method-name">parse_block_value</span><span class="method-args">(level, rule, path, uniq_table, container)</span>
|
757
|
+
</a>
|
758
|
+
</div>
|
759
|
+
|
760
|
+
<div class="method-description">
|
761
|
+
<p><a class="source-toggle" href="#"
|
762
|
+
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
763
|
+
<div class="method-source-code" id="M000055-source">
|
764
|
+
<pre>
|
765
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 235</span>
|
766
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_block_value</span>(<span class="ruby-identifier">level</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
767
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
768
|
+
<span class="ruby-comment cmt">## nil</span>
|
769
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@column</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">level</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">eos?</span>
|
770
|
+
<span class="ruby-comment cmt">## anchor and alias</span>
|
771
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>
|
772
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\&([-\w]+)/</span>)
|
773
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">parse_anchor</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
774
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\*([-\w]+)/</span>)
|
775
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parse_alias</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
776
|
+
<span class="ruby-keyword kw">end</span>
|
777
|
+
<span class="ruby-comment cmt">## type</span>
|
778
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/!!?\w+/</span>)
|
779
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
780
|
+
<span class="ruby-keyword kw">end</span>
|
781
|
+
<span class="ruby-comment cmt">## sequence</span>
|
782
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/-\s+/</span>)
|
783
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">sequence</span>
|
784
|
+
<span class="ruby-comment cmt">#_validate_error("sequence is not expected.", path)</span>
|
785
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-keyword kw">nil</span>
|
786
|
+
<span class="ruby-keyword kw">end</span>
|
787
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-identifier">create_sequence</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span>)
|
788
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">seq</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
789
|
+
<span class="ruby-identifier">parse_block_seq</span>(<span class="ruby-identifier">seq</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
790
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">seq</span>
|
791
|
+
<span class="ruby-keyword kw">end</span>
|
792
|
+
<span class="ruby-comment cmt">## mapping</span>
|
793
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-constant">MAPKEY_PATTERN</span>)
|
794
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">mapping</span>
|
795
|
+
<span class="ruby-comment cmt">#_validate_error("mapping is not expected.", path)</span>
|
796
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-keyword kw">nil</span>
|
797
|
+
<span class="ruby-keyword kw">end</span>
|
798
|
+
<span class="ruby-identifier">map</span> = <span class="ruby-identifier">create_mapping</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span>)
|
799
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">map</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
800
|
+
<span class="ruby-identifier">parse_block_map</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
801
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">map</span>
|
802
|
+
<span class="ruby-keyword kw">end</span>
|
803
|
+
<span class="ruby-comment cmt">## sequence (flow-style)</span>
|
804
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/\[/</span>)
|
805
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">sequence</span>
|
806
|
+
<span class="ruby-comment cmt">#_validate_error("sequence is not expected.", path)</span>
|
807
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-keyword kw">nil</span>
|
808
|
+
<span class="ruby-keyword kw">end</span>
|
809
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-identifier">create_sequence</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span>)
|
810
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">seq</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
811
|
+
<span class="ruby-identifier">parse_flow_seq</span>(<span class="ruby-identifier">seq</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
812
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">seq</span>
|
813
|
+
<span class="ruby-keyword kw">end</span>
|
814
|
+
<span class="ruby-comment cmt">## mapping (flow-style)</span>
|
815
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/\{/</span>)
|
816
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">mapping</span>
|
817
|
+
<span class="ruby-comment cmt">#_validate_error("mapping is not expected.", path)</span>
|
818
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-keyword kw">nil</span>
|
819
|
+
<span class="ruby-keyword kw">end</span>
|
820
|
+
<span class="ruby-identifier">map</span> = <span class="ruby-identifier">create_mapping</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span>)
|
821
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">map</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
822
|
+
<span class="ruby-identifier">parse_flow_map</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
823
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">map</span>
|
824
|
+
<span class="ruby-keyword kw">end</span>
|
825
|
+
<span class="ruby-comment cmt">## block text</span>
|
826
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/[|>]/</span>)
|
827
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">parse_block_text</span>(<span class="ruby-identifier">level</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
828
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">text</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
829
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">text</span>
|
830
|
+
<span class="ruby-keyword kw">end</span>
|
831
|
+
<span class="ruby-comment cmt">## scalar</span>
|
832
|
+
<span class="ruby-identifier">scalar</span> = <span class="ruby-identifier">parse_block_scalar</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
833
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">scalar</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
834
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">scalar</span>
|
835
|
+
<span class="ruby-keyword kw">end</span>
|
836
|
+
</pre>
|
837
|
+
</div>
|
838
|
+
</div>
|
839
|
+
</div>
|
840
|
+
|
841
|
+
<div id="method-M000051" class="method-detail">
|
842
|
+
<a name="M000051"></a>
|
843
|
+
|
844
|
+
<div class="method-heading">
|
845
|
+
<span class="method-name">parse_documents</span><span class="method-args">(input, opts={}, &block)</span>
|
846
|
+
</div>
|
847
|
+
|
848
|
+
<div class="method-description">
|
849
|
+
<p>
|
850
|
+
Alias for <a href="Parser.html#M000050">parse_stream</a>
|
851
|
+
</p>
|
852
|
+
</div>
|
853
|
+
</div>
|
854
|
+
|
855
|
+
<div id="method-M000048" class="method-detail">
|
856
|
+
<a name="M000048"></a>
|
857
|
+
|
858
|
+
<div class="method-heading">
|
859
|
+
<a href="#M000048" class="method-signature">
|
860
|
+
<span class="method-name">parse_file</span><span class="method-args">(filename, opts={})</span>
|
861
|
+
</a>
|
862
|
+
</div>
|
863
|
+
|
864
|
+
<div class="method-description">
|
865
|
+
<p><a class="source-toggle" href="#"
|
866
|
+
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
867
|
+
<div class="method-source-code" id="M000048-source">
|
868
|
+
<pre>
|
869
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 133</span>
|
870
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">opts</span>={})
|
871
|
+
<span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:filename</span>] = <span class="ruby-identifier">filename</span>
|
872
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parse</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>), <span class="ruby-identifier">opts</span>)
|
873
|
+
<span class="ruby-keyword kw">end</span>
|
874
|
+
</pre>
|
875
|
+
</div>
|
876
|
+
</div>
|
877
|
+
</div>
|
878
|
+
|
879
|
+
<div id="method-M000063" class="method-detail">
|
880
|
+
<a name="M000063"></a>
|
881
|
+
|
882
|
+
<div class="method-heading">
|
883
|
+
<a href="#M000063" class="method-signature">
|
884
|
+
<span class="method-name">parse_flow_map</span><span class="method-args">(map, map_rule, path, uniq_table)</span>
|
885
|
+
</a>
|
886
|
+
</div>
|
887
|
+
|
888
|
+
<div class="method-description">
|
889
|
+
<p><a class="source-toggle" href="#"
|
890
|
+
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
|
891
|
+
<div class="method-source-code" id="M000063-source">
|
892
|
+
<pre>
|
893
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 630</span>
|
894
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_flow_map</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">map_rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
895
|
+
<span class="ruby-comment cmt">#scan(/\{\s*/) # not work?</span>
|
896
|
+
<span class="ruby-identifier">_start_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
897
|
+
<span class="ruby-identifier">_start_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
898
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\{/</span>)
|
899
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
900
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\}/</span>)
|
901
|
+
<span class="ruby-keyword kw">nil</span>
|
902
|
+
<span class="ruby-keyword kw">else</span>
|
903
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">push</span>(<span class="ruby-keyword kw">nil</span>)
|
904
|
+
<span class="ruby-identifier">is_merged</span> = <span class="ruby-keyword kw">false</span>
|
905
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
906
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
907
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
908
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">scan</span>(<span class="ruby-constant">MAPKEY_PATTERN</span>)
|
909
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-value str">"mapping key is expected."</span>, <span class="ruby-identifier">path</span>)
|
910
|
+
<span class="ruby-keyword kw">end</span>
|
911
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">group</span>(<span class="ruby-value">1</span>)
|
912
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
913
|
+
<span class="ruby-identifier">_linenum2</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
914
|
+
<span class="ruby-identifier">_column2</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
915
|
+
<span class="ruby-identifier">is_merged</span> = <span class="ruby-identifier">_parse_map_value</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">map_rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">is_merged</span>,
|
916
|
+
<span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>, <span class="ruby-identifier">_linenum2</span>, <span class="ruby-identifier">_column2</span>)
|
917
|
+
<span class="ruby-comment cmt">#skip_spaces_and_comments()</span>
|
918
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/,\s+/</span>)
|
919
|
+
<span class="ruby-keyword kw">end</span>
|
920
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">pop</span>()
|
921
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\}/</span>)
|
922
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-value str">"flow mapping is not closed by '}'."</span>, <span class="ruby-identifier">path</span>)
|
923
|
+
<span class="ruby-keyword kw">end</span>
|
924
|
+
<span class="ruby-keyword kw">end</span>
|
925
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
926
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_start_linenum</span>, <span class="ruby-identifier">_start_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
927
|
+
<span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">_validate_mapping_required_keys</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">map_rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-ivar">@errors</span>) <span class="ruby-comment cmt">#*V</span>
|
928
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">map_rule</span> <span class="ruby-comment cmt">#*V</span>
|
929
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">map</span>
|
930
|
+
<span class="ruby-keyword kw">end</span>
|
931
|
+
</pre>
|
932
|
+
</div>
|
933
|
+
</div>
|
934
|
+
</div>
|
935
|
+
|
936
|
+
<div id="method-M000064" class="method-detail">
|
937
|
+
<a name="M000064"></a>
|
938
|
+
|
939
|
+
<div class="method-heading">
|
940
|
+
<a href="#M000064" class="method-signature">
|
941
|
+
<span class="method-name">parse_flow_scalar</span><span class="method-args">(rule, path, uniq_table)</span>
|
942
|
+
</a>
|
943
|
+
</div>
|
944
|
+
|
945
|
+
<div class="method-description">
|
946
|
+
<p><a class="source-toggle" href="#"
|
947
|
+
onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
|
948
|
+
<div class="method-source-code" id="M000064-source">
|
949
|
+
<pre>
|
950
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 669</span>
|
951
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_flow_scalar</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
952
|
+
<span class="ruby-identifier">ch</span> = <span class="ruby-identifier">peep</span>(<span class="ruby-value">1</span>)
|
953
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
954
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
955
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ch</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'"'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">ch</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"'"</span>
|
956
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">scan_string</span>()
|
957
|
+
<span class="ruby-keyword kw">else</span>
|
958
|
+
<span class="ruby-identifier">str</span> = <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/[^,\]\}\#]*/</span>)
|
959
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/,\S/</span>)
|
960
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/,\S/</span>)
|
961
|
+
<span class="ruby-identifier">str</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/./</span>)
|
962
|
+
<span class="ruby-identifier">str</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/[^,\]\}\#]*/</span>)
|
963
|
+
<span class="ruby-keyword kw">end</span>
|
964
|
+
<span class="ruby-keyword kw">end</span>
|
965
|
+
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">rstrip!</span>
|
966
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">to_scalar</span>(<span class="ruby-identifier">str</span>)
|
967
|
+
<span class="ruby-keyword kw">end</span>
|
968
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">create_scalar</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-comment cmt">#*V</span>
|
969
|
+
<span class="ruby-comment cmt">#_set_error_info(_linenum, _column) do #*V</span>
|
970
|
+
<span class="ruby-comment cmt"># @validator._validate_unique(val, rule, path, @errors, uniq_table) #*V</span>
|
971
|
+
<span class="ruby-comment cmt">#end if uniq_table #*V</span>
|
972
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
973
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
|
974
|
+
<span class="ruby-keyword kw">end</span>
|
975
|
+
</pre>
|
976
|
+
</div>
|
977
|
+
</div>
|
978
|
+
</div>
|
979
|
+
|
980
|
+
<div id="method-M000062" class="method-detail">
|
981
|
+
<a name="M000062"></a>
|
982
|
+
|
983
|
+
<div class="method-heading">
|
984
|
+
<a href="#M000062" class="method-signature">
|
985
|
+
<span class="method-name">parse_flow_seq</span><span class="method-args">(seq, seq_rule, path, uniq_table)</span>
|
986
|
+
</a>
|
987
|
+
</div>
|
988
|
+
|
989
|
+
<div class="method-description">
|
990
|
+
<p><a class="source-toggle" href="#"
|
991
|
+
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
|
992
|
+
<div class="method-source-code" id="M000062-source">
|
993
|
+
<pre>
|
994
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 593</span>
|
995
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_flow_seq</span>(<span class="ruby-identifier">seq</span>, <span class="ruby-identifier">seq_rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
996
|
+
<span class="ruby-comment cmt">#scan(/\[\s*/)</span>
|
997
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\[/</span>)
|
998
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
999
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\]/</span>)
|
1000
|
+
<span class="ruby-keyword kw">nil</span>
|
1001
|
+
<span class="ruby-keyword kw">else</span>
|
1002
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-identifier">seq_rule</span> <span class="ruby-value">? </span><span class="ruby-identifier">seq_rule</span>.<span class="ruby-identifier">sequence</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
1003
|
+
<span class="ruby-identifier">uniq_table</span> = <span class="ruby-identifier">rule</span> <span class="ruby-value">? </span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">_uniqueness_check_table</span>() <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
1004
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">push</span>(<span class="ruby-keyword kw">nil</span>)
|
1005
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
|
1006
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
1007
|
+
<span class="ruby-identifier">path</span>[<span class="ruby-value">-1</span>] = <span class="ruby-identifier">i</span>
|
1008
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
1009
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
1010
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">parse_flow_value</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">seq</span>)
|
1011
|
+
<span class="ruby-identifier">add_to_seq</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">seq</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-comment cmt"># seq << val</span>
|
1012
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
1013
|
+
<span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">val</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-ivar">@errors</span>, <span class="ruby-ivar">@done</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-keyword kw">false</span>) <span class="ruby-comment cmt">#*V</span>
|
1014
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">equal?</span>(<span class="ruby-constant">PRECEDING_ALIAS_PLACEHOLDER</span>) <span class="ruby-comment cmt">#*V</span>
|
1015
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1016
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/,\s+/</span>)
|
1017
|
+
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
1018
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/\]/</span>)
|
1019
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-value str">"sequence item required (or last comma is extra)."</span>, <span class="ruby-identifier">path</span>)
|
1020
|
+
<span class="ruby-keyword kw">end</span>
|
1021
|
+
<span class="ruby-keyword kw">end</span>
|
1022
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">pop</span>()
|
1023
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\]/</span>)
|
1024
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-value str">"flow sequence is not closed by ']'."</span>, <span class="ruby-identifier">path</span>)
|
1025
|
+
<span class="ruby-keyword kw">end</span>
|
1026
|
+
<span class="ruby-keyword kw">end</span>
|
1027
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1028
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">seq</span>
|
1029
|
+
<span class="ruby-keyword kw">end</span>
|
1030
|
+
</pre>
|
1031
|
+
</div>
|
1032
|
+
</div>
|
1033
|
+
</div>
|
1034
|
+
|
1035
|
+
<div id="method-M000061" class="method-detail">
|
1036
|
+
<a name="M000061"></a>
|
1037
|
+
|
1038
|
+
<div class="method-heading">
|
1039
|
+
<a href="#M000061" class="method-signature">
|
1040
|
+
<span class="method-name">parse_flow_value</span><span class="method-args">(rule, path, uniq_table, container)</span>
|
1041
|
+
</a>
|
1042
|
+
</div>
|
1043
|
+
|
1044
|
+
<div class="method-description">
|
1045
|
+
<p><a class="source-toggle" href="#"
|
1046
|
+
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
|
1047
|
+
<div class="method-source-code" id="M000061-source">
|
1048
|
+
<pre>
|
1049
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 551</span>
|
1050
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_flow_value</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
1051
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1052
|
+
<span class="ruby-comment cmt">## anchor and alias</span>
|
1053
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>
|
1054
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\&([-\w]+)/</span>)
|
1055
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">parse_anchor</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
1056
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\*([-\w]+)/</span>)
|
1057
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parse_alias</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">container</span>)
|
1058
|
+
<span class="ruby-keyword kw">end</span>
|
1059
|
+
<span class="ruby-comment cmt">## type</span>
|
1060
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/!!?\w+/</span>)
|
1061
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1062
|
+
<span class="ruby-keyword kw">end</span>
|
1063
|
+
<span class="ruby-comment cmt">## sequence</span>
|
1064
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/\[/</span>)
|
1065
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">sequence</span> <span class="ruby-comment cmt">#*V</span>
|
1066
|
+
<span class="ruby-comment cmt">#_validate_error("sequence is not expected.", path) #*V</span>
|
1067
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
1068
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt">#*V</span>
|
1069
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-identifier">create_sequence</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span>)
|
1070
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">seq</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
1071
|
+
<span class="ruby-identifier">parse_flow_seq</span>(<span class="ruby-identifier">seq</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
1072
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">seq</span>
|
1073
|
+
<span class="ruby-keyword kw">end</span>
|
1074
|
+
<span class="ruby-comment cmt">## mapping</span>
|
1075
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/\{/</span>)
|
1076
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rule</span>.<span class="ruby-identifier">mapping</span> <span class="ruby-comment cmt">#*V</span>
|
1077
|
+
<span class="ruby-comment cmt">#_validate_error("mapping is not expected.", path) #*V</span>
|
1078
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
1079
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt">#*V</span>
|
1080
|
+
<span class="ruby-identifier">map</span> = <span class="ruby-identifier">create_mapping</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-ivar">@linenum</span>, <span class="ruby-ivar">@column</span>)
|
1081
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">map</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
1082
|
+
<span class="ruby-identifier">parse_flow_map</span>(<span class="ruby-identifier">map</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
1083
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">map</span>
|
1084
|
+
<span class="ruby-keyword kw">end</span>
|
1085
|
+
<span class="ruby-comment cmt">## scalar</span>
|
1086
|
+
<span class="ruby-identifier">scalar</span> = <span class="ruby-identifier">parse_flow_scalar</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>)
|
1087
|
+
<span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">scalar</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
|
1088
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">scalar</span>
|
1089
|
+
<span class="ruby-keyword kw">end</span>
|
1090
|
+
</pre>
|
1091
|
+
</div>
|
1092
|
+
</div>
|
1093
|
+
</div>
|
1094
|
+
|
1095
|
+
<div id="method-M000049" class="method-detail">
|
1096
|
+
<a name="M000049"></a>
|
1097
|
+
|
1098
|
+
<div class="method-heading">
|
1099
|
+
<a href="#M000049" class="method-signature">
|
1100
|
+
<span class="method-name">parse_next</span><span class="method-args">()</span>
|
1101
|
+
</a>
|
1102
|
+
</div>
|
1103
|
+
|
1104
|
+
<div class="method-description">
|
1105
|
+
<p><a class="source-toggle" href="#"
|
1106
|
+
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
1107
|
+
<div class="method-source-code" id="M000049-source">
|
1108
|
+
<pre>
|
1109
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 139</span>
|
1110
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_next</span>()
|
1111
|
+
<span class="ruby-identifier">reset_parser</span>()
|
1112
|
+
<span class="ruby-identifier">path</span> = []
|
1113
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1114
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">document_start?</span>()
|
1115
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/.*\n/</span>)
|
1116
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1117
|
+
<span class="ruby-keyword kw">end</span>
|
1118
|
+
<span class="ruby-identifier">_linenum</span> = <span class="ruby-ivar">@linenum</span> <span class="ruby-comment cmt">#*V</span>
|
1119
|
+
<span class="ruby-identifier">_column</span> = <span class="ruby-ivar">@column</span> <span class="ruby-comment cmt">#*V</span>
|
1120
|
+
<span class="ruby-identifier">rule</span> = <span class="ruby-ivar">@validator</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">rule</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
1121
|
+
<span class="ruby-identifier">uniq_table</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
1122
|
+
<span class="ruby-identifier">parent</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">#*V</span>
|
1123
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">parse_block_value</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-identifier">parent</span>)
|
1124
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
1125
|
+
<span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">val</span>, <span class="ruby-identifier">rule</span>, [], <span class="ruby-ivar">@errors</span>, <span class="ruby-ivar">@done</span>, <span class="ruby-identifier">uniq_table</span>, <span class="ruby-keyword kw">false</span>) <span class="ruby-comment cmt">#*V</span>
|
1126
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-comment cmt">#*V</span>
|
1127
|
+
<span class="ruby-identifier">resolve_preceding_aliases</span>(<span class="ruby-identifier">val</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@preceding_alias</span>
|
1128
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">eos?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">document_start?</span>() <span class="ruby-operator">||</span> <span class="ruby-identifier">stream_end?</span>()
|
1129
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-value str">"document end expected (maybe invalid tab char found)."</span>, <span class="ruby-identifier">path</span>)
|
1130
|
+
<span class="ruby-keyword kw">end</span>
|
1131
|
+
<span class="ruby-ivar">@doc</span> = <span class="ruby-identifier">val</span>
|
1132
|
+
<span class="ruby-ivar">@location_table</span>[<span class="ruby-value">-1</span>] = [<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>]
|
1133
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
|
1134
|
+
<span class="ruby-keyword kw">end</span>
|
1135
|
+
</pre>
|
1136
|
+
</div>
|
1137
|
+
</div>
|
1138
|
+
</div>
|
1139
|
+
|
1140
|
+
<div id="method-M000050" class="method-detail">
|
1141
|
+
<a name="M000050"></a>
|
1142
|
+
|
1143
|
+
<div class="method-heading">
|
1144
|
+
<a href="#M000050" class="method-signature">
|
1145
|
+
<span class="method-name">parse_stream</span><span class="method-args">(input, opts={}) {|ydoc)| ...}</span>
|
1146
|
+
</a>
|
1147
|
+
</div>
|
1148
|
+
|
1149
|
+
<div class="method-description">
|
1150
|
+
<p><a class="source-toggle" href="#"
|
1151
|
+
onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
|
1152
|
+
<div class="method-source-code" id="M000050-source">
|
1153
|
+
<pre>
|
1154
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 166</span>
|
1155
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_stream</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">opts</span>={}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
1156
|
+
<span class="ruby-identifier">reset_scanner</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:filename</span>], <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:untabify</span>])
|
1157
|
+
<span class="ruby-identifier">ydocs</span> = <span class="ruby-identifier">block_given?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> []
|
1158
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
1159
|
+
<span class="ruby-identifier">ydoc</span> = <span class="ruby-identifier">parse_next</span>()
|
1160
|
+
<span class="ruby-identifier">ydocs</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">ydocs</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">ydoc</span>) <span class="ruby-operator">:</span> (<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">ydoc</span>)
|
1161
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eos?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">stream_end?</span>()
|
1162
|
+
<span class="ruby-identifier">document_start?</span>() <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-value str">"** internal error"</span>
|
1163
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/.*\n/</span>)
|
1164
|
+
<span class="ruby-keyword kw">end</span>
|
1165
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ydocs</span>
|
1166
|
+
<span class="ruby-keyword kw">end</span>
|
1167
|
+
</pre>
|
1168
|
+
</div>
|
1169
|
+
</div>
|
1170
|
+
</div>
|
1171
|
+
|
1172
|
+
<div id="method-M000041" class="method-detail">
|
1173
|
+
<a name="M000041"></a>
|
1174
|
+
|
1175
|
+
<div class="method-heading">
|
1176
|
+
<a href="#M000041" class="method-signature">
|
1177
|
+
<span class="method-name">reset_parser</span><span class="method-args">()</span>
|
1178
|
+
</a>
|
1179
|
+
</div>
|
1180
|
+
|
1181
|
+
<div class="method-description">
|
1182
|
+
<p><a class="source-toggle" href="#"
|
1183
|
+
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
1184
|
+
<div class="method-source-code" id="M000041-source">
|
1185
|
+
<pre>
|
1186
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 60</span>
|
1187
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset_parser</span>()
|
1188
|
+
<span class="ruby-ivar">@anchors</span> = {}
|
1189
|
+
<span class="ruby-ivar">@errors</span> = []
|
1190
|
+
<span class="ruby-ivar">@done</span> = {}
|
1191
|
+
<span class="ruby-ivar">@preceding_aliases</span> = []
|
1192
|
+
<span class="ruby-ivar">@location_table</span> = {} <span class="ruby-comment cmt"># object_id -> sequence or mapping</span>
|
1193
|
+
<span class="ruby-ivar">@doc</span> = <span class="ruby-keyword kw">nil</span>
|
1194
|
+
<span class="ruby-keyword kw">end</span>
|
1195
|
+
</pre>
|
1196
|
+
</div>
|
1197
|
+
</div>
|
1198
|
+
</div>
|
1199
|
+
|
1200
|
+
<div id="method-M000054" class="method-detail">
|
1201
|
+
<a name="M000054"></a>
|
1202
|
+
|
1203
|
+
<div class="method-heading">
|
1204
|
+
<a href="#M000054" class="method-signature">
|
1205
|
+
<span class="method-name">resolve_preceding_aliases</span><span class="method-args">(val)</span>
|
1206
|
+
</a>
|
1207
|
+
</div>
|
1208
|
+
|
1209
|
+
<div class="method-description">
|
1210
|
+
<p><a class="source-toggle" href="#"
|
1211
|
+
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
1212
|
+
<div class="method-source-code" id="M000054-source">
|
1213
|
+
<pre>
|
1214
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 215</span>
|
1215
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resolve_preceding_aliases</span>(<span class="ruby-identifier">val</span>)
|
1216
|
+
<span class="ruby-ivar">@preceding_aliases</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">container</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span><span class="ruby-operator">|</span>
|
1217
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@anchors</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">name</span>)
|
1218
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">_syntax_error</span>(<span class="ruby-node">"*#{name}: anchor not found."</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>)
|
1219
|
+
<span class="ruby-keyword kw">end</span>
|
1220
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">path</span>[<span class="ruby-value">-1</span>]
|
1221
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-ivar">@anchors</span>[<span class="ruby-identifier">name</span>]
|
1222
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-operator">!</span><span class="ruby-identifier">container</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">'[]'</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">container</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">equal?</span>(<span class="ruby-constant">PRECEDING_ALIAS_PLACEHOLDER</span>)
|
1223
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">container</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
1224
|
+
<span class="ruby-identifier">container</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">val</span>
|
1225
|
+
<span class="ruby-keyword kw">else</span>
|
1226
|
+
<span class="ruby-identifier">put_to_map</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">container</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>)
|
1227
|
+
<span class="ruby-keyword kw">end</span>
|
1228
|
+
<span class="ruby-identifier">_set_error_info</span>(<span class="ruby-identifier">_linenum</span>, <span class="ruby-identifier">_column</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt">#*V</span>
|
1229
|
+
<span class="ruby-ivar">@validator</span>.<span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">val</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-ivar">@errors</span>, <span class="ruby-ivar">@done</span>, <span class="ruby-keyword kw">false</span>) <span class="ruby-comment cmt">#*V</span>
|
1230
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-comment cmt">#*V</span>
|
1231
|
+
<span class="ruby-keyword kw">end</span>
|
1232
|
+
<span class="ruby-keyword kw">end</span>
|
1233
|
+
</pre>
|
1234
|
+
</div>
|
1235
|
+
</div>
|
1236
|
+
</div>
|
1237
|
+
|
1238
|
+
<div id="method-M000073" class="method-detail">
|
1239
|
+
<a name="M000073"></a>
|
1240
|
+
|
1241
|
+
<div class="method-heading">
|
1242
|
+
<a href="#M000073" class="method-signature">
|
1243
|
+
<span class="method-name">set_errors_linenum</span><span class="method-args">(errors)</span>
|
1244
|
+
</a>
|
1245
|
+
</div>
|
1246
|
+
|
1247
|
+
<div class="method-description">
|
1248
|
+
<p><a class="source-toggle" href="#"
|
1249
|
+
onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
|
1250
|
+
<div class="method-source-code" id="M000073-source">
|
1251
|
+
<pre>
|
1252
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 830</span>
|
1253
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_errors_linenum</span>(<span class="ruby-identifier">errors</span>)
|
1254
|
+
<span class="ruby-identifier">errors</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">error</span><span class="ruby-operator">|</span>
|
1255
|
+
<span class="ruby-identifier">error</span>.<span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">error</span>.<span class="ruby-identifier">column</span> = <span class="ruby-identifier">location</span>(<span class="ruby-identifier">error</span>.<span class="ruby-identifier">path</span>)
|
1256
|
+
<span class="ruby-keyword kw">end</span>
|
1257
|
+
<span class="ruby-keyword kw">end</span>
|
1258
|
+
</pre>
|
1259
|
+
</div>
|
1260
|
+
</div>
|
1261
|
+
</div>
|
1262
|
+
|
1263
|
+
<div id="method-M000043" class="method-detail">
|
1264
|
+
<a name="M000043"></a>
|
1265
|
+
|
1266
|
+
<div class="method-heading">
|
1267
|
+
<a href="#M000043" class="method-signature">
|
1268
|
+
<span class="method-name">skip_spaces_and_comments</span><span class="method-args">()</span>
|
1269
|
+
</a>
|
1270
|
+
</div>
|
1271
|
+
|
1272
|
+
<div class="method-description">
|
1273
|
+
<p><a class="source-toggle" href="#"
|
1274
|
+
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
1275
|
+
<div class="method-source-code" id="M000043-source">
|
1276
|
+
<pre>
|
1277
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 103</span>
|
1278
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1279
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\s+/</span>)
|
1280
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/\#/</span>)
|
1281
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/.*?\n/</span>)
|
1282
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\s+/</span>)
|
1283
|
+
<span class="ruby-keyword kw">end</span>
|
1284
|
+
<span class="ruby-keyword kw">end</span>
|
1285
|
+
</pre>
|
1286
|
+
</div>
|
1287
|
+
</div>
|
1288
|
+
</div>
|
1289
|
+
|
1290
|
+
<div id="method-M000045" class="method-detail">
|
1291
|
+
<a name="M000045"></a>
|
1292
|
+
|
1293
|
+
<div class="method-heading">
|
1294
|
+
<a href="#M000045" class="method-signature">
|
1295
|
+
<span class="method-name">stream_end?</span><span class="method-args">()</span>
|
1296
|
+
</a>
|
1297
|
+
</div>
|
1298
|
+
|
1299
|
+
<div class="method-description">
|
1300
|
+
<p><a class="source-toggle" href="#"
|
1301
|
+
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
1302
|
+
<div class="method-source-code" id="M000045-source">
|
1303
|
+
<pre>
|
1304
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 117</span>
|
1305
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stream_end?</span>()
|
1306
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">match?</span>(<span class="ruby-regexp re">/\.\.\.\s/</span>) <span class="ruby-operator">&&</span> <span class="ruby-ivar">@column</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
1307
|
+
<span class="ruby-keyword kw">end</span>
|
1308
|
+
</pre>
|
1309
|
+
</div>
|
1310
|
+
</div>
|
1311
|
+
</div>
|
1312
|
+
|
1313
|
+
<div id="method-M000065" class="method-detail">
|
1314
|
+
<a name="M000065"></a>
|
1315
|
+
|
1316
|
+
<div class="method-heading">
|
1317
|
+
<a href="#M000065" class="method-signature">
|
1318
|
+
<span class="method-name">to_scalar</span><span class="method-args">(str)</span>
|
1319
|
+
</a>
|
1320
|
+
</div>
|
1321
|
+
|
1322
|
+
<div class="method-description">
|
1323
|
+
<p><a class="source-toggle" href="#"
|
1324
|
+
onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
|
1325
|
+
<div class="method-source-code" id="M000065-source">
|
1326
|
+
<pre>
|
1327
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 698</span>
|
1328
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_scalar</span>(<span class="ruby-identifier">str</span>)
|
1329
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">str</span>
|
1330
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">nil</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">nil</span>
|
1331
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A-?\d+\.\d+\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">to_f</span>
|
1332
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A-?\d+\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">to_i</span>
|
1333
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A(true|yes)\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">true</span>
|
1334
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A(false|no)\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">false</span>
|
1335
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A(null|~)\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">nil</span>
|
1336
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A"(.*)"\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-identifier">$1</span>
|
1337
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A'(.*)'\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-identifier">$1</span>
|
1338
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A:(\w+)\z/</span> ; <span class="ruby-identifier">val</span> = <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">intern</span>
|
1339
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\A(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d):(\d\d))?\z/</span>
|
1340
|
+
<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span> = <span class="ruby-identifier">$1</span>, <span class="ruby-identifier">$2</span>, <span class="ruby-identifier">$3</span>, <span class="ruby-identifier">$4</span>, <span class="ruby-identifier">$5</span>, <span class="ruby-identifier">$6</span>
|
1341
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hour</span>
|
1342
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">mktime</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>)
|
1343
|
+
<span class="ruby-keyword kw">else</span>
|
1344
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">year</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">month</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">day</span>.<span class="ruby-identifier">to_i</span>)
|
1345
|
+
<span class="ruby-keyword kw">end</span>
|
1346
|
+
<span class="ruby-comment cmt">## or</span>
|
1347
|
+
<span class="ruby-comment cmt">#params = [$1, $2, $3, $4, $5, $6]</span>
|
1348
|
+
<span class="ruby-comment cmt">#val = Time.mktime(*params)</span>
|
1349
|
+
<span class="ruby-keyword kw">else</span>
|
1350
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">str</span>
|
1351
|
+
<span class="ruby-keyword kw">end</span>
|
1352
|
+
<span class="ruby-identifier">skip_spaces_and_comments</span>()
|
1353
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
|
1354
|
+
<span class="ruby-keyword kw">end</span>
|
1355
|
+
</pre>
|
1356
|
+
</div>
|
1357
|
+
</div>
|
1358
|
+
</div>
|
1359
|
+
|
1360
|
+
<h3 class="section-bar">Protected Instance methods</h3>
|
1361
|
+
|
1362
|
+
<div id="method-M000071" class="method-detail">
|
1363
|
+
<a name="M000071"></a>
|
1364
|
+
|
1365
|
+
<div class="method-heading">
|
1366
|
+
<a href="#M000071" class="method-signature">
|
1367
|
+
<span class="method-name">_getclass</span><span class="method-args">(classname)</span>
|
1368
|
+
</a>
|
1369
|
+
</div>
|
1370
|
+
|
1371
|
+
<div class="method-description">
|
1372
|
+
<p><a class="source-toggle" href="#"
|
1373
|
+
onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
|
1374
|
+
<div class="method-source-code" id="M000071-source">
|
1375
|
+
<pre>
|
1376
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 779</span>
|
1377
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_getclass</span>(<span class="ruby-identifier">classname</span>)
|
1378
|
+
<span class="ruby-identifier">mod</span> = <span class="ruby-constant">Object</span>
|
1379
|
+
<span class="ruby-identifier">classname</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/::/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">modname</span><span class="ruby-operator">|</span>
|
1380
|
+
<span class="ruby-identifier">mod</span> = <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">modname</span>) <span class="ruby-comment cmt"># raises NameError when module not found</span>
|
1381
|
+
<span class="ruby-keyword kw">end</span>
|
1382
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">mod</span>
|
1383
|
+
<span class="ruby-keyword kw">end</span>
|
1384
|
+
</pre>
|
1385
|
+
</div>
|
1386
|
+
</div>
|
1387
|
+
</div>
|
1388
|
+
|
1389
|
+
<div id="method-M000069" class="method-detail">
|
1390
|
+
<a name="M000069"></a>
|
1391
|
+
|
1392
|
+
<div class="method-heading">
|
1393
|
+
<a href="#M000069" class="method-signature">
|
1394
|
+
<span class="method-name">add_to_seq</span><span class="method-args">(rule, seq, val, linenum, column)</span>
|
1395
|
+
</a>
|
1396
|
+
</div>
|
1397
|
+
|
1398
|
+
<div class="method-description">
|
1399
|
+
<p><a class="source-toggle" href="#"
|
1400
|
+
onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
|
1401
|
+
<div class="method-source-code" id="M000069-source">
|
1402
|
+
<pre>
|
1403
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 758</span>
|
1404
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_to_seq</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">seq</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">column</span>)
|
1405
|
+
<span class="ruby-identifier">seq</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">val</span>
|
1406
|
+
<span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">__id__</span>] <span class="ruby-operator"><<</span> [<span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">column</span>]
|
1407
|
+
<span class="ruby-keyword kw">end</span>
|
1408
|
+
</pre>
|
1409
|
+
</div>
|
1410
|
+
</div>
|
1411
|
+
</div>
|
1412
|
+
|
1413
|
+
<div id="method-M000067" class="method-detail">
|
1414
|
+
<a name="M000067"></a>
|
1415
|
+
|
1416
|
+
<div class="method-heading">
|
1417
|
+
<a href="#M000067" class="method-signature">
|
1418
|
+
<span class="method-name">create_mapping</span><span class="method-args">(rule, linenum, column)</span>
|
1419
|
+
</a>
|
1420
|
+
</div>
|
1421
|
+
|
1422
|
+
<div class="method-description">
|
1423
|
+
<p><a class="source-toggle" href="#"
|
1424
|
+
onclick="toggleCode('M000067-source');return false;">[Source]</a></p>
|
1425
|
+
<div class="method-source-code" id="M000067-source">
|
1426
|
+
<pre>
|
1427
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 739</span>
|
1428
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_mapping</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">column</span>)
|
1429
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rule</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">classobj</span> <span class="ruby-operator">&&</span> <span class="ruby-ivar">@data_binding</span>
|
1430
|
+
<span class="ruby-identifier">classobj</span> = <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">classobj</span>
|
1431
|
+
<span class="ruby-identifier">map</span> = <span class="ruby-identifier">classobj</span>.<span class="ruby-identifier">new</span>
|
1432
|
+
<span class="ruby-keyword kw">else</span>
|
1433
|
+
<span class="ruby-identifier">classobj</span> = <span class="ruby-keyword kw">nil</span>
|
1434
|
+
<span class="ruby-identifier">map</span> = <span class="ruby-ivar">@mapping_class</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># {}</span>
|
1435
|
+
<span class="ruby-keyword kw">end</span>
|
1436
|
+
<span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">map</span>.<span class="ruby-identifier">__id__</span>] = <span class="ruby-identifier">hash</span> = {}
|
1437
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">:classobj</span>] = <span class="ruby-identifier">classobj</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">classobj</span>
|
1438
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">map</span>
|
1439
|
+
<span class="ruby-keyword kw">end</span>
|
1440
|
+
</pre>
|
1441
|
+
</div>
|
1442
|
+
</div>
|
1443
|
+
</div>
|
1444
|
+
|
1445
|
+
<div id="method-M000068" class="method-detail">
|
1446
|
+
<a name="M000068"></a>
|
1447
|
+
|
1448
|
+
<div class="method-heading">
|
1449
|
+
<a href="#M000068" class="method-signature">
|
1450
|
+
<span class="method-name">create_scalar</span><span class="method-args">(rule, value, linenum, column)</span>
|
1451
|
+
</a>
|
1452
|
+
</div>
|
1453
|
+
|
1454
|
+
<div class="method-description">
|
1455
|
+
<p><a class="source-toggle" href="#"
|
1456
|
+
onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
|
1457
|
+
<div class="method-source-code" id="M000068-source">
|
1458
|
+
<pre>
|
1459
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 753</span>
|
1460
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_scalar</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">column</span>)
|
1461
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">value</span>
|
1462
|
+
<span class="ruby-keyword kw">end</span>
|
1463
|
+
</pre>
|
1464
|
+
</div>
|
1465
|
+
</div>
|
1466
|
+
</div>
|
1467
|
+
|
1468
|
+
<div id="method-M000066" class="method-detail">
|
1469
|
+
<a name="M000066"></a>
|
1470
|
+
|
1471
|
+
<div class="method-heading">
|
1472
|
+
<a href="#M000066" class="method-signature">
|
1473
|
+
<span class="method-name">create_sequence</span><span class="method-args">(rule, linenum, column)</span>
|
1474
|
+
</a>
|
1475
|
+
</div>
|
1476
|
+
|
1477
|
+
<div class="method-description">
|
1478
|
+
<p><a class="source-toggle" href="#"
|
1479
|
+
onclick="toggleCode('M000066-source');return false;">[Source]</a></p>
|
1480
|
+
<div class="method-source-code" id="M000066-source">
|
1481
|
+
<pre>
|
1482
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 732</span>
|
1483
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_sequence</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">column</span>)
|
1484
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-ivar">@sequence_class</span>.<span class="ruby-identifier">new</span>
|
1485
|
+
<span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">__id__</span>] = []
|
1486
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">seq</span>
|
1487
|
+
<span class="ruby-keyword kw">end</span>
|
1488
|
+
</pre>
|
1489
|
+
</div>
|
1490
|
+
</div>
|
1491
|
+
</div>
|
1492
|
+
|
1493
|
+
<div id="method-M000070" class="method-detail">
|
1494
|
+
<a name="M000070"></a>
|
1495
|
+
|
1496
|
+
<div class="method-heading">
|
1497
|
+
<a href="#M000070" class="method-signature">
|
1498
|
+
<span class="method-name">put_to_map</span><span class="method-args">(rule, map, key, val, linenum, column)</span>
|
1499
|
+
</a>
|
1500
|
+
</div>
|
1501
|
+
|
1502
|
+
<div class="method-description">
|
1503
|
+
<p><a class="source-toggle" href="#"
|
1504
|
+
onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
|
1505
|
+
<div class="method-source-code" id="M000070-source">
|
1506
|
+
<pre>
|
1507
|
+
<span class="ruby-comment cmt"># File kwalify/parser/yaml.rb, line 764</span>
|
1508
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_to_map</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">map</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">column</span>)
|
1509
|
+
<span class="ruby-comment cmt">#if map.is_a?(Hash)</span>
|
1510
|
+
<span class="ruby-comment cmt"># map[key] = val</span>
|
1511
|
+
<span class="ruby-comment cmt">#elsif map.respond_to?(name="#{key}=")</span>
|
1512
|
+
<span class="ruby-comment cmt"># map.__send__(name, val)</span>
|
1513
|
+
<span class="ruby-comment cmt">#elsif map.respond_to?('[]=')</span>
|
1514
|
+
<span class="ruby-comment cmt"># map[key] = val</span>
|
1515
|
+
<span class="ruby-comment cmt">#else</span>
|
1516
|
+
<span class="ruby-comment cmt"># map.instance_variable_set("@#{key}", val)</span>
|
1517
|
+
<span class="ruby-comment cmt">#end</span>
|
1518
|
+
<span class="ruby-identifier">map</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">val</span>
|
1519
|
+
<span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">map</span>.<span class="ruby-identifier">__id__</span>][<span class="ruby-identifier">key</span>] = [<span class="ruby-identifier">linenum</span>, <span class="ruby-identifier">column</span>]
|
1520
|
+
<span class="ruby-keyword kw">end</span>
|
1521
|
+
</pre>
|
1522
|
+
</div>
|
1523
|
+
</div>
|
1524
|
+
</div>
|
1525
|
+
|
1526
|
+
|
1527
|
+
</div>
|
1528
|
+
|
1529
|
+
|
1530
|
+
</div>
|
1531
|
+
|
1532
|
+
|
1533
|
+
<div id="validator-badges">
|
1534
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
1535
|
+
</div>
|
1536
|
+
|
1537
|
+
</body>
|
1538
|
+
</html>
|