summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-09-27 18:51:05 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-09-27 18:51:05 -0700
commit15b81ea96f80efc5042b1200bbaf13aa59e90e2d (patch)
treec392693e5f4b3a62344935e5d6d9b843244099de /lib
parent6f404ba338038732d8f3ebbb02b977d1ab42e0a1 (diff)
downloadpsych-15b81ea96f80efc5042b1200bbaf13aa59e90e2d.zip
adding accessors for document information
Diffstat (limited to 'lib')
-rw-r--r--lib/psych.rb1
-rw-r--r--lib/psych/nodes/document.rb9
-rw-r--r--lib/psych/nodes/sequence.rb13
-rw-r--r--lib/psych/tree_builder.rb9
4 files changed, 32 insertions, 0 deletions
diff --git a/lib/psych.rb b/lib/psych.rb
index d39a284..9c6397d 100644
--- a/lib/psych.rb
+++ b/lib/psych.rb
@@ -1,6 +1,7 @@
require 'psych/nodes/node'
require 'psych/nodes/stream'
require 'psych/nodes/document'
+require 'psych/nodes/sequence'
require 'psych/handler'
require 'psych/tree_builder'
diff --git a/lib/psych/nodes/document.rb b/lib/psych/nodes/document.rb
index 8dc0a13..05eca82 100644
--- a/lib/psych/nodes/document.rb
+++ b/lib/psych/nodes/document.rb
@@ -1,6 +1,15 @@
module Psych
module Nodes
class Document < Psych::Nodes::Node
+ # The version of the YAML document
+ attr_accessor :version
+
+ # A list of tag directives for this document
+ attr_accessor :tag_directives
+
+ # Was this document implicitly created?
+ attr_accessor :implicit
+
def initialize version, tag_directives, implicit
super()
@version = version
diff --git a/lib/psych/nodes/sequence.rb b/lib/psych/nodes/sequence.rb
new file mode 100644
index 0000000..fbcb45e
--- /dev/null
+++ b/lib/psych/nodes/sequence.rb
@@ -0,0 +1,13 @@
+module Psych
+ module Nodes
+ class Sequence < Psych::Nodes::Node
+ def initialize anchor, tag, implicit, style
+ super()
+ @anchor = anchor
+ @tag = tag
+ @implicit = implicit
+ @style = style
+ end
+ end
+ end
+end
diff --git a/lib/psych/tree_builder.rb b/lib/psych/tree_builder.rb
index 3f11fd9..c7e46fb 100644
--- a/lib/psych/tree_builder.rb
+++ b/lib/psych/tree_builder.rb
@@ -17,13 +17,22 @@ module Psych
end
def start_stream encoding
+ super
@stack.push Nodes::Stream.new encoding
end
def start_document version = [], tag_directives = [], implicit = true
+ super
doc = Nodes::Document.new version, tag_directives, implicit
@stack.last.children << doc
@stack.push doc
end
+
+ def start_sequence anchor = nil, tag = nil, implicit = true, style = BLOCK_SEQUENCE_STYLE
+ super
+ seq = Nodes::Sequence.new anchor, tag, implicit, style
+ @stack.last.children << seq
+ @stack.push seq
+ end
end
end