r44646 - in /trunk/libconfig-std-perl: Changes META.yml README debian/changelog debian/control lib/Config/Std.pm t/00write.t t/01read.t t/01read_renamed.t t/02rewrite.t t/comments.t

carnil-guest at users.alioth.debian.org carnil-guest at users.alioth.debian.org
Tue Sep 22 17:07:36 UTC 2009


Author: carnil-guest
Date: Tue Sep 22 17:07:31 2009
New Revision: 44646

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=44646
Log:
New upstream release 

Modified:
    trunk/libconfig-std-perl/Changes
    trunk/libconfig-std-perl/META.yml
    trunk/libconfig-std-perl/README
    trunk/libconfig-std-perl/debian/changelog
    trunk/libconfig-std-perl/debian/control
    trunk/libconfig-std-perl/lib/Config/Std.pm
    trunk/libconfig-std-perl/t/00write.t
    trunk/libconfig-std-perl/t/01read.t
    trunk/libconfig-std-perl/t/01read_renamed.t
    trunk/libconfig-std-perl/t/02rewrite.t
    trunk/libconfig-std-perl/t/comments.t

Modified: trunk/libconfig-std-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/Changes?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/Changes (original)
+++ trunk/libconfig-std-perl/Changes Tue Sep 22 17:07:31 2009
@@ -21,7 +21,7 @@
 
     - Removed unused "" sections from read_config hash (thanks carcassonne)
 
-    - Added logic to decide whether new sections has spaces after them
+    - Added logic to decide whether new sections have spaces after them
 
     - Changed write_config() behaviour for undefined hash entries: they now
       throw an exception (thanks David)
@@ -33,3 +33,18 @@
 0.0.4  Mon Feb 20 08:03:45 2006
 
     - Removed spurious dependency on Smart::Comments
+
+
+
+0.0.5  Tue Sep 22 15:17:49 2009
+
+    - Made spacing between key/values more intelligent
+
+    - Added def_sep option to control that intelligence (thanks David)
+
+    - Added support for standard INI-style comments:   ; like this
+      (thanks William and FSD)
+
+    - Fixed bug in section heading parsing (thanks Kirk)
+
+

Modified: trunk/libconfig-std-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/META.yml?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/META.yml (original)
+++ trunk/libconfig-std-perl/META.yml Tue Sep 22 17:07:31 2009
@@ -1,13 +1,16 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         Config-Std
-version:      v0.0.4
-version_from: lib/Config/Std.pm
-installdirs:  site
-requires:
+--- #YAML:1.0
+name:                Config-Std
+version:             0.0.5
+abstract:            Load and save configuration files in a standard format
+license:             ~
+author:              
+    - Damian Conway <DCONWAY at cpan.org>
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
     Class::Std:                    0
     Test::More:                    0
     version:                       0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: trunk/libconfig-std-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/README?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/README (original)
+++ trunk/libconfig-std-perl/README Tue Sep 22 17:07:31 2009
@@ -1,4 +1,4 @@
-Config::Std version 0.0.4
+Config::Std version 0.0.5
 
 This module implements yet another damn configuration-file system.
 

Modified: trunk/libconfig-std-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/debian/changelog?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/debian/changelog (original)
+++ trunk/libconfig-std-perl/debian/changelog Tue Sep 22 17:07:31 2009
@@ -1,4 +1,4 @@
-libconfig-std-perl (0.0.4-4) UNRELEASED; urgency=low
+libconfig-std-perl (0.0.5-1) UNRELEASED; urgency=low
 
   [ gregor herrmann ]
   * Move test.cfg to debian/patches; add quilt framework.
@@ -10,7 +10,10 @@
   [ Nathan Handler ]
   * debian/watch: Update to ignore development releases.
 
- -- gregor herrmann <gregoa at debian.org>  Sat, 07 Jun 2008 21:25:04 +0200
+  [ Salvatore Bonaccorso ]
+  * New upstream release 
+
+ -- Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>  Tue, 22 Sep 2009 14:40:51 +0000
 
 libconfig-std-perl (0.0.4-3) unstable; urgency=low
 

Modified: trunk/libconfig-std-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/debian/control?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/debian/control (original)
+++ trunk/libconfig-std-perl/debian/control Tue Sep 22 17:07:31 2009
@@ -5,7 +5,8 @@
 Build-Depends-Indep: perl (>= 5.8.8-7), libclass-std-perl, libversion-perl,
  libtest-pod-perl, libtest-pod-coverage-perl
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Damyan Ivanov <dmn at debian.org>
+Uploaders: Damyan Ivanov <dmn at debian.org>, 
+ Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>
 Standards-Version: 3.7.3
 Homepage: http://search.cpan.org/dist/Config-Std/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libconfig-std-perl/

Modified: trunk/libconfig-std-perl/lib/Config/Std.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/lib/Config/Std.pm?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/lib/Config/Std.pm (original)
+++ trunk/libconfig-std-perl/lib/Config/Std.pm Tue Sep 22 17:07:31 2009
@@ -1,13 +1,15 @@
 package Config::Std;
 
-use version; $VERSION = qv('0.0.4');
+use version; our $VERSION = qv('0.0.5');
 
 my %global_def_sep;
+my %global_inter_gap;
 
 sub import {
     my ($package, $opt_ref) = @_;
     my $caller = caller();
     $global_def_sep{$caller} = $opt_ref->{def_sep};
+    $global_inter_gap{$caller} = $opt_ref->{def_gap};
     for my $sub_name (qw( read_config write_config )) {
         $opt_ref->{$sub_name} ||= $sub_name;
     }
@@ -17,7 +19,6 @@
 
 package Config::Std::Gap;
 use Class::Std;
-### [caller 0]
 {
     sub serialize { return "\n" }
     sub update  {}
@@ -163,7 +164,7 @@
     }
 
     sub serialize {
-        my ($self, $first, $caller, $post_gap) = @_;
+        my ($self, $first, $caller, $post_gap, $inter_gap) = @_;
         my $ident = ident $self;
 
         return q{} if $deleted_of{$ident};
@@ -185,7 +186,7 @@
             :                                                            '='
             ;
 
-        $self->ensure_gap() if !$is_anon;
+        $self->ensure_gap() if $inter_gap && !$is_anon;
 
         for my $comp ( @{$components_of{$ident}} ) {
             $serialization .= $comp->serialize($def_sep, $name_of{$ident});
@@ -209,15 +210,19 @@
     }
 
     sub extend {
-        my ($self, $hash_ref, $updated_ref, $post_gap) = @_;
+        my ($self, $hash_ref, $updated_ref, $post_gap, $inter_gap) = @_;
 
         # Only the first occurrence of a block has new keys added...
         return unless $is_first{ident $self};
 
         my $first = 1;
         for my $key ( grep {!$updated_ref->{$_}} keys %{$hash_ref}) {
-            $self->ensure_gap() if !$first++ || $post_gap;
+            my $separate = ref $value || $value =~ m/\n./xms;
+            $block->ensure_gap() if ($first ? $post_gap : $inter_gap)
+                                    || $separate;
             $self->add_keyval($key, undef, $hash_ref->{$key});
+            $block->add_gap() if $separate;
+            $first = 0;
         }
     }
 
@@ -283,7 +288,16 @@
         croak "Missing filename for call to write_config()"
             unless $filename;
 
-        my $post_gap = ($post_section_gap_for{$hash_ref} || 0) >= 0;
+        my $caller = caller;
+
+        my $inter_gap
+            = exists $global_inter_gap{$caller} ? $global_inter_gap{$caller}
+            :                                      1;
+        my $post_gap
+            = $post_section_gap_for{$hash_ref}
+            || (defined $global_inter_gap{$caller} ? $global_inter_gap{$caller}
+                                                   : 1
+               );
 
         # Update existing keyvals in each block...
         my %updated;
@@ -295,7 +309,9 @@
         # Add new keyvals to the first section of block...
         for my $block ( @{$array_rep_for{$hash_ref}} ) {
             my $block_name = $block->get_name();
-            $block->extend($hash_ref->{$block_name}, $updated{$block_name}, $post_gap);
+            $block->extend($hash_ref->{$block_name}, $updated{$block_name},
+                           $post_gap, inter_gap
+                          );
         }
 
         # Add new blocks at the end...
@@ -307,10 +323,15 @@
                 if (!defined $subhash->{$key}) {
                     croak "Can't save undefined value for key {'$block_name'}{'$key'} (only scalars or array refs)";
                 }
-                $block->ensure_gap() if !$first++ || $post_gap;
-                $block->add_keyval($key, undef, $subhash->{$key});
-                $block->add_gap();
+                my $value = $subhash->{$key};
+                my $separate = ref $value || $value =~ m/\n./xms;
+                $block->ensure_gap() if ($first ? $post_gap : $inter_gap)
+                                     || $separate;
+                $block->add_keyval($key, undef, $value);
+                $block->add_gap() if $separate;
+                $first = 0;
             }
+            $block->ensure_gap();
             push @{$array_rep_for{$hash_ref}}, $block;
         }
 
@@ -395,13 +416,13 @@
                 }
 
                 # Comment...
-                elsif (m/\G (\s* [#] [^\n]* (?:\n|\z) )/gcxms) {
+                elsif (m/\G (\s* [#;] [^\n]* (?:\n|\z) )/gcxms) {
                     ### Found comment: $1
                     $comment .= $1;
                 }
 
                 # Block...
-                elsif (m/\G ([^\S\n]*) [[]  ( [^]\n]* ) []] ( ([^\S\n]*) [#] [^\n]* )? (?:\n|\z)/gcxms) {
+                elsif (m/\G ([^\S\n]*) [[]  ( [^]\n]* ) []] ( ([^\S\n]*) [#;] [^\n]* )? [^\S\n]* (?:\n|\z)/gcxms) {
                     my ($pre, $name, $parcomm, $ws) = ($1, $2, $3, $4);
                     ### Found block: $name
                     if ($parcomm) {
@@ -444,9 +465,8 @@
 
                     ### Found kv: $key, $val
 
-                    $config_file[-1]->add_keyval($key, $pure_sep, $val, $comment);
-                    $comment = q{};
-                }
+                    $config_file[-1]->add_keyval($key, $pure_sep, $val,
+                    $comment); $comment = q{}; }
 
                 # Mystery...
                 else {
@@ -472,7 +492,7 @@
 
 =head1 VERSION
 
-This document describes Config::Std version 0.0.4
+This document describes Config::Std version 0.0.5
 
 
 =head1 SYNOPSIS
@@ -512,9 +532,12 @@
 
 =head3 Comments
 
-A comment starts with a C<#> character and runs to the end of the same line:
+A comment starts with a C<#> character (Perl-style) or a C<;> character
+(INI-style), and runs to the end of the same line:
 
     # This is a comment
+
+    ; Ywis, eke hight thilke
 
 Comments can be placed almost anywhere in a configuration file, except inside
 a section label, or in the key or value of a configuration variable:
@@ -522,8 +545,8 @@
     # Valid comment
     [ # Not a comment, just a weird section label ]
 
-    # Valid comment
-    key: value  # Not a comment, just part of the value
+    ; Valid comment
+    key: value  ; Not a comment, just part of the value
 
 
 =head3 Sections
@@ -811,6 +834,20 @@
 
     update_ini(%config_hash);
 
+You can also control how much spacing the module puts between single-
+line values when they are first written to a file, by using the
+C<def_gap> option:
+
+    # No empty line between single-line config values...
+    use Config::Std { def_gap => 0 }; 
+
+    # An empty line between all single-line config values...
+    use Config::Std { def_gap => 1 }; 
+
+Regardless of the value passed for C<def_gap>, new multi-line values are
+always written with an empty line above and below them. Likewise, values
+that were previously read in from a file are always written back with
+whatever spacing they originally had.
 
 =head1 DIAGNOSTICS
 

Modified: trunk/libconfig-std-perl/t/00write.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/t/00write.t?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/t/00write.t (original)
+++ trunk/libconfig-std-perl/t/00write.t Tue Sep 22 17:07:31 2009
@@ -9,6 +9,8 @@
         'def1'     => 'def val 1',
         'def 2'    => 'def val 2',
         'def 3 ml' => "def val 3\nacross several\n   lines",
+        'def 3'    => 'def val 3',
+        'def 4'    => 'def val 4',
     },
 
     # Named section...
@@ -37,18 +39,19 @@
 
 __DATA__
 
+def 3: def val 3
 def 2: def val 2
 
 def 3 ml: def val 3
         : across several
         :    lines
 
+def 4: def val 4
 def1: def val 1
 
 [Complex named!!!]
 
 %^$%$#%: curses
-
 123456789: zero
 
 [Named]

Modified: trunk/libconfig-std-perl/t/01read.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/t/01read.t?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/t/01read.t (original)
+++ trunk/libconfig-std-perl/t/01read.t Tue Sep 22 17:07:31 2009
@@ -9,6 +9,8 @@
         'def1'     => 'def val 1',
         'def 2'    => 'def val 2',
         'def 3 ml' => "def val 3\nacross several\n   lines",
+        'def 3'    => 'def val 3',
+        'def 4'    => 'def val 4',
     },
 
     # Named section...

Modified: trunk/libconfig-std-perl/t/01read_renamed.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/t/01read_renamed.t?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/t/01read_renamed.t (original)
+++ trunk/libconfig-std-perl/t/01read_renamed.t Tue Sep 22 17:07:31 2009
@@ -9,6 +9,8 @@
         'def1'     => 'def val 1',
         'def 2'    => 'def val 2',
         'def 3 ml' => "def val 3\nacross several\n   lines",
+        'def 3'    => 'def val 3',
+        'def 4'    => 'def val 4',
     },
 
     # Named section...

Modified: trunk/libconfig-std-perl/t/02rewrite.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/t/02rewrite.t?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/t/02rewrite.t (original)
+++ trunk/libconfig-std-perl/t/02rewrite.t Tue Sep 22 17:07:31 2009
@@ -9,6 +9,8 @@
         'def1'     => 'def val 1',
         'def 2'    => 'def val 2',
         'def 3 ml' => "def val 3\nacross several\n   lines",
+        'def 3'    => 'def val 3',
+        'def 4'    => 'def val 4',
     },
 
     # Named section...

Modified: trunk/libconfig-std-perl/t/comments.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-std-perl/t/comments.t?rev=44646&op=diff
==============================================================================
--- trunk/libconfig-std-perl/t/comments.t (original)
+++ trunk/libconfig-std-perl/t/comments.t Tue Sep 22 17:07:31 2009
@@ -4,6 +4,9 @@
 my $data = q{
 # A comment
 foo: bar   # Not a trailing comment. This is data for the 'foo' config var
+
+; Another comment
+baz: qux   ; Not a trailing comment. This is data for the 'qux' config var
 };
 
 # Read in the config file from Example 19-3...
@@ -13,7 +16,9 @@
 is $results, $data    => "Comments preserved on simple round-trip";
 
 $config{""}{foo} = 'baz';
+$config{""}{baz} = 'foo';
 $data =~ s/bar.*/baz/;
+$data =~ s/qux.*/foo/;
 
 write_config %config, \$results;
 is $results, $data    => "Comments preserved on mutating round-trip";




More information about the Pkg-perl-cvs-commits mailing list