blib/lib/XML/Grammar/Fortune/Synd/App.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 92.8% 26 / 28 CC 1 SCAR 0.4
CC
1
Cov
90%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/XML/Grammar/Fortune/Synd/Heap/Elem.pm ↑ Summary blib/lib/XML/Grammar/Fortune/Synd.pm »
1 package XML::Grammar::Fortune::Synd::App;
2 $XML::Grammar::Fortune::Synd::App::VERSION = '0.0212';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use vars qw(@EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 @EXPORT=('run');
11  
12 2 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use XML::Grammar::Fortune::Synd;
Subroutine BEGIN: called CC=1 SCAR=2.6
16  
17  
18  
19 sub run
20 {
21 my $dir;
22 my $yaml_data_file;
23 my @xml_files = ();
24 my $atom_output_fn;
25 my $rss_output_fn;
26 my $master_url;
27 my $feed_title;
28 my $feed_tagline;
29 my $feed_author;
30  
31 GetOptions(
32 'dir=s' => \$dir,
33 'xml-file=s' => \@xml_files,
34 'yaml-data=s' => \$yaml_data_file,
35 'atom-output=s' => \$atom_output_fn,
36 'rss-output=s' => \$rss_output_fn,
37 'master-url=s' => \$master_url,
38 'title=s' => \$feed_title,
39 'tagline=s' => \$feed_tagline,
40 'author=s' => \$feed_author,
41 );
42  
43  
44 my $url_callback = sub {
45 my ($self, $args) = @_;
46  
47 my $id_obj = $args->{id_obj};
48  
49 my $base_fn = $id_obj->file();
50  
51 $base_fn =~ s{\.[^\.]*\z}{}ms;
52  
53 return $master_url . $base_fn . ".html" . "#" . $id_obj->id();
54 };
55  
56 my $syndicator = XML::Grammar::Fortune::Synd->new(
57 {
58 xml_files => \@xml_files,
59 url_callback => $url_callback,
60 }
61 );
62  
63 my @more_params;
64  
65 if ($atom_output_fn)
66 {
67 my (undef, undef, $atom_base) = File::Spec->splitpath($atom_output_fn);
68 push @more_params, (atom_self_link => "$master_url$atom_base");
69 }
70  
71 if ($rss_output_fn)
72 {
73 my (undef, undef, $rss_base) = File::Spec->splitpath($rss_output_fn);
74 push @more_params, (rss_self_link => "$master_url$rss_base");
75 }
76  
77 my $recent_ids_struct = $syndicator->calc_feeds(
78 {
79 yaml_persistence_file => $yaml_data_file,
80 yaml_persistence_file_out => $yaml_data_file,
81 xmls_dir => $dir,
82 feed_params =>
83 {
84 title => $feed_title,
85 'link' => $master_url,
86 tagline => $feed_tagline,
87 author => $feed_author,
88 @more_params,
89 },
90 }
91 );
92  
93 if (defined($atom_output_fn))
94 {
95 open my $atom_out, ">", $atom_output_fn;
96 print {$atom_out} $recent_ids_struct->{'feeds'}->{'Atom'}->as_xml();
97 close($atom_out);
98 }
99  
100 if (defined($rss_output_fn))
101 {
102 open my $rss20_out, ">", $rss_output_fn;
103 print {$rss20_out} $recent_ids_struct->{'feeds'}->{'rss20'}->as_xml();
104 close($rss20_out);
105 }
106 }
107 1;
108  
109 __END__
110  
111 =pod
112  
113 =encoding UTF-8
114  
115 =head1 NAME
116  
117 XML::Grammar::Fortune::Synd::App - module implementing a command line
118 application to syndicate FortuneXML as Atom/RSS.
119  
120 =head1 VERSION
121  
122 version 0.0212
123  
124 =head1 SYNOPSIS
125  
126 perl -MXML::Grammar::Fortune::Synd::App -e 'run()' [ARGS] \
127  
128 =head1 VERSION
129  
130 version 0.0212
131  
132 =head1 FUNCTIONS
133  
134 =head2 run()
135  
136 Call with no arguments to run the application from the commandline.
137  
138 =head1 AUTHOR
139  
140 Shlomi Fish <shlomif@cpan.org>
141  
142 =head1 COPYRIGHT AND LICENSE
143  
144 This software is Copyright (c) 2018 by Shlomi Fish.
145  
146 This is free software, licensed under:
147  
148 The MIT (X11) License
149  
150 =head1 BUGS
151  
152 Please report any bugs or feature requests on the bugtracker website
153 L<https://github.com/shlomif/xml-grammar-fortune-synd/issues>
154  
155 When submitting a bug or request, please include a test-file or a
156 patch to an existing test-file that illustrates the bug or desired
157 feature.
158  
159 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
160  
161 =head1 SUPPORT
162  
163 =head2 Perldoc
164  
165 You can find documentation for this module with the perldoc command.
166  
167 perldoc XML::Grammar::Fortune::Synd::App
168  
169 =head2 Websites
170  
171 The following websites have more information about this module, and may be of help to you. As always,
172 in addition to those websites please use your favorite search engine to discover more resources.
173  
174 =over 4
175  
176 =item *
177  
178 MetaCPAN
179  
180 A modern, open-source CPAN search engine, useful to view POD in HTML format.
181  
182 L<https://metacpan.org/release/XML-Grammar-Fortune-Synd>
183  
184 =item *
185  
186 Search CPAN
187  
188 The default CPAN search engine, useful to view POD in HTML format.
189  
190 L<http://search.cpan.org/dist/XML-Grammar-Fortune-Synd>
191  
192 =item *
193  
194 RT: CPAN's Bug Tracker
195  
196 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
197  
198 L<https://rt.cpan.org/Public/Dist/Display.html?Name=XML-Grammar-Fortune-Synd>
199  
200 =item *
201  
202 AnnoCPAN
203  
204 The AnnoCPAN is a website that allows community annotations of Perl module documentation.
205  
206 L<http://annocpan.org/dist/XML-Grammar-Fortune-Synd>
207  
208 =item *
209  
210 CPAN Ratings
211  
212 The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.
213  
214 L<http://cpanratings.perl.org/d/XML-Grammar-Fortune-Synd>
215  
216 =item *
217  
218 CPANTS
219  
220 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
221  
222 L<http://cpants.cpanauthors.org/dist/XML-Grammar-Fortune-Synd>
223  
224 =item *
225  
226 CPAN Testers
227  
228 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
229  
230 L<http://www.cpantesters.org/distro/X/XML-Grammar-Fortune-Synd>
231  
232 =item *
233  
234 CPAN Testers Matrix
235  
236 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
237  
238 L<http://matrix.cpantesters.org/?dist=XML-Grammar-Fortune-Synd>
239  
240 =item *
241  
242 CPAN Testers Dependencies
243  
244 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
245  
246 L<http://deps.cpantesters.org/?module=XML::Grammar::Fortune::Synd>
247  
248 =back
249  
250 =head2 Bugs / Feature Requests
251  
252 Please report any bugs or feature requests by email to C<bug-xml-grammar-fortune-synd at rt.cpan.org>, or through
253 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-Grammar-Fortune-Synd>. You will be automatically notified of any
254 progress on the request by the system.
255  
256 =head2 Source Code
257  
258 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
259 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
260 from your repository :)
261  
262 L<https://github.com/shlomif/xml-grammar-fortune-synd>
263  
264 git clone https://bitbucket.org/shlomif/fortune-xml
265  
266 =cut
« blib/lib/XML/Grammar/Fortune/Synd/Heap/Elem.pm ↑ Summary blib/lib/XML/Grammar/Fortune/Synd.pm »