Commits

Anonymous committed b799234

[Docmake] Added the --stringparam option.

1. Added "use strict"/"use warnings" to Docmake.pm.

2. Added the $VERSION.

3. Added the --stringparam.

4. Testing that the --stringparam (and other operations) work.

Comments (0)

Files changed (3)

modules/App-XML-DocBook-Docmake/META.yml

     version: 0.01
   App::XML::DocBook::Docmake:
     file: lib/App/XML/DocBook/Docmake.pm
-generated_by: Module::Build version 0.2801
+    version: 0.01
+generated_by: Module::Build version 0.2808
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.2.html
   version: 1.2

modules/App-XML-DocBook-Docmake/lib/App/XML/DocBook/Docmake.pm

 package App::XML::DocBook::Docmake;
 
+use strict;
+use warnings;
+
 use Getopt::Long qw(GetOptionsFromArray);
 
 use base 'Class::Accessor';
 
 =cut
 
+use vars qw($VERSION);
+
+$VERSION = "0.01";
+
 __PACKAGE__->mk_accessors(qw(
     _input_path
     _mode
     _stylesheet
     _verbose
     _xslt_mode
+    _xslt_stringparams
 ));
 
 =head1 SYNOPSIS
     my $output_path;
     my $verbose = 0;
     my $stylesheet;
+    my @in_stringparams;
 
     my $ret = GetOptionsFromArray($argv,
         "o=s" => \$output_path,
         "v|verbose" => \$verbose,
         "x|stylesheet=s" => \$stylesheet,
+        "stringparam=s" => \@in_stringparams,
     );
 
+    my @stringparams;
+    foreach my $param (@in_stringparams)
+    {
+        if ($param =~ m{\A([^=]+)=(.+)\z}ms)
+        {
+            push @stringparams, [$1,$2];
+        }
+        else
+        {
+            die "Wrong stringparam argument '$param'! Does not contain a '='!";
+        }
+    }
+
     $self->_output_path($output_path);
     $self->_verbose($verbose);
     $self->_stylesheet($stylesheet);
+    $self->_xslt_stringparams(\@stringparams);
 
     my $mode = shift(@$argv);
 
         [
             "xsltproc",
             "-o", $output_path,
+            (map { ("--stringparam", @$_ ) } @{$self->_xslt_stringparams()}),
             @stylesheet_params,
             $self->_input_path(),
         ],

modules/App-XML-DocBook-Docmake/t/01-use.t

 use strict;
 use warnings;
 
-use Test::More tests => 2;
+use Test::More tests => 4;
 use Test::Trap qw( trap $trap :flow:stderr(systemsafe):stdout(systemsafe):warn );
 
 use App::XML::DocBook::Docmake;
 
+package MyTest::DocmakeAppDebug;
+
+use vars qw(@commands_executed);
+
+use base 'App::XML::DocBook::Docmake';
+
+sub _exec_command
+{
+    my ($self, $cmd) = @_;
+    
+    push @commands_executed, [@$cmd];
+}
+
+sub debug_commands
+{
+    my @ret = @commands_executed;
+
+    # Reset the commands to allow for future use.
+    @commands_executed = ();
+
+    return \@ret;
+}
+
+package main;
+
 {
     my $docmake = App::XML::DocBook::Docmake->new({argv => ["help"]});
 
           "Testing output of help"
     );
 }
+
+{
+    my $docmake = MyTest::DocmakeAppDebug->new({argv => [
+            "-v",
+            "--stringparam",
+            "chunk.section.depth=2",
+            "-o", "output.xhtml",
+            "xhtml",
+            "input.xml",
+            ]});
+
+    # TEST
+    ok ($docmake, "Docmake was constructed successfully");
+
+    $docmake->run();
+
+    # TEST
+    is_deeply(MyTest::DocmakeAppDebug->debug_commands(),
+        [
+            [
+                "xsltproc",
+                "-o", "output.xhtml",
+                "--stringparam", "chunk.section.depth", "2",
+                "http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl",
+                "input.xml",
+            ]
+        ],
+        "stringparam is propagated to the xsltproc command",
+    );
+}
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.