xmltv/lib Supplement.pm.in,1.15,1.16
Geoff <[email protected]>
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/lib
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19204
Modified Files:
Supplement.pm.in
Log Message:
Add GetSupplementLines, GetSupplementRoot, GetSupplementDir
Index: Supplement.pm.in
===================================================================
RCS file: /cvsroot/xmltv/xmltv/lib/Supplement.pm.in,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Supplement.pm.in 21 Jun 2011 03:35:07 -0000 1.15
--- Supplement.pm.in 8 Jan 2014 12:01:21 -0000 1.16
***************
*** 3,6 ****
--- 3,10 ----
use strict;
+ # use version number for feature detection:
+ # 0.005065 : addition of GetSupplementLines, GetSupplementRoot, GetSupplementDir
+ our $VERSION = 0.005065;
+
BEGIN {
use Exporter ();
***************
*** 10,14 ****
@EXPORT = qw( );
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
! @EXPORT_OK = qw/GetSupplement SetSupplementRoot/;
}
our @EXPORT_OK;
--- 14,18 ----
@EXPORT = qw( );
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
! @EXPORT_OK = qw/GetSupplement GetSupplementLines SetSupplementRoot GetSupplementRoot GetSupplementDir/;
}
our @EXPORT_OK;
***************
*** 126,129 ****
--- 130,166 ----
}
+ =item GetSupplementLines
+
+ Load a supplement file and return it as an array. Any comments or blank lines
+ will be removed. Takes two parameters: directory and filename.
+
+ my $content = GetSupplementLines( 'tv_grab_uk_rt', 'channel_ids' );
+
+ GetSupplementLines will always return an array with the content. If it fails
+ to get the content, it prints an error-message and aborts the program.
+
+ =cut
+
+ sub GetSupplementLines {
+ my $supplement_string = GetSupplement( @_ );
+ my @supplement_array;
+ my @supplement_lines = split( /\n+/, $supplement_string );
+ foreach ( @supplement_lines ) {
+ tr/\r//d; # strip CRs
+ s/#.*//; # strip comment
+ next if m/^\s*$/; # ignore blank lines
+ s/^\s+|\s+$//g; # remove leading & trailing spaces
+ push @supplement_array, $_;
+ }
+
+ return \@supplement_array;
+ }
+
+ =item GetSupplementFile
+
+ Get the supplement file from the local machine
+
+ =cut
+
sub GetSupplementFile {
my( $directory, $name ) = @_;
***************
*** 151,154 ****
--- 188,197 ----
}
+ =item GetSupplementUrl
+
+ Get the supplement file from a URL
+
+ =cut
+
sub GetSupplementUrl {
my( $directory, $name ) = @_;
***************
*** 227,230 ****
--- 270,311 ----
}
+ =item GetSupplementDir
+
+ Get the base directory containing supplementary files.
+ e.g. $ENV{HOME}/.xmltv/supplement
+
+ =cut
+
+ sub GetSupplementDir {
+ create_cachedir() if not defined $cachedir;
+ return $cachedir;
+ }
+
+ =item SetSupplementRoot
+
+ Set the root directory for loading supplementary files.
+
+ SetSupplementRoot( '/usr/share/xmltv' );
+ SetSupplementRoot( 'http://my.server.org/xmltv' );
+
+ =cut
+
+ sub SetSupplementRoot {
+ my( $root ) = @_;
+
+ $supplement_root = $root;
+ }
+
+ =item GetSupplementRoot
+
+ Get the root directory for loading supplementary files.
+
+ =cut
+
+ sub GetSupplementRoot {
+ set_supplement_root() if not defined $supplement_root;
+ return $supplement_root;
+ }
+
sub write_meta {
my( $directory, $url, $file, $resp, $meta ) = @_;
***************
*** 299,318 ****
}
-
- =item SetSupplementRoot
-
- Set the root directory for loading supplementary files.
-
- SetSupplementRoot( '/usr/share/xmltv' );
- SetSupplementRoot( 'http://my.server.org/xmltv' );
-
- =cut
-
- sub SetSupplementRoot {
- my( $root ) = @_;
-
- $supplement_root = $root;
- }
-
=back
--- 380,383 ----
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk