[libconfig-model-dpkg-perl] 09/11: added dpkg parser and writer examples

dod at debian.org dod at debian.org
Fri Jan 13 13:01:40 UTC 2017


This is an automated email from the git hooks/post-receive script.

dod pushed a commit to branch master
in repository libconfig-model-dpkg-perl.

commit e40342b49a6d85e3a99d652baaedaaf754d75e76
Author: Dominique Dumont <dod at debian.org>
Date:   Fri Jan 13 13:49:55 2017 +0100

    added dpkg parser and writer examples
---
 examples/dpkg-new       | 13 +++++++++++++
 examples/dpkg-parser.pl | 29 +++++++++++++++++++++++++++++
 examples/dpkg-test      | 14 ++++++++++++++
 examples/dpkg-writer.pl | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 91 insertions(+)

diff --git a/examples/dpkg-new b/examples/dpkg-new
new file mode 100644
index 0000000..4fbb624
--- /dev/null
+++ b/examples/dpkg-new
@@ -0,0 +1,13 @@
+# section comment
+Name: Foo
+# data comment
+Version: 1.2
+
+Name: Bar
+Version: 1.3
+Files: file1,
+# inline comment
+       file2
+Description: A very
+ .
+ long description
diff --git a/examples/dpkg-parser.pl b/examples/dpkg-parser.pl
new file mode 100644
index 0000000..53d9a8c
--- /dev/null
+++ b/examples/dpkg-parser.pl
@@ -0,0 +1,29 @@
+package MyParser ;
+
+use strict;
+use warnings;
+
+use 5.20.1;
+
+use Log::Log4perl qw(:easy);
+Log::Log4perl->easy_init($WARN);
+
+# load role
+use Mouse ;
+with 'Config::Model::Backend::DpkgSyntax';
+
+package main ;
+use IO::File;
+use Data::Dumper;
+
+my $file = 'examples/dpkg-test';
+my $fh = IO::File->new();
+$fh->open("<  $file");
+
+my $parser = MyParser->new() ;
+
+my $data = $parser->parse_dpkg_file($file, $fh, 'yes', 1);
+$fh->close;
+
+print Dumper $data;
+
diff --git a/examples/dpkg-test b/examples/dpkg-test
new file mode 100644
index 0000000..f1ac661
--- /dev/null
+++ b/examples/dpkg-test
@@ -0,0 +1,14 @@
+Name: Foo
+Version: 1.2
+
+# section comment
+Name: Bar
+# data comment
+Version: 1.3
+Files: file1,
+# inline comment
+       file2
+Description: A very
+ .
+ long description
+
diff --git a/examples/dpkg-writer.pl b/examples/dpkg-writer.pl
new file mode 100644
index 0000000..85b91f4
--- /dev/null
+++ b/examples/dpkg-writer.pl
@@ -0,0 +1,35 @@
+package MyParser ;
+
+use strict;
+use warnings;
+
+use 5.20.1;
+
+use Log::Log4perl qw(:easy);
+Log::Log4perl->easy_init($WARN);
+
+# load role
+use Mouse ;
+with 'Config::Model::Backend::DpkgSyntax';
+
+package main ;
+use IO::File;
+use Data::Dumper;
+
+my $data = [
+    [ '# section comment', qw/Name Foo/, '# data comment', qw/Version 1.2/ ],
+    [
+        qw/Name Bar Version 1.3/ ,
+        Files => [qw/file1/, [ 'file2' , '# inline comment'] ] ,
+        Description => "A very\n\nlong description"
+    ]
+];
+
+my $parser = MyParser->new() ;
+
+
+my $fhw = IO::File->new ;
+$fhw -> open ( 'examples/dpkg-new' ,'>',"," ) ;
+
+$parser->write_dpkg_file($fhw,$data) ;
+$fhw->close;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.git



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