psych 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,7 +74,7 @@ yaml_emitter_flush(yaml_emitter_t *emitter)
74
74
  unsigned int value;
75
75
  size_t k;
76
76
 
77
- /*
77
+ /*
78
78
  * See the "reader.c" code for more details on UTF-8 encoding. Note
79
79
  * that we assume that the buffer contains a valid UTF-8 sequence.
80
80
  */
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: false
2
+ require 'psych/versions'
2
3
  case RUBY_ENGINE
3
4
  when 'jruby'
4
5
  require 'psych_jars'
@@ -223,9 +224,6 @@ require 'psych/class_loader'
223
224
  # # => "a"
224
225
 
225
226
  module Psych
226
- # The version is Psych you're using
227
- VERSION = '2.1.1'
228
-
229
227
  # The version of libyaml Psych is using
230
228
  LIBYAML_VERSION = Psych.libyaml_version.join '.'
231
229
 
@@ -1,4 +1,9 @@
1
1
  # frozen_string_literal: false
2
2
  module Psych
3
- DEFAULT_SNAKEYAML_VERSION = '1.14'.freeze
3
+ # The version is Psych you're using
4
+ VERSION = '2.2.1'
5
+
6
+ if RUBY_ENGINE == 'jruby'
7
+ DEFAULT_SNAKEYAML_VERSION = '1.17'.freeze
8
+ end
4
9
  end
@@ -1,10 +1,12 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift './lib'
3
+ load 'psych/versions.rb'
2
4
 
3
5
  Gem::Specification.new do |s|
4
6
  s.name = "psych"
5
- s.version = "2.2.0"
6
- s.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
7
- s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"]
7
+ s.version = Psych::VERSION
8
+ s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
9
+ s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org", "headius@headius.com"]
8
10
  s.date = "2016-11-14"
9
11
  s.summary = "Psych is a YAML parser and emitter"
10
12
  s.description = <<-DESCRIPTION
@@ -17,7 +19,7 @@ DESCRIPTION
17
19
  s.require_paths = ["lib"]
18
20
 
19
21
  # for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
- s.files = [".gitignore", ".travis.yml", "CHANGELOG.rdoc", "Gemfile", "Mavenfile", "README.md", "Rakefile", "bin/console", "bin/setup", "ext/java/PsychEmitter.java", "ext/java/PsychLibrary.java", "ext/java/PsychParser.java", "ext/java/PsychToRuby.java", "ext/java/PsychYamlTree.java", "ext/psych/.gitignore", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h", "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h", "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h", "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c", "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c", "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h", "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/deprecated.rb", "lib/psych/exception.rb", "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb", "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb", "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb", "lib/psych/versions.rb", "lib/psych/visitors.rb","lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb", "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "lib/psych_jars.rb", "psych.gemspec"]
22
+ s.files = [".gitignore", ".travis.yml", "CHANGELOG.rdoc", "Gemfile", "Mavenfile", "README.md", "Rakefile", "bin/console", "bin/setup", "ext/psych/.gitignore", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h", "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h", "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h", "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c", "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c", "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h", "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/deprecated.rb", "lib/psych/exception.rb", "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb", "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb", "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb", "lib/psych/versions.rb", "lib/psych/visitors.rb","lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb", "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "psych.gemspec"]
21
23
 
22
24
  s.rdoc_options = ["--main", "README.md"]
23
25
  s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md"]
@@ -29,9 +31,9 @@ DESCRIPTION
29
31
  s.add_development_dependency 'rake-compiler', ">= 0.4.1"
30
32
  s.add_development_dependency 'minitest', "~> 5.0"
31
33
 
32
- if RUBY_PLATFORM =~ /java/
33
- require 'psych/versions'
34
+ if RUBY_ENGINE == 'jruby'
34
35
  s.platform = 'java'
36
+ s.files.concat ["ext/java/PsychEmitter.java", "ext/java/PsychLibrary.java", "ext/java/PsychParser.java", "ext/java/PsychToRuby.java", "ext/java/PsychYamlTree.java", "lib/psych_jars.rb", "lib/psych.jar"]
35
37
  s.requirements = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}"
36
38
  s.add_dependency 'jar-dependencies', '>= 0.1.7'
37
39
  s.add_development_dependency 'ruby-maven'
metadata CHANGED
@@ -1,11 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psych
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  - SHIBATA Hiroshi
9
+ - Charles Oliver Nutter
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
@@ -46,6 +47,7 @@ description: |
46
47
  email:
47
48
  - aaron@tenderlovemaking.com
48
49
  - hsbt@ruby-lang.org
50
+ - headius@headius.com
49
51
  executables: []
50
52
  extensions:
51
53
  - ext/psych/extconf.rb
@@ -62,11 +64,6 @@ files:
62
64
  - Rakefile
63
65
  - bin/console
64
66
  - bin/setup
65
- - ext/java/PsychEmitter.java
66
- - ext/java/PsychLibrary.java
67
- - ext/java/PsychParser.java
68
- - ext/java/PsychToRuby.java
69
- - ext/java/PsychYamlTree.java
70
67
  - ext/psych/.gitignore
71
68
  - ext/psych/depend
72
69
  - ext/psych/extconf.rb
@@ -130,7 +127,6 @@ files:
130
127
  - lib/psych/visitors/visitor.rb
131
128
  - lib/psych/visitors/yaml_tree.rb
132
129
  - lib/psych/y.rb
133
- - lib/psych_jars.rb
134
130
  - psych.gemspec
135
131
  homepage: https://github.com/ruby/psych
136
132
  licenses:
@@ -1,345 +0,0 @@
1
- /***** BEGIN LICENSE BLOCK *****
2
- * Version: EPL 1.0/GPL 2.0/LGPL 2.1
3
- *
4
- * The contents of this file are subject to the Eclipse Public
5
- * License Version 1.0 (the "License"); you may not use this file
6
- * except in compliance with the License. You may obtain a copy of
7
- * the License at http://www.eclipse.org/legal/epl-v10.html
8
- *
9
- * Software distributed under the License is distributed on an "AS
10
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
- * implied. See the License for the specific language governing
12
- * rights and limitations under the License.
13
- *
14
- * Copyright (C) 2010 Charles O Nutter <headius@headius.com>
15
- *
16
- * Alternatively, the contents of this file may be used under the terms of
17
- * either of the GNU General Public License Version 2 or later (the "GPL"),
18
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
19
- * in which case the provisions of the GPL or the LGPL are applicable instead
20
- * of those above. If you wish to allow use of your version of this file only
21
- * under the terms of either the GPL or the LGPL, and not to allow others to
22
- * use your version of this file under the terms of the EPL, indicate your
23
- * decision by deleting the provisions above and replace them with the notice
24
- * and other provisions required by the GPL or the LGPL. If you do not delete
25
- * the provisions above, a recipient may use your version of this file under
26
- * the terms of any one of the EPL, the GPL or the LGPL.
27
- ***** END LICENSE BLOCK *****/
28
- package org.jruby.ext.psych;
29
-
30
- import java.io.IOException;
31
- import java.io.OutputStreamWriter;
32
- import java.nio.charset.Charset;
33
- import java.util.HashMap;
34
- import java.util.Map;
35
-
36
- import org.jcodings.Encoding;
37
- import org.jruby.Ruby;
38
- import org.jruby.RubyArray;
39
- import org.jruby.RubyClass;
40
- import org.jruby.RubyFixnum;
41
- import org.jruby.RubyModule;
42
- import org.jruby.RubyObject;
43
- import org.jruby.RubyString;
44
- import org.jruby.anno.JRubyMethod;
45
- import org.jruby.runtime.ObjectAllocator;
46
- import org.jruby.runtime.ThreadContext;
47
- import org.jruby.runtime.builtin.IRubyObject;
48
- import org.jruby.util.IOOutputStream;
49
- import org.yaml.snakeyaml.DumperOptions;
50
- import org.yaml.snakeyaml.emitter.Emitter;
51
- import org.yaml.snakeyaml.emitter.EmitterException;
52
- import org.yaml.snakeyaml.error.Mark;
53
- import org.yaml.snakeyaml.events.AliasEvent;
54
- import org.yaml.snakeyaml.events.DocumentEndEvent;
55
- import org.yaml.snakeyaml.events.DocumentStartEvent;
56
- import org.yaml.snakeyaml.events.Event;
57
- import org.yaml.snakeyaml.events.ImplicitTuple;
58
- import org.yaml.snakeyaml.events.MappingEndEvent;
59
- import org.yaml.snakeyaml.events.MappingStartEvent;
60
- import org.yaml.snakeyaml.events.ScalarEvent;
61
- import org.yaml.snakeyaml.events.SequenceEndEvent;
62
- import org.yaml.snakeyaml.events.SequenceStartEvent;
63
- import org.yaml.snakeyaml.events.StreamEndEvent;
64
- import org.yaml.snakeyaml.events.StreamStartEvent;
65
-
66
- import static org.jruby.runtime.Visibility.*;
67
-
68
- public class PsychEmitter extends RubyObject {
69
- public static void initPsychEmitter(Ruby runtime, RubyModule psych) {
70
- RubyClass psychHandler = runtime.defineClassUnder("Handler", runtime.getObject(), runtime.getObject().getAllocator(), psych);
71
- RubyClass psychEmitter = runtime.defineClassUnder("Emitter", psychHandler, new ObjectAllocator() {
72
- public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
73
- return new PsychEmitter(runtime, klazz);
74
- }
75
- }, psych);
76
-
77
- psychEmitter.defineAnnotatedMethods(PsychEmitter.class);
78
- }
79
-
80
- public PsychEmitter(Ruby runtime, RubyClass klass) {
81
- super(runtime, klass);
82
- }
83
-
84
- @JRubyMethod(visibility = PRIVATE)
85
- public IRubyObject initialize(ThreadContext context, IRubyObject io) {
86
- options = new DumperOptions();
87
- options.setIndent(2);
88
-
89
- this.io = io;
90
-
91
- return context.nil;
92
- }
93
-
94
- @JRubyMethod(visibility = PRIVATE)
95
- public IRubyObject initialize(ThreadContext context, IRubyObject io, IRubyObject rbOptions) {
96
- IRubyObject width = rbOptions.callMethod(context, "line_width");
97
- IRubyObject canonical = rbOptions.callMethod(context, "canonical");
98
- IRubyObject level = rbOptions.callMethod(context, "indentation");
99
-
100
- options = new DumperOptions();
101
-
102
- options.setCanonical(canonical.isTrue());
103
- options.setIndent((int)level.convertToInteger().getLongValue());
104
- options.setWidth((int)width.convertToInteger().getLongValue());
105
-
106
- this.io = io;
107
-
108
- return context.nil;
109
- }
110
-
111
- @JRubyMethod
112
- public IRubyObject start_stream(ThreadContext context, IRubyObject encoding) {
113
- if (!(encoding instanceof RubyFixnum)) {
114
- throw context.runtime.newTypeError(encoding, context.runtime.getFixnum());
115
- }
116
-
117
- initEmitter(context, encoding);
118
-
119
- StreamStartEvent event = new StreamStartEvent(NULL_MARK, NULL_MARK);
120
-
121
- emit(context, event);
122
-
123
- return this;
124
- }
125
-
126
- @JRubyMethod
127
- public IRubyObject end_stream(ThreadContext context) {
128
- StreamEndEvent event = new StreamEndEvent(NULL_MARK, NULL_MARK);
129
- emit(context, event);
130
- return this;
131
- }
132
-
133
- @JRubyMethod
134
- public IRubyObject start_document(ThreadContext context, IRubyObject _version, IRubyObject tags, IRubyObject implicit) {
135
- DumperOptions.Version version = null;
136
- boolean implicitBool = implicit.isTrue();
137
- Map<String, String> tagsMap = null;
138
-
139
- RubyArray versionAry = _version.convertToArray();
140
- if (versionAry.size() == 2) {
141
- int versionInt0 = (int)versionAry.eltInternal(0).convertToInteger().getLongValue();
142
- int versionInt1 = (int)versionAry.eltInternal(1).convertToInteger().getLongValue();
143
-
144
- if (versionInt0 == 1) {
145
- if (versionInt1 == 0) {
146
- version = DumperOptions.Version.V1_0;
147
- } else if (versionInt1 == 1) {
148
- version = DumperOptions.Version.V1_1;
149
- }
150
- }
151
- if (version == null) {
152
- throw context.runtime.newArgumentError("invalid YAML version: " + versionAry);
153
- }
154
- }
155
-
156
- RubyArray tagsAry = tags.convertToArray();
157
- if (tagsAry.size() > 0) {
158
- tagsMap = new HashMap<String, String>(tagsAry.size());
159
- for (int i = 0; i < tagsAry.size(); i++) {
160
- RubyArray tagsTuple = tagsAry.eltInternal(i).convertToArray();
161
- if (tagsTuple.size() != 2) {
162
- throw context.runtime.newRuntimeError("tags tuple must be of length 2");
163
- }
164
- IRubyObject key = tagsTuple.eltInternal(0);
165
- IRubyObject value = tagsTuple.eltInternal(1);
166
- tagsMap.put(
167
- key.asJavaString(),
168
- value.asJavaString());
169
- }
170
- }
171
-
172
- DocumentStartEvent event = new DocumentStartEvent(NULL_MARK, NULL_MARK, !implicitBool, version, tagsMap);
173
- emit(context, event);
174
- return this;
175
- }
176
-
177
- @JRubyMethod
178
- public IRubyObject end_document(ThreadContext context, IRubyObject implicit) {
179
- DocumentEndEvent event = new DocumentEndEvent(NULL_MARK, NULL_MARK, !implicit.isTrue());
180
- emit(context, event);
181
- return this;
182
- }
183
-
184
- @JRubyMethod(required = 6)
185
- public IRubyObject scalar(ThreadContext context, IRubyObject[] args) {
186
- IRubyObject value = args[0];
187
- IRubyObject anchor = args[1];
188
- IRubyObject tag = args[2];
189
- IRubyObject plain = args[3];
190
- IRubyObject quoted = args[4];
191
- IRubyObject style = args[5];
192
-
193
- if (!(value instanceof RubyString)) {
194
- throw context.runtime.newTypeError(value, context.runtime.getString());
195
- }
196
-
197
- ScalarEvent event = new ScalarEvent(
198
- anchor.isNil() ? null : anchor.asJavaString(),
199
- tag.isNil() ? null : tag.asJavaString(),
200
- new ImplicitTuple(plain.isTrue(),
201
- quoted.isTrue()),
202
- value.asJavaString(),
203
- NULL_MARK,
204
- NULL_MARK,
205
- SCALAR_STYLES[(int)style.convertToInteger().getLongValue()]);
206
- emit(context, event);
207
- return this;
208
- }
209
-
210
- @JRubyMethod(required = 4)
211
- public IRubyObject start_sequence(ThreadContext context, IRubyObject[] args) {
212
- IRubyObject anchor = args[0];
213
- IRubyObject tag = args[1];
214
- IRubyObject implicit = args[2];
215
- IRubyObject style = args[3];
216
-
217
- final int SEQUENCE_BLOCK = 1; // see psych/nodes/sequence.rb
218
-
219
- SequenceStartEvent event = new SequenceStartEvent(
220
- anchor.isNil() ? null : anchor.asJavaString(),
221
- tag.isNil() ? null : tag.asJavaString(),
222
- implicit.isTrue(),
223
- NULL_MARK,
224
- NULL_MARK,
225
- SEQUENCE_BLOCK != style.convertToInteger().getLongValue());
226
- emit(context, event);
227
- return this;
228
- }
229
-
230
- @JRubyMethod
231
- public IRubyObject end_sequence(ThreadContext context) {
232
- SequenceEndEvent event = new SequenceEndEvent(NULL_MARK, NULL_MARK);
233
- emit(context, event);
234
- return this;
235
- }
236
-
237
- @JRubyMethod(required = 4)
238
- public IRubyObject start_mapping(ThreadContext context, IRubyObject[] args) {
239
- IRubyObject anchor = args[0];
240
- IRubyObject tag = args[1];
241
- IRubyObject implicit = args[2];
242
- IRubyObject style = args[3];
243
-
244
- final int MAPPING_BLOCK = 1; // see psych/nodes/mapping.rb
245
-
246
- MappingStartEvent event = new MappingStartEvent(
247
- anchor.isNil() ? null : anchor.asJavaString(),
248
- tag.isNil() ? null : tag.asJavaString(),
249
- implicit.isTrue(),
250
- NULL_MARK,
251
- NULL_MARK,
252
- MAPPING_BLOCK != style.convertToInteger().getLongValue());
253
- emit(context, event);
254
- return this;
255
- }
256
-
257
- @JRubyMethod
258
- public IRubyObject end_mapping(ThreadContext context) {
259
- MappingEndEvent event = new MappingEndEvent(NULL_MARK, NULL_MARK);
260
- emit(context, event);
261
- return this;
262
- }
263
-
264
- @JRubyMethod
265
- public IRubyObject alias(ThreadContext context, IRubyObject anchor) {
266
- AliasEvent event = new AliasEvent(anchor.asJavaString(), NULL_MARK, NULL_MARK);
267
- emit(context, event);
268
- return this;
269
- }
270
-
271
- @JRubyMethod(name = "canonical=")
272
- public IRubyObject canonical_set(ThreadContext context, IRubyObject canonical) {
273
- // TODO: unclear if this affects a running emitter
274
- options.setCanonical(canonical.isTrue());
275
- return canonical;
276
- }
277
-
278
- @JRubyMethod
279
- public IRubyObject canonical(ThreadContext context) {
280
- // TODO: unclear if this affects a running emitter
281
- return context.runtime.newBoolean(options.isCanonical());
282
- }
283
-
284
- @JRubyMethod(name = "indentation=")
285
- public IRubyObject indentation_set(ThreadContext context, IRubyObject level) {
286
- // TODO: unclear if this affects a running emitter
287
- options.setIndent((int)level.convertToInteger().getLongValue());
288
- return level;
289
- }
290
-
291
- @JRubyMethod
292
- public IRubyObject indentation(ThreadContext context) {
293
- // TODO: unclear if this affects a running emitter
294
- return context.runtime.newFixnum(options.getIndent());
295
- }
296
-
297
- @JRubyMethod(name = "line_width=")
298
- public IRubyObject line_width_set(ThreadContext context, IRubyObject width) {
299
- options.setWidth((int)width.convertToInteger().getLongValue());
300
- return width;
301
- }
302
-
303
- @JRubyMethod
304
- public IRubyObject line_width(ThreadContext context) {
305
- return context.runtime.newFixnum(options.getWidth());
306
- }
307
-
308
- private void emit(ThreadContext context, Event event) {
309
- try {
310
- if (emitter == null) throw context.runtime.newRuntimeError("uninitialized emitter");
311
-
312
- emitter.emit(event);
313
- } catch (IOException ioe) {
314
- throw context.runtime.newIOErrorFromException(ioe);
315
- } catch (EmitterException ee) {
316
- throw context.runtime.newRuntimeError(ee.toString());
317
- }
318
- }
319
-
320
- private void initEmitter(ThreadContext context, IRubyObject _encoding) {
321
- if (emitter != null) throw context.runtime.newRuntimeError("already initialized emitter");
322
-
323
- Encoding encoding = PsychLibrary.YAMLEncoding.values()[(int)_encoding.convertToInteger().getLongValue()].encoding;
324
- Charset charset = context.runtime.getEncodingService().charsetForEncoding(encoding);
325
-
326
- emitter = new Emitter(new OutputStreamWriter(new IOOutputStream(io, encoding), charset), options);
327
- }
328
-
329
- Emitter emitter;
330
- DumperOptions options = new DumperOptions();
331
- IRubyObject io;
332
-
333
- private static final Mark NULL_MARK = new Mark(null, 0, 0, 0, null, 0);
334
-
335
- // Map style constants from Psych values (ANY = 0 ... FOLDED = 5)
336
- // to SnakeYaml values; see psych/nodes/scalar.rb.
337
- private static final Character[] SCALAR_STYLES = new Character[] {
338
- null, // ANY; we'll choose plain
339
- null, // PLAIN
340
- '\'', // SINGLE_QUOTED
341
- '"', // DOUBLE_QUOTED
342
- '|', // LITERAL
343
- '>', // FOLDED
344
- };
345
- }