From d7e73ec4c238d0eb1c5493bb90c022d683123296 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Wed, 15 Feb 2012 23:59:42 +0100 Subject: Initial commit with skeleton of the project. Also added original Perl, together with PHP and Javascript ports. --- .gitignore | 2 + .gitmodules | 3 + Data-YAML-0.0.6/Changes | 14 + Data-YAML-0.0.6/MANIFEST | 16 + Data-YAML-0.0.6/META.yml | 21 + Data-YAML-0.0.6/Makefile | 833 +++++++++++++++++++++++ Data-YAML-0.0.6/Makefile.PL | 22 + Data-YAML-0.0.6/README | 22 + Data-YAML-0.0.6/SIGNATURE | 38 ++ Data-YAML-0.0.6/blib/arch/.exists | 0 Data-YAML-0.0.6/blib/arch/auto/Data/YAML/.exists | 0 Data-YAML-0.0.6/blib/bin/.exists | 0 Data-YAML-0.0.6/blib/lib/Data/.exists | 0 Data-YAML-0.0.6/blib/lib/Data/YAML.pm | 145 ++++ Data-YAML-0.0.6/blib/lib/Data/YAML/Reader.pm | 422 ++++++++++++ Data-YAML-0.0.6/blib/lib/Data/YAML/Writer.pm | 269 ++++++++ Data-YAML-0.0.6/blib/lib/auto/Data/YAML/.exists | 0 Data-YAML-0.0.6/blib/man1/.exists | 0 Data-YAML-0.0.6/blib/man3/.exists | 0 Data-YAML-0.0.6/blib/man3/Data::YAML.3pm | 264 +++++++ Data-YAML-0.0.6/blib/man3/Data::YAML::Reader.3pm | 243 +++++++ Data-YAML-0.0.6/blib/man3/Data::YAML::Writer.3pm | 261 +++++++ Data-YAML-0.0.6/blib/script/.exists | 0 Data-YAML-0.0.6/lib/Data/YAML.pm | 145 ++++ Data-YAML-0.0.6/lib/Data/YAML/Reader.pm | 422 ++++++++++++ Data-YAML-0.0.6/lib/Data/YAML/Writer.pm | 269 ++++++++ Data-YAML-0.0.6/pm_to_blib | 0 Data-YAML-0.0.6/t/00.load.t | 8 + Data-YAML-0.0.6/t/10-input.t | 103 +++ Data-YAML-0.0.6/t/20-reader.t | 419 ++++++++++++ Data-YAML-0.0.6/t/30-output.t | 107 +++ Data-YAML-0.0.6/t/40-writer.t | 200 ++++++ Data-YAML-0.0.6/t/pod-coverage.t | 9 + Data-YAML-0.0.6/t/pod.t | 6 + README | 6 + test/00.load.py | 10 + test/10-input.py | 103 +++ test/20-reader.py | 419 ++++++++++++ test/30-output.py | 107 +++ test/40-writer.py | 200 ++++++ test/pod-coverage.py | 9 + test/pod.py | 6 + yamlish.js | 1 + yamlish.py | 1 + yamlishwriter-php-v0.0.1/Changes | 3 + yamlishwriter-php-v0.0.1/MANIFEST | 10 + yamlishwriter-php-v0.0.1/Makefile | 21 + yamlishwriter-php-v0.0.1/README | 33 + yamlishwriter-php-v0.0.1/dist.sh | 16 + yamlishwriter-php-v0.0.1/lib/yamlishwriter.php | 125 ++++ yamlishwriter-php-v0.0.1/t/00-load.php | 9 + yamlishwriter-php-v0.0.1/t/10-writer.php | 180 +++++ yamlishwriter-php-v0.0.1/t/harness.t | 29 + yamlishwriter-php-v0.0.1/t/lib/TestLite.php | 79 +++ 54 files changed, 5630 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Data-YAML-0.0.6/Changes create mode 100644 Data-YAML-0.0.6/MANIFEST create mode 100644 Data-YAML-0.0.6/META.yml create mode 100644 Data-YAML-0.0.6/Makefile create mode 100644 Data-YAML-0.0.6/Makefile.PL create mode 100644 Data-YAML-0.0.6/README create mode 100644 Data-YAML-0.0.6/SIGNATURE create mode 100644 Data-YAML-0.0.6/blib/arch/.exists create mode 100644 Data-YAML-0.0.6/blib/arch/auto/Data/YAML/.exists create mode 100644 Data-YAML-0.0.6/blib/bin/.exists create mode 100644 Data-YAML-0.0.6/blib/lib/Data/.exists create mode 100644 Data-YAML-0.0.6/blib/lib/Data/YAML.pm create mode 100644 Data-YAML-0.0.6/blib/lib/Data/YAML/Reader.pm create mode 100644 Data-YAML-0.0.6/blib/lib/Data/YAML/Writer.pm create mode 100644 Data-YAML-0.0.6/blib/lib/auto/Data/YAML/.exists create mode 100644 Data-YAML-0.0.6/blib/man1/.exists create mode 100644 Data-YAML-0.0.6/blib/man3/.exists create mode 100644 Data-YAML-0.0.6/blib/man3/Data::YAML.3pm create mode 100644 Data-YAML-0.0.6/blib/man3/Data::YAML::Reader.3pm create mode 100644 Data-YAML-0.0.6/blib/man3/Data::YAML::Writer.3pm create mode 100644 Data-YAML-0.0.6/blib/script/.exists create mode 100644 Data-YAML-0.0.6/lib/Data/YAML.pm create mode 100644 Data-YAML-0.0.6/lib/Data/YAML/Reader.pm create mode 100644 Data-YAML-0.0.6/lib/Data/YAML/Writer.pm create mode 100644 Data-YAML-0.0.6/pm_to_blib create mode 100644 Data-YAML-0.0.6/t/00.load.t create mode 100644 Data-YAML-0.0.6/t/10-input.t create mode 100644 Data-YAML-0.0.6/t/20-reader.t create mode 100644 Data-YAML-0.0.6/t/30-output.t create mode 100644 Data-YAML-0.0.6/t/40-writer.t create mode 100644 Data-YAML-0.0.6/t/pod-coverage.t create mode 100644 Data-YAML-0.0.6/t/pod.t create mode 100644 README create mode 100644 test/00.load.py create mode 100644 test/10-input.py create mode 100644 test/20-reader.py create mode 100644 test/30-output.py create mode 100644 test/40-writer.py create mode 100644 test/pod-coverage.py create mode 100644 test/pod.py create mode 160000 yamlish.js create mode 100644 yamlish.py create mode 100644 yamlishwriter-php-v0.0.1/Changes create mode 100644 yamlishwriter-php-v0.0.1/MANIFEST create mode 100644 yamlishwriter-php-v0.0.1/Makefile create mode 100644 yamlishwriter-php-v0.0.1/README create mode 100755 yamlishwriter-php-v0.0.1/dist.sh create mode 100644 yamlishwriter-php-v0.0.1/lib/yamlishwriter.php create mode 100644 yamlishwriter-php-v0.0.1/t/00-load.php create mode 100644 yamlishwriter-php-v0.0.1/t/10-writer.php create mode 100644 yamlishwriter-php-v0.0.1/t/harness.t create mode 100644 yamlishwriter-php-v0.0.1/t/lib/TestLite.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e388c1d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.py[ocw] +*~ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a514517 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "yamlish.js"] + path = yamlish.js + url = git://github.com/isaacs/yamlish.git diff --git a/Data-YAML-0.0.6/Changes b/Data-YAML-0.0.6/Changes new file mode 100644 index 0000000..7dd53ea --- /dev/null +++ b/Data-YAML-0.0.6/Changes @@ -0,0 +1,14 @@ +Revision history for Data-YAML + +0.0.3 2007-03-17 + - Initial release. + +0.0.4 2007-03-17 + - Added tests for input / output modes + - Added the tests to MANIFEST. D'oh. + +0.0.5 2007-03-20 + +0.0.6 2009-03-07 + - Fix ESCAPE_CHAR regex. Refs #31804. + diff --git a/Data-YAML-0.0.6/MANIFEST b/Data-YAML-0.0.6/MANIFEST new file mode 100644 index 0000000..cd73769 --- /dev/null +++ b/Data-YAML-0.0.6/MANIFEST @@ -0,0 +1,16 @@ +Changes +lib/Data/YAML.pm +lib/Data/YAML/Reader.pm +lib/Data/YAML/Writer.pm +Makefile.PL +MANIFEST +README +t/00.load.t +t/10-input.t +t/20-reader.t +t/30-output.t +t/40-writer.t +t/pod-coverage.t +t/pod.t +META.yml Module meta-data (added by MakeMaker) +SIGNATURE Public-key signature (added by MakeMaker) diff --git a/Data-YAML-0.0.6/META.yml b/Data-YAML-0.0.6/META.yml new file mode 100644 index 0000000..de934af --- /dev/null +++ b/Data-YAML-0.0.6/META.yml @@ -0,0 +1,21 @@ +--- #YAML:1.0 +name: Data-YAML +version: 0.0.6 +abstract: Easy YAML serialisation of Perl data structures +author: + - Andy Armstrong +license: perl +distribution_type: module +configure_requires: + ExtUtils::MakeMaker: 0 +requires: + Test::More: 0 + version: 0 +no_index: + directory: + - t + - inc +generated_by: ExtUtils::MakeMaker version 6.48 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 diff --git a/Data-YAML-0.0.6/Makefile b/Data-YAML-0.0.6/Makefile new file mode 100644 index 0000000..2364db0 --- /dev/null +++ b/Data-YAML-0.0.6/Makefile @@ -0,0 +1,833 @@ +# This Makefile is for the Data::YAML extension to perl. +# +# It was generated automatically by MakeMaker version +# 6.55_02 (Revision: 65502) from the contents of +# Makefile.PL. Don't edit this file, edit Makefile.PL instead. +# +# ANY CHANGES MADE HERE WILL BE LOST! +# +# MakeMaker ARGV: () +# + +# MakeMaker Parameters: + +# ABSTRACT_FROM => q[lib/Data/YAML.pm] +# AUTHOR => q[Andy Armstrong ] +# BUILD_REQUIRES => { } +# LICENSE => q[perl] +# NAME => q[Data::YAML] +# PL_FILES => { } +# PREREQ_PM => { Test::More=>q[0], version=>q[0] } +# SIGN => q[1] +# VERSION_FROM => q[lib/Data/YAML.pm] +# clean => { FILES=>q[Data-YAML-*] } +# dist => { COMPRESS=>q[gzip -9f], SUFFIX=>q[gz] } + +# --- MakeMaker post_initialize section: + + +# --- MakeMaker const_config section: + +# These definitions are from config.sh (via /usr/lib64/perl5/Config.pm). +# They may have been overridden via Makefile.PL or on the command line. +AR = ar +CC = gcc +CCCDLFLAGS = -fPIC +CCDLFLAGS = -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE +DLEXT = so +DLSRC = dl_dlopen.xs +EXE_EXT = +FULL_AR = /usr/bin/ar +LD = gcc +LDDLFLAGS = -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic +LDFLAGS = -fstack-protector +LIBC = +LIB_EXT = .a +OBJ_EXT = .o +OSNAME = linux +OSVERS = 2.6.18-274.3.1.el5 +RANLIB = : +SITELIBEXP = /usr/local/share/perl5 +SITEARCHEXP = /usr/local/lib64/perl5 +SO = so +VENDORARCHEXP = /usr/lib64/perl5/vendor_perl +VENDORLIBEXP = /usr/share/perl5/vendor_perl + + +# --- MakeMaker constants section: +AR_STATIC_ARGS = cr +DIRFILESEP = / +DFSEP = $(DIRFILESEP) +NAME = Data::YAML +NAME_SYM = Data_YAML +VERSION = 0.0.6 +VERSION_MACRO = VERSION +VERSION_SYM = 0_0_6 +DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" +XS_VERSION = 0.0.6 +XS_VERSION_MACRO = XS_VERSION +XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" +INST_ARCHLIB = blib/arch +INST_SCRIPT = blib/script +INST_BIN = blib/bin +INST_LIB = blib/lib +INST_MAN1DIR = blib/man1 +INST_MAN3DIR = blib/man3 +MAN1EXT = 1 +MAN3EXT = 3pm +INSTALLDIRS = site +DESTDIR = +PREFIX = $(SITEPREFIX) +PERLPREFIX = /usr +SITEPREFIX = /usr/local +VENDORPREFIX = /usr +INSTALLPRIVLIB = /usr/share/perl5 +DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) +INSTALLSITELIB = /usr/local/share/perl5 +DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) +INSTALLVENDORLIB = /usr/share/perl5/vendor_perl +DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) +INSTALLARCHLIB = /usr/lib64/perl5 +DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) +INSTALLSITEARCH = /usr/local/lib64/perl5 +DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) +INSTALLVENDORARCH = /usr/lib64/perl5/vendor_perl +DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) +INSTALLBIN = /usr/bin +DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) +INSTALLSITEBIN = /usr/local/bin +DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) +INSTALLVENDORBIN = /usr/bin +DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) +INSTALLSCRIPT = /usr/bin +DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) +INSTALLSITESCRIPT = /usr/local/bin +DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT) +INSTALLVENDORSCRIPT = /usr/bin +DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT) +INSTALLMAN1DIR = /usr/share/man/man1 +DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) +INSTALLSITEMAN1DIR = /usr/local/share/man/man1 +DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) +INSTALLVENDORMAN1DIR = /usr/share/man/man1 +DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) +INSTALLMAN3DIR = /usr/share/man/man3 +DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) +INSTALLSITEMAN3DIR = /usr/local/share/man/man3 +DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) +INSTALLVENDORMAN3DIR = /usr/share/man/man3 +DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) +PERL_LIB = /usr/share/perl5 +PERL_ARCHLIB = /usr/lib64/perl5 +LIBPERL_A = libperl.a +FIRST_MAKEFILE = Makefile +MAKEFILE_OLD = Makefile.old +MAKE_APERL_FILE = Makefile.aperl +PERLMAINCC = $(CC) +PERL_INC = /usr/lib64/perl5/CORE +PERL = /usr/bin/perl +FULLPERL = /usr/bin/perl +ABSPERL = $(PERL) +PERLRUN = $(PERL) +FULLPERLRUN = $(FULLPERL) +ABSPERLRUN = $(ABSPERL) +PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" +FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" +ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" +PERL_CORE = 0 +PERM_DIR = 755 +PERM_RW = 644 +PERM_RWX = 755 + +MAKEMAKER = /usr/share/perl5/ExtUtils/MakeMaker.pm +MM_VERSION = 6.55_02 +MM_REVISION = 65502 + +# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). +# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) +# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) +# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +MAKE = make +FULLEXT = Data/YAML +BASEEXT = YAML +PARENT_NAME = Data +DLBASE = $(BASEEXT) +VERSION_FROM = lib/Data/YAML.pm +OBJECT = +LDFROM = $(OBJECT) +LINKTYPE = dynamic +BOOTDEP = + +# Handy lists of source code files: +XS_FILES = +C_FILES = +O_FILES = +H_FILES = +MAN1PODS = +MAN3PODS = lib/Data/YAML.pm \ + lib/Data/YAML/Reader.pm \ + lib/Data/YAML/Writer.pm + +# Where is the Config information that we are using/depend on +CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h + +# Where to build things +INST_LIBDIR = $(INST_LIB)/Data +INST_ARCHLIBDIR = $(INST_ARCHLIB)/Data + +INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) +INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) + +INST_STATIC = +INST_DYNAMIC = +INST_BOOT = + +# Extra linker info +EXPORT_LIST = +PERL_ARCHIVE = +PERL_ARCHIVE_AFTER = + + +TO_INST_PM = lib/Data/YAML.pm \ + lib/Data/YAML/Reader.pm \ + lib/Data/YAML/Writer.pm + +PM_TO_BLIB = lib/Data/YAML/Reader.pm \ + blib/lib/Data/YAML/Reader.pm \ + lib/Data/YAML.pm \ + blib/lib/Data/YAML.pm \ + lib/Data/YAML/Writer.pm \ + blib/lib/Data/YAML/Writer.pm + + +# --- MakeMaker platform_constants section: +MM_Unix_VERSION = 6.55_02 +PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc + + +# --- MakeMaker tool_autosplit section: +# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto +AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' -- + + + +# --- MakeMaker tool_xsubpp section: + + +# --- MakeMaker tools_other section: +SHELL = /bin/sh +CHMOD = chmod +CP = cp +MV = mv +NOOP = $(TRUE) +NOECHO = @ +RM_F = rm -f +RM_RF = rm -rf +TEST_F = test -f +TOUCH = touch +UMASK_NULL = umask 0 +DEV_NULL = > /dev/null 2>&1 +MKPATH = $(ABSPERLRUN) -MExtUtils::Command -e 'mkpath' -- +EQUALIZE_TIMESTAMP = $(ABSPERLRUN) -MExtUtils::Command -e 'eqtime' -- +FALSE = false +TRUE = true +ECHO = echo +ECHO_N = echo -n +UNINST = 0 +VERBINST = 0 +MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {@ARGV}, verbose => '\''$(VERBINST)'\'', uninstall_shadows => '\''$(UNINST)'\'', dir_mode => '\''$(PERM_DIR)'\'' ]);' -- +DOC_INSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'perllocal_install' -- +UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' -- +WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' -- +MACROSTART = +MACROEND = +USEMAKEFILE = -f +FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' -- + + +# --- MakeMaker makemakerdflt section: +makemakerdflt : all + $(NOECHO) $(NOOP) + + +# --- MakeMaker dist section: +TAR = tar +TARFLAGS = cvf +ZIP = zip +ZIPFLAGS = -r +COMPRESS = gzip -9f +SUFFIX = gz +SHAR = shar +PREOP = $(NOECHO) $(NOOP) +POSTOP = $(NOECHO) $(NOOP) +TO_UNIX = $(NOECHO) $(NOOP) +CI = ci -u +RCS_LABEL = rcs -Nv$(VERSION_SYM): -q +DIST_CP = best +DIST_DEFAULT = tardist +DISTNAME = Data-YAML +DISTVNAME = Data-YAML-0.0.6 + + +# --- MakeMaker macro section: + + +# --- MakeMaker depend section: + + +# --- MakeMaker cflags section: + + +# --- MakeMaker const_loadlibs section: + + +# --- MakeMaker const_cccmd section: + + +# --- MakeMaker post_constants section: + + +# --- MakeMaker pasthru section: + +PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ + LINKTYPE="$(LINKTYPE)"\ + PREFIX="$(PREFIX)" + + +# --- MakeMaker special_targets section: +.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) + +.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir + + + +# --- MakeMaker c_o section: + + +# --- MakeMaker xs_c section: + + +# --- MakeMaker xs_o section: + + +# --- MakeMaker top_targets section: +all :: pure_all manifypods + $(NOECHO) $(NOOP) + + +pure_all :: config pm_to_blib subdirs linkext + $(NOECHO) $(NOOP) + +subdirs :: $(MYEXTLIB) + $(NOECHO) $(NOOP) + +config :: $(FIRST_MAKEFILE) blibdirs + $(NOECHO) $(NOOP) + +help : + perldoc ExtUtils::MakeMaker + + +# --- MakeMaker blibdirs section: +blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists + $(NOECHO) $(NOOP) + +# Backwards compat with 6.18 through 6.25 +blibdirs.ts : blibdirs + $(NOECHO) $(NOOP) + +$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_LIBDIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR) + $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists + +$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHLIB) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB) + $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists + +$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_AUTODIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR) + $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists + +$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR) + $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists + +$(INST_BIN)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_BIN) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN) + $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists + +$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_SCRIPT) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT) + $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists + +$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN1DIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR) + $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists + +$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN3DIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR) + $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists + + + +# --- MakeMaker linkext section: + +linkext :: $(LINKTYPE) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dlsyms section: + + +# --- MakeMaker dynamic section: + +dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dynamic_bs section: + +BOOTSTRAP = + + +# --- MakeMaker dynamic_lib section: + + +# --- MakeMaker static section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make static" +static :: $(FIRST_MAKEFILE) $(INST_STATIC) + $(NOECHO) $(NOOP) + + +# --- MakeMaker static_lib section: + + +# --- MakeMaker manifypods section: + +POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" +POD2MAN = $(POD2MAN_EXE) + + +manifypods : pure_all \ + lib/Data/YAML/Reader.pm \ + lib/Data/YAML.pm \ + lib/Data/YAML/Writer.pm + $(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) \ + lib/Data/YAML/Reader.pm $(INST_MAN3DIR)/Data::YAML::Reader.$(MAN3EXT) \ + lib/Data/YAML.pm $(INST_MAN3DIR)/Data::YAML.$(MAN3EXT) \ + lib/Data/YAML/Writer.pm $(INST_MAN3DIR)/Data::YAML::Writer.$(MAN3EXT) + + + + +# --- MakeMaker processPL section: + + +# --- MakeMaker installbin section: + + +# --- MakeMaker subdirs section: + +# none + +# --- MakeMaker clean_subdirs section: +clean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker clean section: + +# Delete temporary files but do not touch installed files. We don't delete +# the Makefile here so a later make realclean still has a makefile to use. + +clean :: clean_subdirs + - $(RM_F) \ + *$(LIB_EXT) core \ + core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \ + core.[0-9][0-9] $(BASEEXT).bso \ + pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \ + $(BASEEXT).x $(BOOTSTRAP) \ + perl$(EXE_EXT) tmon.out \ + *$(OBJ_EXT) pm_to_blib \ + $(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \ + core.[0-9][0-9][0-9][0-9][0-9] *perl.core \ + core.*perl.*.? $(MAKE_APERL_FILE) \ + perl $(BASEEXT).def \ + core.[0-9][0-9][0-9] mon.out \ + lib$(BASEEXT).def perlmain.c \ + perl.exe so_locations \ + $(BASEEXT).exp + - $(RM_RF) \ + Data-YAML-* blib + - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) + + +# --- MakeMaker realclean_subdirs section: +realclean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker realclean section: +# Delete temporary files (via clean) and also delete dist files +realclean purge :: clean realclean_subdirs + - $(RM_F) \ + $(MAKEFILE_OLD) $(FIRST_MAKEFILE) + - $(RM_RF) \ + $(DISTVNAME) + + +# --- MakeMaker metafile section: +metafile : create_distdir + $(NOECHO) $(ECHO) Generating META.yml + $(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml + $(NOECHO) $(ECHO) 'name: Data-YAML' >> META_new.yml + $(NOECHO) $(ECHO) 'version: 0.0.6' >> META_new.yml + $(NOECHO) $(ECHO) 'abstract: Easy YAML serialisation of Perl data structures' >> META_new.yml + $(NOECHO) $(ECHO) 'author:' >> META_new.yml + $(NOECHO) $(ECHO) ' - Andy Armstrong ' >> META_new.yml + $(NOECHO) $(ECHO) 'license: perl' >> META_new.yml + $(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml + $(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml + $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml + $(NOECHO) $(ECHO) 'build_requires:' >> META_new.yml + $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml + $(NOECHO) $(ECHO) 'requires:' >> META_new.yml + $(NOECHO) $(ECHO) ' Test::More: 0' >> META_new.yml + $(NOECHO) $(ECHO) ' version: 0' >> META_new.yml + $(NOECHO) $(ECHO) 'no_index:' >> META_new.yml + $(NOECHO) $(ECHO) ' directory:' >> META_new.yml + $(NOECHO) $(ECHO) ' - t' >> META_new.yml + $(NOECHO) $(ECHO) ' - inc' >> META_new.yml + $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.55_02' >> META_new.yml + $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml + $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml + $(NOECHO) $(ECHO) ' version: 1.4' >> META_new.yml + -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml + + +# --- MakeMaker signature section: +signature : + cpansign -s + + +# --- MakeMaker dist_basics section: +distclean :: realclean distcheck + $(NOECHO) $(NOOP) + +distcheck : + $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck + +skipcheck : + $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck + +manifest : + $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest + +veryclean : realclean + $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old + + + +# --- MakeMaker dist_core section: + +dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) + $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ + -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' -- + +tardist : $(DISTVNAME).tar$(SUFFIX) + $(NOECHO) $(NOOP) + +uutardist : $(DISTVNAME).tar$(SUFFIX) + uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu + +$(DISTVNAME).tar$(SUFFIX) : distdir + $(PREOP) + $(TO_UNIX) + $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(COMPRESS) $(DISTVNAME).tar + $(POSTOP) + +zipdist : $(DISTVNAME).zip + $(NOECHO) $(NOOP) + +$(DISTVNAME).zip : distdir + $(PREOP) + $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(POSTOP) + +shdist : distdir + $(PREOP) + $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar + $(RM_RF) $(DISTVNAME) + $(POSTOP) + + +# --- MakeMaker distdir section: +create_distdir : + $(RM_RF) $(DISTVNAME) + $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ + -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" + +distdir : create_distdir distmeta distsignature + $(NOECHO) $(NOOP) + + + +# --- MakeMaker dist_test section: +disttest : distdir + cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL + cd $(DISTVNAME) && $(MAKE) $(PASTHRU) + cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) + + + +# --- MakeMaker dist_ci section: + +ci : + $(PERLRUN) "-MExtUtils::Manifest=maniread" \ + -e "@all = keys %{ maniread() };" \ + -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ + -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" + + +# --- MakeMaker distmeta section: +distmeta : create_distdir metafile + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' -- + + + +# --- MakeMaker distsignature section: +distsignature : create_distdir + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' -- + $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE + cd $(DISTVNAME) && cpansign -s + + + +# --- MakeMaker install section: + +install :: pure_install doc_install + $(NOECHO) $(NOOP) + +install_perl :: pure_perl_install doc_perl_install + $(NOECHO) $(NOOP) + +install_site :: pure_site_install doc_site_install + $(NOECHO) $(NOOP) + +install_vendor :: pure_vendor_install doc_vendor_install + $(NOECHO) $(NOOP) + +pure_install :: pure_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) + +doc_install :: doc_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) + +pure__install : pure_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +doc__install : doc_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +pure_perl_install :: all + $(NOECHO) $(MOD_INSTALL) \ + read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLPRIVLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ + $(INST_BIN) $(DESTINSTALLBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(SITEARCHEXP)/auto/$(FULLEXT) + + +pure_site_install :: all + $(NOECHO) $(MOD_INSTALL) \ + read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLSITELIB) \ + $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ + $(INST_BIN) $(DESTINSTALLSITEBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(PERL_ARCHLIB)/auto/$(FULLEXT) + +pure_vendor_install :: all + $(NOECHO) $(MOD_INSTALL) \ + read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLVENDORLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ + $(INST_BIN) $(DESTINSTALLVENDORBIN) \ + $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) + +doc_perl_install :: all + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLPRIVLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_site_install :: all + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLSITELIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_vendor_install :: all + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLVENDORLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + + +uninstall :: uninstall_from_$(INSTALLDIRS)dirs + $(NOECHO) $(NOOP) + +uninstall_from_perldirs :: + $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist + +uninstall_from_sitedirs :: + $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist + +uninstall_from_vendordirs :: + $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist + + +# --- MakeMaker force section: +# Phony target to force checking subdirectories. +FORCE : + $(NOECHO) $(NOOP) + + +# --- MakeMaker perldepend section: + + +# --- MakeMaker makefile section: +# We take a very conservative approach here, but it's worth it. +# We move Makefile to Makefile.old here to avoid gnu make looping. +$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) + $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" + $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." + -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) + -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) + $(PERLRUN) Makefile.PL + $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" + $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" + $(FALSE) + + + +# --- MakeMaker staticmake section: + +# --- MakeMaker makeaperl section --- +MAP_TARGET = perl +FULLPERL = /usr/bin/perl + +$(MAP_TARGET) :: static $(MAKE_APERL_FILE) + $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ + +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib + $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) + $(NOECHO) $(PERLRUNINST) \ + Makefile.PL DIR= \ + MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ + MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= + + +# --- MakeMaker test section: + +TEST_VERBOSE=0 +TEST_TYPE=test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = t/*.t +TESTDB_SW = -d + +testdb :: testdb_$(LINKTYPE) + +test :: $(TEST_TYPE) subdirs-test + +subdirs-test :: + $(NOECHO) $(NOOP) + + +test_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) + +testdb_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) + +test_ : test_dynamic + +test_static :: test_dynamic +testdb_static :: testdb_dynamic + + +# --- MakeMaker ppd section: +# Creates a PPD (Perl Package Description) for a binary distribution. +ppd : + $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' Easy YAML serialisation of Perl data structures' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' Andy Armstrong <andy@hexten.net>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd + + +# --- MakeMaker pm_to_blib section: + +pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM) + $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \ + lib/Data/YAML/Reader.pm blib/lib/Data/YAML/Reader.pm \ + lib/Data/YAML.pm blib/lib/Data/YAML.pm \ + lib/Data/YAML/Writer.pm blib/lib/Data/YAML/Writer.pm + $(NOECHO) $(TOUCH) pm_to_blib + + +# --- MakeMaker selfdocument section: + + +# --- MakeMaker postamble section: + + +# End. diff --git a/Data-YAML-0.0.6/Makefile.PL b/Data-YAML-0.0.6/Makefile.PL new file mode 100644 index 0000000..d04335d --- /dev/null +++ b/Data-YAML-0.0.6/Makefile.PL @@ -0,0 +1,22 @@ +use strict; +use warnings; +use ExtUtils::MakeMaker; + +eval 'use ExtUtils::MakeMaker::Coverage'; +warn "Optional ExtUtils::MakeMaker::Coverage not available\n" if $@; + +WriteMakefile( + ( MM->can( 'signature_target' ) ? ( SIGN => 1 ) : () ), + NAME => 'Data::YAML', + AUTHOR => 'Andy Armstrong ', + LICENSE => 'perl', + VERSION_FROM => 'lib/Data/YAML.pm', + ABSTRACT_FROM => 'lib/Data/YAML.pm', + PL_FILES => {}, + PREREQ_PM => { + 'Test::More' => 0, + 'version' => 0, + }, + dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, + clean => { FILES => 'Data-YAML-*' }, +); diff --git a/Data-YAML-0.0.6/README b/Data-YAML-0.0.6/README new file mode 100644 index 0000000..21ce3a9 --- /dev/null +++ b/Data-YAML-0.0.6/README @@ -0,0 +1,22 @@ +Data-YAML version 0.0.6 + +INSTALLATION + +To install this module, run the following commands: + + perl Makefile.PL + make + make test + make install + + +DEPENDENCIES + +None. + +COPYRIGHT AND LICENCE + +Copyright (C) 2007, Andy Armstrong + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. diff --git a/Data-YAML-0.0.6/SIGNATURE b/Data-YAML-0.0.6/SIGNATURE new file mode 100644 index 0000000..d8abc76 --- /dev/null +++ b/Data-YAML-0.0.6/SIGNATURE @@ -0,0 +1,38 @@ +This file contains message digests of all files listed in MANIFEST, +signed via the Module::Signature module, version 0.55. + +To verify the content in this distribution, first make sure you have +Module::Signature installed, then type: + + % cpansign -v + +It will check each file's integrity, as well as the signature's +validity. If "==> Signature verified OK! <==" is not displayed, +the distribution may already have been compromised, and you should +not run its Makefile.PL or Build.PL. + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +SHA1 a796da56d11015113d6690491bd352c9958c5c64 Changes +SHA1 1f4a6f38328ce9be2882634c0bdc84d6d9cb98e4 MANIFEST +SHA1 06f48c95ab84fcd8dd0e1a92e45c48dd8b65395e META.yml +SHA1 6a0c4a0f0093335e6e1e8f7d6fd1fcecad0c4a83 Makefile.PL +SHA1 0aa5814a1f2c123d5b0f51643a1eff297543e589 README +SHA1 446ba3a109b32a9091b4313fb1b70bb1e704ed76 lib/Data/YAML.pm +SHA1 32611505ba10508d42104ee676466edd0f7ffa89 lib/Data/YAML/Reader.pm +SHA1 ae4f9923febd88025bb2f923b1f6b6e8ec5e9982 lib/Data/YAML/Writer.pm +SHA1 4cf9e6d03b2ba3e3ab482d138a94e95c6ecf6492 t/00.load.t +SHA1 161ecef48d8e921399c3406cc2b2ca85442bd0e7 t/10-input.t +SHA1 e3de4eff0004dcaf16aaed29a3df478f50a7058c t/20-reader.t +SHA1 ae69251cc811bc4934ad08c165f34be398474e4f t/30-output.t +SHA1 9b7b9be6fd31c4b378dd4b1a866cb68a51b1030c t/40-writer.t +SHA1 aeaa691851a425f07ab6a8d4f825e2ad9d92b8ee t/pod-coverage.t +SHA1 0190346d7072d458c8a10a45c19f86db641dcc48 t/pod.t +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.9 (Darwin) + +iEYEARECAAYFAkmzB+4ACgkQwoknRJZQnCEljwCgiQmQmQlvYQOTc118yk1GxyRk +O2IAoMAritfzopChUsyF9HyFXCFUrfLl +=o0s7 +-----END PGP SIGNATURE----- diff --git a/Data-YAML-0.0.6/blib/arch/.exists b/Data-YAML-0.0.6/blib/arch/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/blib/arch/auto/Data/YAML/.exists b/Data-YAML-0.0.6/blib/arch/auto/Data/YAML/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/blib/bin/.exists b/Data-YAML-0.0.6/blib/bin/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/blib/lib/Data/.exists b/Data-YAML-0.0.6/blib/lib/Data/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/blib/lib/Data/YAML.pm b/Data-YAML-0.0.6/blib/lib/Data/YAML.pm new file mode 100644 index 0000000..dd6716b --- /dev/null +++ b/Data-YAML-0.0.6/blib/lib/Data/YAML.pm @@ -0,0 +1,145 @@ +package Data::YAML; + +use strict; +use warnings; + +use vars qw{$VERSION}; + +$VERSION = '0.0.6'; + +1; + +__END__ + +=head1 NAME + +Data::YAML - Easy YAML serialisation of Perl data structures + +=head1 VERSION + +This document describes Data::YAML version 0.0.6 + +=head1 DESCRIPTION + +In the spirit of L, L and +L provide lightweight, dependency-free YAML +handling. While C is designed principally for working with +configuration files C concentrates on the transparent round- +tripping of YAML serialized Perl data structures. + +As an example of why this distinction matters consider that +C doesn't handle hashes with keys containing non-printable +characters. This is fine for configuration files but likely to cause +problems when handling arbitrary Perl data structures. C +handles exotic hash keys correctly. + +The syntax accepted by C is a subset of YAML. Specifically +it is the same subset of YAML that L produces. See +L for more information. + +=head2 YAML syntax + +Although YAML appears to be a simple language the entire YAML +specification is huge. C implements a small subset of the +complete syntax trading completeness for compactness and simplicity. +This restricted syntax is known (to me at least) as 'YAMLish'. + +These examples demonstrates the full range of supported syntax. + +All YAML documents must begin with '---' and end with a line +containing '...'. + + --- Simple scalar + ... + +Unprintable characters are represented using standard escapes in double +quoted strings. + + --- "\t\x01\x02\n" + ... + +Array and hashes are represented thusly + + --- + - "This" + - "is" + - "an" + - "array" + ... + + --- + This: is + a: hash + ... + +Structures may nest arbitrarily + + --- + - + name: 'Hash one' + value: 1 + - + name: 'Hash two' + value: 2 + ... + +Undef is a tilde + + --- ~ + ... + +=head2 Uses + +Use C may be used any time you need to freeze and thaw Perl +data structures into a human readable format. The output from +C should be readable by any YAML parser. + +C was originally written to allow machine-readable +diagnostic information to be passed from test scripts to +L. That means that if you're writing a testing system that +needs to output TAP version 13 or later syntax you might find +C useful. + +Read more about TAP and YAMLish here: L + +=head1 BUGS AND LIMITATIONS + +No bugs have been reported. + +Please report any bugs or feature requests to +C, or through the web interface at +L. + +=head1 AUTHOR + +Andy Armstrong C<< >> + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. + +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See L. + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. diff --git a/Data-YAML-0.0.6/blib/lib/Data/YAML/Reader.pm b/Data-YAML-0.0.6/blib/lib/Data/YAML/Reader.pm new file mode 100644 index 0000000..dbd5189 --- /dev/null +++ b/Data-YAML-0.0.6/blib/lib/Data/YAML/Reader.pm @@ -0,0 +1,422 @@ +package Data::YAML::Reader; + +use strict; +use warnings; +use Carp; + +use vars qw{$VERSION}; + +$VERSION = '0.0.6'; + +# TODO: +# Handle blessed object syntax + +# Printable characters for escapes +my %UNESCAPES = ( + z => "\x00", + a => "\x07", + t => "\x09", + n => "\x0a", + v => "\x0b", + f => "\x0c", + r => "\x0d", + e => "\x1b", + '\\' => '\\', +); + +my $QQ_STRING = qr{ " (?:\\. | [^"])* " }x; +my $HASH_LINE = qr{ ^ ($QQ_STRING|\S+) \s* : (?: \s+ (.+?) \s* )? $ }x; +my $IS_HASH_KEY = qr{ ^ [\w\'\"] }x; +my $IS_END_YAML = qr{ ^ [.][.][.] \s* $ }x; +my $IS_QQ_STRING = qr{ ^ $QQ_STRING $ }x; + +# Create an empty Data::YAML::Reader object +sub new { + my $class = shift; + bless {}, $class; +} + +sub _make_reader { + my $self = shift; + my $obj = shift; + + croak "Must have something to read from" + unless defined $obj; + + if ( my $ref = ref $obj ) { + if ( 'CODE' eq $ref ) { + return $obj; + } + elsif ( 'ARRAY' eq $ref ) { + return sub { shift @$obj }; + } + elsif ( 'SCALAR' eq $ref ) { + return $self->_make_reader( $$obj ); + } + elsif ( 'GLOB' eq $ref || 'IO::Handle' eq $ref ) { + return sub { + my $line = <$obj>; + chomp $line if defined $line; + return $line; + }; + } + croak "Don't know how to read $ref"; + } + else { + my @lines = split( /\n/, $obj ); + return sub { shift @lines }; + } +} + +sub read { + my $self = shift; + my $obj = shift; + + $self->{reader} = $self->_make_reader( $obj ); + $self->{capture} = []; + + # Prime the reader + $self->_next; + + my $doc = $self->_read; + + # The terminator is mandatory otherwise we'd consume a line from the + # iterator that doesn't belong to us. If we want to remove this + # restriction we'll have to implement look-ahead in the iterators. + # Which might not be a bad idea. + my $dots = $self->_peek; + croak "Missing '...' at end of YAML" + unless $dots =~ $IS_END_YAML; + + delete $self->{reader}; + delete $self->{next}; + + return $doc; +} + +sub get_raw { + my $self = shift; + + if ( defined( my $capture = $self->{capture} ) ) { + return join( "\n", @$capture ) . "\n"; + } + + return ''; +} + +sub _peek { + my $self = shift; + return $self->{next} unless wantarray; + my $line = $self->{next}; + $line =~ /^ (\s*) (.*) $ /x; + return ( $2, length $1 ); +} + +sub _next { + my $self = shift; + croak "_next called with no reader" + unless $self->{reader}; + my $line = $self->{reader}->(); + $self->{next} = $line; + push @{ $self->{capture} }, $line; +} + +sub _read { + my $self = shift; + + my $line = $self->_peek; + + # Do we have a document header? + if ( $line =~ /^ --- (?: \s* (.+?) \s* )? $/x ) { + $self->_next; + + return $self->_read_scalar( $1 ) if defined $1; # Inline? + + my ( $next, $indent ) = $self->_peek; + + if ( $next =~ /^ - /x ) { + return $self->_read_array( $indent ); + } + elsif ( $next =~ $IS_HASH_KEY ) { + return $self->_read_hash( $next, $indent ); + } + elsif ( $next =~ $IS_END_YAML ) { + croak "Premature end of YAML"; + } + else { + croak "Unsupported YAML syntax: '$next'"; + } + } + else { + croak "YAML document header not found"; + } +} + +# Parse a double quoted string +sub _read_qq { + my $self = shift; + my $str = shift; + + unless ( $str =~ s/^ " (.*?) " $/$1/x ) { + die "Internal: not a quoted string"; + } + + $str =~ s/\\"/"/gx; + $str =~ s/ \\ ( [tartan\\favez] | x([0-9a-fA-F]{2}) ) + / (length($1) > 1) ? pack("H2", $2) : $UNESCAPES{$1} /gex; + return $str; +} + +# Parse a scalar string to the actual scalar +sub _read_scalar { + my $self = shift; + my $string = shift; + + return undef if $string eq '~'; + + if ( $string eq '>' || $string eq '|' ) { + + my ( $line, $indent ) = $self->_peek; + die "Multi-line scalar content missing" unless defined $line; + + my @multiline = ( $line ); + + while ( 1 ) { + $self->_next; + my ( $next, $ind ) = $self->_peek; + last if $ind < $indent; + push @multiline, $next; + } + + return join( ( $string eq '>' ? ' ' : "\n" ), @multiline ) . "\n"; + } + + if ( $string =~ /^ ' (.*) ' $/x ) { + ( my $rv = $1 ) =~ s/''/'/g; + return $rv; + } + + if ( $string =~ $IS_QQ_STRING ) { + return $self->_read_qq( $string ); + } + + if ( $string =~ /^['"]/ ) { + + # A quote with folding... we don't support that + die __PACKAGE__ . " does not support multi-line quoted scalars"; + } + + # Regular unquoted string + return $string; +} + +sub _read_nested { + my $self = shift; + + my ( $line, $indent ) = $self->_peek; + + if ( $line =~ /^ -/x ) { + return $self->_read_array( $indent ); + } + elsif ( $line =~ $IS_HASH_KEY ) { + return $self->_read_hash( $line, $indent ); + } + else { + croak "Unsupported YAML syntax: '$line'"; + } +} + +# Parse an array +sub _read_array { + my ( $self, $limit ) = @_; + + my $ar = []; + + while ( 1 ) { + my ( $line, $indent ) = $self->_peek; + last if $indent < $limit || !defined $line || $line =~ $IS_END_YAML; + + if ( $indent > $limit ) { + croak "Array line over-indented"; + } + + if ( $line =~ /^ (- \s+) \S+ \s* : (?: \s+ | $ ) /x ) { + $indent += length $1; + $line =~ s/-\s+//; + push @$ar, $self->_read_hash( $line, $indent ); + } + elsif ( $line =~ /^ - \s* (.+?) \s* $/x ) { + croak "Unexpected start of YAML" if $line =~ /^---/; + $self->_next; + push @$ar, $self->_read_scalar( $1 ); + } + elsif ( $line =~ /^ - \s* $/x ) { + $self->_next; + push @$ar, $self->_read_nested; + } + elsif ( $line =~ $IS_HASH_KEY ) { + $self->_next; + push @$ar, $self->_read_hash( $line, $indent, ); + } + else { + croak "Unsupported YAML syntax: '$line'"; + } + } + + return $ar; +} + +sub _read_hash { + my ( $self, $line, $limit ) = @_; + + my $indent; + my $hash = {}; + + while ( 1 ) { + croak "Badly formed hash line: '$line'" + unless $line =~ $HASH_LINE; + + my ( $key, $value ) = ( $self->_read_scalar( $1 ), $2 ); + $self->_next; + + if ( defined $value ) { + $hash->{$key} = $self->_read_scalar( $value ); + } + else { + $hash->{$key} = $self->_read_nested; + } + + ( $line, $indent ) = $self->_peek; + last if $indent < $limit || !defined $line || $line =~ $IS_END_YAML; + } + + return $hash; +} + +1; + +__END__ + +=head1 NAME + +Data::YAML::Reader - Parse YAML created by Data::YAML::Writer + +=head1 VERSION + +This document describes Data::YAML::Reader version 0.0.6 + +=head1 SYNOPSIS + + use Data::YAML::Reader; + + my $yr = Data::YAML::Reader->new; + + # Read from an array... + my $from_array = $yr->read( \@some_array ); + + # ...an open file handle... + my $from_handle = $yr->read( $some_file ); + + # ...a string containing YAML... + my $from_string = $yr->read( $some_string ); + + # ...or a closure + my $from_code = $yr->read( sub { return get_next_line() } ); + +=head1 DESCRIPTION + +In the spirit of L this is a lightweight, dependency-free +YAML reader. While C is designed principally for working +with configuration files C concentrates on the transparent +round-tripping of YAML serialized Perl data structures. + +The syntax accepted by C is a subset of YAML. +Specifically it is the same subset of YAML that L +produces. See L for more information. + +=head1 INTERFACE + +=over + +=item C<< new >> + +Creates and returns an empty C object. No options may be passed. + +=item C<< read( $source ) >> + +Read YAML and return the data structure it represents. The YAML data may be supplied by a + +=over + +=item * scalar string containing YAML source + +=item * the handle of an open file + +=item * a reference to an array of lines + +=item * a code reference + +=back + +In the case of a code reference a subroutine (most likely a closure) +that returns successive lines of YAML must be supplied. Lines should +have no trailing newline. When the YAML is exhausted the subroutine must +return undef. + +Returns the data structure (specifically either a scalar, hash ref or +array ref) that results from decoding the YAML. + +=item C<< get_raw >> + +Return the raw YAML source from the most recent C. + +=back + +=head1 BUGS AND LIMITATIONS + +No bugs have been reported. + +Please report any bugs or feature requests to +C, or through the web interface at +L. + +=head1 SEE ALSO + +L, L, L, L, L + +=head1 AUTHOR + +Andy Armstrong C<< >> + +Adam Kennedy wrote L which provided the template and many of +the YAML matching regular expressions for this module. + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. + +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See L. + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. diff --git a/Data-YAML-0.0.6/blib/lib/Data/YAML/Writer.pm b/Data-YAML-0.0.6/blib/lib/Data/YAML/Writer.pm new file mode 100644 index 0000000..abce670 --- /dev/null +++ b/Data-YAML-0.0.6/blib/lib/Data/YAML/Writer.pm @@ -0,0 +1,269 @@ +package Data::YAML::Writer; + +use strict; +use warnings; +use Carp; + +use vars qw{$VERSION}; + +$VERSION = '0.0.6'; + +my $ESCAPE_CHAR = qr{ [\x00-\x1f\"] }x; + +my @UNPRINTABLE = qw( + z x01 x02 x03 x04 x05 x06 a + x08 t n v f r x0e x0f + x10 x11 x12 x13 x14 x15 x16 x17 + x18 x19 x1a e x1c x1d x1e x1f +); + +# Create an empty Data::YAML::Writer object +sub new { + my $class = shift; + bless {}, $class; +} + +sub write { + my $self = shift; + + croak "Need something to write" + unless @_; + + my $obj = shift; + my $out = shift || \*STDOUT; + + croak "Need a reference to something I can write to" + unless ref $out; + + $self->{writer} = $self->_make_writer( $out ); + + $self->_write_obj( '---', $obj ); + $self->_put( '...' ); + + delete $self->{writer}; +} + +sub _make_writer { + my $self = shift; + my $out = shift; + + my $ref = ref $out; + + if ( 'CODE' eq $ref ) { + return $out; + } + elsif ( 'ARRAY' eq $ref ) { + return sub { push @$out, shift }; + } + elsif ( 'SCALAR' eq $ref ) { + return sub { $$out .= shift() . "\n" }; + } + elsif ( 'GLOB' eq $ref || 'IO::Handle' eq $ref ) { + return sub { print $out shift(), "\n" }; + } + + croak "Can't write to $out"; +} + +sub _put { + my $self = shift; + $self->{writer}->( join '', @_ ); +} + +sub _enc_scalar { + my $self = shift; + my $val = shift; + + return '~' unless defined $val; + + if ( $val =~ /$ESCAPE_CHAR/ ) { + $val =~ s/\\/\\\\/g; + $val =~ s/"/\\"/g; + $val =~ s/ ( [\x00-\x1f] ) / '\\' . $UNPRINTABLE[ ord($1) ] /gex; + return qq{"$val"}; + } + + if ( length( $val ) == 0 or $val =~ /\s/ ) { + $val =~ s/'/''/; + return "'$val'"; + } + + return $val; +} + +sub _write_obj { + my $self = shift; + my $prefix = shift; + my $obj = shift; + my $indent = shift || 0; + + if ( my $ref = ref $obj ) { + my $pad = ' ' x $indent; + $self->_put( $prefix ); + if ( 'HASH' eq $ref ) { + for my $key ( sort keys %$obj ) { + my $value = $obj->{$key}; + $self->_write_obj( $pad . $self->_enc_scalar( $key ) . ':', + $value, $indent + 1 ); + } + } + elsif ( 'ARRAY' eq $ref ) { + for my $value ( @$obj ) { + $self->_write_obj( $pad . '-', $value, $indent + 1 ); + } + } + else { + croak "Don't know how to encode $ref"; + } + } + else { + $self->_put( $prefix, ' ', $self->_enc_scalar( $obj ) ); + } +} + +1; + +__END__ + + +=head1 NAME + +Data::YAML::Writer - Easy YAML serialisation + +=head1 VERSION + +This document describes Data::YAML::Writer version 0.0.6 + +=head1 SYNOPSIS + + use Data::YAML::Writer; + + my $data = { + one => 1, + two => 2, + three => [ 1, 2, 3 ], + }; + + my $yw = Data::YAML::Writer->new; + + # Write to an array... + $yw->write( $data, \@some_array ); + + # ...an open file handle... + $yw->write( $data, $some_file_handle ); + + # ...a string ... + $yw->write( $data, \$some_string ); + + # ...or a closure + $yw->write( $data, sub { + my $line = shift; + print "$line\n"; + } ); + + +=head1 DESCRIPTION + +Encodes a scalar, hash reference or array reference as YAML. + +In the spirit of L this is a lightweight, dependency-free +YAML writer. While C is designed principally for working +with configuration files C concentrates on the transparent +round-tripping of YAML serialized Perl data structures. + +The syntax produced by C is a subset of YAML. +Specifically it is the same subset of YAML that L +consumes. See L for more information. + +=head1 INTERFACE + +=over + +=item C<< new >> + +The constructor C creates and returns an empty C object. + +=item C<< write( $obj, $output ) >> + +Encode a scalar, hash reference or array reference as YAML. + + my $writer = sub { + my $line = shift; + print SOMEFILE "$line\n"; + }; + + my $data = { + one => 1, + two => 2, + three => [ 1, 2, 3 ], + }; + + my $yw = Data::YAML::Writer->new; + $yw->write( $data, $writer ); + + +The C< $output > argument may be + +=over + +=item * a reference to a scalar to append YAML to + +=item * the handle of an open file + +=item * a reference to an array into which YAML will be pushed + +=item * a code reference + +=back + +If you supply a code reference the subroutine will be called once for +each line of output with the line as its only argument. Passed lines +will have no trailing newline. + +=back + +=head1 BUGS AND LIMITATIONS + +No bugs have been reported. + +Please report any bugs or feature requests to +C, or through the web interface at +L. + +=head1 SEE ALSO + +L, L, L, L, L + +=head1 AUTHOR + +Andy Armstrong C<< >> + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. + +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See L. + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. diff --git a/Data-YAML-0.0.6/blib/lib/auto/Data/YAML/.exists b/Data-YAML-0.0.6/blib/lib/auto/Data/YAML/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/blib/man1/.exists b/Data-YAML-0.0.6/blib/man1/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/blib/man3/.exists b/Data-YAML-0.0.6/blib/man3/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/blib/man3/Data::YAML.3pm b/Data-YAML-0.0.6/blib/man3/Data::YAML.3pm new file mode 100644 index 0000000..b0f422d --- /dev/null +++ b/Data-YAML-0.0.6/blib/man3/Data::YAML.3pm @@ -0,0 +1,264 @@ +.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "Data::YAML 3" +.TH Data::YAML 3 "2009-03-08" "perl v5.10.1" "User Contributed Perl Documentation" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +Data::YAML \- Easy YAML serialisation of Perl data structures +.SH "VERSION" +.IX Header "VERSION" +This document describes Data::YAML version 0.0.6 +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +In the spirit of YAML::Tiny, Data::YAML::Reader and +Data::YAML::Writer provide lightweight, dependency-free \s-1YAML\s0 +handling. While \f(CW\*(C`YAML::Tiny\*(C'\fR is designed principally for working with +configuration files \f(CW\*(C`Data::YAML\*(C'\fR concentrates on the transparent round\- +tripping of \s-1YAML\s0 serialized Perl data structures. +.PP +As an example of why this distinction matters consider that +\&\f(CW\*(C`YAML::Tiny\*(C'\fR doesn't handle hashes with keys containing non-printable +characters. This is fine for configuration files but likely to cause +problems when handling arbitrary Perl data structures. \f(CW\*(C`Data::YAML\*(C'\fR +handles exotic hash keys correctly. +.PP +The syntax accepted by \f(CW\*(C`Data::YAML\*(C'\fR is a subset of \s-1YAML\s0. Specifically +it is the same subset of \s-1YAML\s0 that Data::YAML::Writer produces. See +Data::YAML for more information. +.SS "\s-1YAML\s0 syntax" +.IX Subsection "YAML syntax" +Although \s-1YAML\s0 appears to be a simple language the entire \s-1YAML\s0 +specification is huge. \f(CW\*(C`Data::YAML\*(C'\fR implements a small subset of the +complete syntax trading completeness for compactness and simplicity. +This restricted syntax is known (to me at least) as 'YAMLish'. +.PP +These examples demonstrates the full range of supported syntax. +.PP +All \s-1YAML\s0 documents must begin with '\-\-\-' and end with a line +containing '...'. +.PP +.Vb 2 +\& \-\-\- Simple scalar +\& ... +.Ve +.PP +Unprintable characters are represented using standard escapes in double +quoted strings. +.PP +.Vb 2 +\& \-\-\- "\et\ex01\ex02\en" +\& ... +.Ve +.PP +Array and hashes are represented thusly +.PP +.Vb 6 +\& \-\-\- +\& \- "This" +\& \- "is" +\& \- "an" +\& \- "array" +\& ... +\& +\& \-\-\- +\& This: is +\& a: hash +\& ... +.Ve +.PP +Structures may nest arbitrarily +.PP +.Vb 8 +\& \-\-\- +\& \- +\& name: \*(AqHash one\*(Aq +\& value: 1 +\& \- +\& name: \*(AqHash two\*(Aq +\& value: 2 +\& ... +.Ve +.PP +Undef is a tilde +.PP +.Vb 2 +\& \-\-\- ~ +\& ... +.Ve +.SS "Uses" +.IX Subsection "Uses" +Use \f(CW\*(C`Data::YAML\*(C'\fR may be used any time you need to freeze and thaw Perl +data structures into a human readable format. The output from +\&\f(CW\*(C`Data::YAML::Writer\*(C'\fR should be readable by any \s-1YAML\s0 parser. +.PP +\&\f(CW\*(C`Data::YAML\*(C'\fR was originally written to allow machine-readable +diagnostic information to be passed from test scripts to +TAP::Harness. That means that if you're writing a testing system that +needs to output \s-1TAP\s0 version 13 or later syntax you might find +\&\f(CW\*(C`Data::YAML\*(C'\fR useful. +.PP +Read more about \s-1TAP\s0 and YAMLish here: +.SH "BUGS AND LIMITATIONS" +.IX Header "BUGS AND LIMITATIONS" +No bugs have been reported. +.PP +Please report any bugs or feature requests to +\&\f(CW\*(C`data\-yaml@rt.cpan.org\*(C'\fR, or through the web interface at +. +.SH "AUTHOR" +.IX Header "AUTHOR" +Andy Armstrong \f(CW\*(C`\*(C'\fR +.SH "LICENCE AND COPYRIGHT" +.IX Header "LICENCE AND COPYRIGHT" +Copyright (c) 2007, Andy Armstrong \f(CW\*(C`\*(C'\fR. All rights reserved. +.PP +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See perlartistic. +.SH "DISCLAIMER OF WARRANTY" +.IX Header "DISCLAIMER OF WARRANTY" +\&\s-1BECAUSE\s0 \s-1THIS\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1LICENSED\s0 \s-1FREE\s0 \s-1OF\s0 \s-1CHARGE\s0, \s-1THERE\s0 \s-1IS\s0 \s-1NO\s0 \s-1WARRANTY\s0 +\&\s-1FOR\s0 \s-1THE\s0 \s-1SOFTWARE\s0, \s-1TO\s0 \s-1THE\s0 \s-1EXTENT\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0. \s-1EXCEPT\s0 \s-1WHEN\s0 +\&\s-1OTHERWISE\s0 \s-1STATED\s0 \s-1IN\s0 \s-1WRITING\s0 \s-1THE\s0 \s-1COPYRIGHT\s0 \s-1HOLDERS\s0 \s-1AND/OR\s0 \s-1OTHER\s0 \s-1PARTIES\s0 +\&\s-1PROVIDE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1WITHOUT\s0 \s-1WARRANTY\s0 \s-1OF\s0 \s-1ANY\s0 \s-1KIND\s0, \s-1EITHER\s0 +\&\s-1EXPRESSED\s0 \s-1OR\s0 \s-1IMPLIED\s0, \s-1INCLUDING\s0, \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0, \s-1THE\s0 \s-1IMPLIED\s0 +\&\s-1WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. \s-1THE\s0 +\&\s-1ENTIRE\s0 \s-1RISK\s0 \s-1AS\s0 \s-1TO\s0 \s-1THE\s0 \s-1QUALITY\s0 \s-1AND\s0 \s-1PERFORMANCE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1WITH\s0 +\&\s-1YOU\s0. \s-1SHOULD\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1PROVE\s0 \s-1DEFECTIVE\s0, \s-1YOU\s0 \s-1ASSUME\s0 \s-1THE\s0 \s-1COST\s0 \s-1OF\s0 \s-1ALL\s0 +\&\s-1NECESSARY\s0 \s-1SERVICING\s0, \s-1REPAIR\s0, \s-1OR\s0 \s-1CORRECTION\s0. +.PP +\&\s-1IN\s0 \s-1NO\s0 \s-1EVENT\s0 \s-1UNLESS\s0 \s-1REQUIRED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0 \s-1OR\s0 \s-1AGREED\s0 \s-1TO\s0 \s-1IN\s0 \s-1WRITING\s0 +\&\s-1WILL\s0 \s-1ANY\s0 \s-1COPYRIGHT\s0 \s-1HOLDER\s0, \s-1OR\s0 \s-1ANY\s0 \s-1OTHER\s0 \s-1PARTY\s0 \s-1WHO\s0 \s-1MAY\s0 \s-1MODIFY\s0 \s-1AND/OR\s0 +\&\s-1REDISTRIBUTE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1AS\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1THE\s0 \s-1ABOVE\s0 \s-1LICENCE\s0, \s-1BE\s0 +\&\s-1LIABLE\s0 \s-1TO\s0 \s-1YOU\s0 \s-1FOR\s0 \s-1DAMAGES\s0, \s-1INCLUDING\s0 \s-1ANY\s0 \s-1GENERAL\s0, \s-1SPECIAL\s0, \s-1INCIDENTAL\s0, +\&\s-1OR\s0 \s-1CONSEQUENTIAL\s0 \s-1DAMAGES\s0 \s-1ARISING\s0 \s-1OUT\s0 \s-1OF\s0 \s-1THE\s0 \s-1USE\s0 \s-1OR\s0 \s-1INABILITY\s0 \s-1TO\s0 \s-1USE\s0 +\&\s-1THE\s0 \s-1SOFTWARE\s0 (\s-1INCLUDING\s0 \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0 \s-1LOSS\s0 \s-1OF\s0 \s-1DATA\s0 \s-1OR\s0 \s-1DATA\s0 \s-1BEING\s0 +\&\s-1RENDERED\s0 \s-1INACCURATE\s0 \s-1OR\s0 \s-1LOSSES\s0 \s-1SUSTAINED\s0 \s-1BY\s0 \s-1YOU\s0 \s-1OR\s0 \s-1THIRD\s0 \s-1PARTIES\s0 \s-1OR\s0 A +\&\s-1FAILURE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1TO\s0 \s-1OPERATE\s0 \s-1WITH\s0 \s-1ANY\s0 \s-1OTHER\s0 \s-1SOFTWARE\s0), \s-1EVEN\s0 \s-1IF\s0 +\&\s-1SUCH\s0 \s-1HOLDER\s0 \s-1OR\s0 \s-1OTHER\s0 \s-1PARTY\s0 \s-1HAS\s0 \s-1BEEN\s0 \s-1ADVISED\s0 \s-1OF\s0 \s-1THE\s0 \s-1POSSIBILITY\s0 \s-1OF\s0 +\&\s-1SUCH\s0 \s-1DAMAGES\s0. diff --git a/Data-YAML-0.0.6/blib/man3/Data::YAML::Reader.3pm b/Data-YAML-0.0.6/blib/man3/Data::YAML::Reader.3pm new file mode 100644 index 0000000..f01295e --- /dev/null +++ b/Data-YAML-0.0.6/blib/man3/Data::YAML::Reader.3pm @@ -0,0 +1,243 @@ +.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "Data::YAML::Reader 3" +.TH Data::YAML::Reader 3 "2009-03-08" "perl v5.10.1" "User Contributed Perl Documentation" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +Data::YAML::Reader \- Parse YAML created by Data::YAML::Writer +.SH "VERSION" +.IX Header "VERSION" +This document describes Data::YAML::Reader version 0.0.6 +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +.Vb 1 +\& use Data::YAML::Reader; +\& +\& my $yr = Data::YAML::Reader\->new; +\& +\& # Read from an array... +\& my $from_array = $yr\->read( \e@some_array ); +\& +\& # ...an open file handle... +\& my $from_handle = $yr\->read( $some_file ); +\& +\& # ...a string containing YAML... +\& my $from_string = $yr\->read( $some_string ); +\& +\& # ...or a closure +\& my $from_code = $yr\->read( sub { return get_next_line() } ); +.Ve +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +In the spirit of YAML::Tiny this is a lightweight, dependency-free +\&\s-1YAML\s0 reader. While \f(CW\*(C`YAML::Tiny\*(C'\fR is designed principally for working +with configuration files \f(CW\*(C`Data::YAML\*(C'\fR concentrates on the transparent +round-tripping of \s-1YAML\s0 serialized Perl data structures. +.PP +The syntax accepted by \f(CW\*(C`Data::YAML::Reader\*(C'\fR is a subset of \s-1YAML\s0. +Specifically it is the same subset of \s-1YAML\s0 that Data::YAML::Writer +produces. See Data::YAML for more information. +.SH "INTERFACE" +.IX Header "INTERFACE" +.ie n .IP """new""" 4 +.el .IP "\f(CWnew\fR" 4 +.IX Item "new" +Creates and returns an empty \f(CW\*(C`Data::YAML::Reader\*(C'\fR object. No options may be passed. +.ie n .IP """read( $source )""" 4 +.el .IP "\f(CWread( $source )\fR" 4 +.IX Item "read( $source )" +Read \s-1YAML\s0 and return the data structure it represents. The \s-1YAML\s0 data may be supplied by a +.RS 4 +.IP "\(bu" 4 +scalar string containing \s-1YAML\s0 source +.IP "\(bu" 4 +the handle of an open file +.IP "\(bu" 4 +a reference to an array of lines +.IP "\(bu" 4 +a code reference +.RE +.RS 4 +.Sp +In the case of a code reference a subroutine (most likely a closure) +that returns successive lines of \s-1YAML\s0 must be supplied. Lines should +have no trailing newline. When the \s-1YAML\s0 is exhausted the subroutine must +return undef. +.Sp +Returns the data structure (specifically either a scalar, hash ref or +array ref) that results from decoding the \s-1YAML\s0. +.RE +.ie n .IP """get_raw""" 4 +.el .IP "\f(CWget_raw\fR" 4 +.IX Item "get_raw" +Return the raw \s-1YAML\s0 source from the most recent \f(CW\*(C`read\*(C'\fR. +.SH "BUGS AND LIMITATIONS" +.IX Header "BUGS AND LIMITATIONS" +No bugs have been reported. +.PP +Please report any bugs or feature requests to +\&\f(CW\*(C`data\-yaml@rt.cpan.org\*(C'\fR, or through the web interface at +. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +YAML::Tiny, \s-1YAML\s0, YAML::Syck, Config::Tiny, CSS::Tiny +.SH "AUTHOR" +.IX Header "AUTHOR" +Andy Armstrong \f(CW\*(C`\*(C'\fR +.PP +Adam Kennedy wrote YAML::Tiny which provided the template and many of +the \s-1YAML\s0 matching regular expressions for this module. +.SH "LICENCE AND COPYRIGHT" +.IX Header "LICENCE AND COPYRIGHT" +Copyright (c) 2007, Andy Armstrong \f(CW\*(C`\*(C'\fR. All rights reserved. +.PP +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See perlartistic. +.SH "DISCLAIMER OF WARRANTY" +.IX Header "DISCLAIMER OF WARRANTY" +\&\s-1BECAUSE\s0 \s-1THIS\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1LICENSED\s0 \s-1FREE\s0 \s-1OF\s0 \s-1CHARGE\s0, \s-1THERE\s0 \s-1IS\s0 \s-1NO\s0 \s-1WARRANTY\s0 +\&\s-1FOR\s0 \s-1THE\s0 \s-1SOFTWARE\s0, \s-1TO\s0 \s-1THE\s0 \s-1EXTENT\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0. \s-1EXCEPT\s0 \s-1WHEN\s0 +\&\s-1OTHERWISE\s0 \s-1STATED\s0 \s-1IN\s0 \s-1WRITING\s0 \s-1THE\s0 \s-1COPYRIGHT\s0 \s-1HOLDERS\s0 \s-1AND/OR\s0 \s-1OTHER\s0 \s-1PARTIES\s0 +\&\s-1PROVIDE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1WITHOUT\s0 \s-1WARRANTY\s0 \s-1OF\s0 \s-1ANY\s0 \s-1KIND\s0, \s-1EITHER\s0 +\&\s-1EXPRESSED\s0 \s-1OR\s0 \s-1IMPLIED\s0, \s-1INCLUDING\s0, \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0, \s-1THE\s0 \s-1IMPLIED\s0 +\&\s-1WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. \s-1THE\s0 +\&\s-1ENTIRE\s0 \s-1RISK\s0 \s-1AS\s0 \s-1TO\s0 \s-1THE\s0 \s-1QUALITY\s0 \s-1AND\s0 \s-1PERFORMANCE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1WITH\s0 +\&\s-1YOU\s0. \s-1SHOULD\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1PROVE\s0 \s-1DEFECTIVE\s0, \s-1YOU\s0 \s-1ASSUME\s0 \s-1THE\s0 \s-1COST\s0 \s-1OF\s0 \s-1ALL\s0 +\&\s-1NECESSARY\s0 \s-1SERVICING\s0, \s-1REPAIR\s0, \s-1OR\s0 \s-1CORRECTION\s0. +.PP +\&\s-1IN\s0 \s-1NO\s0 \s-1EVENT\s0 \s-1UNLESS\s0 \s-1REQUIRED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0 \s-1OR\s0 \s-1AGREED\s0 \s-1TO\s0 \s-1IN\s0 \s-1WRITING\s0 +\&\s-1WILL\s0 \s-1ANY\s0 \s-1COPYRIGHT\s0 \s-1HOLDER\s0, \s-1OR\s0 \s-1ANY\s0 \s-1OTHER\s0 \s-1PARTY\s0 \s-1WHO\s0 \s-1MAY\s0 \s-1MODIFY\s0 \s-1AND/OR\s0 +\&\s-1REDISTRIBUTE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1AS\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1THE\s0 \s-1ABOVE\s0 \s-1LICENCE\s0, \s-1BE\s0 +\&\s-1LIABLE\s0 \s-1TO\s0 \s-1YOU\s0 \s-1FOR\s0 \s-1DAMAGES\s0, \s-1INCLUDING\s0 \s-1ANY\s0 \s-1GENERAL\s0, \s-1SPECIAL\s0, \s-1INCIDENTAL\s0, +\&\s-1OR\s0 \s-1CONSEQUENTIAL\s0 \s-1DAMAGES\s0 \s-1ARISING\s0 \s-1OUT\s0 \s-1OF\s0 \s-1THE\s0 \s-1USE\s0 \s-1OR\s0 \s-1INABILITY\s0 \s-1TO\s0 \s-1USE\s0 +\&\s-1THE\s0 \s-1SOFTWARE\s0 (\s-1INCLUDING\s0 \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0 \s-1LOSS\s0 \s-1OF\s0 \s-1DATA\s0 \s-1OR\s0 \s-1DATA\s0 \s-1BEING\s0 +\&\s-1RENDERED\s0 \s-1INACCURATE\s0 \s-1OR\s0 \s-1LOSSES\s0 \s-1SUSTAINED\s0 \s-1BY\s0 \s-1YOU\s0 \s-1OR\s0 \s-1THIRD\s0 \s-1PARTIES\s0 \s-1OR\s0 A +\&\s-1FAILURE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1TO\s0 \s-1OPERATE\s0 \s-1WITH\s0 \s-1ANY\s0 \s-1OTHER\s0 \s-1SOFTWARE\s0), \s-1EVEN\s0 \s-1IF\s0 +\&\s-1SUCH\s0 \s-1HOLDER\s0 \s-1OR\s0 \s-1OTHER\s0 \s-1PARTY\s0 \s-1HAS\s0 \s-1BEEN\s0 \s-1ADVISED\s0 \s-1OF\s0 \s-1THE\s0 \s-1POSSIBILITY\s0 \s-1OF\s0 +\&\s-1SUCH\s0 \s-1DAMAGES\s0. diff --git a/Data-YAML-0.0.6/blib/man3/Data::YAML::Writer.3pm b/Data-YAML-0.0.6/blib/man3/Data::YAML::Writer.3pm new file mode 100644 index 0000000..2ec49e5 --- /dev/null +++ b/Data-YAML-0.0.6/blib/man3/Data::YAML::Writer.3pm @@ -0,0 +1,261 @@ +.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "Data::YAML::Writer 3" +.TH Data::YAML::Writer 3 "2009-03-08" "perl v5.10.1" "User Contributed Perl Documentation" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +Data::YAML::Writer \- Easy YAML serialisation +.SH "VERSION" +.IX Header "VERSION" +This document describes Data::YAML::Writer version 0.0.6 +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +.Vb 1 +\& use Data::YAML::Writer; +\& +\& my $data = { +\& one => 1, +\& two => 2, +\& three => [ 1, 2, 3 ], +\& }; +\& +\& my $yw = Data::YAML::Writer\->new; +\& +\& # Write to an array... +\& $yw\->write( $data, \e@some_array ); +\& +\& # ...an open file handle... +\& $yw\->write( $data, $some_file_handle ); +\& +\& # ...a string ... +\& $yw\->write( $data, \e$some_string ); +\& +\& # ...or a closure +\& $yw\->write( $data, sub { +\& my $line = shift; +\& print "$line\en"; +\& } ); +.Ve +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +Encodes a scalar, hash reference or array reference as \s-1YAML\s0. +.PP +In the spirit of YAML::Tiny this is a lightweight, dependency-free +\&\s-1YAML\s0 writer. While \f(CW\*(C`YAML::Tiny\*(C'\fR is designed principally for working +with configuration files \f(CW\*(C`Data::YAML\*(C'\fR concentrates on the transparent +round-tripping of \s-1YAML\s0 serialized Perl data structures. +.PP +The syntax produced by \f(CW\*(C`Data::YAML::Writer\*(C'\fR is a subset of \s-1YAML\s0. +Specifically it is the same subset of \s-1YAML\s0 that Data::YAML::Reader +consumes. See Data::YAML for more information. +.SH "INTERFACE" +.IX Header "INTERFACE" +.ie n .IP """new""" 4 +.el .IP "\f(CWnew\fR" 4 +.IX Item "new" +The constructor \f(CW\*(C`new\*(C'\fR creates and returns an empty \f(CW\*(C`Data::YAML::Writer\*(C'\fR object. +.ie n .IP """write( $obj, $output )""" 4 +.el .IP "\f(CWwrite( $obj, $output )\fR" 4 +.IX Item "write( $obj, $output )" +Encode a scalar, hash reference or array reference as \s-1YAML\s0. +.Sp +.Vb 4 +\& my $writer = sub { +\& my $line = shift; +\& print SOMEFILE "$line\en"; +\& }; +\& +\& my $data = { +\& one => 1, +\& two => 2, +\& three => [ 1, 2, 3 ], +\& }; +\& +\& my $yw = Data::YAML::Writer\->new; +\& $yw\->write( $data, $writer ); +.Ve +.Sp +The \f(CW $output \fR argument may be +.RS 4 +.IP "\(bu" 4 +a reference to a scalar to append \s-1YAML\s0 to +.IP "\(bu" 4 +the handle of an open file +.IP "\(bu" 4 +a reference to an array into which \s-1YAML\s0 will be pushed +.IP "\(bu" 4 +a code reference +.RE +.RS 4 +.Sp +If you supply a code reference the subroutine will be called once for +each line of output with the line as its only argument. Passed lines +will have no trailing newline. +.RE +.SH "BUGS AND LIMITATIONS" +.IX Header "BUGS AND LIMITATIONS" +No bugs have been reported. +.PP +Please report any bugs or feature requests to +\&\f(CW\*(C`data\-yaml@rt.cpan.org\*(C'\fR, or through the web interface at +. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +YAML::Tiny, \s-1YAML\s0, YAML::Syck, Config::Tiny, CSS::Tiny +.SH "AUTHOR" +.IX Header "AUTHOR" +Andy Armstrong \f(CW\*(C`\*(C'\fR +.SH "LICENCE AND COPYRIGHT" +.IX Header "LICENCE AND COPYRIGHT" +Copyright (c) 2007, Andy Armstrong \f(CW\*(C`\*(C'\fR. All rights reserved. +.PP +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See perlartistic. +.SH "DISCLAIMER OF WARRANTY" +.IX Header "DISCLAIMER OF WARRANTY" +\&\s-1BECAUSE\s0 \s-1THIS\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1LICENSED\s0 \s-1FREE\s0 \s-1OF\s0 \s-1CHARGE\s0, \s-1THERE\s0 \s-1IS\s0 \s-1NO\s0 \s-1WARRANTY\s0 +\&\s-1FOR\s0 \s-1THE\s0 \s-1SOFTWARE\s0, \s-1TO\s0 \s-1THE\s0 \s-1EXTENT\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0. \s-1EXCEPT\s0 \s-1WHEN\s0 +\&\s-1OTHERWISE\s0 \s-1STATED\s0 \s-1IN\s0 \s-1WRITING\s0 \s-1THE\s0 \s-1COPYRIGHT\s0 \s-1HOLDERS\s0 \s-1AND/OR\s0 \s-1OTHER\s0 \s-1PARTIES\s0 +\&\s-1PROVIDE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1WITHOUT\s0 \s-1WARRANTY\s0 \s-1OF\s0 \s-1ANY\s0 \s-1KIND\s0, \s-1EITHER\s0 +\&\s-1EXPRESSED\s0 \s-1OR\s0 \s-1IMPLIED\s0, \s-1INCLUDING\s0, \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0, \s-1THE\s0 \s-1IMPLIED\s0 +\&\s-1WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. \s-1THE\s0 +\&\s-1ENTIRE\s0 \s-1RISK\s0 \s-1AS\s0 \s-1TO\s0 \s-1THE\s0 \s-1QUALITY\s0 \s-1AND\s0 \s-1PERFORMANCE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1WITH\s0 +\&\s-1YOU\s0. \s-1SHOULD\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1PROVE\s0 \s-1DEFECTIVE\s0, \s-1YOU\s0 \s-1ASSUME\s0 \s-1THE\s0 \s-1COST\s0 \s-1OF\s0 \s-1ALL\s0 +\&\s-1NECESSARY\s0 \s-1SERVICING\s0, \s-1REPAIR\s0, \s-1OR\s0 \s-1CORRECTION\s0. +.PP +\&\s-1IN\s0 \s-1NO\s0 \s-1EVENT\s0 \s-1UNLESS\s0 \s-1REQUIRED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0 \s-1OR\s0 \s-1AGREED\s0 \s-1TO\s0 \s-1IN\s0 \s-1WRITING\s0 +\&\s-1WILL\s0 \s-1ANY\s0 \s-1COPYRIGHT\s0 \s-1HOLDER\s0, \s-1OR\s0 \s-1ANY\s0 \s-1OTHER\s0 \s-1PARTY\s0 \s-1WHO\s0 \s-1MAY\s0 \s-1MODIFY\s0 \s-1AND/OR\s0 +\&\s-1REDISTRIBUTE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1AS\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1THE\s0 \s-1ABOVE\s0 \s-1LICENCE\s0, \s-1BE\s0 +\&\s-1LIABLE\s0 \s-1TO\s0 \s-1YOU\s0 \s-1FOR\s0 \s-1DAMAGES\s0, \s-1INCLUDING\s0 \s-1ANY\s0 \s-1GENERAL\s0, \s-1SPECIAL\s0, \s-1INCIDENTAL\s0, +\&\s-1OR\s0 \s-1CONSEQUENTIAL\s0 \s-1DAMAGES\s0 \s-1ARISING\s0 \s-1OUT\s0 \s-1OF\s0 \s-1THE\s0 \s-1USE\s0 \s-1OR\s0 \s-1INABILITY\s0 \s-1TO\s0 \s-1USE\s0 +\&\s-1THE\s0 \s-1SOFTWARE\s0 (\s-1INCLUDING\s0 \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0 \s-1LOSS\s0 \s-1OF\s0 \s-1DATA\s0 \s-1OR\s0 \s-1DATA\s0 \s-1BEING\s0 +\&\s-1RENDERED\s0 \s-1INACCURATE\s0 \s-1OR\s0 \s-1LOSSES\s0 \s-1SUSTAINED\s0 \s-1BY\s0 \s-1YOU\s0 \s-1OR\s0 \s-1THIRD\s0 \s-1PARTIES\s0 \s-1OR\s0 A +\&\s-1FAILURE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1TO\s0 \s-1OPERATE\s0 \s-1WITH\s0 \s-1ANY\s0 \s-1OTHER\s0 \s-1SOFTWARE\s0), \s-1EVEN\s0 \s-1IF\s0 +\&\s-1SUCH\s0 \s-1HOLDER\s0 \s-1OR\s0 \s-1OTHER\s0 \s-1PARTY\s0 \s-1HAS\s0 \s-1BEEN\s0 \s-1ADVISED\s0 \s-1OF\s0 \s-1THE\s0 \s-1POSSIBILITY\s0 \s-1OF\s0 +\&\s-1SUCH\s0 \s-1DAMAGES\s0. diff --git a/Data-YAML-0.0.6/blib/script/.exists b/Data-YAML-0.0.6/blib/script/.exists new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/lib/Data/YAML.pm b/Data-YAML-0.0.6/lib/Data/YAML.pm new file mode 100644 index 0000000..dd6716b --- /dev/null +++ b/Data-YAML-0.0.6/lib/Data/YAML.pm @@ -0,0 +1,145 @@ +package Data::YAML; + +use strict; +use warnings; + +use vars qw{$VERSION}; + +$VERSION = '0.0.6'; + +1; + +__END__ + +=head1 NAME + +Data::YAML - Easy YAML serialisation of Perl data structures + +=head1 VERSION + +This document describes Data::YAML version 0.0.6 + +=head1 DESCRIPTION + +In the spirit of L, L and +L provide lightweight, dependency-free YAML +handling. While C is designed principally for working with +configuration files C concentrates on the transparent round- +tripping of YAML serialized Perl data structures. + +As an example of why this distinction matters consider that +C doesn't handle hashes with keys containing non-printable +characters. This is fine for configuration files but likely to cause +problems when handling arbitrary Perl data structures. C +handles exotic hash keys correctly. + +The syntax accepted by C is a subset of YAML. Specifically +it is the same subset of YAML that L produces. See +L for more information. + +=head2 YAML syntax + +Although YAML appears to be a simple language the entire YAML +specification is huge. C implements a small subset of the +complete syntax trading completeness for compactness and simplicity. +This restricted syntax is known (to me at least) as 'YAMLish'. + +These examples demonstrates the full range of supported syntax. + +All YAML documents must begin with '---' and end with a line +containing '...'. + + --- Simple scalar + ... + +Unprintable characters are represented using standard escapes in double +quoted strings. + + --- "\t\x01\x02\n" + ... + +Array and hashes are represented thusly + + --- + - "This" + - "is" + - "an" + - "array" + ... + + --- + This: is + a: hash + ... + +Structures may nest arbitrarily + + --- + - + name: 'Hash one' + value: 1 + - + name: 'Hash two' + value: 2 + ... + +Undef is a tilde + + --- ~ + ... + +=head2 Uses + +Use C may be used any time you need to freeze and thaw Perl +data structures into a human readable format. The output from +C should be readable by any YAML parser. + +C was originally written to allow machine-readable +diagnostic information to be passed from test scripts to +L. That means that if you're writing a testing system that +needs to output TAP version 13 or later syntax you might find +C useful. + +Read more about TAP and YAMLish here: L + +=head1 BUGS AND LIMITATIONS + +No bugs have been reported. + +Please report any bugs or feature requests to +C, or through the web interface at +L. + +=head1 AUTHOR + +Andy Armstrong C<< >> + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. + +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See L. + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. diff --git a/Data-YAML-0.0.6/lib/Data/YAML/Reader.pm b/Data-YAML-0.0.6/lib/Data/YAML/Reader.pm new file mode 100644 index 0000000..dbd5189 --- /dev/null +++ b/Data-YAML-0.0.6/lib/Data/YAML/Reader.pm @@ -0,0 +1,422 @@ +package Data::YAML::Reader; + +use strict; +use warnings; +use Carp; + +use vars qw{$VERSION}; + +$VERSION = '0.0.6'; + +# TODO: +# Handle blessed object syntax + +# Printable characters for escapes +my %UNESCAPES = ( + z => "\x00", + a => "\x07", + t => "\x09", + n => "\x0a", + v => "\x0b", + f => "\x0c", + r => "\x0d", + e => "\x1b", + '\\' => '\\', +); + +my $QQ_STRING = qr{ " (?:\\. | [^"])* " }x; +my $HASH_LINE = qr{ ^ ($QQ_STRING|\S+) \s* : (?: \s+ (.+?) \s* )? $ }x; +my $IS_HASH_KEY = qr{ ^ [\w\'\"] }x; +my $IS_END_YAML = qr{ ^ [.][.][.] \s* $ }x; +my $IS_QQ_STRING = qr{ ^ $QQ_STRING $ }x; + +# Create an empty Data::YAML::Reader object +sub new { + my $class = shift; + bless {}, $class; +} + +sub _make_reader { + my $self = shift; + my $obj = shift; + + croak "Must have something to read from" + unless defined $obj; + + if ( my $ref = ref $obj ) { + if ( 'CODE' eq $ref ) { + return $obj; + } + elsif ( 'ARRAY' eq $ref ) { + return sub { shift @$obj }; + } + elsif ( 'SCALAR' eq $ref ) { + return $self->_make_reader( $$obj ); + } + elsif ( 'GLOB' eq $ref || 'IO::Handle' eq $ref ) { + return sub { + my $line = <$obj>; + chomp $line if defined $line; + return $line; + }; + } + croak "Don't know how to read $ref"; + } + else { + my @lines = split( /\n/, $obj ); + return sub { shift @lines }; + } +} + +sub read { + my $self = shift; + my $obj = shift; + + $self->{reader} = $self->_make_reader( $obj ); + $self->{capture} = []; + + # Prime the reader + $self->_next; + + my $doc = $self->_read; + + # The terminator is mandatory otherwise we'd consume a line from the + # iterator that doesn't belong to us. If we want to remove this + # restriction we'll have to implement look-ahead in the iterators. + # Which might not be a bad idea. + my $dots = $self->_peek; + croak "Missing '...' at end of YAML" + unless $dots =~ $IS_END_YAML; + + delete $self->{reader}; + delete $self->{next}; + + return $doc; +} + +sub get_raw { + my $self = shift; + + if ( defined( my $capture = $self->{capture} ) ) { + return join( "\n", @$capture ) . "\n"; + } + + return ''; +} + +sub _peek { + my $self = shift; + return $self->{next} unless wantarray; + my $line = $self->{next}; + $line =~ /^ (\s*) (.*) $ /x; + return ( $2, length $1 ); +} + +sub _next { + my $self = shift; + croak "_next called with no reader" + unless $self->{reader}; + my $line = $self->{reader}->(); + $self->{next} = $line; + push @{ $self->{capture} }, $line; +} + +sub _read { + my $self = shift; + + my $line = $self->_peek; + + # Do we have a document header? + if ( $line =~ /^ --- (?: \s* (.+?) \s* )? $/x ) { + $self->_next; + + return $self->_read_scalar( $1 ) if defined $1; # Inline? + + my ( $next, $indent ) = $self->_peek; + + if ( $next =~ /^ - /x ) { + return $self->_read_array( $indent ); + } + elsif ( $next =~ $IS_HASH_KEY ) { + return $self->_read_hash( $next, $indent ); + } + elsif ( $next =~ $IS_END_YAML ) { + croak "Premature end of YAML"; + } + else { + croak "Unsupported YAML syntax: '$next'"; + } + } + else { + croak "YAML document header not found"; + } +} + +# Parse a double quoted string +sub _read_qq { + my $self = shift; + my $str = shift; + + unless ( $str =~ s/^ " (.*?) " $/$1/x ) { + die "Internal: not a quoted string"; + } + + $str =~ s/\\"/"/gx; + $str =~ s/ \\ ( [tartan\\favez] | x([0-9a-fA-F]{2}) ) + / (length($1) > 1) ? pack("H2", $2) : $UNESCAPES{$1} /gex; + return $str; +} + +# Parse a scalar string to the actual scalar +sub _read_scalar { + my $self = shift; + my $string = shift; + + return undef if $string eq '~'; + + if ( $string eq '>' || $string eq '|' ) { + + my ( $line, $indent ) = $self->_peek; + die "Multi-line scalar content missing" unless defined $line; + + my @multiline = ( $line ); + + while ( 1 ) { + $self->_next; + my ( $next, $ind ) = $self->_peek; + last if $ind < $indent; + push @multiline, $next; + } + + return join( ( $string eq '>' ? ' ' : "\n" ), @multiline ) . "\n"; + } + + if ( $string =~ /^ ' (.*) ' $/x ) { + ( my $rv = $1 ) =~ s/''/'/g; + return $rv; + } + + if ( $string =~ $IS_QQ_STRING ) { + return $self->_read_qq( $string ); + } + + if ( $string =~ /^['"]/ ) { + + # A quote with folding... we don't support that + die __PACKAGE__ . " does not support multi-line quoted scalars"; + } + + # Regular unquoted string + return $string; +} + +sub _read_nested { + my $self = shift; + + my ( $line, $indent ) = $self->_peek; + + if ( $line =~ /^ -/x ) { + return $self->_read_array( $indent ); + } + elsif ( $line =~ $IS_HASH_KEY ) { + return $self->_read_hash( $line, $indent ); + } + else { + croak "Unsupported YAML syntax: '$line'"; + } +} + +# Parse an array +sub _read_array { + my ( $self, $limit ) = @_; + + my $ar = []; + + while ( 1 ) { + my ( $line, $indent ) = $self->_peek; + last if $indent < $limit || !defined $line || $line =~ $IS_END_YAML; + + if ( $indent > $limit ) { + croak "Array line over-indented"; + } + + if ( $line =~ /^ (- \s+) \S+ \s* : (?: \s+ | $ ) /x ) { + $indent += length $1; + $line =~ s/-\s+//; + push @$ar, $self->_read_hash( $line, $indent ); + } + elsif ( $line =~ /^ - \s* (.+?) \s* $/x ) { + croak "Unexpected start of YAML" if $line =~ /^---/; + $self->_next; + push @$ar, $self->_read_scalar( $1 ); + } + elsif ( $line =~ /^ - \s* $/x ) { + $self->_next; + push @$ar, $self->_read_nested; + } + elsif ( $line =~ $IS_HASH_KEY ) { + $self->_next; + push @$ar, $self->_read_hash( $line, $indent, ); + } + else { + croak "Unsupported YAML syntax: '$line'"; + } + } + + return $ar; +} + +sub _read_hash { + my ( $self, $line, $limit ) = @_; + + my $indent; + my $hash = {}; + + while ( 1 ) { + croak "Badly formed hash line: '$line'" + unless $line =~ $HASH_LINE; + + my ( $key, $value ) = ( $self->_read_scalar( $1 ), $2 ); + $self->_next; + + if ( defined $value ) { + $hash->{$key} = $self->_read_scalar( $value ); + } + else { + $hash->{$key} = $self->_read_nested; + } + + ( $line, $indent ) = $self->_peek; + last if $indent < $limit || !defined $line || $line =~ $IS_END_YAML; + } + + return $hash; +} + +1; + +__END__ + +=head1 NAME + +Data::YAML::Reader - Parse YAML created by Data::YAML::Writer + +=head1 VERSION + +This document describes Data::YAML::Reader version 0.0.6 + +=head1 SYNOPSIS + + use Data::YAML::Reader; + + my $yr = Data::YAML::Reader->new; + + # Read from an array... + my $from_array = $yr->read( \@some_array ); + + # ...an open file handle... + my $from_handle = $yr->read( $some_file ); + + # ...a string containing YAML... + my $from_string = $yr->read( $some_string ); + + # ...or a closure + my $from_code = $yr->read( sub { return get_next_line() } ); + +=head1 DESCRIPTION + +In the spirit of L this is a lightweight, dependency-free +YAML reader. While C is designed principally for working +with configuration files C concentrates on the transparent +round-tripping of YAML serialized Perl data structures. + +The syntax accepted by C is a subset of YAML. +Specifically it is the same subset of YAML that L +produces. See L for more information. + +=head1 INTERFACE + +=over + +=item C<< new >> + +Creates and returns an empty C object. No options may be passed. + +=item C<< read( $source ) >> + +Read YAML and return the data structure it represents. The YAML data may be supplied by a + +=over + +=item * scalar string containing YAML source + +=item * the handle of an open file + +=item * a reference to an array of lines + +=item * a code reference + +=back + +In the case of a code reference a subroutine (most likely a closure) +that returns successive lines of YAML must be supplied. Lines should +have no trailing newline. When the YAML is exhausted the subroutine must +return undef. + +Returns the data structure (specifically either a scalar, hash ref or +array ref) that results from decoding the YAML. + +=item C<< get_raw >> + +Return the raw YAML source from the most recent C. + +=back + +=head1 BUGS AND LIMITATIONS + +No bugs have been reported. + +Please report any bugs or feature requests to +C, or through the web interface at +L. + +=head1 SEE ALSO + +L, L, L, L, L + +=head1 AUTHOR + +Andy Armstrong C<< >> + +Adam Kennedy wrote L which provided the template and many of +the YAML matching regular expressions for this module. + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. + +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See L. + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. diff --git a/Data-YAML-0.0.6/lib/Data/YAML/Writer.pm b/Data-YAML-0.0.6/lib/Data/YAML/Writer.pm new file mode 100644 index 0000000..abce670 --- /dev/null +++ b/Data-YAML-0.0.6/lib/Data/YAML/Writer.pm @@ -0,0 +1,269 @@ +package Data::YAML::Writer; + +use strict; +use warnings; +use Carp; + +use vars qw{$VERSION}; + +$VERSION = '0.0.6'; + +my $ESCAPE_CHAR = qr{ [\x00-\x1f\"] }x; + +my @UNPRINTABLE = qw( + z x01 x02 x03 x04 x05 x06 a + x08 t n v f r x0e x0f + x10 x11 x12 x13 x14 x15 x16 x17 + x18 x19 x1a e x1c x1d x1e x1f +); + +# Create an empty Data::YAML::Writer object +sub new { + my $class = shift; + bless {}, $class; +} + +sub write { + my $self = shift; + + croak "Need something to write" + unless @_; + + my $obj = shift; + my $out = shift || \*STDOUT; + + croak "Need a reference to something I can write to" + unless ref $out; + + $self->{writer} = $self->_make_writer( $out ); + + $self->_write_obj( '---', $obj ); + $self->_put( '...' ); + + delete $self->{writer}; +} + +sub _make_writer { + my $self = shift; + my $out = shift; + + my $ref = ref $out; + + if ( 'CODE' eq $ref ) { + return $out; + } + elsif ( 'ARRAY' eq $ref ) { + return sub { push @$out, shift }; + } + elsif ( 'SCALAR' eq $ref ) { + return sub { $$out .= shift() . "\n" }; + } + elsif ( 'GLOB' eq $ref || 'IO::Handle' eq $ref ) { + return sub { print $out shift(), "\n" }; + } + + croak "Can't write to $out"; +} + +sub _put { + my $self = shift; + $self->{writer}->( join '', @_ ); +} + +sub _enc_scalar { + my $self = shift; + my $val = shift; + + return '~' unless defined $val; + + if ( $val =~ /$ESCAPE_CHAR/ ) { + $val =~ s/\\/\\\\/g; + $val =~ s/"/\\"/g; + $val =~ s/ ( [\x00-\x1f] ) / '\\' . $UNPRINTABLE[ ord($1) ] /gex; + return qq{"$val"}; + } + + if ( length( $val ) == 0 or $val =~ /\s/ ) { + $val =~ s/'/''/; + return "'$val'"; + } + + return $val; +} + +sub _write_obj { + my $self = shift; + my $prefix = shift; + my $obj = shift; + my $indent = shift || 0; + + if ( my $ref = ref $obj ) { + my $pad = ' ' x $indent; + $self->_put( $prefix ); + if ( 'HASH' eq $ref ) { + for my $key ( sort keys %$obj ) { + my $value = $obj->{$key}; + $self->_write_obj( $pad . $self->_enc_scalar( $key ) . ':', + $value, $indent + 1 ); + } + } + elsif ( 'ARRAY' eq $ref ) { + for my $value ( @$obj ) { + $self->_write_obj( $pad . '-', $value, $indent + 1 ); + } + } + else { + croak "Don't know how to encode $ref"; + } + } + else { + $self->_put( $prefix, ' ', $self->_enc_scalar( $obj ) ); + } +} + +1; + +__END__ + + +=head1 NAME + +Data::YAML::Writer - Easy YAML serialisation + +=head1 VERSION + +This document describes Data::YAML::Writer version 0.0.6 + +=head1 SYNOPSIS + + use Data::YAML::Writer; + + my $data = { + one => 1, + two => 2, + three => [ 1, 2, 3 ], + }; + + my $yw = Data::YAML::Writer->new; + + # Write to an array... + $yw->write( $data, \@some_array ); + + # ...an open file handle... + $yw->write( $data, $some_file_handle ); + + # ...a string ... + $yw->write( $data, \$some_string ); + + # ...or a closure + $yw->write( $data, sub { + my $line = shift; + print "$line\n"; + } ); + + +=head1 DESCRIPTION + +Encodes a scalar, hash reference or array reference as YAML. + +In the spirit of L this is a lightweight, dependency-free +YAML writer. While C is designed principally for working +with configuration files C concentrates on the transparent +round-tripping of YAML serialized Perl data structures. + +The syntax produced by C is a subset of YAML. +Specifically it is the same subset of YAML that L +consumes. See L for more information. + +=head1 INTERFACE + +=over + +=item C<< new >> + +The constructor C creates and returns an empty C object. + +=item C<< write( $obj, $output ) >> + +Encode a scalar, hash reference or array reference as YAML. + + my $writer = sub { + my $line = shift; + print SOMEFILE "$line\n"; + }; + + my $data = { + one => 1, + two => 2, + three => [ 1, 2, 3 ], + }; + + my $yw = Data::YAML::Writer->new; + $yw->write( $data, $writer ); + + +The C< $output > argument may be + +=over + +=item * a reference to a scalar to append YAML to + +=item * the handle of an open file + +=item * a reference to an array into which YAML will be pushed + +=item * a code reference + +=back + +If you supply a code reference the subroutine will be called once for +each line of output with the line as its only argument. Passed lines +will have no trailing newline. + +=back + +=head1 BUGS AND LIMITATIONS + +No bugs have been reported. + +Please report any bugs or feature requests to +C, or through the web interface at +L. + +=head1 SEE ALSO + +L, L, L, L, L + +=head1 AUTHOR + +Andy Armstrong C<< >> + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. + +This module is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. See L. + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. diff --git a/Data-YAML-0.0.6/pm_to_blib b/Data-YAML-0.0.6/pm_to_blib new file mode 100644 index 0000000..e69de29 diff --git a/Data-YAML-0.0.6/t/00.load.t b/Data-YAML-0.0.6/t/00.load.t new file mode 100644 index 0000000..4b0baad --- /dev/null +++ b/Data-YAML-0.0.6/t/00.load.t @@ -0,0 +1,8 @@ +use Test::More tests => 2; + +BEGIN { + use_ok( 'Data::YAML::Reader' ); + use_ok( 'Data::YAML::Writer' ); +} + +diag( "Testing Data::YAML $Data::YAML::Reader::VERSION" ); diff --git a/Data-YAML-0.0.6/t/10-input.t b/Data-YAML-0.0.6/t/10-input.t new file mode 100644 index 0000000..70b230e --- /dev/null +++ b/Data-YAML-0.0.6/t/10-input.t @@ -0,0 +1,103 @@ +use strict; +use warnings; +use Test::More tests => 12; +use Data::Dumper; + +use Data::YAML::Reader; + +my $in = [ + "---", + "bill-to:", + " address:", + " city: \"Royal Oak\"", + " lines: \"458 Walkman Dr.\\nSuite #292\\n\"", + " postal: 48046", + " state: MI", + " family: Dumars", + " given: Chris", + "comments: \"Late afternoon is best. Backup contact is Nancy Billsmer \@ 338-4338\\n\"", + "date: 2001-01-23", + "invoice: 34843", + "product:", + " -", + " description: Basketball", + " price: 450.00", + " quantity: 4", + " sku: BL394D", + " -", + " description: \"Super Hoop\"", + " price: 2392.00", + " quantity: 1", + " sku: BL4438H", + "tax: 251.42", + "total: 4443.52", + "...", +]; + +my $out = { + 'bill-to' => { + 'given' => 'Chris', + 'address' => { + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + }, + 'family' => 'Dumars' + }, + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => [ + { + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + }, + { + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + } + ], + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' +}; + +my @lines = @$in; +my $scalar = join( "\n", @lines ) . "\n"; + +my @source = ( + { + name => 'Array reference', + source => $in, + }, + { + name => 'Closure', + source => sub { shift @lines }, + }, + { + name => 'Scalar', + source => $scalar, + }, + { + name => 'Scalar ref', + source => \$scalar, + }, +); + +for my $src ( @source ) { + my $name = $src->{name}; + ok my $yaml = Data::YAML::Reader->new, "$name: Created"; + isa_ok $yaml, 'Data::YAML::Reader'; + + my $got = eval { $yaml->read( $src->{source} ) }; + unless ( is_deeply $got, $out, "$name: Result matches" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$got], ['$got'] ) ); + diag( Data::Dumper->Dump( [$out], ['$expected'] ) ); + } +} diff --git a/Data-YAML-0.0.6/t/20-reader.t b/Data-YAML-0.0.6/t/20-reader.t new file mode 100644 index 0000000..fc6806f --- /dev/null +++ b/Data-YAML-0.0.6/t/20-reader.t @@ -0,0 +1,419 @@ +use strict; +use warnings; +use Test::More; +use Data::Dumper; + +use Data::YAML::Reader; + +my @SCHEDULE; + +BEGIN { + @SCHEDULE = ( + { + name => 'Hello World', + in => [ '--- Hello, World', '...', ], + out => "Hello, World", + }, + { + name => 'Hello World 2', + in => [ '--- \'Hello, \'\'World\'', '...', ], + out => "Hello, 'World", + }, + { + name => 'Hello World 3', + in => [ '--- "Hello, World"', '...', ], + out => "Hello, World", + }, + { + name => 'Hello World 4', + in => [ '--- "Hello, World"', '...', ], + out => "Hello, World", + }, + { + name => 'Hello World 4', + in => [ '--- >', ' Hello,', ' World', '...', ], + out => "Hello, World\n", + }, + { + name => 'Hello World 5', + in => [ '--- >', ' Hello,', ' World', '...', ], + error => qr{Missing\s+'[.][.][.]'}, + }, + { + name => 'Simple array', + in => [ '---', '- 1', '- 2', '- 3', '...', ], + out => [ '1', '2', '3' ], + }, + { + name => 'Mixed array', + in => [ '---', '- 1', '- \'two\'', '- "three\n"', '...', ], + out => [ '1', 'two', "three\n" ], + }, + { + name => 'Hash in array', + in => [ '---', '- 1', '- two: 2', '- 3', '...', ], + out => [ '1', { two => '2' }, '3' ], + }, + { + name => 'Hash in array 2', + in => [ '---', '- 1', '- two: 2', ' three: 3', '- 4', '...', ], + out => [ '1', { two => '2', three => '3' }, '4' ], + }, + { + name => 'Nested array', + in => [ + '---', + '- one', + '-', + ' - two', + ' -', + ' - three', + ' - four', + '- five', + '...', + ], + out => [ 'one', [ 'two', ['three'], 'four' ], 'five' ], + }, + { + name => 'Nested hash', + in => [ + '---', + 'one:', + ' five: 5', + ' two:', + ' four: 4', + ' three: 3', + 'six: 6', + '...', + ], + out => { + one => { two => { three => '3', four => '4' }, five => '5' }, + six => '6' + }, + }, + + { + name => 'Original YAML::Tiny test', + in => [ + '---', + 'invoice: 34843', + 'date : 2001-01-23', + 'bill-to:', + ' given : Chris', + ' family : Dumars', + ' address:', + ' lines: |', + ' 458 Walkman Dr.', + ' Suite #292', + ' city : Royal Oak', + ' state : MI', + ' postal : 48046', + 'product:', + ' - sku : BL394D', + ' quantity : 4', + ' description : Basketball', + ' price : 450.00', + ' - sku : BL4438H', + ' quantity : 1', + ' description : Super Hoop', + ' price : 2392.00', + 'tax : 251.42', + 'total: 4443.52', + 'comments: >', + ' Late afternoon is best.', + ' Backup contact is Nancy', + ' Billsmer @ 338-4338', + '...', + ], + out => { + 'bill-to' => { + 'given' => 'Chris', + 'address' => { + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + }, + 'family' => 'Dumars' + }, + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => [ + { + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + }, + { + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + } + ], + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' + } + }, + + # Tests harvested from YAML::Tiny + { + in => ['...'], + name => 'Regression: empty', + error => qr{document\s+header\s+not\s+found} + }, + { + in => [ '# comment', '...' ], + name => 'Regression: only_comment', + error => qr{document\s+header\s+not\s+found} + }, + { + out => undef, + in => [ '---', '...' ], + name => 'Regression: only_header', + error => qr{Premature\s+end}i, + }, + { + out => undef, + in => [ '---', '---', '...' ], + name => 'Regression: two_header', + error => qr{Unexpected\s+start}i, + }, + { + out => undef, + in => [ '--- ~', '...' ], + name => 'Regression: one_undef' + }, + { + out => undef, + in => [ '--- ~', '...' ], + name => 'Regression: one_undef2' + }, + { + in => [ '--- ~', '---', '...' ], + name => 'Regression: two_undef', + error => qr{Missing\s+'[.][.][.]'}, + }, + { + out => 'foo', + in => [ '--- foo', '...' ], + name => 'Regression: one_scalar', + }, + { + out => 'foo', + in => [ '--- foo', '...' ], + name => 'Regression: one_scalar2', + }, + { + in => [ '--- foo', '--- bar', '...' ], + name => 'Regression: two_scalar', + error => qr{Missing\s+'[.][.][.]'}, + }, + { + out => ['foo'], + in => [ '---', '- foo', '...' ], + name => 'Regression: one_list1' + }, + { + out => [ 'foo', 'bar' ], + in => [ '---', '- foo', '- bar', '...' ], + name => 'Regression: one_list2' + }, + { + out => [ undef, 'bar' ], + in => [ '---', '- ~', '- bar', '...' ], + name => 'Regression: one_listundef' + }, + { + out => { 'foo' => 'bar' }, + in => [ '---', 'foo: bar', '...' ], + name => 'Regression: one_hash1' + }, + { + out => { + 'foo' => 'bar', + 'this' => undef + }, + in => [ '---', 'foo: bar', 'this: ~', '...' ], + name => 'Regression: one_hash2' + }, + { + out => { 'foo' => [ 'bar', undef, 'baz' ] }, + in => [ '---', 'foo:', ' - bar', ' - ~', ' - baz', '...' ], + name => 'Regression: array_in_hash' + }, + { + out => { + 'bar' => { 'foo' => 'bar' }, + 'foo' => undef + }, + in => [ '---', 'foo: ~', 'bar:', ' foo: bar', '...' ], + name => 'Regression: hash_in_hash' + }, + { + out => [ + { + 'foo' => undef, + 'this' => 'that' + }, + 'foo', undef, + { + 'foo' => 'bar', + 'this' => 'that' + } + ], + in => [ + '---', + '-', + ' foo: ~', + ' this: that', + '- foo', + '- ~', + '-', + ' foo: bar', + ' this: that', + '...' + ], + name => 'Regression: hash_in_array' + }, + { + out => ['foo'], + in => [ '---', '- \'foo\'', '...' ], + name => 'Regression: single_quote1' + }, + { + out => [' '], + in => [ '---', '- \' \'', '...' ], + name => 'Regression: single_spaces' + }, + { + out => [''], + in => [ '---', '- \'\'', '...' ], + name => 'Regression: single_null' + }, + { + out => ' ', + in => [ '--- " "', '...' ], + name => 'Regression: only_spaces' + }, + { + out => [ + undef, + { + 'foo' => 'bar', + 'this' => 'that' + }, + 'baz' + ], + in => + [ '---', '- ~', '- foo: bar', ' this: that', '- baz', '...' ], + name => 'Regression: inline_nested_hash' + }, + { + name => "Unprintables", + in => [ + "---", + "- \"\\z\\x01\\x02\\x03\\x04\\x05\\x06\\a\\x08\\t\\n\\v\\f\\r\\x0e\\x0f\"", + "- \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\e\\x1c\\x1d\\x1e\\x1f\"", + "- \" !\\\"#\$%&'()*+,-./\"", + "- 0123456789:;<=>?", + "- '\@ABCDEFGHIJKLMNO'", + "- 'PQRSTUVWXYZ[\\]^_'", + "- '`abcdefghijklmno'", + "- 'pqrstuvwxyz{|}~\177'", + "- \200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217", + "- \220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237", + "- \240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257", + "- \260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277", + "- \300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317", + "- \320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337", + "- \340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357", + "- \360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377", + "..." + ], + out => [ + "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17", + "\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37", + " !\"#\$%&'()*+,-./", + "0123456789:;<=>?", + "\@ABCDEFGHIJKLMNO", + "PQRSTUVWXYZ[\\]^_", + "`abcdefghijklmno", + "pqrstuvwxyz{|}~\177", + "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217", + "\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237", + "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257", + "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277", + "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317", + "\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337", + "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357", + "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" + ], + }, + { + name => 'Quoted hash keys', + in => [ + '---', ' "quoted": Magic!', ' "\n\t": newline, tab', '...', + ], + out => { + quoted => 'Magic!', + "\n\t" => 'newline, tab', + }, + }, + ); + + plan tests => @SCHEDULE * 5; +} + +sub iter { + my $ar = shift; + return sub { + return shift @$ar; + }; +} + +for my $test ( @SCHEDULE ) { + my $name = $test->{name}; + ok my $yaml = Data::YAML::Reader->new, "$name: Created"; + isa_ok $yaml, 'Data::YAML::Reader'; + + # diag "$name\n"; + + # unless ( $test->{in} ) { + # pass for 1 .. 2; + # use YAML; + # diag "Input for test:\n"; + # diag( Dump( $test->{out} ) ); + # next; + # } + + my $source = join( "\n", @{ $test->{in} } ) . "\n"; + + my $iter = iter( $test->{in} ); + my $got = eval { $yaml->read( $iter ) }; + + my $raw = $yaml->get_raw; + + if ( my $err = $test->{error} ) { + unless ( like $@, $err, "$name: Error message" ) { + diag "Error: $@\n"; + } + ok !$got, "$name: No result"; + pass; + } + else { + my $want = $test->{out}; + unless ( ok !$@, "$name: No error" ) { + diag "Error: $@\n"; + } + unless ( is_deeply $got, $want, "$name: Result matches" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$got], ['$got'] ) ); + diag( Data::Dumper->Dump( [$want], ['$expected'] ) ); + } + is $raw, $source, "$name: Captured source matches"; + } +} diff --git a/Data-YAML-0.0.6/t/30-output.t b/Data-YAML-0.0.6/t/30-output.t new file mode 100644 index 0000000..56cfb0a --- /dev/null +++ b/Data-YAML-0.0.6/t/30-output.t @@ -0,0 +1,107 @@ +use strict; +use warnings; +use Test::More tests => 9; +use Data::Dumper; + +use Data::YAML::Writer; + +my $out = [ + "---", + "bill-to:", + " address:", + " city: 'Royal Oak'", + " lines: \"458 Walkman Dr.\\nSuite #292\\n\"", + " postal: 48046", + " state: MI", + " family: Dumars", + " given: Chris", + "comments: \"Late afternoon is best. Backup contact is Nancy Billsmer \@ 338-4338\\n\"", + "date: 2001-01-23", + "invoice: 34843", + "product:", + " -", + " description: Basketball", + " price: 450.00", + " quantity: 4", + " sku: BL394D", + " -", + " description: 'Super Hoop'", + " price: 2392.00", + " quantity: 1", + " sku: BL4438H", + "tax: 251.42", + "total: 4443.52", + "...", +]; + +my $in = { + 'bill-to' => { + 'given' => 'Chris', + 'address' => { + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + }, + 'family' => 'Dumars' + }, + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => [ + { + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + }, + { + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + } + ], + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' +}; + +my @buf1 = (); +my @buf2 = (); +my $buf3 = ''; + +my @destination = ( + { + name => 'Array reference', + destination => \@buf1, + normalise => sub { return \@buf1 }, + }, + { + name => 'Closure', + destination => sub { push @buf2, shift }, + normalise => sub { return \@buf2 }, + }, + { + name => 'Scalar', + destination => \$buf3, + normalise => sub { + my @ar = split( /\n/, $buf3 ); + return \@ar; + }, + }, +); + +for my $dest ( @destination ) { + my $name = $dest->{name}; + ok my $yaml = Data::YAML::Writer->new, "$name: Created"; + isa_ok $yaml, 'Data::YAML::Writer'; + + $yaml->write( $in, $dest->{destination} ); + my $got = $dest->{normalise}->(); + unless ( is_deeply $got, $out, "$name: Result matches" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$got], ['$got'] ) ); + diag( Data::Dumper->Dump( [$out], ['$expected'] ) ); + } +} diff --git a/Data-YAML-0.0.6/t/40-writer.t b/Data-YAML-0.0.6/t/40-writer.t new file mode 100644 index 0000000..4d70780 --- /dev/null +++ b/Data-YAML-0.0.6/t/40-writer.t @@ -0,0 +1,200 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; +use Data::Dumper; +use Data::YAML::Reader; +use Data::YAML::Writer; + +my @SCHEDULE; + +BEGIN { + @SCHEDULE = ( + { + name => 'Simple scalar', + in => 1, + out => [ '--- 1', '...', ], + }, + { + name => 'Undef', + in => undef, + out => [ '--- ~', '...', ], + }, + { + name => 'Unprintable', + in => "\x01\n\t", + out => [ '--- "\x01\n\t"', '...', ], + }, + { + name => 'Simple array', + in => [ 1, 2, 3 ], + out => [ '---', '- 1', '- 2', '- 3', '...', ], + }, + { + name => 'Array, two elements, undef', + in => [ undef, undef ], + out => [ '---', '- ~', '- ~', '...', ], + }, + { + name => 'Nested array', + in => [ 1, 2, [ 3, 4 ], 5 ], + out => + [ '---', '- 1', '- 2', '-', ' - 3', ' - 4', '- 5', '...', ], + }, + { + name => 'Simple hash', + in => { one => '1', two => '2', three => '3' }, + out => [ '---', 'one: 1', 'three: 3', 'two: 2', '...', ], + }, + { + name => 'Nested hash', + in => { + one => '1', + two => '2', + more => { three => '3', four => '4' } + }, + out => [ + '---', + 'more:', + ' four: 4', + ' three: 3', + 'one: 1', + 'two: 2', + '...', + ], + }, + { + name => 'Unprintable key', + in => { one => '1', "\x02" => '2', three => '3' }, + out => [ '---', '"\x02": 2', 'one: 1', 'three: 3', '...', ], + }, + { + name => 'Empty key', + in => { '' => 'empty' }, + out => [ '---', "'': empty", '...', ], + }, + { + name => 'Empty value', + in => { '' => '' }, + out => [ '---', "'': ''", '...', ], + }, + { + name => 'Complex', + in => { + 'bill-to' => { + 'given' => 'Chris', + 'address' => { + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + }, + 'family' => 'Dumars' + }, + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => [ + { + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + }, + { + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + } + ], + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' + }, + out => [ + "---", + "bill-to:", + " address:", + " city: 'Royal Oak'", + " lines: \"458 Walkman Dr.\\nSuite #292\\n\"", + " postal: 48046", + " state: MI", + " family: Dumars", + " given: Chris", + "comments: \"Late afternoon is best. Backup contact is Nancy Billsmer \@ 338-4338\\n\"", + "date: 2001-01-23", + "invoice: 34843", + "product:", + " -", + " description: Basketball", + " price: 450.00", + " quantity: 4", + " sku: BL394D", + " -", + " description: 'Super Hoop'", + " price: 2392.00", + " quantity: 1", + " sku: BL4438H", + "tax: 251.42", + "total: 4443.52", + "...", + ], + }, + ); + + plan tests => @SCHEDULE * 5; +} + +sub iter { + my $ar = shift; + return sub { + return shift @$ar; + }; +} + +for my $test ( @SCHEDULE ) { + my $name = $test->{name}; + ok my $yaml = Data::YAML::Writer->new, "$name: Created"; + isa_ok $yaml, 'Data::YAML::Writer'; + + my $got = []; + my $writer = sub { push @$got, shift }; + + my $data = $test->{in}; + + eval { $yaml->write( $data, $writer ) }; + + if ( my $err = $test->{error} ) { + unless ( like $@, $err, "$name: Error message" ) { + diag "Error: $@\n"; + } + is_deeply $got, [], "$name: No result"; + pass; + } + else { + my $want = $test->{out}; + unless ( ok !$@, "$name: No error" ) { + diag "Error: $@\n"; + } + unless ( is_deeply $got, $want, "$name: Result matches" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$got], ['$got'] ) ); + diag( Data::Dumper->Dump( [$want], ['$expected'] ) ); + } + + my $yr = Data::YAML::Reader->new; + + # Now try parsing it + my $reader = sub { shift @$got }; + my $parsed = $yr->read( $reader ); + + unless ( is_deeply $parsed, $data, "$name: Reparse OK" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$parsed], ['$parsed'] ) ); + diag( Data::Dumper->Dump( [$data], ['$data'] ) ); + } + } +} + diff --git a/Data-YAML-0.0.6/t/pod-coverage.t b/Data-YAML-0.0.6/t/pod-coverage.t new file mode 100644 index 0000000..c412996 --- /dev/null +++ b/Data-YAML-0.0.6/t/pod-coverage.t @@ -0,0 +1,9 @@ +#!perl -T + +use Test::More; +eval "use Test::Pod::Coverage 1.04"; +plan skip_all => + "Test::Pod::Coverage 1.04 required for testing POD coverage" + if $@; +all_pod_coverage_ok( + { private => [ qr{^BUILD|DEMOLISH|AUTOMETHOD|START$}, qr{^_} ] } ); diff --git a/Data-YAML-0.0.6/t/pod.t b/Data-YAML-0.0.6/t/pod.t new file mode 100644 index 0000000..976d7cd --- /dev/null +++ b/Data-YAML-0.0.6/t/pod.t @@ -0,0 +1,6 @@ +#!perl -T + +use Test::More; +eval "use Test::Pod 1.14"; +plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; +all_pod_files_ok(); diff --git a/README b/README new file mode 100644 index 0000000..0f580f9 --- /dev/null +++ b/README @@ -0,0 +1,6 @@ +Based on Data-YAML version 0.0.6 (Copyright (C) 2007, Andy Armstrong), but it +is so thoroughly rewritten that I don't consider it derived work and I don't +feel the need to resolve what "This library is free software; you can +redistribute it and/or modify it under the same terms as Perl itself." actually +means. + diff --git a/test/00.load.py b/test/00.load.py new file mode 100644 index 0000000..e4f3f5f --- /dev/null +++ b/test/00.load.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +import unittest + +class TestBasics(unittest.TestCase): + def test_import(self): + import yamlish + from yamlish import Reader + from yamlish import Writer + self.assert_(True, + "Testing import of yamlish, version %s." % yamlish.__version__) diff --git a/test/10-input.py b/test/10-input.py new file mode 100644 index 0000000..5ec8d96 --- /dev/null +++ b/test/10-input.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +import unittest + +IN = """ + --- + bill-to: + address: + city: "Royal Oak" + lines: "458 Walkman Dr.\nSuite #292\n" + postal: 48046 + state: MI + family: Dumars + given: Chris + comments: "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n" + date: 2001-01-23 + invoice: 34843 + product: + - + description: Basketball + price: 450.00 + quantity: 4 + sku: BL394D + - + description: "Super Hoop" + price: 2392.00 + quantity: 1 + sku: BL4438H + tax: 251.42 + total: 4443.52 + ... +""" + +OUT = { + 'bill-to': { + 'given': 'Chris', + 'address': { + 'city': 'Royal Oak', + 'postal': '48046', + 'lines': "458 Walkman Dr.\nSuite #292\n", + 'state': 'MI' + }, + 'family': 'Dumars' + }, + 'invoice': '34843', + 'date': '2001-01-23', + 'tax': '251.42', + 'product': [ + { + 'sku': 'BL394D', + 'quantity': '4', + 'price': '450.00', + 'description': 'Basketball' + }, + { + 'sku': 'BL4438H', + 'quantity': '1', + 'price': '2392.00', + 'description': 'Super Hoop' + } + ], + 'comments': + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total': '4443.52' +} + +class TestInput(unittest.TestCase): + """FIXME description of this class""" + def test_reader(self): + #my @lines = @$in; + #my $scalar = join("\n", @lines) . "\n"; + # + #my @source = ( + # { + # name= > 'Array reference', + # source= > $in, + # }, + # { + # name= > 'Closure', + # source= > sub { shift @lines }, + # }, + # { + # name= > 'Scalar', + # source= > $scalar, + # }, + # { + # name= > 'Scalar ref', + # source= > \$scalar, + # }, + #); + # + #for my $src (@source) { + # my $name = $src -> {name}; + # ok my $yaml = Data::YAML::Reader -> new, "$name: Created"; + # isa_ok $yaml, 'Data::YAML::Reader'; + # + # my $got = eval { $yaml -> read($src -> {source}) }; + # unless (is_deeply $got, $out, "$name: Result matches") { + # local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + # diag(Data::Dumper -> Dump([$got], ['$got'])); + # diag(Data::Dumper -> Dump([$out], ['$expected'])); + # } + #} + pass diff --git a/test/20-reader.py b/test/20-reader.py new file mode 100644 index 0000000..fc6806f --- /dev/null +++ b/test/20-reader.py @@ -0,0 +1,419 @@ +use strict; +use warnings; +use Test::More; +use Data::Dumper; + +use Data::YAML::Reader; + +my @SCHEDULE; + +BEGIN { + @SCHEDULE = ( + { + name => 'Hello World', + in => [ '--- Hello, World', '...', ], + out => "Hello, World", + }, + { + name => 'Hello World 2', + in => [ '--- \'Hello, \'\'World\'', '...', ], + out => "Hello, 'World", + }, + { + name => 'Hello World 3', + in => [ '--- "Hello, World"', '...', ], + out => "Hello, World", + }, + { + name => 'Hello World 4', + in => [ '--- "Hello, World"', '...', ], + out => "Hello, World", + }, + { + name => 'Hello World 4', + in => [ '--- >', ' Hello,', ' World', '...', ], + out => "Hello, World\n", + }, + { + name => 'Hello World 5', + in => [ '--- >', ' Hello,', ' World', '...', ], + error => qr{Missing\s+'[.][.][.]'}, + }, + { + name => 'Simple array', + in => [ '---', '- 1', '- 2', '- 3', '...', ], + out => [ '1', '2', '3' ], + }, + { + name => 'Mixed array', + in => [ '---', '- 1', '- \'two\'', '- "three\n"', '...', ], + out => [ '1', 'two', "three\n" ], + }, + { + name => 'Hash in array', + in => [ '---', '- 1', '- two: 2', '- 3', '...', ], + out => [ '1', { two => '2' }, '3' ], + }, + { + name => 'Hash in array 2', + in => [ '---', '- 1', '- two: 2', ' three: 3', '- 4', '...', ], + out => [ '1', { two => '2', three => '3' }, '4' ], + }, + { + name => 'Nested array', + in => [ + '---', + '- one', + '-', + ' - two', + ' -', + ' - three', + ' - four', + '- five', + '...', + ], + out => [ 'one', [ 'two', ['three'], 'four' ], 'five' ], + }, + { + name => 'Nested hash', + in => [ + '---', + 'one:', + ' five: 5', + ' two:', + ' four: 4', + ' three: 3', + 'six: 6', + '...', + ], + out => { + one => { two => { three => '3', four => '4' }, five => '5' }, + six => '6' + }, + }, + + { + name => 'Original YAML::Tiny test', + in => [ + '---', + 'invoice: 34843', + 'date : 2001-01-23', + 'bill-to:', + ' given : Chris', + ' family : Dumars', + ' address:', + ' lines: |', + ' 458 Walkman Dr.', + ' Suite #292', + ' city : Royal Oak', + ' state : MI', + ' postal : 48046', + 'product:', + ' - sku : BL394D', + ' quantity : 4', + ' description : Basketball', + ' price : 450.00', + ' - sku : BL4438H', + ' quantity : 1', + ' description : Super Hoop', + ' price : 2392.00', + 'tax : 251.42', + 'total: 4443.52', + 'comments: >', + ' Late afternoon is best.', + ' Backup contact is Nancy', + ' Billsmer @ 338-4338', + '...', + ], + out => { + 'bill-to' => { + 'given' => 'Chris', + 'address' => { + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + }, + 'family' => 'Dumars' + }, + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => [ + { + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + }, + { + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + } + ], + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' + } + }, + + # Tests harvested from YAML::Tiny + { + in => ['...'], + name => 'Regression: empty', + error => qr{document\s+header\s+not\s+found} + }, + { + in => [ '# comment', '...' ], + name => 'Regression: only_comment', + error => qr{document\s+header\s+not\s+found} + }, + { + out => undef, + in => [ '---', '...' ], + name => 'Regression: only_header', + error => qr{Premature\s+end}i, + }, + { + out => undef, + in => [ '---', '---', '...' ], + name => 'Regression: two_header', + error => qr{Unexpected\s+start}i, + }, + { + out => undef, + in => [ '--- ~', '...' ], + name => 'Regression: one_undef' + }, + { + out => undef, + in => [ '--- ~', '...' ], + name => 'Regression: one_undef2' + }, + { + in => [ '--- ~', '---', '...' ], + name => 'Regression: two_undef', + error => qr{Missing\s+'[.][.][.]'}, + }, + { + out => 'foo', + in => [ '--- foo', '...' ], + name => 'Regression: one_scalar', + }, + { + out => 'foo', + in => [ '--- foo', '...' ], + name => 'Regression: one_scalar2', + }, + { + in => [ '--- foo', '--- bar', '...' ], + name => 'Regression: two_scalar', + error => qr{Missing\s+'[.][.][.]'}, + }, + { + out => ['foo'], + in => [ '---', '- foo', '...' ], + name => 'Regression: one_list1' + }, + { + out => [ 'foo', 'bar' ], + in => [ '---', '- foo', '- bar', '...' ], + name => 'Regression: one_list2' + }, + { + out => [ undef, 'bar' ], + in => [ '---', '- ~', '- bar', '...' ], + name => 'Regression: one_listundef' + }, + { + out => { 'foo' => 'bar' }, + in => [ '---', 'foo: bar', '...' ], + name => 'Regression: one_hash1' + }, + { + out => { + 'foo' => 'bar', + 'this' => undef + }, + in => [ '---', 'foo: bar', 'this: ~', '...' ], + name => 'Regression: one_hash2' + }, + { + out => { 'foo' => [ 'bar', undef, 'baz' ] }, + in => [ '---', 'foo:', ' - bar', ' - ~', ' - baz', '...' ], + name => 'Regression: array_in_hash' + }, + { + out => { + 'bar' => { 'foo' => 'bar' }, + 'foo' => undef + }, + in => [ '---', 'foo: ~', 'bar:', ' foo: bar', '...' ], + name => 'Regression: hash_in_hash' + }, + { + out => [ + { + 'foo' => undef, + 'this' => 'that' + }, + 'foo', undef, + { + 'foo' => 'bar', + 'this' => 'that' + } + ], + in => [ + '---', + '-', + ' foo: ~', + ' this: that', + '- foo', + '- ~', + '-', + ' foo: bar', + ' this: that', + '...' + ], + name => 'Regression: hash_in_array' + }, + { + out => ['foo'], + in => [ '---', '- \'foo\'', '...' ], + name => 'Regression: single_quote1' + }, + { + out => [' '], + in => [ '---', '- \' \'', '...' ], + name => 'Regression: single_spaces' + }, + { + out => [''], + in => [ '---', '- \'\'', '...' ], + name => 'Regression: single_null' + }, + { + out => ' ', + in => [ '--- " "', '...' ], + name => 'Regression: only_spaces' + }, + { + out => [ + undef, + { + 'foo' => 'bar', + 'this' => 'that' + }, + 'baz' + ], + in => + [ '---', '- ~', '- foo: bar', ' this: that', '- baz', '...' ], + name => 'Regression: inline_nested_hash' + }, + { + name => "Unprintables", + in => [ + "---", + "- \"\\z\\x01\\x02\\x03\\x04\\x05\\x06\\a\\x08\\t\\n\\v\\f\\r\\x0e\\x0f\"", + "- \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\e\\x1c\\x1d\\x1e\\x1f\"", + "- \" !\\\"#\$%&'()*+,-./\"", + "- 0123456789:;<=>?", + "- '\@ABCDEFGHIJKLMNO'", + "- 'PQRSTUVWXYZ[\\]^_'", + "- '`abcdefghijklmno'", + "- 'pqrstuvwxyz{|}~\177'", + "- \200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217", + "- \220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237", + "- \240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257", + "- \260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277", + "- \300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317", + "- \320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337", + "- \340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357", + "- \360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377", + "..." + ], + out => [ + "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17", + "\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37", + " !\"#\$%&'()*+,-./", + "0123456789:;<=>?", + "\@ABCDEFGHIJKLMNO", + "PQRSTUVWXYZ[\\]^_", + "`abcdefghijklmno", + "pqrstuvwxyz{|}~\177", + "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217", + "\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237", + "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257", + "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277", + "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317", + "\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337", + "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357", + "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" + ], + }, + { + name => 'Quoted hash keys', + in => [ + '---', ' "quoted": Magic!', ' "\n\t": newline, tab', '...', + ], + out => { + quoted => 'Magic!', + "\n\t" => 'newline, tab', + }, + }, + ); + + plan tests => @SCHEDULE * 5; +} + +sub iter { + my $ar = shift; + return sub { + return shift @$ar; + }; +} + +for my $test ( @SCHEDULE ) { + my $name = $test->{name}; + ok my $yaml = Data::YAML::Reader->new, "$name: Created"; + isa_ok $yaml, 'Data::YAML::Reader'; + + # diag "$name\n"; + + # unless ( $test->{in} ) { + # pass for 1 .. 2; + # use YAML; + # diag "Input for test:\n"; + # diag( Dump( $test->{out} ) ); + # next; + # } + + my $source = join( "\n", @{ $test->{in} } ) . "\n"; + + my $iter = iter( $test->{in} ); + my $got = eval { $yaml->read( $iter ) }; + + my $raw = $yaml->get_raw; + + if ( my $err = $test->{error} ) { + unless ( like $@, $err, "$name: Error message" ) { + diag "Error: $@\n"; + } + ok !$got, "$name: No result"; + pass; + } + else { + my $want = $test->{out}; + unless ( ok !$@, "$name: No error" ) { + diag "Error: $@\n"; + } + unless ( is_deeply $got, $want, "$name: Result matches" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$got], ['$got'] ) ); + diag( Data::Dumper->Dump( [$want], ['$expected'] ) ); + } + is $raw, $source, "$name: Captured source matches"; + } +} diff --git a/test/30-output.py b/test/30-output.py new file mode 100644 index 0000000..56cfb0a --- /dev/null +++ b/test/30-output.py @@ -0,0 +1,107 @@ +use strict; +use warnings; +use Test::More tests => 9; +use Data::Dumper; + +use Data::YAML::Writer; + +my $out = [ + "---", + "bill-to:", + " address:", + " city: 'Royal Oak'", + " lines: \"458 Walkman Dr.\\nSuite #292\\n\"", + " postal: 48046", + " state: MI", + " family: Dumars", + " given: Chris", + "comments: \"Late afternoon is best. Backup contact is Nancy Billsmer \@ 338-4338\\n\"", + "date: 2001-01-23", + "invoice: 34843", + "product:", + " -", + " description: Basketball", + " price: 450.00", + " quantity: 4", + " sku: BL394D", + " -", + " description: 'Super Hoop'", + " price: 2392.00", + " quantity: 1", + " sku: BL4438H", + "tax: 251.42", + "total: 4443.52", + "...", +]; + +my $in = { + 'bill-to' => { + 'given' => 'Chris', + 'address' => { + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + }, + 'family' => 'Dumars' + }, + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => [ + { + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + }, + { + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + } + ], + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' +}; + +my @buf1 = (); +my @buf2 = (); +my $buf3 = ''; + +my @destination = ( + { + name => 'Array reference', + destination => \@buf1, + normalise => sub { return \@buf1 }, + }, + { + name => 'Closure', + destination => sub { push @buf2, shift }, + normalise => sub { return \@buf2 }, + }, + { + name => 'Scalar', + destination => \$buf3, + normalise => sub { + my @ar = split( /\n/, $buf3 ); + return \@ar; + }, + }, +); + +for my $dest ( @destination ) { + my $name = $dest->{name}; + ok my $yaml = Data::YAML::Writer->new, "$name: Created"; + isa_ok $yaml, 'Data::YAML::Writer'; + + $yaml->write( $in, $dest->{destination} ); + my $got = $dest->{normalise}->(); + unless ( is_deeply $got, $out, "$name: Result matches" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$got], ['$got'] ) ); + diag( Data::Dumper->Dump( [$out], ['$expected'] ) ); + } +} diff --git a/test/40-writer.py b/test/40-writer.py new file mode 100644 index 0000000..4d70780 --- /dev/null +++ b/test/40-writer.py @@ -0,0 +1,200 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; +use Data::Dumper; +use Data::YAML::Reader; +use Data::YAML::Writer; + +my @SCHEDULE; + +BEGIN { + @SCHEDULE = ( + { + name => 'Simple scalar', + in => 1, + out => [ '--- 1', '...', ], + }, + { + name => 'Undef', + in => undef, + out => [ '--- ~', '...', ], + }, + { + name => 'Unprintable', + in => "\x01\n\t", + out => [ '--- "\x01\n\t"', '...', ], + }, + { + name => 'Simple array', + in => [ 1, 2, 3 ], + out => [ '---', '- 1', '- 2', '- 3', '...', ], + }, + { + name => 'Array, two elements, undef', + in => [ undef, undef ], + out => [ '---', '- ~', '- ~', '...', ], + }, + { + name => 'Nested array', + in => [ 1, 2, [ 3, 4 ], 5 ], + out => + [ '---', '- 1', '- 2', '-', ' - 3', ' - 4', '- 5', '...', ], + }, + { + name => 'Simple hash', + in => { one => '1', two => '2', three => '3' }, + out => [ '---', 'one: 1', 'three: 3', 'two: 2', '...', ], + }, + { + name => 'Nested hash', + in => { + one => '1', + two => '2', + more => { three => '3', four => '4' } + }, + out => [ + '---', + 'more:', + ' four: 4', + ' three: 3', + 'one: 1', + 'two: 2', + '...', + ], + }, + { + name => 'Unprintable key', + in => { one => '1', "\x02" => '2', three => '3' }, + out => [ '---', '"\x02": 2', 'one: 1', 'three: 3', '...', ], + }, + { + name => 'Empty key', + in => { '' => 'empty' }, + out => [ '---', "'': empty", '...', ], + }, + { + name => 'Empty value', + in => { '' => '' }, + out => [ '---', "'': ''", '...', ], + }, + { + name => 'Complex', + in => { + 'bill-to' => { + 'given' => 'Chris', + 'address' => { + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + }, + 'family' => 'Dumars' + }, + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => [ + { + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + }, + { + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + } + ], + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' + }, + out => [ + "---", + "bill-to:", + " address:", + " city: 'Royal Oak'", + " lines: \"458 Walkman Dr.\\nSuite #292\\n\"", + " postal: 48046", + " state: MI", + " family: Dumars", + " given: Chris", + "comments: \"Late afternoon is best. Backup contact is Nancy Billsmer \@ 338-4338\\n\"", + "date: 2001-01-23", + "invoice: 34843", + "product:", + " -", + " description: Basketball", + " price: 450.00", + " quantity: 4", + " sku: BL394D", + " -", + " description: 'Super Hoop'", + " price: 2392.00", + " quantity: 1", + " sku: BL4438H", + "tax: 251.42", + "total: 4443.52", + "...", + ], + }, + ); + + plan tests => @SCHEDULE * 5; +} + +sub iter { + my $ar = shift; + return sub { + return shift @$ar; + }; +} + +for my $test ( @SCHEDULE ) { + my $name = $test->{name}; + ok my $yaml = Data::YAML::Writer->new, "$name: Created"; + isa_ok $yaml, 'Data::YAML::Writer'; + + my $got = []; + my $writer = sub { push @$got, shift }; + + my $data = $test->{in}; + + eval { $yaml->write( $data, $writer ) }; + + if ( my $err = $test->{error} ) { + unless ( like $@, $err, "$name: Error message" ) { + diag "Error: $@\n"; + } + is_deeply $got, [], "$name: No result"; + pass; + } + else { + my $want = $test->{out}; + unless ( ok !$@, "$name: No error" ) { + diag "Error: $@\n"; + } + unless ( is_deeply $got, $want, "$name: Result matches" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$got], ['$got'] ) ); + diag( Data::Dumper->Dump( [$want], ['$expected'] ) ); + } + + my $yr = Data::YAML::Reader->new; + + # Now try parsing it + my $reader = sub { shift @$got }; + my $parsed = $yr->read( $reader ); + + unless ( is_deeply $parsed, $data, "$name: Reparse OK" ) { + local $Data::Dumper::Useqq = $Data::Dumper::Useqq = 1; + diag( Data::Dumper->Dump( [$parsed], ['$parsed'] ) ); + diag( Data::Dumper->Dump( [$data], ['$data'] ) ); + } + } +} + diff --git a/test/pod-coverage.py b/test/pod-coverage.py new file mode 100644 index 0000000..c412996 --- /dev/null +++ b/test/pod-coverage.py @@ -0,0 +1,9 @@ +#!perl -T + +use Test::More; +eval "use Test::Pod::Coverage 1.04"; +plan skip_all => + "Test::Pod::Coverage 1.04 required for testing POD coverage" + if $@; +all_pod_coverage_ok( + { private => [ qr{^BUILD|DEMOLISH|AUTOMETHOD|START$}, qr{^_} ] } ); diff --git a/test/pod.py b/test/pod.py new file mode 100644 index 0000000..976d7cd --- /dev/null +++ b/test/pod.py @@ -0,0 +1,6 @@ +#!perl -T + +use Test::More; +eval "use Test::Pod 1.14"; +plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; +all_pod_files_ok(); diff --git a/yamlish.js b/yamlish.js new file mode 160000 index 0000000..25bec9d --- /dev/null +++ b/yamlish.js @@ -0,0 +1 @@ +Subproject commit 25bec9d8d5111bd6574964fbcd2bec2425460c13 diff --git a/yamlish.py b/yamlish.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/yamlish.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/yamlishwriter-php-v0.0.1/Changes b/yamlishwriter-php-v0.0.1/Changes new file mode 100644 index 0000000..4bf0e3c --- /dev/null +++ b/yamlishwriter-php-v0.0.1/Changes @@ -0,0 +1,3 @@ +0.0.1 2007-03-19 + - Initial release + \ No newline at end of file diff --git a/yamlishwriter-php-v0.0.1/MANIFEST b/yamlishwriter-php-v0.0.1/MANIFEST new file mode 100644 index 0000000..1f7a3cc --- /dev/null +++ b/yamlishwriter-php-v0.0.1/MANIFEST @@ -0,0 +1,10 @@ +./Changes +./dist.sh +./lib/yamlishwriter.php +./Makefile +./README +./t/00-load.php +./t/10-writer.php +./t/harness.t +./t/lib/TestLite.php +./MANIFEST diff --git a/yamlishwriter-php-v0.0.1/Makefile b/yamlishwriter-php-v0.0.1/Makefile new file mode 100644 index 0000000..09e4803 --- /dev/null +++ b/yamlishwriter-php-v0.0.1/Makefile @@ -0,0 +1,21 @@ +# Makefile for YAMLish + +PHP = /usr/bin/php +PROVE = prove -r t + +VERSION = 0.0.1 +DISTNAME = yamlishwriter-php-v$(VERSION) + +default: + +test: + PHP=$(PHP) $(PROVE) + +dist: manifest + ./dist.sh $(DISTNAME) + +manifest: + rm -f MANIFEST + find . -type f | grep -vE '\.svn|\.DS_Store|\.tmproj' > MANIFEST + echo './MANIFEST' >> MANIFEST + \ No newline at end of file diff --git a/yamlishwriter-php-v0.0.1/README b/yamlishwriter-php-v0.0.1/README new file mode 100644 index 0000000..bbd6204 --- /dev/null +++ b/yamlishwriter-php-v0.0.1/README @@ -0,0 +1,33 @@ +YAMLishWriter.php Version 0.0.1 + +This is a simple implementation of a YAMLish writer for PHP. See + + http://testanything.org/wiki/index.php/YAMLish + +for more information about YAMLish. + +You can find the YAMLishWriter class in lib/yamlishwriter.php in this +distribution. YAMLishWriter is a self contained PHP class. To use it + + // Or wherever it is on your include path + include('yamlishwriter.php'); + + // And then later + $writer = new YAMLishWriter; + + $data = array( 'got' => 1, 'expected' => 2 ); + $output = $writer->write($data); + +The returned value is an array containing the lines of YAMLish. + +This distribution contains a rudimentary test harness for which you'll +need Perl prove command. To run the tests edit Makefile to reflect the +location of your php command and then + + make test + +Copyright 2007 Andy Armstrong, andy@hexten.net. + +YAMLishWriter is distributed under Perl Artistic Licence: + + http://www.opensource.org/licenses/artistic-license.php diff --git a/yamlishwriter-php-v0.0.1/dist.sh b/yamlishwriter-php-v0.0.1/dist.sh new file mode 100755 index 0000000..5752e53 --- /dev/null +++ b/yamlishwriter-php-v0.0.1/dist.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +distname=$1 +distarc="$distname.tar.gz" + +echo "Making $distarc" +for f in `cat MANIFEST` +do + d=`dirname $f` + mkdir -p "$distname/$d" + echo "Adding $f" + cp $f "$distname/$f" +done + +tar zcf $distarc $distname +rm -rf $distname diff --git a/yamlishwriter-php-v0.0.1/lib/yamlishwriter.php b/yamlishwriter-php-v0.0.1/lib/yamlishwriter.php new file mode 100644 index 0000000..62035a9 --- /dev/null +++ b/yamlishwriter-php-v0.0.1/lib/yamlishwriter.php @@ -0,0 +1,125 @@ +_write_obj( $out, '---', $obj ); + $out[] = '...'; + + return $out; + } + + function _write_hash( &$out, $obj, $indent, $pad ) { + while ( list($k, $v) = each( $obj ) ) { + $this->_write_obj( + $out, + $pad . $this->_enc_scalar($k) . ':', + $v, $indent + 1 + ); + } + } + + function _write_array( &$out, $obj, $indent ) { + $pad = ''; + for ( $i = 0; $i < $indent; $i++ ) { + $pad .= ' '; + } + + $nout = array(); + $idx = 0; + while ( list($k, $v) = each( $obj ) ) { + if (gettype($k) != 'integer' || $k != $idx) { + # If we find it's not actually an array discard what we've done + # and write a hash instead. Usually we should find out pretty + # early. + $this->_write_hash( $out, $obj, $indent, $pad ); + return; + } + + $this->_write_obj( $nout, "$pad-", $v, $indent + 1); + $idx++; + } + + array_splice( $out, count($out), 0, $nout ); + } + + function _enc_string ( $str ) { + if (preg_match('/[\x00-\x1f\"]/', $str)) { + $str = preg_replace('/\\\\/', '\\\\', $str); + $str = preg_replace('/"/', '\\"', $str); + $str = preg_replace_callback( '/([\x00-\x1f])/', '__escape_unprintable', $str ); + return '"' . $str . '"'; + } + + if ( strlen($str) == 0 || preg_match( '/\s/', $str ) ) { + return "'" . preg_replace('/\'/', "''", $str) . "'"; + } + + return $str; + } + + function _enc_scalar( $obj ) { + $type = gettype( $obj ); + switch ($type) { + case 'boolean': + return $obj ? '1' : '0'; + + case 'double' : + case 'integer': + return "$obj"; + + case 'NULL': + return '~'; + + case 'string': + return $this->_enc_string( $obj ); + + default: + die('Unhandled scalar type ' . $type); + } + } + + function _write_obj( &$out, $prefix, $obj, $indent = 0 ) { + $type = gettype( $obj ); + + switch ($type) { + case 'boolean': + case 'integer': + case 'double' : + case 'string': + case 'NULL': + $out[] = "$prefix " . $this->_enc_scalar( $obj ); + break; + + case 'array': + $out[] = $prefix; + $this->_write_array( $out, $obj, $indent ); + break; + + case 'object': + case 'resource': + default: + die('Unhandled type ' . $type); + } + } + } + +?> diff --git a/yamlishwriter-php-v0.0.1/t/00-load.php b/yamlishwriter-php-v0.0.1/t/00-load.php new file mode 100644 index 0000000..afe3000 --- /dev/null +++ b/yamlishwriter-php-v0.0.1/t/00-load.php @@ -0,0 +1,9 @@ + diff --git a/yamlishwriter-php-v0.0.1/t/10-writer.php b/yamlishwriter-php-v0.0.1/t/10-writer.php new file mode 100644 index 0000000..146b356 --- /dev/null +++ b/yamlishwriter-php-v0.0.1/t/10-writer.php @@ -0,0 +1,180 @@ + 'Simple scalar', + 'in' => 1, + 'out' => array( + '--- 1', + '...', + ), + ), + array( + 'name' => 'Undef', + 'in' => null, + 'out' => array( + '--- ~', + '...', + ), + ), + array( + 'name' => 'Unprintable', + 'in' => "\x01\n\t", + 'out' => array( + '--- "\x01\n\t"', + '...', + ), + ), + array( + 'name' => 'Simple array', + 'in' => array( 1, 2, 3 ), + 'out' => array( + '---', + '- 1', + '- 2', + '- 3', + '...', + ), + ), + array( + 'name' => 'Array, two elements, null', + 'in' => array( null, null ), + 'out' => array( + '---', + '- ~', + '- ~', + '...', + ), + ), + array( + 'name' => 'Nested array', + 'in' => array( 1, 2, array( 3, 4 ), 5 ), + 'out' => array( + '---', + '- 1', + '- 2', + '-', + ' - 3', + ' - 4', + '- 5', + '...', + ), + ), + array( + 'name' => 'Simple hash', + 'in' => array( 'one' => '1', 'two' => '2', 'three' => '3' ), + 'out' => array( + '---', + 'one: 1', + 'two: 2', + 'three: 3', + '...', + ), + ), + array( + 'name' => 'Nested hash', + 'in' => array( + 'one' => '1', 'two' => '2', 'more' => array( 'three' => '3', 'four' => '4' ) + ), + 'out' => array( + '---', + 'one: 1', + 'two: 2', + 'more:', + ' three: 3', + ' four: 4', + '...', + ), + ), + array( + 'name' => 'Unprintable key', + 'in' => array( 'one' => '1', "\x02" => '2', 'three' => '3' ), + 'out' => array( + '---', + 'one: 1', + '"\x02": 2', + 'three: 3', + '...', + ), + ), + array( + 'name' => 'Complex', + 'in' => array( + 'bill-to' => array( + 'given' => 'Chris', + 'address' => array( + 'city' => 'Royal Oak', + 'postal' => '48046', + 'lines' => "458 Walkman Dr.\nSuite #292\n", + 'state' => 'MI' + ), + 'family' => 'Dumars' + ), + 'invoice' => '34843', + 'date' => '2001-01-23', + 'tax' => '251.42', + 'product' => array( + array( + 'sku' => 'BL394D', + 'quantity' => '4', + 'price' => '450.00', + 'description' => 'Basketball' + ), + array( + 'sku' => 'BL4438H', + 'quantity' => '1', + 'price' => '2392.00', + 'description' => 'Super Hoop' + ) + ), + 'comments' => + "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", + 'total' => '4443.52' + ), + 'out' => array( + "---", + "bill-to:", + " given: Chris", + " address:", + " city: 'Royal Oak'", + " postal: 48046", + " lines: \"458 Walkman Dr.\\nSuite #292\\n\"", + " state: MI", + " family: Dumars", + "invoice: 34843", + "date: 2001-01-23", + "tax: 251.42", + "product:", + " -", + " sku: BL394D", + " quantity: 4", + " price: 450.00", + " description: Basketball", + " -", + " sku: BL4438H", + " quantity: 1", + " price: 2392.00", + " description: 'Super Hoop'", + "comments: \"Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\\n\"", + "total: 4443.52", + "...", + ), + ), + ); + + plan( count($schedule) * 1 ); + + include_once('./lib/yamlishwriter.php'); + + foreach ($schedule as $test) { + $name = $test['name']; + $writer = new YAMLishWriter; + $got = $writer->write($test['in']); + is_deeply_array($got, $test['out'], "$name: output matches"); + } + +?> diff --git a/yamlishwriter-php-v0.0.1/t/harness.t b/yamlishwriter-php-v0.0.1/t/harness.t new file mode 100644 index 0000000..abc51f8 --- /dev/null +++ b/yamlishwriter-php-v0.0.1/t/harness.t @@ -0,0 +1,29 @@ +use strict; +use warnings; + +my $php = $ENV{PHP} || 'php'; + +my $TESTS = 't/*.php'; + +my $planned = 0; + +for my $test ( glob( $TESTS ) ) { + warn "# $test\n"; + my $offset = $planned; + my @command = ( $php, $test ); + open my $th, '-|', @command or die "Can't run $test ($?)\n"; + while ( defined( my $line = <$th> ) ) { + chomp $line; + if ( $line =~ /^1..(\d+)/ ) { + $planned += $1; + } + else { + $line =~ s/^((?:not\s+)?ok\s+)(\d+)/$1 . ($2 + $offset)/e; + print "$line\n"; + } + } + close $th or die "Can't run $test ($?)\n"; +} + +# Trailing plan +print "1..$planned\n"; diff --git a/yamlishwriter-php-v0.0.1/t/lib/TestLite.php b/yamlishwriter-php-v0.0.1/t/lib/TestLite.php new file mode 100644 index 0000000..231001b --- /dev/null +++ b/yamlishwriter-php-v0.0.1/t/lib/TestLite.php @@ -0,0 +1,79 @@ + -- cgit