Hello community,

here is the log from the commit of package perl-YAML-PP for openSUSE:Factory 
checked in at 2020-03-01 21:28:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-YAML-PP (Old)
 and      /work/SRC/openSUSE:Factory/.perl-YAML-PP.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-YAML-PP"

Sun Mar  1 21:28:03 2020 rev:4 rq:780473 version:0.021

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-YAML-PP/perl-YAML-PP.changes        
2020-02-18 13:30:28.580827480 +0100
+++ /work/SRC/openSUSE:Factory/.perl-YAML-PP.new.26092/perl-YAML-PP.changes     
2020-03-01 21:28:24.844605237 +0100
@@ -1,0 +2,11 @@
+Fri Feb 28 03:14:57 UTC 2020 -  <[email protected]>
+
+- updated to 0.021
+   see /usr/share/doc/packages/perl-YAML-PP/Changes
+
+  0.021 2020-02-27 19:04:58+01:00
+  
+      - Add option 'preserve' for preserving hash key order and quoting
+        style when loading and dumping
+
+-------------------------------------------------------------------

Old:
----
  YAML-PP-0.020.tar.gz

New:
----
  YAML-PP-0.021.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-YAML-PP.spec ++++++
--- /var/tmp/diff_new_pack.OpGRsE/_old  2020-03-01 21:28:27.348610324 +0100
+++ /var/tmp/diff_new_pack.OpGRsE/_new  2020-03-01 21:28:27.348610324 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           perl-YAML-PP
-Version:        0.020
+Version:        0.021
 Release:        0
 %define cpan_name YAML-PP
 Summary:        YAML 1.2 processor

++++++ YAML-PP-0.020.tar.gz -> YAML-PP-0.021.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/Changes new/YAML-PP-0.021/Changes
--- old/YAML-PP-0.020/Changes   2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/Changes   2020-02-27 19:07:59.000000000 +0100
@@ -1,5 +1,10 @@
 Revision history for Perl module YAML::PP
 
+0.021 2020-02-27 19:04:58+01:00
+
+    - Add option 'preserve' for preserving hash key order and quoting
+      style when loading and dumping
+
 0.020 2020-02-17 15:35:44+01:00
 
     - Change default schema from JSON to Core (this change was supposed
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/MANIFEST new/YAML-PP-0.021/MANIFEST
--- old/YAML-PP-0.020/MANIFEST  2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/MANIFEST  2020-02-27 19:07:59.000000000 +0100
@@ -95,6 +95,7 @@
 t/49.include.t
 t/50.clone.t
 t/51.directives.t
+t/52.preserve.t
 t/data/include/circular1.yaml
 t/data/include/circular2.yaml
 t/data/include/include.yaml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/META.json new/YAML-PP-0.021/META.json
--- old/YAML-PP-0.020/META.json 2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/META.json 2020-02-27 19:07:59.000000000 +0100
@@ -36,6 +36,7 @@
             "MIME::Base64" : "0",
             "Module::Load" : "0",
             "Scalar::Util" : "1.07",
+            "Tie::Hash" : "0",
             "base" : "0",
             "constant" : "0",
             "overload" : "0",
@@ -62,119 +63,127 @@
    "provides" : {
       "YAML::PP" : {
          "file" : "lib/YAML/PP.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Common" : {
          "file" : "lib/YAML/PP/Common.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Constructor" : {
          "file" : "lib/YAML/PP/Constructor.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Dumper" : {
          "file" : "lib/YAML/PP/Dumper.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Emitter" : {
          "file" : "lib/YAML/PP/Emitter.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Exception" : {
          "file" : "lib/YAML/PP/Exception.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Grammar" : {
          "file" : "lib/YAML/PP/Grammar.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Highlight" : {
          "file" : "lib/YAML/PP/Highlight.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Lexer" : {
          "file" : "lib/YAML/PP/Lexer.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Loader" : {
          "file" : "lib/YAML/PP/Loader.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Parser" : {
          "file" : "lib/YAML/PP/Parser.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Perl" : {
          "file" : "lib/YAML/PP/Perl.pm",
-         "version" : "0.020"
+         "version" : "0.021"
+      },
+      "YAML::PP::Preserve::Hash" : {
+         "file" : "lib/YAML/PP.pm",
+         "version" : "0.021"
+      },
+      "YAML::PP::Preserve::Scalar" : {
+         "file" : "lib/YAML/PP.pm",
+         "version" : "0.021"
       },
       "YAML::PP::Reader" : {
          "file" : "lib/YAML/PP/Reader.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Reader::File" : {
          "file" : "lib/YAML/PP/Reader.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Render" : {
          "file" : "lib/YAML/PP/Render.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Representer" : {
          "file" : "lib/YAML/PP/Representer.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema" : {
          "file" : "lib/YAML/PP/Schema.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::Binary" : {
          "file" : "lib/YAML/PP/Schema/Binary.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::Core" : {
          "file" : "lib/YAML/PP/Schema/Core.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::Failsafe" : {
          "file" : "lib/YAML/PP/Schema/Failsafe.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::Include" : {
          "file" : "lib/YAML/PP/Schema/Include.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::JSON" : {
          "file" : "lib/YAML/PP/Schema/JSON.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::Merge" : {
          "file" : "lib/YAML/PP/Schema/Merge.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::Perl" : {
          "file" : "lib/YAML/PP/Schema/Perl.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::Tie::IxHash" : {
          "file" : "lib/YAML/PP/Schema/Tie/IxHash.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Schema::YAML1_1" : {
          "file" : "lib/YAML/PP/Schema/YAML1_1.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Type::MergeKey" : {
          "file" : "lib/YAML/PP/Type/MergeKey.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Writer" : {
          "file" : "lib/YAML/PP/Writer.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       },
       "YAML::PP::Writer::File" : {
          "file" : "lib/YAML/PP/Writer/File.pm",
-         "version" : "0.020"
+         "version" : "0.021"
       }
    },
    "release_status" : "stable",
@@ -188,7 +197,7 @@
          "web" : "https://github.com/perlpunk/YAML-PP-p5";
       }
    },
-   "version" : "0.020",
+   "version" : "0.021",
    "x_generated_by_perl" : "v5.24.1",
    "x_serialization_backend" : "Cpanel::JSON::XS version 4.02"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/META.yml new/YAML-PP-0.021/META.yml
--- old/YAML-PP-0.020/META.yml  2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/META.yml  2020-02-27 19:07:59.000000000 +0100
@@ -25,91 +25,97 @@
 provides:
   YAML::PP:
     file: lib/YAML/PP.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Common:
     file: lib/YAML/PP/Common.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Constructor:
     file: lib/YAML/PP/Constructor.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Dumper:
     file: lib/YAML/PP/Dumper.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Emitter:
     file: lib/YAML/PP/Emitter.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Exception:
     file: lib/YAML/PP/Exception.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Grammar:
     file: lib/YAML/PP/Grammar.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Highlight:
     file: lib/YAML/PP/Highlight.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Lexer:
     file: lib/YAML/PP/Lexer.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Loader:
     file: lib/YAML/PP/Loader.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Parser:
     file: lib/YAML/PP/Parser.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Perl:
     file: lib/YAML/PP/Perl.pm
-    version: '0.020'
+    version: '0.021'
+  YAML::PP::Preserve::Hash:
+    file: lib/YAML/PP.pm
+    version: '0.021'
+  YAML::PP::Preserve::Scalar:
+    file: lib/YAML/PP.pm
+    version: '0.021'
   YAML::PP::Reader:
     file: lib/YAML/PP/Reader.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Reader::File:
     file: lib/YAML/PP/Reader.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Render:
     file: lib/YAML/PP/Render.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Representer:
     file: lib/YAML/PP/Representer.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema:
     file: lib/YAML/PP/Schema.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::Binary:
     file: lib/YAML/PP/Schema/Binary.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::Core:
     file: lib/YAML/PP/Schema/Core.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::Failsafe:
     file: lib/YAML/PP/Schema/Failsafe.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::Include:
     file: lib/YAML/PP/Schema/Include.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::JSON:
     file: lib/YAML/PP/Schema/JSON.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::Merge:
     file: lib/YAML/PP/Schema/Merge.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::Perl:
     file: lib/YAML/PP/Schema/Perl.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::Tie::IxHash:
     file: lib/YAML/PP/Schema/Tie/IxHash.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Schema::YAML1_1:
     file: lib/YAML/PP/Schema/YAML1_1.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Type::MergeKey:
     file: lib/YAML/PP/Type/MergeKey.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Writer:
     file: lib/YAML/PP/Writer.pm
-    version: '0.020'
+    version: '0.021'
   YAML::PP::Writer::File:
     file: lib/YAML/PP/Writer/File.pm
-    version: '0.020'
+    version: '0.021'
 requires:
   B: '0'
   B::Deparse: '0'
@@ -121,6 +127,7 @@
   MIME::Base64: '0'
   Module::Load: '0'
   Scalar::Util: '1.07'
+  Tie::Hash: '0'
   base: '0'
   constant: '0'
   overload: '0'
@@ -130,6 +137,6 @@
 resources:
   bugtracker: https://github.com/perlpunk/YAML-PP-p5/issues
   repository: https://github.com/perlpunk/YAML-PP-p5
-version: '0.020'
+version: '0.021'
 x_generated_by_perl: v5.24.1
 x_serialization_backend: 'YAML::Tiny version 1.73'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/Makefile.PL 
new/YAML-PP-0.021/Makefile.PL
--- old/YAML-PP-0.020/Makefile.PL       2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/Makefile.PL       2020-02-27 19:07:59.000000000 +0100
@@ -34,6 +34,7 @@
     "MIME::Base64" => 0,
     "Module::Load" => 0,
     "Scalar::Util" => "1.07",
+    "Tie::Hash" => 0,
     "base" => 0,
     "constant" => 0,
     "overload" => 0,
@@ -51,7 +52,7 @@
     "blib" => "1.01",
     "lib" => 0
   },
-  "VERSION" => "0.020",
+  "VERSION" => "0.021",
   "test" => {
     "TESTS" => "t/*.t"
   }
@@ -76,6 +77,7 @@
   "Test::Deep" => 0,
   "Test::More" => "0.98",
   "Test::Warn" => 0,
+  "Tie::Hash" => 0,
   "base" => 0,
   "blib" => "1.01",
   "constant" => 0,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/README new/YAML-PP-0.021/README
--- old/YAML-PP-0.020/README    2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/README    2020-02-27 19:07:59.000000000 +0100
@@ -1,5 +1,5 @@
 This archive contains the distribution YAML-PP,
-version 0.020:
+version 0.021:
 
   YAML 1.2 Processor
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/bin/yamlpp5-load 
new/YAML-PP-0.021/bin/yamlpp5-load
--- old/YAML-PP-0.020/bin/yamlpp5-load  2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/bin/yamlpp5-load  2020-02-27 19:07:59.000000000 +0100
@@ -14,7 +14,7 @@
     $yaml = decode_utf8($yaml);
 }
 
-my $ypp = YAML::PP->new;
+my $ypp = YAML::PP->new( preserve => 1 );
 my @docs = $file ? $ypp->load_file($file) : $ypp->load_string($yaml);
 
 local $Data::Dumper::Useqq = 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/bin/yamlpp5-load-dump 
new/YAML-PP-0.021/bin/yamlpp5-load-dump
--- old/YAML-PP-0.020/bin/yamlpp5-load-dump     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/bin/yamlpp5-load-dump     2020-02-27 19:07:59.000000000 
+0100
@@ -14,7 +14,7 @@
     $yaml = decode_utf8($yaml);
 }
 
-my $ypp = YAML::PP->new(boolean => 'JSON::PP');
+my $ypp = YAML::PP->new(boolean => 'JSON::PP', preserve => 1);
 my @docs = $file ? $ypp->load_file($file) : $ypp->load_string($yaml);
 my $out_yaml = $ypp->dump_string(@docs);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/dist.ini new/YAML-PP-0.021/dist.ini
--- old/YAML-PP-0.020/dist.ini  2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/dist.ini  2020-02-27 19:07:59.000000000 +0100
@@ -4,7 +4,7 @@
 copyright_holder = Tina Müller
 copyright_year   = 2020
 
-version = 0.020
+version = 0.021
 
 [@Filter]
 -bundle = @Basic
@@ -20,6 +20,7 @@
 skip = JSON::PP
 skip = HTML::Entities
 skip = Tie::IxHash
+skip = Tie::StdHash
 [Prereqs / TestRequires]
 Test::More = 0.98
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Common.pm 
new/YAML-PP-0.021/lib/YAML/PP/Common.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Common.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Common.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Common;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use base 'Exporter';
 
@@ -17,6 +17,8 @@
 
     YAML_ANY_MAPPING_STYLE
     YAML_BLOCK_MAPPING_STYLE YAML_FLOW_MAPPING_STYLE
+
+    PRESERVE_ALL PRESERVE_ORDER PRESERVE_SCALAR_STYLE
 /;
 
 use constant {
@@ -35,6 +37,10 @@
     YAML_ANY_MAPPING_STYLE   => 'any',
     YAML_BLOCK_MAPPING_STYLE => 'block',
     YAML_FLOW_MAPPING_STYLE  => 'flow',
+
+    PRESERVE_ALL          => 1,
+    PRESERVE_ORDER        => 2,
+    PRESERVE_SCALAR_STYLE => 4,
 };
 
 my %scalar_style_to_string = (
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Constructor.pm 
new/YAML-PP-0.021/lib/YAML/PP/Constructor.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Constructor.pm        2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Constructor.pm        2020-02-27 
19:07:59.000000000 +0100
@@ -3,9 +3,10 @@
 use warnings;
 package YAML::PP::Constructor;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use YAML::PP;
+use YAML::PP::Common qw/ PRESERVE_ALL PRESERVE_ORDER PRESERVE_SCALAR_STYLE /;
 use Scalar::Util qw/ reftype /;
 
 use constant DEBUG => ($ENV{YAML_PP_LOAD_DEBUG} or $ENV{YAML_PP_LOAD_TRACE}) ? 
1 : 0;
@@ -17,6 +18,10 @@
     my ($class, %args) = @_;
 
     my $default_yaml_version = delete $args{default_yaml_version};
+    my $preserve = delete $args{preserve} || 0;
+    if ($preserve == PRESERVE_ALL) {
+        $preserve = PRESERVE_ORDER | PRESERVE_SCALAR_STYLE;
+    }
     my $cyclic_refs = delete $args{cyclic_refs} || 'allow';
     die "Invalid value for cyclic_refs: $cyclic_refs"
         unless $cyclic_refs{ $cyclic_refs };
@@ -30,6 +35,7 @@
         default_yaml_version => $default_yaml_version,
         schemas => $schemas,
         cyclic_refs => $cyclic_refs,
+        preserve => $preserve,
     }, $class;
     $self->init;
     return $self;
@@ -42,6 +48,7 @@
         schema => $self->{schema},
         default_yaml_version => $self->{default_yaml_version},
         cyclic_refs => $self->cyclic_refs,
+        preserve => $self->{preserve},
     };
     return bless $clone, ref $self;
 }
@@ -69,6 +76,8 @@
 sub yaml_version { return $_[0]->{yaml_version} }
 sub set_yaml_version { $_[0]->{yaml_version} = $_[1] }
 sub default_yaml_version { return $_[0]->{default_yaml_version} }
+sub preserve_order { return $_[0]->{preserve} & PRESERVE_ORDER }
+sub preserve_scalar_style { return $_[0]->{preserve} & PRESERVE_SCALAR_STYLE }
 
 sub document_start_event {
     my ($self, $event) = @_;
@@ -114,6 +123,10 @@
     };
     my $stack = $self->stack;
 
+    if ($self->preserve_order and not tied(%$data)) {
+        tie %$data, 'YAML::PP::Preserve::Hash';
+    }
+
     push @$stack, $ref;
     if (defined(my $anchor = $event->{anchor})) {
         $self->anchors->{ $anchor } = { data => $ref->{data} };
@@ -230,6 +243,13 @@
         $self->anchors->{ $name } = { data => $value, finished => 1 };
     }
     my $last = $self->stack->[-1];
+    if ($self->preserve_scalar_style and not ref $value) {
+        $value = YAML::PP::Preserve::Scalar->new(
+            value => $value,
+            style => $event->{style},
+            tag => $event->{tag},
+        );
+    }
     push @{ $last->{ref} }, $value;
 }
 
@@ -263,6 +283,7 @@
 
 sub stringify_complex {
     my ($self, $data) = @_;
+    return $data if ref $data eq 'YAML::PP::Preserve::Scalar' and 
$self->preserve_scalar_style;
     require Data::Dumper;
     local $Data::Dumper::Quotekeys = 0;
     local $Data::Dumper::Terse = 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Dumper.pm 
new/YAML-PP-0.021/lib/YAML/PP/Dumper.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Dumper.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Dumper.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Dumper;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use Scalar::Util qw/ blessed refaddr reftype /;
 use YAML::PP;
@@ -27,6 +27,7 @@
     my $footer = delete $args{footer};
     $footer = 0 unless defined $footer;
     my $version_directive = delete $args{version_directive};
+    my $preserve = delete $args{preserve};
 
     my $schema = delete $args{schema} || YAML::PP->default_schema(
         boolean => 'perl',
@@ -45,6 +46,7 @@
     my $self = bless {
         representer => YAML::PP::Representer->new(
             schema => $schema,
+            preserve => $preserve,
         ),
         version_directive => $version_directive,
         emitter => $emitter,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Emitter.pm 
new/YAML-PP-0.021/lib/YAML/PP/Emitter.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Emitter.pm    2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Emitter.pm    2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Emitter;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 use Data::Dumper;
 
 use YAML::PP::Common qw/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Exception.pm 
new/YAML-PP-0.021/lib/YAML/PP/Exception.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Exception.pm  2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Exception.pm  2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Exception;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use overload '""' => \&to_string;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Grammar.pm 
new/YAML-PP-0.021/lib/YAML/PP/Grammar.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Grammar.pm    2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Grammar.pm    2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Grammar;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use base 'Exporter';
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Highlight.pm 
new/YAML-PP-0.021/lib/YAML/PP/Highlight.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Highlight.pm  2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Highlight.pm  2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Highlight;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 our @EXPORT_OK = qw/ Dump /;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Lexer.pm 
new/YAML-PP-0.021/lib/YAML/PP/Lexer.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Lexer.pm      2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Lexer.pm      2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Lexer;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0;
 use constant DEBUG => ($ENV{YAML_PP_DEBUG} || $ENV{YAML_PP_TRACE}) ? 1 : 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Loader.pm 
new/YAML-PP-0.021/lib/YAML/PP/Loader.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Loader.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Loader.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -3,7 +3,7 @@
 use warnings;
 package YAML::PP::Loader;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use YAML::PP::Parser;
 use YAML::PP::Constructor;
@@ -14,6 +14,7 @@
 
     my $cyclic_refs = delete $args{cyclic_refs} || 'allow';
     my $default_yaml_version = delete $args{default_yaml_version} || '1.2';
+    my $preserve = delete $args{preserve};
     my $schemas = delete $args{schemas};
     $schemas ||= {
         '1.2' => YAML::PP->default_schema(
@@ -25,6 +26,7 @@
         schemas => $schemas,
         cyclic_refs => $cyclic_refs,
         default_yaml_version => $default_yaml_version,
+        preserve => $preserve,
     );
     my $parser = delete $args{parser};
     unless ($parser) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Parser.pm 
new/YAML-PP-0.021/lib/YAML/PP/Parser.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Parser.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Parser.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -3,7 +3,7 @@
 use warnings;
 package YAML::PP::Parser;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0;
 use constant DEBUG => ($ENV{YAML_PP_DEBUG} || $ENV{YAML_PP_TRACE}) ? 1 : 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Perl.pm 
new/YAML-PP-0.021/lib/YAML/PP/Perl.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Perl.pm       2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Perl.pm       2020-02-27 19:07:59.000000000 
+0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Perl;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use base 'Exporter';
 use base 'YAML::PP';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Reader.pm 
new/YAML-PP-0.021/lib/YAML/PP/Reader.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Reader.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Reader.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -3,7 +3,7 @@
 use warnings;
 package YAML::PP::Reader;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 sub input { return $_[0]->{input} }
 sub set_input { $_[0]->{input} = $_[1] }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Render.pm 
new/YAML-PP-0.021/lib/YAML/PP/Render.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Render.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Render.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -3,7 +3,7 @@
 use warnings;
 package YAML::PP::Render;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Representer.pm 
new/YAML-PP-0.021/lib/YAML/PP/Representer.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Representer.pm        2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Representer.pm        2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Representer;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use Scalar::Util qw/ reftype blessed refaddr /;
 
@@ -13,14 +13,23 @@
     YAML_LITERAL_SCALAR_STYLE YAML_FOLDED_SCALAR_STYLE
     YAML_FLOW_SEQUENCE_STYLE YAML_FLOW_MAPPING_STYLE
     YAML_BLOCK_MAPPING_STYLE YAML_BLOCK_SEQUENCE_STYLE
+    PRESERVE_ALL PRESERVE_ORDER PRESERVE_SCALAR_STYLE
 /;
 use B;
 
 sub new {
     my ($class, %args) = @_;
+    my $preserve = delete $args{preserve} || 0;
+    if ($preserve == PRESERVE_ALL) {
+        $preserve = PRESERVE_ORDER | PRESERVE_SCALAR_STYLE;
+    }
     my $self = bless {
-        schema => $args{schema},
+        schema => delete $args{schema},
+        preserve => $preserve,
     }, $class;
+    if (keys %args) {
+        die "Unexpected arguments: " . join ', ', sort keys %args;
+    }
     return $self;
 }
 
@@ -28,15 +37,28 @@
     my ($self) = @_;
     my $clone = {
         schema => $self->schema,
+        preserve => $self->{preserve},
     };
     return bless $clone, ref $self;
 }
 
 sub schema { return $_[0]->{schema} }
+sub preserve_order { return $_[0]->{preserve} & PRESERVE_ORDER }
+sub preserve_scalar_style { return $_[0]->{preserve} & PRESERVE_SCALAR_STYLE }
 
 sub represent_node {
     my ($self, $node) = @_;
 
+    if ($self->preserve_scalar_style) {
+        if (ref $node->{value} eq 'YAML::PP::Preserve::Scalar') {
+            my $value = $node->{value}->value;
+            if ($node->{value}->style != YAML_FOLDED_SCALAR_STYLE) {
+                $node->{style} = $node->{value}->style;
+            }
+#            $node->{tag} = $node->{value}->tag;
+            $node->{value} = $value;
+        }
+    }
     $node->{reftype} = reftype($node->{value});
 
     if (ref $node->{value}) {
@@ -59,7 +81,14 @@
     if ($node->{reftype} eq 'HASH') {
         unless (defined $node->{items}) {
             # by default we sort hash keys
-            for my $key (sort keys %{ $node->{data} }) {
+            my @keys;
+            if ($self->preserve_order) {
+                @keys = keys %{ $node->{data} };
+            }
+            else {
+                @keys = sort keys %{ $node->{data} };
+            }
+            for my $key (@keys) {
                 push @{ $node->{items} }, $key, $node->{data}->{ $key };
             }
         }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/Binary.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/Binary.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/Binary.pm      2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/Binary.pm      2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::Binary;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use MIME::Base64 qw/ decode_base64 encode_base64 /;
 use YAML::PP::Common qw/ YAML_ANY_SCALAR_STYLE /;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/Core.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/Core.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/Core.pm        2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/Core.pm        2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::Core;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use YAML::PP::Schema::JSON qw/
     represent_int represent_float represent_literal represent_bool
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/Failsafe.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/Failsafe.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/Failsafe.pm    2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/Failsafe.pm    2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::Failsafe;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 sub register {
     my ($self, %args) = @_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/Include.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/Include.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/Include.pm     2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/Include.pm     2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::Include;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use Carp qw/ croak /;
 use Scalar::Util qw/ weaken /;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/JSON.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/JSON.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/JSON.pm        2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/JSON.pm        2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::JSON;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use base 'Exporter';
 our @EXPORT_OK = qw/
@@ -121,7 +121,7 @@
 
 sub represent_literal {
     my ($rep, $node) = @_;
-    $node->{style} = YAML_SINGLE_QUOTED_SCALAR_STYLE;
+    $node->{style} ||= YAML_SINGLE_QUOTED_SCALAR_STYLE;
     $node->{data} = "$node->{value}";
     return 1;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/Merge.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/Merge.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/Merge.pm       2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/Merge.pm       2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::Merge;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use YAML::PP::Type::MergeKey;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/Perl.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/Perl.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/Perl.pm        2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/Perl.pm        2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::Perl;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use Scalar::Util qw/ blessed reftype /;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/Tie/IxHash.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/Tie/IxHash.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/Tie/IxHash.pm  2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/Tie/IxHash.pm  2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::Tie::IxHash;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use base 'YAML::PP::Schema';
 
@@ -37,7 +37,7 @@
 
 =head1 NAME
 
-YAML::PP::Schema::Tie::IxHash - Schema for serializing ordered hashes
+YAML::PP::Schema::Tie::IxHash - (Deprecated) Schema for serializing ordered 
hashes
 
 =head1 SYNOPSIS
 
@@ -61,6 +61,8 @@
 
 =head1 DESCRIPTION
 
+This is deprecated. See the new option C<preserve> in L<YAML::PP>.
+
 This schema allows you to dump ordered hashes which are tied to
 L<Tie::IxHash>.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema/YAML1_1.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema/YAML1_1.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema/YAML1_1.pm     2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema/YAML1_1.pm     2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Schema::YAML1_1;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use YAML::PP::Schema::JSON qw/
     represent_int represent_float represent_literal represent_bool
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Schema.pm 
new/YAML-PP-0.021/lib/YAML/PP/Schema.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Schema.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Schema.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -4,7 +4,7 @@
 use B;
 use Module::Load qw//;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use YAML::PP::Common qw/ YAML_PLAIN_SCALAR_STYLE /;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Type/MergeKey.pm 
new/YAML-PP-0.021/lib/YAML/PP/Type/MergeKey.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Type/MergeKey.pm      2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Type/MergeKey.pm      2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Type::MergeKey;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 sub new {
     my ($class) = @_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Writer/File.pm 
new/YAML-PP-0.021/lib/YAML/PP/Writer/File.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Writer/File.pm        2020-02-17 
15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Writer/File.pm        2020-02-27 
19:07:59.000000000 +0100
@@ -2,7 +2,7 @@
 use warnings;
 package YAML::PP::Writer::File;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use Scalar::Util qw/ openhandle /;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP/Writer.pm 
new/YAML-PP-0.021/lib/YAML/PP/Writer.pm
--- old/YAML-PP-0.020/lib/YAML/PP/Writer.pm     2020-02-17 15:37:21.000000000 
+0100
+++ new/YAML-PP-0.021/lib/YAML/PP/Writer.pm     2020-02-27 19:07:59.000000000 
+0100
@@ -3,7 +3,7 @@
 use warnings;
 package YAML::PP::Writer;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 sub output { return $_[0]->{output} }
 sub set_output { $_[0]->{output} = $_[1] }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/lib/YAML/PP.pm 
new/YAML-PP-0.021/lib/YAML/PP.pm
--- old/YAML-PP-0.020/lib/YAML/PP.pm    2020-02-17 15:37:21.000000000 +0100
+++ new/YAML-PP-0.021/lib/YAML/PP.pm    2020-02-27 19:07:59.000000000 +0100
@@ -3,7 +3,7 @@
 use warnings;
 package YAML::PP;
 
-our $VERSION = '0.020'; # VERSION
+our $VERSION = '0.021'; # VERSION
 
 use YAML::PP::Schema;
 use YAML::PP::Schema::JSON;
@@ -32,11 +32,15 @@
     my $yaml_version = $class->_arg_yaml_version(delete $args{yaml_version});
     my $default_yaml_version = $yaml_version->[0];
     my $version_directive = delete $args{version_directive};
+    my $preserve = delete $args{preserve};
     my $parser = delete $args{parser};
     my $emitter = delete $args{emitter} || {
         indent => $indent,
         writer => $writer,
     };
+    if (keys %args) {
+        die "Unexpected arguments: " . join ', ', sort keys %args;
+    }
 
     my %schemas;
     for my $v (@$yaml_version) {
@@ -60,6 +64,7 @@
         cyclic_refs => $cyclic_refs,
         parser => $parser,
         default_yaml_version => $default_yaml_version,
+        preserve => $preserve,
     );
     my $dumper = YAML::PP::Dumper->new(
         schema => $default_schema,
@@ -67,6 +72,7 @@
         header => $header,
         footer => $footer,
         version_directive => $version_directive,
+        preserve => $preserve,
     );
 
     my $self = bless {
@@ -180,6 +186,91 @@
     YAML::PP->new->dump_file($file, @data);
 }
 
+package YAML::PP::Preserve::Hash;
+# experimental
+use Tie::Hash;
+use base qw/ Tie::StdHash /;
+
+sub TIEHASH {
+    my ($class) = @_;
+    my $self = bless {
+        keys => [],
+        data => {},
+    }, $class;
+}
+
+sub STORE {
+    my ($self, $key, $val) = @_;
+    my $keys = $self->{keys};
+    if (exists $self->{data}->{ $key }) {
+        @$keys = grep { $_ ne $key } @$keys;
+    }
+    push @$keys, "$key";
+    $self->{data}->{ $key } = $val;
+}
+
+sub FIRSTKEY {
+    my ($self) = @_;
+    return $self->{keys}->[0];
+}
+
+sub NEXTKEY {
+    my ($self, $last) = @_;
+    my $keys = $self->{keys};
+    for my $i (0 .. $#$keys) {
+        if ($keys->[ $i ] eq $last) {
+            return $keys->[ $i + 1 ];
+        }
+    }
+    return;
+}
+
+sub FETCH {
+    my ($self, $key) = @_;
+    my $val = $self->{data}->{ $key };
+}
+
+sub DELETE {
+    my ($self, $key) = @_;
+    @{ $self->{keys} } = grep { $_ ne $key } @{ $self->{keys} };
+    delete $self->{data}->{ $key };
+}
+
+sub EXISTS {
+    my ($self, $key) = @_;
+    return exists $self->{data}->{ $key };
+}
+
+sub CLEAR {
+    my ($self) = @_;
+    $self->{keys} = [];
+    $self->{data} = {};
+}
+
+sub SCALAR {
+    my ($self) = @_;
+    return scalar %{ $self->{data} };
+}
+
+package YAML::PP::Preserve::Scalar;
+
+use overload
+    '+' => \&value,
+    '""' => \&value,
+    'bool' => \&value,
+    'eq' => \&value,
+    ;
+sub new {
+    my ($class, %args) = @_;
+    my $self = {
+        %args,
+    };
+    bless $self, $class;
+}
+sub value { $_[0]->{value} }
+sub tag { $_[0]->{tag} }
+sub style { $_[0]->{style} }
+
 1;
 
 __END__
@@ -323,7 +414,7 @@
 
 =item L<YAML::PP::Schema::Tie::IxHash>
 
-In progress. Keeping hash key order.
+Deprecated. See option C<preserve>
 
 =item L<YAML::PP::Schema::Merge>
 
@@ -360,9 +451,6 @@
 For dumping blessed objects and things like coderefs have a look at
 L<YAML::PP::Perl>/L<YAML::PP::Schema::Perl>.
 
-For keeping your ordered L<Tie::IxHash> hashes, try out
-L<YAML::PP::Schema::Tie::IxHash>.
-
 =over
 
 =item L<YAML::PP::Lexer>
@@ -706,6 +794,48 @@
 Print Version Directive C<%YAML 1.2> (or C<%YAML 1.1>) on top of each YAML
 document. It will use the first version specified in the C<yaml_version> 
option.
 
+=item preserve (since 0.021)
+
+Experimental. Default: false
+
+    use YAML::PP::Common qw/ PRESERVE_ORDER PRESERVE_SCALAR_STYLE /;
+    # Preserve the order of hash keys
+    my $yp = YAML::PP->new( preserve => PRESERVE_ORDER );
+    # Preserve the quoting style of scalars
+    my $yp = YAML::PP->new( preserve => PRESERVE_SCALAR_STYLE );
+    # Preserve order and scalar style
+    my $yp = YAML::PP->new( preserve => PRESERVE_ORDER | PRESERVE_SCALAR_STYLE 
);
+
+Do NOT rely on the internal implementation of it.
+
+If you load the following input:
+
+    ---
+    z: 1
+    a: 2
+    ---
+    - plain
+    - 'single'
+    - "double"
+    - |
+      literal
+
+    my $yp = YAML::PP->new( preserve => PRESERVE_ORDER | PRESERVE_SCALAR_STYLE 
);
+    my ($hash, $styles) = $yp->load_file($file);
+
+Then dumping it will return the same output.
+Only folded block scalars '>' cannot preserve the style yet.
+
+When loading, hashes will be tied to an internal class
+(C<YAML::PP::Preserve::Hash>) that keeps the key order.
+
+Scalars will be returned as objects of an internal class
+(C<YAML::PP::Preserve::Scalar>) with overloading. If you assign to such
+a scalar, the object will be replaced by a simple scalar.
+
+    # assignment, style gets lost
+    $styles->[1] .= ' append';
+
 =back
 
 =item load_string
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/YAML-PP-0.020/t/52.preserve.t 
new/YAML-PP-0.021/t/52.preserve.t
--- old/YAML-PP-0.020/t/52.preserve.t   1970-01-01 01:00:00.000000000 +0100
+++ new/YAML-PP-0.021/t/52.preserve.t   2020-02-27 19:07:59.000000000 +0100
@@ -0,0 +1,121 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use Test::Deep;
+use FindBin '$Bin';
+use YAML::PP;
+use YAML::PP::Common qw/ PRESERVE_ORDER PRESERVE_SCALAR_STYLE /;
+
+
+subtest 'preserve-scalar-style' => sub {
+    my $yp = YAML::PP->new( preserve => PRESERVE_SCALAR_STYLE );
+    my $yaml = <<'EOM';
+---
+- plain
+- 'single'
+- "double"
+- >-
+  folded
+- |-
+  literal
+- |+
+
+...
+---
+- 0
+- null
+- 23
+- "42"
+- !!int '99'
+EOM
+    my $exp_styles = <<'EOM';
+---
+- plain
+- 'single'
+- "double"
+- folded
+- |-
+  literal
+- |+
+
+...
+EOM
+    my $exp_data = <<'EOM';
+---
+- 0
+- null
+- 23
+- "42"
+- 99
+EOM
+    my @docs = $yp->load_string($yaml);
+    my $styles = $docs[0];
+    my $data = $docs[1];
+
+    my $dump_styles = $yp->dump_string($styles);
+    is($dump_styles, $exp_styles, 'preserve=1 dump styless ok');
+
+    my $newline = pop @$styles;
+    my $string = "@$styles";
+    is($string, 'plain single double folded literal', 'Strings');
+
+    my $dump_data = $yp->dump_string($data);
+    is($dump_data, $exp_data, 'preserve=1 dump data ok');
+
+    $styles->[1] .= ' APPEND';
+    is($styles->[1], 'single APPEND', 'append works');
+    is($yp->dump_string($styles->[1]), "--- single APPEND\n", 'Style gets lost 
on append');
+
+    $newline->{value} = "\n\n";
+    is($yp->dump_string($newline),qq{--- |+\n\n\n...\n}, 'Style is preserved 
for direct assignment');
+    $newline->{value} = "\0";
+    is($yp->dump_string($newline),qq{--- "\\0"\n}, 'Style gets changed if 
necessary');
+};
+
+subtest 'preserve-order' => sub {
+    my $yp = YAML::PP->new( preserve => PRESERVE_ORDER );
+
+    my $yaml = <<'EOM';
+---
+z: 1
+a: 2
+y: 3
+b: 4
+x: 5
+c: 6
+EOM
+
+    my $data = $yp->load_string($yaml);
+    my $dump = $yp->dump_string($data);
+
+    is($dump, $yaml, 'preserve=1 Key order preserved');
+
+    my @keys = keys %$data;
+    is("@keys", "z a y b x c", 'keys()');
+
+    is($data->{a}, 2, 'hash a');
+    my $first = each %$data;
+    is($first, 'z', 'First key');
+    my $next = each %$data;
+    is($next, 'a', 'Next key');
+
+    is(delete $data->{z}, 1, 'delete(z)');
+    @keys = keys %$data;
+    is("@keys", "a y b x c", 'keys()');
+
+    $data->{z} = 99;
+    @keys = keys %$data;
+    is("@keys", "a y b x c z", 'keys()');
+
+    my @values = values %$data;
+    is("@values", "2 3 4 5 6 99", 'values()');
+
+    is(exists $data->{a}, 1, 'exists(a)');
+    is(exists $data->{A}, '', 'exists(A)');
+
+    %$data = ();
+    is(scalar keys %$data, 0, 'clear');
+};
+
+done_testing;


Reply via email to