Commits

Anonymous committed 0e4b4e1

Added a test for running the application and made sure it passes - there
were some problems before hand.

Comments (0)

Files changed (7)

XML-Grammar-Fortune-Synd/module/MANIFEST

 Build.PL
 Changes
+inc/Test/Run/Builder.pm
 lib/XML/Grammar/Fortune/Synd/App.pm
 lib/XML/Grammar/Fortune/Synd/Heap/Elem.pm
 lib/XML/Grammar/Fortune/Synd.pm
-inc/Test/Run/Builder.pm
 Makefile.PL
 MANIFEST
 META.yml
 README
 t/00-load.t
+t/01-run.t
+t/data/fortune-synd-1/irc-conversation-4-several-convos.xml
+t/data/fortune-synd-1/screenplay-fort-sample-1.xml
+t/data/out-fortune-synd-1/PLACEHOLDER
 t/pod-coverage.t
 t/pod.t

XML-Grammar-Fortune-Synd/module/lib/XML/Grammar/Fortune/Synd.pm

 use Heap::Binary;
 use XML::Feed;
 use XML::Grammar::Fortune;
+use DateTime::Format::W3CDTF;
+use XML::Grammar::Fortune::Synd::Heap::Elem;
 
 __PACKAGE__->mk_accessors(qw(
         _xml_parser
     my $xmls_dir = $args->{xmls_dir};
 
 
-    my $persistent_data = LoadFile($scripts_hash_filename);
+    my $persistent_data;
+    if (-e $scripts_hash_filename)
+    {
+        $persistent_data = LoadFile ($scripts_hash_filename);
+    }
+    else
+    {
+        $persistent_data = +{};
+    }
 
     if (!exists($persistent_data->{'files'}))
     {

XML-Grammar-Fortune-Synd/module/lib/XML/Grammar/Fortune/Synd/App.pm

 use strict;
 use warnings;
 
+use base 'Exporter';
+
+use vars qw(@EXPORT);
+
+@EXPORT=('run');
+
+use Getopt::Long;
+use File::Spec;
+
+use XML::Grammar::Fortune::Synd;
+
 =head1 NAME
 
 XML::Grammar::Fortune::Synd::App - module implementing a command line 
 
 =cut
 
-use Getopt::Long;
-use File::Spec;
 
 sub run
 {
         push @more_params, (rss_self_link => "$master_url$rss_base");
     }
 
-    my $recent_ids_struct = $syndicator->get_most_recent_ids(
+    my $recent_ids_struct = $syndicator->calc_feeds(
            {
                 yaml_persistence_file => $yaml_data_file,
                 yaml_persistence_file_out => $yaml_data_file,

XML-Grammar-Fortune-Synd/module/t/01-run.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+# TEST
+ok (!system(
+    $^X,
+    "-MXML::Grammar::Fortune::Synd::App",
+    "-e",
+    "run()",
+    "--",
+    "--dir" => "t/data/fortune-synd-1",
+    qw(
+        --xml-file irc-conversation-4-several-convos.xml
+        --xml-file screenplay-fort-sample-1.xml
+    ),
+    "--yaml-data" => "t/data/out-fortune-synd-1/fort.yaml",
+    "--atom-output" => "t/data/out-fortune-synd-1/fort.atom",
+    "--rss-output" => "t/data/out-fortune-synd-1/fort.rss",
+    "--master-url" => "http://www.fortunes.tld/My-Fortunes/",
+    "--title" => "My Fortune Feeds",
+    "--tagline" => "My Fortune Feeds",
+    "--author" => "shlomif\@iglu.org.il (Shlomi Fish)",
+));
+

XML-Grammar-Fortune-Synd/module/t/data/fortune-synd-1/irc-conversation-4-several-convos.xml

+<?xml version="1.0" encoding="utf-8"?>
+<collection>
+    <head />
+    <list>
+        <fortune id="Im-not-an-asshole">
+            <meta>
+                <title>I'm not an Asshole…</title>
+            </meta>
+            <irc>
+                <body>
+                    <joins who="mofino">has joined #perlcafe</joins>
+                    <saying who="mofino">I'm not an asshole. I just play one on T.V.</saying>
+                    <leaves who="mofino">has left #perlcafe</leaves>
+                </body>
+                <info>
+                    <channel>#perlcafe</channel>
+                    <network>Freenode</network>
+                    <tagline>Discussing the Subversion Build System</tagline>
+                </info>
+            </irc>
+        </fortune>
+        <fortune id="the-only-language">
+            <meta>
+                <title>"The Only Language"</title>
+            </meta>
+            <irc>
+                <body>
+                    <saying who="rindolf">This reminds me of a fun discussion I had with my co-worker.</saying>
+                    <saying who="rindolf">He had a Firefox window open with an ActiveState page and I read "Perl, PHP, Python, Tcl, XSLT".</saying>
+                    <saying who="rindolf">So he said: "Heresy! C is the only language."</saying>
+                    <saying who="rindolf">So I thought for a moment and said "Intercal is the only language."</saying>
+                    <saying who="nanonyme">lol</saying>
+                    <saying who="rindolf">And then "Real men write in Intercal."</saying>
+                    <saying who="rindolf">"COME FROM" anyone?</saying>
+                </body>
+                <info>
+                    <channel>#perl</channel>
+                    <network>Freenode</network>
+                    <tagline>Shlomi Fish ("rindolf")</tagline>
+                </info>
+            </irc>
+        </fortune>
+        <fortune id="let-me-wikipedia-it">
+            <meta>
+                <title>(Human) Language Fun on Freenode's #perl</title>
+            </meta>
+            <irc>
+                <body>
+                    <saying who="rindolf">Let me wikipedia it.</saying>
+                    <saying who="f00li5h">so now wikipedia is a verb?</saying>
+                    <saying who="rindolf">f00li5h: it's gonna enter the OED.</saying>
+                    <saying who="rindolf">f00li5h: in English every verb can be nounified and every noun can be verbed</saying>
+                </body>
+                <info>
+                    <channel>#perl</channel>
+                    <network>Freenode</network>
+                    <tagline>(Human) Language Fun</tagline>
+                </info>
+            </irc>
+        </fortune>
+    </list>
+</collection>

XML-Grammar-Fortune-Synd/module/t/data/fortune-synd-1/screenplay-fort-sample-1.xml

+<?xml version="1.0" encoding="utf-8"?>
+<collection>
+<head />
+<list>
+<fortune id="david-and-goliath-1">
+<meta>
+<title>David and Goliath - 1</title>
+</meta>
+<screenplay>
+<body>
+<description>
+<para>
+David and 
+<ulink url="http://en.wikipedia.org/wiki/Goliath">Goliath</ulink> 
+are standing by each other.
+</para>
+</description>
+<saying character="David">
+<para>
+I will kill you.<br />
+I will kill you.<br />
+You will not survive.<br />
+I will kill you.<br />
+I will kill you.<br />
+Ask Jive.
+</para>
+</saying>
+<saying character="Goliath">
+<para>
+no way, you little idiot!
+</para>
+</saying>
+<saying character="David">
+<para>
+yes way!
+</para>
+</saying>
+</body>
+<info>
+<author>Shlomi Fish</author>
+<work href="http://www.shlomifish.org/">David and Goliath Skit</work>
+</info>
+</screenplay>
+</fortune>
+</list>
+</collection>

XML-Grammar-Fortune-Synd/module/t/data/out-fortune-synd-1/PLACEHOLDER

Empty file added.