psych 2.0.14-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +18 -0
- data/.gemtest +0 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.rdoc +576 -0
- data/Manifest.txt +114 -0
- data/README.rdoc +71 -0
- data/Rakefile +123 -0
- data/ext/psych/depend +3 -0
- data/ext/psych/extconf.rb +38 -0
- data/ext/psych/psych.c +34 -0
- data/ext/psych/psych.h +20 -0
- data/ext/psych/psych_emitter.c +555 -0
- data/ext/psych/psych_emitter.h +8 -0
- data/ext/psych/psych_parser.c +597 -0
- data/ext/psych/psych_parser.h +6 -0
- data/ext/psych/psych_to_ruby.c +43 -0
- data/ext/psych/psych_to_ruby.h +8 -0
- data/ext/psych/psych_yaml_tree.c +24 -0
- data/ext/psych/psych_yaml_tree.h +8 -0
- data/ext/psych/yaml/LICENSE +19 -0
- data/ext/psych/yaml/api.c +1415 -0
- data/ext/psych/yaml/config.h +10 -0
- data/ext/psych/yaml/dumper.c +394 -0
- data/ext/psych/yaml/emitter.c +2329 -0
- data/ext/psych/yaml/loader.c +459 -0
- data/ext/psych/yaml/parser.c +1370 -0
- data/ext/psych/yaml/reader.c +469 -0
- data/ext/psych/yaml/scanner.c +3576 -0
- data/ext/psych/yaml/writer.c +141 -0
- data/ext/psych/yaml/yaml.h +1971 -0
- data/ext/psych/yaml/yaml_private.h +664 -0
- data/lib/psych.jar +0 -0
- data/lib/psych.rb +504 -0
- data/lib/psych/class_loader.rb +101 -0
- data/lib/psych/coder.rb +94 -0
- data/lib/psych/core_ext.rb +35 -0
- data/lib/psych/deprecated.rb +85 -0
- data/lib/psych/exception.rb +13 -0
- data/lib/psych/handler.rb +249 -0
- data/lib/psych/handlers/document_stream.rb +22 -0
- data/lib/psych/handlers/recorder.rb +39 -0
- data/lib/psych/json/ruby_events.rb +19 -0
- data/lib/psych/json/stream.rb +16 -0
- data/lib/psych/json/tree_builder.rb +12 -0
- data/lib/psych/json/yaml_events.rb +29 -0
- data/lib/psych/nodes.rb +77 -0
- data/lib/psych/nodes/alias.rb +18 -0
- data/lib/psych/nodes/document.rb +60 -0
- data/lib/psych/nodes/mapping.rb +56 -0
- data/lib/psych/nodes/node.rb +55 -0
- data/lib/psych/nodes/scalar.rb +67 -0
- data/lib/psych/nodes/sequence.rb +81 -0
- data/lib/psych/nodes/stream.rb +37 -0
- data/lib/psych/omap.rb +4 -0
- data/lib/psych/parser.rb +51 -0
- data/lib/psych/scalar_scanner.rb +149 -0
- data/lib/psych/set.rb +4 -0
- data/lib/psych/stream.rb +37 -0
- data/lib/psych/streaming.rb +27 -0
- data/lib/psych/syntax_error.rb +21 -0
- data/lib/psych/tree_builder.rb +96 -0
- data/lib/psych/versions.rb +3 -0
- data/lib/psych/visitors.rb +6 -0
- data/lib/psych/visitors/depth_first.rb +26 -0
- data/lib/psych/visitors/emitter.rb +51 -0
- data/lib/psych/visitors/json_tree.rb +24 -0
- data/lib/psych/visitors/to_ruby.rb +404 -0
- data/lib/psych/visitors/visitor.rb +19 -0
- data/lib/psych/visitors/yaml_tree.rb +605 -0
- data/lib/psych/y.rb +9 -0
- data/lib/psych_jars.rb +5 -0
- data/test/psych/handlers/test_recorder.rb +25 -0
- data/test/psych/helper.rb +121 -0
- data/test/psych/json/test_stream.rb +109 -0
- data/test/psych/nodes/test_enumerable.rb +43 -0
- data/test/psych/test_alias_and_anchor.rb +96 -0
- data/test/psych/test_array.rb +57 -0
- data/test/psych/test_boolean.rb +36 -0
- data/test/psych/test_class.rb +36 -0
- data/test/psych/test_coder.rb +206 -0
- data/test/psych/test_date_time.rb +38 -0
- data/test/psych/test_deprecated.rb +214 -0
- data/test/psych/test_document.rb +46 -0
- data/test/psych/test_emitter.rb +93 -0
- data/test/psych/test_encoding.rb +259 -0
- data/test/psych/test_exception.rb +157 -0
- data/test/psych/test_hash.rb +94 -0
- data/test/psych/test_json_tree.rb +65 -0
- data/test/psych/test_merge_keys.rb +180 -0
- data/test/psych/test_nil.rb +18 -0
- data/test/psych/test_null.rb +19 -0
- data/test/psych/test_numeric.rb +45 -0
- data/test/psych/test_object.rb +44 -0
- data/test/psych/test_object_references.rb +71 -0
- data/test/psych/test_omap.rb +75 -0
- data/test/psych/test_parser.rb +339 -0
- data/test/psych/test_psych.rb +168 -0
- data/test/psych/test_safe_load.rb +97 -0
- data/test/psych/test_scalar.rb +11 -0
- data/test/psych/test_scalar_scanner.rb +106 -0
- data/test/psych/test_serialize_subclasses.rb +38 -0
- data/test/psych/test_set.rb +49 -0
- data/test/psych/test_stream.rb +93 -0
- data/test/psych/test_string.rb +226 -0
- data/test/psych/test_struct.rb +49 -0
- data/test/psych/test_symbol.rb +25 -0
- data/test/psych/test_tainted.rb +130 -0
- data/test/psych/test_to_yaml_properties.rb +63 -0
- data/test/psych/test_tree_builder.rb +79 -0
- data/test/psych/test_yaml.rb +1292 -0
- data/test/psych/test_yamldbm.rb +193 -0
- data/test/psych/test_yamlstore.rb +85 -0
- data/test/psych/visitors/test_depth_first.rb +49 -0
- data/test/psych/visitors/test_emitter.rb +144 -0
- data/test/psych/visitors/test_to_ruby.rb +333 -0
- data/test/psych/visitors/test_yaml_tree.rb +173 -0
- metadata +240 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'psych/omap'
|
2
|
+
require 'psych/set'
|
3
|
+
|
4
|
+
module Psych
|
5
|
+
class ClassLoader # :nodoc:
|
6
|
+
BIG_DECIMAL = 'BigDecimal'
|
7
|
+
COMPLEX = 'Complex'
|
8
|
+
DATE = 'Date'
|
9
|
+
DATE_TIME = 'DateTime'
|
10
|
+
EXCEPTION = 'Exception'
|
11
|
+
OBJECT = 'Object'
|
12
|
+
PSYCH_OMAP = 'Psych::Omap'
|
13
|
+
PSYCH_SET = 'Psych::Set'
|
14
|
+
RANGE = 'Range'
|
15
|
+
RATIONAL = 'Rational'
|
16
|
+
REGEXP = 'Regexp'
|
17
|
+
STRUCT = 'Struct'
|
18
|
+
SYMBOL = 'Symbol'
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@cache = CACHE.dup
|
22
|
+
end
|
23
|
+
|
24
|
+
def load klassname
|
25
|
+
return nil if !klassname || klassname.empty?
|
26
|
+
|
27
|
+
find klassname
|
28
|
+
end
|
29
|
+
|
30
|
+
def symbolize sym
|
31
|
+
symbol
|
32
|
+
sym.to_sym
|
33
|
+
end
|
34
|
+
|
35
|
+
constants.each do |const|
|
36
|
+
konst = const_get const
|
37
|
+
define_method(const.to_s.downcase) do
|
38
|
+
load konst
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def find klassname
|
45
|
+
@cache[klassname] ||= resolve(klassname)
|
46
|
+
end
|
47
|
+
|
48
|
+
def resolve klassname
|
49
|
+
name = klassname
|
50
|
+
retried = false
|
51
|
+
|
52
|
+
begin
|
53
|
+
path2class(name)
|
54
|
+
rescue ArgumentError, NameError => ex
|
55
|
+
unless retried
|
56
|
+
name = "Struct::#{name}"
|
57
|
+
retried = ex
|
58
|
+
retry
|
59
|
+
end
|
60
|
+
raise retried
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
CACHE = Hash[constants.map { |const|
|
65
|
+
val = const_get const
|
66
|
+
begin
|
67
|
+
[val, ::Object.const_get(val)]
|
68
|
+
rescue
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
}.compact]
|
72
|
+
|
73
|
+
class Restricted < ClassLoader
|
74
|
+
def initialize classes, symbols
|
75
|
+
@classes = classes
|
76
|
+
@symbols = symbols
|
77
|
+
super()
|
78
|
+
end
|
79
|
+
|
80
|
+
def symbolize sym
|
81
|
+
return super if @symbols.empty?
|
82
|
+
|
83
|
+
if @symbols.include? sym
|
84
|
+
super
|
85
|
+
else
|
86
|
+
raise DisallowedClass, 'Symbol'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def find klassname
|
93
|
+
if @classes.include? klassname
|
94
|
+
super
|
95
|
+
else
|
96
|
+
raise DisallowedClass, klassname
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/lib/psych/coder.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
module Psych
|
2
|
+
###
|
3
|
+
# If an object defines +encode_with+, then an instance of Psych::Coder will
|
4
|
+
# be passed to the method when the object is being serialized. The Coder
|
5
|
+
# automatically assumes a Psych::Nodes::Mapping is being emitted. Other
|
6
|
+
# objects like Sequence and Scalar may be emitted if +seq=+ or +scalar=+ are
|
7
|
+
# called, respectively.
|
8
|
+
class Coder
|
9
|
+
attr_accessor :tag, :style, :implicit, :object
|
10
|
+
attr_reader :type, :seq
|
11
|
+
|
12
|
+
def initialize tag
|
13
|
+
@map = {}
|
14
|
+
@seq = []
|
15
|
+
@implicit = false
|
16
|
+
@type = :map
|
17
|
+
@tag = tag
|
18
|
+
@style = Psych::Nodes::Mapping::BLOCK
|
19
|
+
@scalar = nil
|
20
|
+
@object = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def scalar *args
|
24
|
+
if args.length > 0
|
25
|
+
warn "#{caller[0]}: Coder#scalar(a,b,c) is deprecated" if $VERBOSE
|
26
|
+
@tag, @scalar, _ = args
|
27
|
+
@type = :scalar
|
28
|
+
end
|
29
|
+
@scalar
|
30
|
+
end
|
31
|
+
|
32
|
+
# Emit a map. The coder will be yielded to the block.
|
33
|
+
def map tag = @tag, style = @style
|
34
|
+
@tag = tag
|
35
|
+
@style = style
|
36
|
+
yield self if block_given?
|
37
|
+
@map
|
38
|
+
end
|
39
|
+
|
40
|
+
# Emit a scalar with +value+ and +tag+
|
41
|
+
def represent_scalar tag, value
|
42
|
+
self.tag = tag
|
43
|
+
self.scalar = value
|
44
|
+
end
|
45
|
+
|
46
|
+
# Emit a sequence with +list+ and +tag+
|
47
|
+
def represent_seq tag, list
|
48
|
+
@tag = tag
|
49
|
+
self.seq = list
|
50
|
+
end
|
51
|
+
|
52
|
+
# Emit a sequence with +map+ and +tag+
|
53
|
+
def represent_map tag, map
|
54
|
+
@tag = tag
|
55
|
+
self.map = map
|
56
|
+
end
|
57
|
+
|
58
|
+
# Emit an arbitrary object +obj+ and +tag+
|
59
|
+
def represent_object tag, obj
|
60
|
+
@tag = tag
|
61
|
+
@type = :object
|
62
|
+
@object = obj
|
63
|
+
end
|
64
|
+
|
65
|
+
# Emit a scalar with +value+
|
66
|
+
def scalar= value
|
67
|
+
@type = :scalar
|
68
|
+
@scalar = value
|
69
|
+
end
|
70
|
+
|
71
|
+
# Emit a map with +value+
|
72
|
+
def map= map
|
73
|
+
@type = :map
|
74
|
+
@map = map
|
75
|
+
end
|
76
|
+
|
77
|
+
def []= k, v
|
78
|
+
@type = :map
|
79
|
+
@map[k] = v
|
80
|
+
end
|
81
|
+
alias :add :[]=
|
82
|
+
|
83
|
+
def [] k
|
84
|
+
@type = :map
|
85
|
+
@map[k]
|
86
|
+
end
|
87
|
+
|
88
|
+
# Emit a sequence of +list+
|
89
|
+
def seq= list
|
90
|
+
@type = :seq
|
91
|
+
@seq = list
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Object
|
2
|
+
def self.yaml_tag url
|
3
|
+
Psych.add_tag(url, self)
|
4
|
+
end
|
5
|
+
|
6
|
+
# FIXME: rename this to "to_yaml" when syck is removed
|
7
|
+
|
8
|
+
###
|
9
|
+
# call-seq: to_yaml(options = {})
|
10
|
+
#
|
11
|
+
# Convert an object to YAML. See Psych.dump for more information on the
|
12
|
+
# available +options+.
|
13
|
+
def psych_to_yaml options = {}
|
14
|
+
Psych.dump self, options
|
15
|
+
end
|
16
|
+
remove_method :to_yaml rescue nil
|
17
|
+
alias :to_yaml :psych_to_yaml
|
18
|
+
end
|
19
|
+
|
20
|
+
class Module
|
21
|
+
def psych_yaml_as url
|
22
|
+
return if caller[0].end_with?('rubytypes.rb')
|
23
|
+
if $VERBOSE
|
24
|
+
warn "#{caller[0]}: yaml_as is deprecated, please use yaml_tag"
|
25
|
+
end
|
26
|
+
Psych.add_tag(url, self)
|
27
|
+
end
|
28
|
+
|
29
|
+
remove_method :yaml_as rescue nil
|
30
|
+
alias :yaml_as :psych_yaml_as
|
31
|
+
end
|
32
|
+
|
33
|
+
if defined?(::IRB)
|
34
|
+
require 'psych/y'
|
35
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Psych
|
4
|
+
DEPRECATED = __FILE__ # :nodoc:
|
5
|
+
|
6
|
+
module DeprecatedMethods # :nodoc:
|
7
|
+
attr_accessor :taguri
|
8
|
+
attr_accessor :to_yaml_style
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.quick_emit thing, opts = {}, &block # :nodoc:
|
12
|
+
warn "#{caller[0]}: YAML.quick_emit is deprecated" if $VERBOSE && !caller[0].start_with?(File.dirname(__FILE__))
|
13
|
+
target = eval 'self', block.binding
|
14
|
+
target.extend DeprecatedMethods
|
15
|
+
metaclass = class << target; self; end
|
16
|
+
metaclass.send(:define_method, :encode_with) do |coder|
|
17
|
+
target.taguri = coder.tag
|
18
|
+
target.to_yaml_style = coder.style
|
19
|
+
block.call coder
|
20
|
+
end
|
21
|
+
target.psych_to_yaml unless opts[:nodump]
|
22
|
+
end
|
23
|
+
|
24
|
+
# This method is deprecated, use Psych.load_stream instead.
|
25
|
+
def self.load_documents yaml, &block
|
26
|
+
if $VERBOSE
|
27
|
+
warn "#{caller[0]}: load_documents is deprecated, use load_stream"
|
28
|
+
end
|
29
|
+
list = load_stream yaml
|
30
|
+
return list unless block_given?
|
31
|
+
list.each(&block)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.detect_implicit thing
|
35
|
+
warn "#{caller[0]}: detect_implicit is deprecated" if $VERBOSE
|
36
|
+
return '' unless String === thing
|
37
|
+
return 'null' if '' == thing
|
38
|
+
ss = ScalarScanner.new(ClassLoader.new)
|
39
|
+
ss.tokenize(thing).class.name.downcase
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.add_ruby_type type_tag, &block
|
43
|
+
warn "#{caller[0]}: add_ruby_type is deprecated, use add_domain_type" if $VERBOSE
|
44
|
+
domain = 'ruby.yaml.org,2002'
|
45
|
+
key = ['tag', domain, type_tag].join ':'
|
46
|
+
@domain_types[key] = [key, block]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.add_private_type type_tag, &block
|
50
|
+
warn "#{caller[0]}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
|
51
|
+
domain = 'x-private'
|
52
|
+
key = [domain, type_tag].join ':'
|
53
|
+
@domain_types[key] = [key, block]
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.tagurize thing
|
57
|
+
warn "#{caller[0]}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
|
58
|
+
return thing unless String === thing
|
59
|
+
"tag:yaml.org,2002:#{thing}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.read_type_class type, reference
|
63
|
+
warn "#{caller[0]}: read_type_class is deprecated" if $VERBOSE
|
64
|
+
_, _, type, name = type.split ':', 4
|
65
|
+
|
66
|
+
reference = name.split('::').inject(reference) do |k,n|
|
67
|
+
k.const_get(n.to_sym)
|
68
|
+
end if name
|
69
|
+
[type, reference]
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.object_maker klass, hash
|
73
|
+
warn "#{caller[0]}: object_maker is deprecated" if $VERBOSE
|
74
|
+
klass.allocate.tap do |obj|
|
75
|
+
hash.each { |k,v| obj.instance_variable_set(:"@#{k}", v) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Object
|
81
|
+
undef :to_yaml_properties rescue nil
|
82
|
+
def to_yaml_properties # :nodoc:
|
83
|
+
instance_variables
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
module Psych
|
2
|
+
###
|
3
|
+
# Psych::Handler is an abstract base class that defines the events used
|
4
|
+
# when dealing with Psych::Parser. Clients who want to use Psych::Parser
|
5
|
+
# should implement a class that inherits from Psych::Handler and define
|
6
|
+
# events that they can handle.
|
7
|
+
#
|
8
|
+
# Psych::Handler defines all events that Psych::Parser can possibly send to
|
9
|
+
# event handlers.
|
10
|
+
#
|
11
|
+
# See Psych::Parser for more details
|
12
|
+
class Handler
|
13
|
+
###
|
14
|
+
# Configuration options for dumping YAML.
|
15
|
+
class DumperOptions
|
16
|
+
attr_accessor :line_width, :indentation, :canonical
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@line_width = 0
|
20
|
+
@indentation = 2
|
21
|
+
@canonical = false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Default dumping options
|
26
|
+
OPTIONS = DumperOptions.new
|
27
|
+
|
28
|
+
# Events that a Handler should respond to.
|
29
|
+
EVENTS = [ :alias,
|
30
|
+
:empty,
|
31
|
+
:end_document,
|
32
|
+
:end_mapping,
|
33
|
+
:end_sequence,
|
34
|
+
:end_stream,
|
35
|
+
:scalar,
|
36
|
+
:start_document,
|
37
|
+
:start_mapping,
|
38
|
+
:start_sequence,
|
39
|
+
:start_stream ]
|
40
|
+
|
41
|
+
###
|
42
|
+
# Called with +encoding+ when the YAML stream starts. This method is
|
43
|
+
# called once per stream. A stream may contain multiple documents.
|
44
|
+
#
|
45
|
+
# See the constants in Psych::Parser for the possible values of +encoding+.
|
46
|
+
def start_stream encoding
|
47
|
+
end
|
48
|
+
|
49
|
+
###
|
50
|
+
# Called when the document starts with the declared +version+,
|
51
|
+
# +tag_directives+, if the document is +implicit+.
|
52
|
+
#
|
53
|
+
# +version+ will be an array of integers indicating the YAML version being
|
54
|
+
# dealt with, +tag_directives+ is a list of tuples indicating the prefix
|
55
|
+
# and suffix of each tag, and +implicit+ is a boolean indicating whether
|
56
|
+
# the document is started implicitly.
|
57
|
+
#
|
58
|
+
# === Example
|
59
|
+
#
|
60
|
+
# Given the following YAML:
|
61
|
+
#
|
62
|
+
# %YAML 1.1
|
63
|
+
# %TAG ! tag:tenderlovemaking.com,2009:
|
64
|
+
# --- !squee
|
65
|
+
#
|
66
|
+
# The parameters for start_document must be this:
|
67
|
+
#
|
68
|
+
# version # => [1, 1]
|
69
|
+
# tag_directives # => [["!", "tag:tenderlovemaking.com,2009:"]]
|
70
|
+
# implicit # => false
|
71
|
+
def start_document version, tag_directives, implicit
|
72
|
+
end
|
73
|
+
|
74
|
+
###
|
75
|
+
# Called with the document ends. +implicit+ is a boolean value indicating
|
76
|
+
# whether or not the document has an implicit ending.
|
77
|
+
#
|
78
|
+
# === Example
|
79
|
+
#
|
80
|
+
# Given the following YAML:
|
81
|
+
#
|
82
|
+
# ---
|
83
|
+
# hello world
|
84
|
+
#
|
85
|
+
# +implicit+ will be true. Given this YAML:
|
86
|
+
#
|
87
|
+
# ---
|
88
|
+
# hello world
|
89
|
+
# ...
|
90
|
+
#
|
91
|
+
# +implicit+ will be false.
|
92
|
+
def end_document implicit
|
93
|
+
end
|
94
|
+
|
95
|
+
###
|
96
|
+
# Called when an alias is found to +anchor+. +anchor+ will be the name
|
97
|
+
# of the anchor found.
|
98
|
+
#
|
99
|
+
# === Example
|
100
|
+
#
|
101
|
+
# Here we have an example of an array that references itself in YAML:
|
102
|
+
#
|
103
|
+
# --- &ponies
|
104
|
+
# - first element
|
105
|
+
# - *ponies
|
106
|
+
#
|
107
|
+
# &ponies is the achor, *ponies is the alias. In this case, alias is
|
108
|
+
# called with "ponies".
|
109
|
+
def alias anchor
|
110
|
+
end
|
111
|
+
|
112
|
+
###
|
113
|
+
# Called when a scalar +value+ is found. The scalar may have an
|
114
|
+
# +anchor+, a +tag+, be implicitly +plain+ or implicitly +quoted+
|
115
|
+
#
|
116
|
+
# +value+ is the string value of the scalar
|
117
|
+
# +anchor+ is an associated anchor or nil
|
118
|
+
# +tag+ is an associated tag or nil
|
119
|
+
# +plain+ is a boolean value
|
120
|
+
# +quoted+ is a boolean value
|
121
|
+
# +style+ is an integer idicating the string style
|
122
|
+
#
|
123
|
+
# See the constants in Psych::Nodes::Scalar for the possible values of
|
124
|
+
# +style+
|
125
|
+
#
|
126
|
+
# === Example
|
127
|
+
#
|
128
|
+
# Here is a YAML document that exercises most of the possible ways this
|
129
|
+
# method can be called:
|
130
|
+
#
|
131
|
+
# ---
|
132
|
+
# - !str "foo"
|
133
|
+
# - &anchor fun
|
134
|
+
# - many
|
135
|
+
# lines
|
136
|
+
# - |
|
137
|
+
# many
|
138
|
+
# newlines
|
139
|
+
#
|
140
|
+
# The above YAML document contains a list with four strings. Here are
|
141
|
+
# the parameters sent to this method in the same order:
|
142
|
+
#
|
143
|
+
# # value anchor tag plain quoted style
|
144
|
+
# ["foo", nil, "!str", false, false, 3 ]
|
145
|
+
# ["fun", "anchor", nil, true, false, 1 ]
|
146
|
+
# ["many lines", nil, nil, true, false, 1 ]
|
147
|
+
# ["many\nnewlines\n", nil, nil, false, true, 4 ]
|
148
|
+
#
|
149
|
+
def scalar value, anchor, tag, plain, quoted, style
|
150
|
+
end
|
151
|
+
|
152
|
+
###
|
153
|
+
# Called when a sequence is started.
|
154
|
+
#
|
155
|
+
# +anchor+ is the anchor associated with the sequence or nil.
|
156
|
+
# +tag+ is the tag associated with the sequence or nil.
|
157
|
+
# +implicit+ a boolean indicating whether or not the sequence was implicitly
|
158
|
+
# started.
|
159
|
+
# +style+ is an integer indicating the list style.
|
160
|
+
#
|
161
|
+
# See the constants in Psych::Nodes::Sequence for the possible values of
|
162
|
+
# +style+.
|
163
|
+
#
|
164
|
+
# === Example
|
165
|
+
#
|
166
|
+
# Here is a YAML document that exercises most of the possible ways this
|
167
|
+
# method can be called:
|
168
|
+
#
|
169
|
+
# ---
|
170
|
+
# - !!seq [
|
171
|
+
# a
|
172
|
+
# ]
|
173
|
+
# - &pewpew
|
174
|
+
# - b
|
175
|
+
#
|
176
|
+
# The above YAML document consists of three lists, an outer list that
|
177
|
+
# contains two inner lists. Here is a matrix of the parameters sent
|
178
|
+
# to represent these lists:
|
179
|
+
#
|
180
|
+
# # anchor tag implicit style
|
181
|
+
# [nil, nil, true, 1 ]
|
182
|
+
# [nil, "tag:yaml.org,2002:seq", false, 2 ]
|
183
|
+
# ["pewpew", nil, true, 1 ]
|
184
|
+
|
185
|
+
def start_sequence anchor, tag, implicit, style
|
186
|
+
end
|
187
|
+
|
188
|
+
###
|
189
|
+
# Called when a sequence ends.
|
190
|
+
def end_sequence
|
191
|
+
end
|
192
|
+
|
193
|
+
###
|
194
|
+
# Called when a map starts.
|
195
|
+
#
|
196
|
+
# +anchor+ is the anchor associated with the map or +nil+.
|
197
|
+
# +tag+ is the tag associated with the map or +nil+.
|
198
|
+
# +implicit+ is a boolean indicating whether or not the map was implicitly
|
199
|
+
# started.
|
200
|
+
# +style+ is an integer indicating the mapping style.
|
201
|
+
#
|
202
|
+
# See the constants in Psych::Nodes::Mapping for the possible values of
|
203
|
+
# +style+.
|
204
|
+
#
|
205
|
+
# === Example
|
206
|
+
#
|
207
|
+
# Here is a YAML document that exercises most of the possible ways this
|
208
|
+
# method can be called:
|
209
|
+
#
|
210
|
+
# ---
|
211
|
+
# k: !!map { hello: world }
|
212
|
+
# v: &pewpew
|
213
|
+
# hello: world
|
214
|
+
#
|
215
|
+
# The above YAML document consists of three maps, an outer map that contains
|
216
|
+
# two inner maps. Below is a matrix of the parameters sent in order to
|
217
|
+
# represent these three maps:
|
218
|
+
#
|
219
|
+
# # anchor tag implicit style
|
220
|
+
# [nil, nil, true, 1 ]
|
221
|
+
# [nil, "tag:yaml.org,2002:map", false, 2 ]
|
222
|
+
# ["pewpew", nil, true, 1 ]
|
223
|
+
|
224
|
+
def start_mapping anchor, tag, implicit, style
|
225
|
+
end
|
226
|
+
|
227
|
+
###
|
228
|
+
# Called when a map ends
|
229
|
+
def end_mapping
|
230
|
+
end
|
231
|
+
|
232
|
+
###
|
233
|
+
# Called when an empty event happens. (Which, as far as I can tell, is
|
234
|
+
# never).
|
235
|
+
def empty
|
236
|
+
end
|
237
|
+
|
238
|
+
###
|
239
|
+
# Called when the YAML stream ends
|
240
|
+
def end_stream
|
241
|
+
end
|
242
|
+
|
243
|
+
###
|
244
|
+
# Is this handler a streaming handler?
|
245
|
+
def streaming?
|
246
|
+
false
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|