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,22 @@
|
|
1
|
+
require 'psych/tree_builder'
|
2
|
+
|
3
|
+
module Psych
|
4
|
+
module Handlers
|
5
|
+
class DocumentStream < Psych::TreeBuilder # :nodoc:
|
6
|
+
def initialize &block
|
7
|
+
super
|
8
|
+
@block = block
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_document version, tag_directives, implicit
|
12
|
+
n = Nodes::Document.new version, tag_directives, implicit
|
13
|
+
push n
|
14
|
+
end
|
15
|
+
|
16
|
+
def end_document implicit_end = !streaming?
|
17
|
+
@last.implicit_end = implicit_end
|
18
|
+
@block.call pop
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'psych/handler'
|
2
|
+
|
3
|
+
module Psych
|
4
|
+
module Handlers
|
5
|
+
###
|
6
|
+
# This handler will capture an event and record the event. Recorder events
|
7
|
+
# are available vial Psych::Handlers::Recorder#events.
|
8
|
+
#
|
9
|
+
# For example:
|
10
|
+
#
|
11
|
+
# recorder = Psych::Handlers::Recorder.new
|
12
|
+
# parser = Psych::Parser.new recorder
|
13
|
+
# parser.parse '--- foo'
|
14
|
+
#
|
15
|
+
# recorder.events # => [list of events]
|
16
|
+
#
|
17
|
+
# # Replay the events
|
18
|
+
#
|
19
|
+
# emitter = Psych::Emitter.new $stdout
|
20
|
+
# recorder.events.each do |m, args|
|
21
|
+
# emitter.send m, *args
|
22
|
+
# end
|
23
|
+
|
24
|
+
class Recorder < Psych::Handler
|
25
|
+
attr_reader :events
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@events = []
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
EVENTS.each do |event|
|
33
|
+
define_method event do |*args|
|
34
|
+
@events << [event, args]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Psych
|
2
|
+
module JSON
|
3
|
+
module RubyEvents # :nodoc:
|
4
|
+
def visit_Time o
|
5
|
+
formatted = format_time o
|
6
|
+
@emitter.scalar formatted, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
|
7
|
+
end
|
8
|
+
|
9
|
+
def visit_DateTime o
|
10
|
+
visit_Time o.to_time
|
11
|
+
end
|
12
|
+
|
13
|
+
def visit_String o
|
14
|
+
@emitter.scalar o.to_s, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
|
15
|
+
end
|
16
|
+
alias :visit_Symbol :visit_String
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'psych/json/ruby_events'
|
2
|
+
require 'psych/json/yaml_events'
|
3
|
+
|
4
|
+
module Psych
|
5
|
+
module JSON
|
6
|
+
class Stream < Psych::Visitors::JSONTree
|
7
|
+
include Psych::JSON::RubyEvents
|
8
|
+
include Psych::Streaming
|
9
|
+
extend Psych::Streaming::ClassMethods
|
10
|
+
|
11
|
+
class Emitter < Psych::Stream::Emitter # :nodoc:
|
12
|
+
include Psych::JSON::YAMLEvents
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'psych/json/yaml_events'
|
2
|
+
|
3
|
+
module Psych
|
4
|
+
module JSON
|
5
|
+
###
|
6
|
+
# Psych::JSON::TreeBuilder is an event based AST builder. Events are sent
|
7
|
+
# to an instance of Psych::JSON::TreeBuilder and a JSON AST is constructed.
|
8
|
+
class TreeBuilder < Psych::TreeBuilder
|
9
|
+
include Psych::JSON::YAMLEvents
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Psych
|
2
|
+
module JSON
|
3
|
+
module YAMLEvents # :nodoc:
|
4
|
+
def start_document version, tag_directives, implicit
|
5
|
+
super(version, tag_directives, !streaming?)
|
6
|
+
end
|
7
|
+
|
8
|
+
def end_document implicit_end = !streaming?
|
9
|
+
super(implicit_end)
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_mapping anchor, tag, implicit, style
|
13
|
+
super(anchor, nil, true, Nodes::Mapping::FLOW)
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_sequence anchor, tag, implicit, style
|
17
|
+
super(anchor, nil, true, Nodes::Sequence::FLOW)
|
18
|
+
end
|
19
|
+
|
20
|
+
def scalar value, anchor, tag, plain, quoted, style
|
21
|
+
if "tag:yaml.org,2002:null" == tag
|
22
|
+
super('null', nil, nil, true, false, Nodes::Scalar::PLAIN)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/psych/nodes.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'psych/nodes/node'
|
2
|
+
require 'psych/nodes/stream'
|
3
|
+
require 'psych/nodes/document'
|
4
|
+
require 'psych/nodes/sequence'
|
5
|
+
require 'psych/nodes/scalar'
|
6
|
+
require 'psych/nodes/mapping'
|
7
|
+
require 'psych/nodes/alias'
|
8
|
+
|
9
|
+
module Psych
|
10
|
+
###
|
11
|
+
# = Overview
|
12
|
+
#
|
13
|
+
# When using Psych.load to deserialize a YAML document, the document is
|
14
|
+
# translated to an intermediary AST. That intermediary AST is then
|
15
|
+
# translated in to a Ruby object graph.
|
16
|
+
#
|
17
|
+
# In the opposite direction, when using Psych.dump, the Ruby object graph is
|
18
|
+
# translated to an intermediary AST which is then converted to a YAML
|
19
|
+
# document.
|
20
|
+
#
|
21
|
+
# Psych::Nodes contains all of the classes that make up the nodes of a YAML
|
22
|
+
# AST. You can manually build an AST and use one of the visitors (see
|
23
|
+
# Psych::Visitors) to convert that AST to either a YAML document or to a
|
24
|
+
# Ruby object graph.
|
25
|
+
#
|
26
|
+
# Here is an example of building an AST that represents a list with one
|
27
|
+
# scalar:
|
28
|
+
#
|
29
|
+
# # Create our nodes
|
30
|
+
# stream = Psych::Nodes::Stream.new
|
31
|
+
# doc = Psych::Nodes::Document.new
|
32
|
+
# seq = Psych::Nodes::Sequence.new
|
33
|
+
# scalar = Psych::Nodes::Scalar.new('foo')
|
34
|
+
#
|
35
|
+
# # Build up our tree
|
36
|
+
# stream.children << doc
|
37
|
+
# doc.children << seq
|
38
|
+
# seq.children << scalar
|
39
|
+
#
|
40
|
+
# The stream is the root of the tree. We can then convert the tree to YAML:
|
41
|
+
#
|
42
|
+
# stream.to_yaml => "---\n- foo\n"
|
43
|
+
#
|
44
|
+
# Or convert it to Ruby:
|
45
|
+
#
|
46
|
+
# stream.to_ruby => [["foo"]]
|
47
|
+
#
|
48
|
+
# == YAML AST Requirements
|
49
|
+
#
|
50
|
+
# A valid YAML AST *must* have one Psych::Nodes::Stream at the root. A
|
51
|
+
# Psych::Nodes::Stream node must have 1 or more Psych::Nodes::Document nodes
|
52
|
+
# as children.
|
53
|
+
#
|
54
|
+
# Psych::Nodes::Document nodes must have one and *only* one child. That child
|
55
|
+
# may be one of:
|
56
|
+
#
|
57
|
+
# * Psych::Nodes::Sequence
|
58
|
+
# * Psych::Nodes::Mapping
|
59
|
+
# * Psych::Nodes::Scalar
|
60
|
+
#
|
61
|
+
# Psych::Nodes::Sequence and Psych::Nodes::Mapping nodes may have many
|
62
|
+
# children, but Psych::Nodes::Mapping nodes should have an even number of
|
63
|
+
# children.
|
64
|
+
#
|
65
|
+
# All of these are valid children for Psych::Nodes::Sequence and
|
66
|
+
# Psych::Nodes::Mapping nodes:
|
67
|
+
#
|
68
|
+
# * Psych::Nodes::Sequence
|
69
|
+
# * Psych::Nodes::Mapping
|
70
|
+
# * Psych::Nodes::Scalar
|
71
|
+
# * Psych::Nodes::Alias
|
72
|
+
#
|
73
|
+
# Psych::Nodes::Scalar and Psych::Nodes::Alias are both terminal nodes and
|
74
|
+
# should not have any children.
|
75
|
+
module Nodes
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Psych
|
2
|
+
module Nodes
|
3
|
+
###
|
4
|
+
# This class represents a {YAML Alias}[http://yaml.org/spec/1.1/#alias].
|
5
|
+
# It points to an +anchor+.
|
6
|
+
#
|
7
|
+
# A Psych::Nodes::Alias is a terminal node and may have no children.
|
8
|
+
class Alias < Psych::Nodes::Node
|
9
|
+
# The anchor this alias links to
|
10
|
+
attr_accessor :anchor
|
11
|
+
|
12
|
+
# Create a new Alias that points to an +anchor+
|
13
|
+
def initialize anchor
|
14
|
+
@anchor = anchor
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Psych
|
2
|
+
module Nodes
|
3
|
+
###
|
4
|
+
# This represents a YAML Document. This node must be a child of
|
5
|
+
# Psych::Nodes::Stream. A Psych::Nodes::Document must have one child,
|
6
|
+
# and that child may be one of the following:
|
7
|
+
#
|
8
|
+
# * Psych::Nodes::Sequence
|
9
|
+
# * Psych::Nodes::Mapping
|
10
|
+
# * Psych::Nodes::Scalar
|
11
|
+
class Document < Psych::Nodes::Node
|
12
|
+
# The version of the YAML document
|
13
|
+
attr_accessor :version
|
14
|
+
|
15
|
+
# A list of tag directives for this document
|
16
|
+
attr_accessor :tag_directives
|
17
|
+
|
18
|
+
# Was this document implicitly created?
|
19
|
+
attr_accessor :implicit
|
20
|
+
|
21
|
+
# Is the end of the document implicit?
|
22
|
+
attr_accessor :implicit_end
|
23
|
+
|
24
|
+
###
|
25
|
+
# Create a new Psych::Nodes::Document object.
|
26
|
+
#
|
27
|
+
# +version+ is a list indicating the YAML version.
|
28
|
+
# +tags_directives+ is a list of tag directive declarations
|
29
|
+
# +implicit+ is a flag indicating whether the document will be implicitly
|
30
|
+
# started.
|
31
|
+
#
|
32
|
+
# == Example:
|
33
|
+
# This creates a YAML document object that represents a YAML 1.1 document
|
34
|
+
# with one tag directive, and has an implicit start:
|
35
|
+
#
|
36
|
+
# Psych::Nodes::Document.new(
|
37
|
+
# [1,1],
|
38
|
+
# [["!", "tag:tenderlovemaking.com,2009:"]],
|
39
|
+
# true
|
40
|
+
# )
|
41
|
+
#
|
42
|
+
# == See Also
|
43
|
+
# See also Psych::Handler#start_document
|
44
|
+
def initialize version = [], tag_directives = [], implicit = false
|
45
|
+
super()
|
46
|
+
@version = version
|
47
|
+
@tag_directives = tag_directives
|
48
|
+
@implicit = implicit
|
49
|
+
@implicit_end = true
|
50
|
+
end
|
51
|
+
|
52
|
+
###
|
53
|
+
# Returns the root node. A Document may only have one root node:
|
54
|
+
# http://yaml.org/spec/1.1/#id898031
|
55
|
+
def root
|
56
|
+
children.first
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Psych
|
2
|
+
module Nodes
|
3
|
+
###
|
4
|
+
# This class represents a {YAML Mapping}[http://yaml.org/spec/1.1/#mapping].
|
5
|
+
#
|
6
|
+
# A Psych::Nodes::Mapping node may have 0 or more children, but must have
|
7
|
+
# an even number of children. Here are the valid children a
|
8
|
+
# Psych::Nodes::Mapping node may have:
|
9
|
+
#
|
10
|
+
# * Psych::Nodes::Sequence
|
11
|
+
# * Psych::Nodes::Mapping
|
12
|
+
# * Psych::Nodes::Scalar
|
13
|
+
# * Psych::Nodes::Alias
|
14
|
+
class Mapping < Psych::Nodes::Node
|
15
|
+
# Any Map Style
|
16
|
+
ANY = 0
|
17
|
+
|
18
|
+
# Block Map Style
|
19
|
+
BLOCK = 1
|
20
|
+
|
21
|
+
# Flow Map Style
|
22
|
+
FLOW = 2
|
23
|
+
|
24
|
+
# The optional anchor for this mapping
|
25
|
+
attr_accessor :anchor
|
26
|
+
|
27
|
+
# The optional tag for this mapping
|
28
|
+
attr_accessor :tag
|
29
|
+
|
30
|
+
# Is this an implicit mapping?
|
31
|
+
attr_accessor :implicit
|
32
|
+
|
33
|
+
# The style of this mapping
|
34
|
+
attr_accessor :style
|
35
|
+
|
36
|
+
###
|
37
|
+
# Create a new Psych::Nodes::Mapping object.
|
38
|
+
#
|
39
|
+
# +anchor+ is the anchor associated with the map or +nil+.
|
40
|
+
# +tag+ is the tag associated with the map or +nil+.
|
41
|
+
# +implicit+ is a boolean indicating whether or not the map was implicitly
|
42
|
+
# started.
|
43
|
+
# +style+ is an integer indicating the mapping style.
|
44
|
+
#
|
45
|
+
# == See Also
|
46
|
+
# See also Psych::Handler#start_mapping
|
47
|
+
def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
|
48
|
+
super()
|
49
|
+
@anchor = anchor
|
50
|
+
@tag = tag
|
51
|
+
@implicit = implicit
|
52
|
+
@style = style
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
require 'psych/class_loader'
|
3
|
+
require 'psych/scalar_scanner'
|
4
|
+
|
5
|
+
module Psych
|
6
|
+
module Nodes
|
7
|
+
###
|
8
|
+
# The base class for any Node in a YAML parse tree. This class should
|
9
|
+
# never be instantiated.
|
10
|
+
class Node
|
11
|
+
include Enumerable
|
12
|
+
|
13
|
+
# The children of this node
|
14
|
+
attr_reader :children
|
15
|
+
|
16
|
+
# An associated tag
|
17
|
+
attr_reader :tag
|
18
|
+
|
19
|
+
# Create a new Psych::Nodes::Node
|
20
|
+
def initialize
|
21
|
+
@children = []
|
22
|
+
end
|
23
|
+
|
24
|
+
###
|
25
|
+
# Iterate over each node in the tree. Yields each node to +block+ depth
|
26
|
+
# first.
|
27
|
+
def each &block
|
28
|
+
return enum_for :each unless block_given?
|
29
|
+
Visitors::DepthFirst.new(block).accept self
|
30
|
+
end
|
31
|
+
|
32
|
+
###
|
33
|
+
# Convert this node to Ruby.
|
34
|
+
#
|
35
|
+
# See also Psych::Visitors::ToRuby
|
36
|
+
def to_ruby
|
37
|
+
Visitors::ToRuby.create.accept(self)
|
38
|
+
end
|
39
|
+
alias :transform :to_ruby
|
40
|
+
|
41
|
+
###
|
42
|
+
# Convert this node to YAML.
|
43
|
+
#
|
44
|
+
# See also Psych::Visitors::Emitter
|
45
|
+
def yaml io = nil, options = {}
|
46
|
+
real_io = io || StringIO.new(''.encode('utf-8'))
|
47
|
+
|
48
|
+
Visitors::Emitter.new(real_io, options).accept self
|
49
|
+
return real_io.string unless io
|
50
|
+
io
|
51
|
+
end
|
52
|
+
alias :to_yaml :yaml
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Psych
|
2
|
+
module Nodes
|
3
|
+
###
|
4
|
+
# This class represents a {YAML Scalar}[http://yaml.org/spec/1.1/#id858081].
|
5
|
+
#
|
6
|
+
# This node type is a terminal node and should not have any children.
|
7
|
+
class Scalar < Psych::Nodes::Node
|
8
|
+
# Any style scalar, the emitter chooses
|
9
|
+
ANY = 0
|
10
|
+
|
11
|
+
# Plain scalar style
|
12
|
+
PLAIN = 1
|
13
|
+
|
14
|
+
# Single quoted style
|
15
|
+
SINGLE_QUOTED = 2
|
16
|
+
|
17
|
+
# Double quoted style
|
18
|
+
DOUBLE_QUOTED = 3
|
19
|
+
|
20
|
+
# Literal style
|
21
|
+
LITERAL = 4
|
22
|
+
|
23
|
+
# Folded style
|
24
|
+
FOLDED = 5
|
25
|
+
|
26
|
+
# The scalar value
|
27
|
+
attr_accessor :value
|
28
|
+
|
29
|
+
# The anchor value (if there is one)
|
30
|
+
attr_accessor :anchor
|
31
|
+
|
32
|
+
# The tag value (if there is one)
|
33
|
+
attr_accessor :tag
|
34
|
+
|
35
|
+
# Is this a plain scalar?
|
36
|
+
attr_accessor :plain
|
37
|
+
|
38
|
+
# Is this scalar quoted?
|
39
|
+
attr_accessor :quoted
|
40
|
+
|
41
|
+
# The style of this scalar
|
42
|
+
attr_accessor :style
|
43
|
+
|
44
|
+
###
|
45
|
+
# Create a new Psych::Nodes::Scalar object.
|
46
|
+
#
|
47
|
+
# +value+ is the string value of the scalar
|
48
|
+
# +anchor+ is an associated anchor or nil
|
49
|
+
# +tag+ is an associated tag or nil
|
50
|
+
# +plain+ is a boolean value
|
51
|
+
# +quoted+ is a boolean value
|
52
|
+
# +style+ is an integer idicating the string style
|
53
|
+
#
|
54
|
+
# == See Also
|
55
|
+
#
|
56
|
+
# See also Psych::Handler#scalar
|
57
|
+
def initialize value, anchor = nil, tag = nil, plain = true, quoted = false, style = ANY
|
58
|
+
@value = value
|
59
|
+
@anchor = anchor
|
60
|
+
@tag = tag
|
61
|
+
@plain = plain
|
62
|
+
@quoted = quoted
|
63
|
+
@style = style
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|