@@ -140,13 +140,18 @@ public IRubyObject start_document(ThreadContext context, IRubyObject _version, I
140
140
TypeConverter .checkType (context , _version , arrayClass );
141
141
142
142
RubyArray versionAry = _version .convertToArray ();
143
+ Optional <SpecVersion > specVersion ;
143
144
if (versionAry .size () == 2 ) {
144
145
int versionInt0 = versionAry .eltInternal (0 ).convertToInteger ().getIntValue ();
145
146
int versionInt1 = versionAry .eltInternal (1 ).convertToInteger ().getIntValue ();
146
147
147
- if (versionInt0 != 1 || versionInt1 != 2 ) {
148
- // throw runtime.newArgumentError("invalid YAML version: " + versionAry);
148
+ if (versionInt0 != 1 ) {
149
+ throw runtime .newArgumentError ("invalid YAML version: " + versionAry );
149
150
}
151
+
152
+ specVersion = Optional .of (new SpecVersion (versionInt0 , versionInt1 ));
153
+ } else {
154
+ specVersion = Optional .empty ();
150
155
}
151
156
152
157
Map <String , String > tagsMap = new HashMap <>();
@@ -171,7 +176,7 @@ public IRubyObject start_document(ThreadContext context, IRubyObject _version, I
171
176
}
172
177
}
173
178
174
- DocumentStartEvent event = new DocumentStartEvent (!implicitBool , Optional . empty () , tagsMap , NULL_MARK , NULL_MARK );
179
+ DocumentStartEvent event = new DocumentStartEvent (!implicitBool , specVersion , tagsMap , NULL_MARK , NULL_MARK );
175
180
emit (context , event );
176
181
return this ;
177
182
}
0 commit comments