I’m searching and searching… but I can not find the
documentation for Psych on http://www.ruby-doc.org/stdlib-1.9.3/.
If I am not mistaken it practically replaces YAML and is part
of the standard library.
I’m searching and searching… but I can not find the
documentation for Psych on http://www.ruby-doc.org/stdlib-1.9.3/.
If I am not mistaken it practically replaces YAML and is part
of the standard library.
Am 19.10.2012 16:52, schrieb [email protected]:
I’m searching and searching… but I can not find the
documentation for Psych on http://www.ruby-doc.org/stdlib-1.9.3/.If I am not mistaken it practically replaces YAML and is part
of the standard library.
It is referenced from the YAML “documentation”
(a term hardly applicable in this case), but on the
referenced page there is no information at all, see
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/yaml/rdoc/Psych.html
On 10/19/2012 07:52 AM, [email protected] wrote:
I’m searching and searching… but I can not find the
documentation for Psych on http://www.ruby-doc.org/stdlib-1.9.3/.If I am not mistaken it practically replaces YAML and is part
of the standard library.
Try http://rdoc.info/stdlib/psych/frames/Psych
Extracting docs from the Ruby source is not straightforward, so
sometimes ruby-doc.org and rdoc.info will have differing levels of
information.
-Justin
On 19 Oct 2012, at 09:04, [email protected] wrote:
I realise this is a bad answer, but the quickest way to get unstuck may
be to download the ruby source tree and read the source.
On Oct 19, 2012, at 07:52 , [email protected] wrote:
I’m searching and searching… but I can not find the
documentation for Psych on http://www.ruby-doc.org/stdlib-1.9.3/.If I am not mistaken it practically replaces YAML and is part
of the standard library.
ri Psych
works great. See below. That said, you shouldn’t be using
Psych directly. Use YAML instead:
% ri19 YAML
= YAML
The YAML module allows you to use one of the two YAML engines that ship
with
ruby. By default Psych is used but the old and unmaintained Syck may be
chosen.
See Psych or Syck for usage and documentation.
To set the YAML engine to syck:
YAML::ENGINE.yamler = ‘syck’
To set the YAML engine back to psych:
YAML::ENGINE.yamler = ‘psych’
…
% ri19 Psych
= Psych
This exists just to satify bugs in marshal’d gemspecs that contain a
reference
to YAML::PrivateType. We prune these out in Specification._load, but if
we
don’t have the constant, Marshal blows up.
This exists just to satify bugs in marshal’d gemspecs that contain a
reference
to YAML::PrivateType. We prune these out in Specification._load, but if
we
don’t have the constant, Marshal blows up.
= Overview
Psych is a YAML parser and emitter. Psych leverages
libyaml[http://libyaml.org] for it’s YAML parsing and emitting
capabilities.
In addition to wrapping libyaml, Psych also knows how to serialize and
de-serialize most Ruby objects to and from the YAML format.
= I NEED TO PARSE OR EMIT YAML RIGHT NOW!
Psych.load(“— foo”) # => “foo”
Psych.dump(“foo”) # => “— foo\n…\n”
{ :a => ‘b’}.to_yaml # => “—\n:a: b\n”
Got more time on your hands? Keep on reading!
== YAML Parsing
Psych provides a range of interfaces for parsing a YAML document ranging
from
low level to high level, depending on your parsing needs. At the lowest
level, is an event based parser. Mid level is access to the raw YAML
AST, and
at the highest level is the ability to unmarshal YAML to ruby objects.
=== Low level parsing
The lowest level parser should be used when the YAML input is already
known,
and the developer does not want to pay the price of building an AST or
automatic detection and conversion to ruby objects. See Psych::Parser
for
more information on using the event based parser.
=== Mid level parsing
Psych provides access to an AST produced from parsing a YAML document.
This
tree is built using the Psych::Parser and Psych::TreeBuilder. The AST
can be
examined and manipulated freely. Please see Psych::parse_stream,
Psych::Nodes, and Psych::Nodes::Node for more information on dealing
with YAML
syntax trees.
=== High level parsing
The high level YAML parser provided by Psych simply takes YAML as input
and
returns a Ruby data structure. For information on using the high level
parser
see Psych.load
== YAML Emitting
Psych provides a range of interfaces ranging from low to high level for
producing YAML documents. Very similar to the YAML parsing interfaces,
Psych
provides at the lowest level, an event based system, mid-level is
building a
YAML AST, and the highest level is converting a Ruby object straight to
a YAML
document.
=== Low level emitting
The lowest level emitter is an event based system. Events are sent to a
Psych::Emitter object. That object knows how to convert the events to a
YAML
document. This interface should be used when document format is known
in
advance or speed is a concern. See Psych::Emitter for more information.
=== Mid level emitting
At the mid level is building an AST. This AST is exactly the same as
the AST
used when parsing a YAML document. Users can build an AST by hand and
the AST
knows how to emit itself as a YAML document. See Psych::Nodes,
Psych::Nodes::Node, and Psych::TreeBuilder for more information on
building a
YAML AST.
=== High level emitting
= Constants:
DEPRECATED:
[not documented]
ENGINE:
[not documented]
LIBYAML_VERSION:
The version of libyaml Psych is using
VERSION:
The version is Psych you’re using
= Class methods:
add_private_type
add_ruby_type
detect_implicit
dump
dump_stream
libyaml_version
load
load_documents
load_file
load_stream
object_maker
parse
parse_file
parse_stream
parser
quick_emit
read_type_class
tagurize
to_json
Am 19.10.2012 22:28, schrieb Ryan D.:
On Oct 19, 2012, at 07:52 , [email protected] wrote:
I’m searching and searching… but I can not find the
documentation for Psych on http://www.ruby-doc.org/stdlib-1.9.3/.
ri Psych
works great. See below. That said, you shouldn’t be using Psych
directly. Use YAML instead:
Thanks Ryan and Justin for your answers.
ri works fine for me but not for my students, because it’s broken
on our Windows machines at school, so I let them use ruby-doc.org.
Imo missing documentation makes a bad impression, so I think I’ll
open an issue.
[email protected] wrote:
Glitch in doc generation.
Should be good nowL
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/psych/rdoc/index.html
James B.
–
jamesbritt.com - Live curious
justthebestparts.com - Feed your head
neurogami.com - Hack your world
Am 21.10.2012 23:15, schrieb James B.:
Glitch in doc generation.
Should be good nowL
Index of Classes & Methods in psych: Ruby Standard Library Documentation (Ruby 1.9.3)
James B.
Thank you for fixing this,
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs