[SCM] Debian packaging of libconfig-augeas-perl branch, master, updated. debian/0.802-1-7-g45934f5

Dominique Dumont dod at debian.org
Fri Nov 25 12:30:59 UTC 2011


The following commit has been merged in the master branch:
commit d596d0f98566fd0f08cb366ca7a540018a5eade7
Author: Dominique Dumont <dod at debian.org>
Date:   Fri Nov 25 11:54:18 2011 +0100

    Imported Upstream version 0.902

diff --git a/Build.PL b/Build.PL
index 34992df..52acbd0 100644
--- a/Build.PL
+++ b/Build.PL
@@ -1,4 +1,5 @@
 #    Copyright (c) 2008-2009 Dominique Dumont.
+#    Copyright (c) 2011 Raphaël Pinson.
 #
 #    This library is free software; you can redistribute it and/or
 #    modify it under the terms of the GNU Lesser Public License as
@@ -54,7 +55,7 @@ EOW1
 my $aug_version = `pkg-config --modversion augeas` ;
 chomp($aug_cflags, $aug_libs, $aug_version) ;
 
-my $min_version = '0.6.0' ;
+my $min_version = '0.9.0' ;
 
 if (   not defined $aug_version or ( $aug_version lt $min_version)) {
     warn << "EOW2" ;
@@ -74,7 +75,7 @@ my $build = Module::Build->new
    module_name   => 'Config::Augeas',
    license       => 'lgpl',
    dist_version_from  => 'lib/Config/Augeas.pm' ,
-   dist_author   => "Dominique Dumont (ddumont at cpan dot org)",
+   dist_author   => "Raphaël Pinson (raphink at cpan dot org)",
    dist_abstract => "Edit configuration files through Augeas C library",
 
    dynamic_config       => 1,
diff --git a/ChangeLog b/ChangeLog
index f1ebbc3..bf9275c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-11-04  Raphaël Pinson <raphink at cpan.org> v0.902
+
+	* Fix documentation and copyrights.
+	* Build.PL: Depend on Augeas 0.9.0.
+
+2011-11-03  Raphaël Pinson <raphink at cpan.org> v0.901
+
+	* lib/Config/Augeas.pm: Added method aug_srun.
+	* lib/Config/Augeas.xs: Added interface for aug_srun.
+
+2011-10-11  Raphaël Pinson <raphink at cpan.org> v0.802
+
+	* lib/Config/Augeas.xs: Use #ifndef to prevent future breakage
+	if Augeas exports its internal constants.
+
+2011-10-11  Raphaël Pinson <raphink at cpan.org> v0.801
+
+	* lib/Config/Augeas.pm: Added method aug_span
+	* lib/Config/Augeas.xs: Added interface for aug_span
+	Fixed flags by using binary or instead of logical or.
+
 2010-02-18  Dominique Dumont  <domi.dumont at free.fr> v0.701
 
 	* lib/Config/Augeas.pm: Added new error strings from Augeas 0.7.0
diff --git a/META.yml b/META.yml
index b30c175..671e35b 100644
--- a/META.yml
+++ b/META.yml
@@ -1,23 +1,22 @@
 ---
-abstract: 'Edit configuration files through Augeas C library'
+name: Config-Augeas
+version: 0.902
 author:
-  - 'Dominique Dumont (ddumont at cpan dot org)'
+  - Raphaël Pinson (raphink at cpan dot org)
+abstract: Edit configuration files through Augeas C library
+license: lgpl
+resources:
+  license: http://opensource.org/licenses/lgpl-license.php
 build_requires:
-  ExtUtils::CBuilder: 0
   Test::More: 0
 configure_requires:
-  Module::Build: 0.36
+  Module::Build: 0.340201
 dynamic_config: 1
-generated_by: 'Module::Build version 0.3603'
-license: lgpl
-meta-spec:
-  url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
-name: Config-Augeas
 provides:
   Config::Augeas:
     file: lib/Config/Augeas.pm
-    version: 0.701
-resources:
-  license: http://opensource.org/licenses/lgpl-license.php
-version: 0.701
+    version: 0.902
+generated_by: Module::Build version 0.340201
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
diff --git a/README b/README
index 66a9967..d610fc8 100644
--- a/README
+++ b/README
@@ -40,6 +40,7 @@ This module requires these other modules and libraries:
 COPYRIGHT AND LICENCE
 
 Copyright (C) 2008-2009 by Dominique Dumont
+Copyright (C) 2011 by Raphaël Pinson
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser Public License as
diff --git a/lib/Config/Augeas.pm b/lib/Config/Augeas.pm
index 41ea562..bcb0e06 100644
--- a/lib/Config/Augeas.pm
+++ b/lib/Config/Augeas.pm
@@ -1,4 +1,5 @@
 #    Copyright (c) 2008-2010 Dominique Dumont.
+#    Copyright (c) 2011 Raphaël Pinson.
 #
 #    This library is free software; you can redistribute it and/or
 #    modify it under the terms of the GNU Lesser Public License as
@@ -22,7 +23,7 @@ use warnings;
 use Carp;
 use IO::File ;
 
-our $VERSION = '0.701';
+our $VERSION = '0.902';
 
 require XSLoader;
 XSLoader::load('Config::Augeas', $VERSION);
@@ -121,17 +122,18 @@ sub new {
     my $root  = delete $args{root} || '';
 
     my $save = delete $args{save} || '';
-    if    ($save eq 'backup')  { $flags ||= &AUG_SAVE_BACKUP }
-    elsif ($save eq 'newfile') { $flags ||= &AUG_SAVE_NEWFILE }
-    elsif ($save =~ 'noop')    { $flags ||= &AUG_SAVE_NOOP }
+    if    ($save eq 'backup')  { $flags |= &AUG_SAVE_BACKUP }
+    elsif ($save eq 'newfile') { $flags |= &AUG_SAVE_NEWFILE }
+    elsif ($save =~ 'noop')    { $flags |= &AUG_SAVE_NOOP }
     elsif ($save) { 
 	croak  __PACKAGE__," new: unexpected save value: $save. ",
 	  "Expected backup or newfile";
     }
 
-    $flags ||= &AUG_TYPE_CHECK if ( delete $args{type_check} || 0 );
-    $flags ||= &AUG_NO_STDINC  if ( delete $args{no_std_inc} || 0 ) ;
-    $flags ||= &AUG_NO_LOAD    if ( delete $args{no_load}    || 0 ) ;
+    $flags |= &AUG_TYPE_CHECK  if ( delete $args{type_check}  || 0 );
+    $flags |= &AUG_NO_STDINC   if ( delete $args{no_std_inc}  || 0 ) ;
+    $flags |= &AUG_NO_LOAD     if ( delete $args{no_load}     || 0 ) ;
+    $flags |= &AUG_ENABLE_SPAN if ( delete $args{enable_span} || 0 ) ;
 
     croak  __PACKAGE__," new: unexpected parameters: ",
       join (' ',keys %args) 
@@ -337,6 +339,33 @@ sub move {
     return $result == 0 ? 1 : 0 ;
 }
 
+
+=head2 span ( path )
+
+Returns a hash containing the C<filename>, C<label_start>, C<label_end>,
+C<value_start>, C<value_end>, C<span_start> and C<span_end> of the given C<path>.
+
+Example:
+
+  my $span = $aug->span('/files/etc/passwd/root') ;
+  # If filename is undefined, there are no valid span information for this node
+  if ($span->{filename}) {
+     print "Found root in passwd at character $span->{span_start}\n" ;
+  }
+
+WARNING: You must check that $span->{filename} is defined. If it isn't,
+the node has no span information and all other values in the hash are wrong.
+
+=cut
+
+sub span {
+    my $self = shift ;
+    my $path = shift || croak __PACKAGE__," span: undefined path";
+
+    return $self->{aug_c} -> span($path) ;
+
+}
+
 =head2 match ( pattern )
 
 Returns an array of the elements that match of the path expression
@@ -472,6 +501,50 @@ sub print {
     return $ret == 0 ? 1 : 0 ;
 }
 
+=head2 srun ( [ text  , [ file ] ] )
+
+Run one or more newline-separated commands listed in C<text>.
+Running just C<help> will print what commands are available.
+Commands accepted by this are identical to what augtool accepts.
+
+The second parameter can be :
+
+=over
+
+=item *
+
+A file name. 
+
+=item *
+
+Omitted. In this case, print to STDOUT
+
+=back
+
+The function returns the number of executed commands on success,
+and 0 otherwise.
+
+=cut
+
+sub srun {
+    my $self   = shift ;
+    my $text   = shift || '' ;
+    my $f_param     = shift ;
+
+    my $fd = IO::File->new ;
+
+    if (defined $f_param) {
+	$fd->open($f_param,"w");
+    }
+    else {
+	# stdio 
+	$fd->fdopen(fileno(STDOUT),"w");
+    } 
+
+    my $ret = $self->{aug_c} -> srun($fd,$text) ;
+    return $ret > 0 ? $ret : 0 ;
+}
+
 =head1 Error reporting
 
 =head2 error
@@ -553,18 +626,46 @@ GUI and advanced validation).
 
 =item *
 
+L<Config::Augeas::Validator> : A unit test framework for configuration files.
+
+=item *
+
+L<Config::Augeas::Exporter> : A module to export the Augeas tree to various formats.
+
+=item *
+
 Augeas mailing list: http://augeas.net/developers.html
 
 =back
 
-=head1 AUTHOR
+=head1 AUTHORS
+
+=over
+
+=item *
 
 Dominique Dumont, E<lt>ddumont at cpan dot org@<gt>
 
+=item *
+
+Raphael Pinson, E<lt>raphink at cpan dot org@<gt>
+
+=back
+
 =head1 COPYRIGHT AND LICENSE
 
+=over
+
+=item *
+
 Copyright (C) 2008-2010 by Dominique Dumont
 
+=item *
+
+Copyright (C) 2011 by Raphael Pinson
+
+=back
+
 This library is free software; you can redistribute it and/or modify
 it under the LGPL terms.
 
diff --git a/lib/Config/Augeas.xs b/lib/Config/Augeas.xs
index 5272cff..10acba4 100644
--- a/lib/Config/Augeas.xs
+++ b/lib/Config/Augeas.xs
@@ -1,4 +1,5 @@
 //    Copyright (c) 2008-2010 Dominique Dumont.
+//    Copyright (c) 2011 Raphaël Pinson.
 // 
 //    This library is free software; you can redistribute it and/or
 //    modify it under the terms of the GNU Lesser Public License as
@@ -26,6 +27,20 @@
 #include <stdio.h>
 #include <augeas.h>
 
+/* Defines from Augeas' internal.h */
+#ifndef AUGEAS_META_TREE
+#define AUGEAS_META_TREE "/augeas"
+#endif
+#ifndef AUGEAS_SPAN_OPTION
+#define AUGEAS_SPAN_OPTION AUGEAS_META_TREE "/span"
+#endif
+#ifndef AUGEAS_ENABLE
+#define AUG_ENABLE "enable"
+#endif
+#ifndef AUGEAS_DISABLE
+#define AUG_DISABLE "disable"
+#endif
+
 typedef augeas   Config_Augeas ;
 typedef PerlIO*  OutputStream;
 
@@ -50,6 +65,7 @@ BOOT:
     newCONSTSUB(stash, "AUG_SAVE_NOOP",    newSViv(AUG_SAVE_NOOP));
     newCONSTSUB(stash, "AUG_NO_LOAD",      newSViv(AUG_NO_LOAD));
     newCONSTSUB(stash, "AUG_NO_MODL_AUTOLOAD", newSViv(AUG_NO_MODL_AUTOLOAD));
+    newCONSTSUB(stash, "AUG_ENABLE_SPAN", newSViv(AUG_ENABLE_SPAN));
 
 
     /* Error reporting */
@@ -62,6 +78,7 @@ BOOT:
     newCONSTSUB(stash, "AUG_ESYNTAX",   newSViv(AUG_ESYNTAX));
     newCONSTSUB(stash, "AUG_ENOLENS",   newSViv(AUG_ENOLENS));
     newCONSTSUB(stash, "AUG_EMXFM",     newSViv(AUG_EMXFM));
+    newCONSTSUB(stash, "AUG_ENOSPAN", newSViv(AUG_ENOSPAN));
 
   }
 
@@ -141,6 +158,41 @@ aug_mv(aug, src, dst);
       const char *src
       const char *dst
 
+SV*
+aug_span(aug, path);
+      Config_Augeas* aug
+      char* path
+    PREINIT:
+      int ret ;
+      char *filename = NULL;
+      const char *option = NULL;
+      uint label_start, label_end, value_start, value_end, span_start, span_end;
+      HV *span_hash;
+    CODE:
+      // Check that span is enabled
+      if (aug_get(aug, AUGEAS_SPAN_OPTION, &option) != 1) {
+	 croak ("Error: option %s not found\n", AUGEAS_SPAN_OPTION);
+      }
+      if (strcmp(AUG_DISABLE, option) == 0) {
+	 croak ("Error: Span is not enabled.\n");
+      }
+      ret = aug_span(aug, path, &filename, &label_start, &label_end, &value_start, &value_end, &span_start, &span_end);
+      span_hash = newHV();
+      if (filename) {
+         (void)hv_store(span_hash, "filename", 8, newSVpv(filename, strlen(filename)), 0);
+         free(filename) ;
+      }
+      (void)hv_store(span_hash, "label_start", 11, newSViv(label_start), 0);
+      (void)hv_store(span_hash, "label_end", 9, newSViv(label_end), 0);
+      (void)hv_store(span_hash, "value_start", 11, newSViv(value_start), 0);
+      (void)hv_store(span_hash, "value_end", 9, newSViv(value_end), 0);
+      (void)hv_store(span_hash, "span_start", 10, newSViv(span_start), 0);
+      (void)hv_store(span_hash, "span_end", 8, newSViv(span_end), 0);
+      RETVAL = newRV_noinc((SV *)span_hash);
+    OUTPUT:
+      RETVAL
+      
+
 void
 aug_match(aug, pattern);
       Config_Augeas *aug
@@ -215,6 +267,22 @@ aug_print(aug, stream, path);
     OUTPUT:
         RETVAL
 
+int
+aug_srun(aug, stream, text);
+        Config_Augeas *aug
+	OutputStream stream
+	const char* text
+    PREINIT:
+        FILE *fp ;
+    CODE:
+        fp = PerlIO_findFILE(stream);
+        if (fp != (FILE*) 0) {
+             RETVAL = aug_srun(aug, fp, text);
+         } else {
+             RETVAL = -1;
+         }
+    OUTPUT:
+        RETVAL
 
  # Error reporting
 
diff --git a/t/Config-Augeas.t b/t/Config-Augeas.t
index df62a13..5fd057c 100644
--- a/t/Config-Augeas.t
+++ b/t/Config-Augeas.t
@@ -8,7 +8,7 @@ use File::Copy ;
 
 use warnings ;
 use strict;
-use Test::More tests => 23 ;
+use Test::More tests => 27 ;
 
 ok(1,"Compilation done");
 
@@ -36,20 +36,20 @@ foreach my $f (qw!hosts ssh/sshd_config!) {
 my $written_file = $aug_root."etc/hosts.augnew" ;
 unlink ($written_file) if -e $written_file ;
 
-my $aug = Config::Augeas->new( root => $aug_root, save => 'newfile' ) ;
+my $aug = Config::Augeas->new( root => $aug_root, save => 'newfile', enable_span => 1 ) ;
 
 ok($aug,"Created new Augeas object");
 
 my $ret = $aug->get("/files/etc/hosts/1/ipaddr") ;
-
 is($ret,'127.0.0.1',"Called get (returned $ret )");
 
-$ret = $aug->get("/files/etc/hosts/1/canonical") ;
+$ret = $aug->srun('get /files/etc/hosts/1/ipaddr') ;
+is($ret,'1',"Called srun get (returned $ret )");
 
+$ret = $aug->get("/files/etc/hosts/1/canonical") ;
 is($ret,'localhost',"Called get (returned $ret )");
 
 $aug->set("/files/etc/hosts/2/canonical","newbilbo") ;
-
 ok($aug,"Set new host");
 
 $ret = $aug->get("/files/etc/hosts/2/canonical") ;
@@ -80,6 +80,11 @@ is_deeply(\@a,["/files/etc/hosts"],"match result") ;
 $ret = $aug->count_match("/files/etc/hosts/") ;
 is($ret,1,"count_match result") ;
 
+my $span = $aug->span('/files/etc/hosts/2') ;
+is($span->{filename}, 'augeas-root/etc/hosts', "filename of span /files/etc/hosts/2") ;
+is($span->{span_start}, '30', "span_start of span /files/etc/hosts/2") ;
+is($span->{span_end}, '48', "span_start of span /files/etc/hosts/2") ;
+
 $ret = $aug->save ;
 ok($ret,"save done") ;
 
@@ -123,4 +128,5 @@ ok($emsg, "error_minor_message: $emsg") ;
 $emsg= $aug->error_details ;
 ok($emsg, "error_details: $emsg") ;
 
+
 #$aug->print('') ;
diff --git a/t/Config-AugeasC.t b/t/Config-AugeasC.t
index 55c8ea8..f931bed 100644
--- a/t/Config-AugeasC.t
+++ b/t/Config-AugeasC.t
@@ -6,7 +6,7 @@
 
 # change 'tests => 2' to 'tests => last_test_to_print';
 
-use Test::More tests => 25;
+use Test::More tests => 29;
 use ExtUtils::testlib;
 use File::Path ;
 use File::Copy ;
@@ -23,9 +23,9 @@ package Config::Augeas;
 my $fail = 0;
 foreach my $constname (qw(AUG_NONE AUG_SAVE_BACKUP AUG_SAVE_NEWFILE 
 			  AUG_TYPE_CHECK AUG_NO_STDINC AUG_SAVE_NOOP
-			  AUG_NO_LOAD AUG_NO_MODL_AUTOLOAD AUG_NOERROR
-			  AUG_ENOMEM AUG_EINTERNAL AUG_EPATHX
-			  AUG_ENOMATCH AUG_EMMATCH AUG_ESYNTAX)) {
+			  AUG_NO_LOAD AUG_NO_MODL_AUTOLOAD AUG_ENABLE_SPAN
+                          AUG_NOERROR AUG_ENOMEM AUG_EINTERNAL AUG_EPATHX
+			  AUG_ENOMATCH AUG_EMMATCH AUG_ESYNTAX AUG_ENOSPAN)) {
   next if (eval "my \$a = $constname; 1");
   if ($@ =~ /^Your vendor has not defined Config::Augeas macro $constname/) {
     print "# pass: $@";
@@ -112,13 +112,17 @@ my $written_file = $aug_root."etc/hosts.augnew" ;
 unlink ($written_file) if -e $written_file ;
 
 my $augc = Config::Augeas::init($aug_root, '' ,
-				&Config::Augeas::AUG_SAVE_NEWFILE) ;
+				&Config::Augeas::AUG_SAVE_NEWFILE |
+                                &Config::Augeas::AUG_ENABLE_SPAN) ;
 
 ok($augc,"Created new Augeas object");
 
 my $string = $augc->get("/files/etc/hosts/1/ipaddr") ;
 is($string,'127.0.0.1',"Called get (returned $string )");
 
+$ret = $augc->srun(*STDOUT, 'get /files/etc/hosts/1/ipaddr') ;
+is($ret,'1',"Called srun get (returned $ret )");
+
 $ret = $augc->set("/files/etc/hosts/2/ipaddr","192.168.0.1") ;
 $ret = $augc->set("/files/etc/hosts/2/canonical","bilbo") ;
 
@@ -153,6 +157,11 @@ is_deeply(\@a,["/files/etc/hosts"],"match result") ;
 $ret = $augc->count_match("/files/etc/hosts") ;
 is($ret,1,"count_match result") ;
 
+my $span = $augc->span('/files/etc/hosts/2') ;
+is($span->{filename}, 'augeas-root/etc/hosts', "filename of span /files/etc/hosts/2") ;
+is($span->{span_start}, '30', "span_start of span /files/etc/hosts/2") ;
+is($span->{span_end}, '48', "span_start of span /files/etc/hosts/2") ;
+
 $ret = $augc->save ;
 is($ret,0,"save done") ;
 

-- 
Debian packaging of libconfig-augeas-perl



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