2011-06-30 04:30:46 +04:00
|
|
|
##
|
2013-07-18 17:50:32 +04:00
|
|
|
# The YAML module is an alias of Psych, the YAML engine for Ruby.
|
2011-06-30 04:30:46 +04:00
|
|
|
|
2012-08-22 21:43:16 +04:00
|
|
|
begin
|
|
|
|
require 'psych'
|
|
|
|
rescue LoadError
|
|
|
|
warn "#{caller[0]}:"
|
|
|
|
warn "It seems your ruby installation is missing psych (for YAML output)."
|
|
|
|
warn "To eliminate this warning, please install libyaml and reinstall your ruby."
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
|
2013-04-28 18:34:22 +04:00
|
|
|
YAML = Psych
|
|
|
|
|
2013-04-27 18:26:20 +04:00
|
|
|
module Psych # :nodoc:
|
2013-04-28 19:40:53 +04:00
|
|
|
# For compatibility, deprecated
|
2013-05-02 06:24:33 +04:00
|
|
|
class EngineManager # :nodoc:
|
2013-04-28 19:40:53 +04:00
|
|
|
attr_reader :yamler # :nodoc:
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2013-02-03 21:40:30 +04:00
|
|
|
def initialize # :nodoc:
|
2012-08-22 21:43:16 +04:00
|
|
|
@yamler = 'psych'
|
2004-07-15 09:04:49 +04:00
|
|
|
end
|
|
|
|
|
2013-02-03 21:40:30 +04:00
|
|
|
def syck? # :nodoc:
|
2012-08-22 21:43:16 +04:00
|
|
|
false
|
2003-05-10 01:25:50 +04:00
|
|
|
end
|
|
|
|
|
2013-05-02 06:24:33 +04:00
|
|
|
# Psych is always used and this method has no effect.
|
2013-02-03 21:40:30 +04:00
|
|
|
#
|
2013-04-28 19:40:53 +04:00
|
|
|
# This method is still present for compatibility.
|
2013-02-03 21:40:30 +04:00
|
|
|
#
|
2013-04-28 19:40:53 +04:00
|
|
|
# You may still use the Syck engine by installing
|
|
|
|
# the 'syck' gem and using the Syck constant.
|
2013-05-02 06:24:33 +04:00
|
|
|
def yamler= engine # :nodoc:
|
2012-08-22 21:43:16 +04:00
|
|
|
case engine
|
2013-04-28 19:40:53 +04:00
|
|
|
when 'syck' then warn "syck has been removed, psych is used instead"
|
2012-08-22 21:43:16 +04:00
|
|
|
when 'psych' then @yamler = 'psych'
|
|
|
|
else
|
|
|
|
raise(ArgumentError, "bad engine")
|
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2010-04-04 01:50:47 +04:00
|
|
|
engine
|
2003-05-10 01:25:50 +04:00
|
|
|
end
|
2010-04-04 01:50:47 +04:00
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2012-08-22 21:43:16 +04:00
|
|
|
ENGINE = EngineManager.new # :nodoc:
|
2010-04-04 01:50:47 +04:00
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2013-04-27 18:26:20 +04:00
|
|
|
# YAML Ain't Markup Language
|
|
|
|
#
|
|
|
|
# This module provides a Ruby interface for data serialization in YAML format.
|
|
|
|
#
|
2013-05-02 06:24:33 +04:00
|
|
|
# The underlying implementation is the libyaml wrapper Psych.
|
2013-04-27 18:26:20 +04:00
|
|
|
#
|
2013-05-02 06:24:33 +04:00
|
|
|
# == Usage
|
2013-04-27 18:26:20 +04:00
|
|
|
#
|
|
|
|
# Working with YAML can be very simple, for example:
|
|
|
|
#
|
|
|
|
# require 'yaml' # STEP ONE, REQUIRE YAML!
|
|
|
|
# # Parse a YAML string
|
|
|
|
# YAML.load("--- foo") #=> "foo"
|
|
|
|
#
|
|
|
|
# # Emit some YAML
|
|
|
|
# YAML.dump("foo") # => "--- foo\n...\n"
|
|
|
|
# { :a => 'b'}.to_yaml # => "---\n:a: b\n"
|
|
|
|
#
|
2013-05-02 06:24:33 +04:00
|
|
|
# == Security
|
|
|
|
#
|
2013-04-27 18:54:37 +04:00
|
|
|
# Do not use YAML to load untrusted data. Doing so is unsafe and could allow
|
|
|
|
# malicious input to execute arbitrary code inside your application. Please see
|
|
|
|
# doc/security.rdoc for more information.
|
|
|
|
#
|
2013-05-02 06:24:33 +04:00
|
|
|
# == History
|
|
|
|
#
|
|
|
|
# Syck was the original for YAML implementation in Ruby's standard library
|
|
|
|
# developed by why the lucky stiff.
|
|
|
|
#
|
|
|
|
# You can still use Syck, if you prefer, for parsing and emitting YAML, but you
|
|
|
|
# must install the 'syck' gem now in order to use it.
|
|
|
|
#
|
|
|
|
# In older Ruby versions, ie. <= 1.9, Syck is still provided, however it was
|
|
|
|
# completely removed with the release of Ruby 2.0.0.
|
|
|
|
#
|
|
|
|
# == More info
|
|
|
|
#
|
2013-04-27 18:26:20 +04:00
|
|
|
# For more advanced details on the implementation see Psych, and also check out
|
2013-04-28 19:40:53 +04:00
|
|
|
# http://yaml.org for spec details and other helpful information.
|
2013-04-28 18:34:22 +04:00
|
|
|
module YAML
|
|
|
|
end
|