Schedule.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary Schedule/Post.pm »
1 package LJ::Schedule;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 LJ::Schedule - A quick and dirty schedule-posting tool for LiveJournal.
9  
10 =head1 VERSION
11  
12 Version 0.6
13  
14 =cut
15  
16 our $VERSION = '0.6';
17  
18 =head1 SYNOPSIS
19  
20 This module is designed to scratch a very specific itch - taking a schedule
21 from a given format (for me, vCal) and constructing an LJ schedule post from
22 it. It is designed to be extensible to other input file formats and other
23 posting methods, although currently only vCal as input and LJ::Simple posting
24 are supported.
25  
26 use LJ::Schedule;
27  
28 # Choose the type of schedule to import
29 my $cal = LJ::Schedule::Vcal->new({filename => $ARGV[0]});
30 $cal->prep_cal_for_lj();
31  
32 my $lj = LJ::Schedule::Post->new();
33 my $post_ok = $lj->post_cal($cal);
34  
35 ...
36  
37 =head1 FUNCTIONS
38  
39 =head2 get_config
40  
41 Reads in the config from the specified config file (.ini style) - defaulting to
42 .lj_cfg.ini if the filename isn't given.
43  
44 Sample config file:
45  
46 # Comment line
47  
48 [private]
49 user=kitty
50 pass=XXXXX
51  
52 [entry]
53 subject='Schedule Post'
54 protect=friends
55  
56 [alias]
57 b=bobt
58  
59 The above config file will post to journal name 'kitty', authenticating with the
60 password XXXXX, with a title of 'Schedule Post', protected to friends-only.
61  
62 The aliases allow a vCal entry such as "Date with B" to be automatically transformed
63 to an LJ user (in this case, of bobt).
64  
65 =cut
66  
67 =head1 AUTHOR
68  
69 Ben Evans, C<< <ben at bpfh.net> >>
70  
71 =head1 BUGS
72  
73 Please report any bugs or feature requests to
74 C<bug-lj-schedule at rt.cpan.org>, or through the web interface at
75 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LJ-Schedule>.
76 I will be notified, and then you'll automatically be notified of progress on
77 your bug as I make changes.
78  
79 =head1 SUPPORT
80  
81 You can find documentation for this module with the perldoc command.
82  
83 perldoc LJ::Schedule
84  
85 You can also look for information at:
86  
87 =over 4
88  
89 =item * AnnoCPAN: Annotated CPAN documentation
90  
91 L<http://annocpan.org/dist/LJ-Schedule>
92  
93 =item * CPAN Ratings
94  
95 L<http://cpanratings.perl.org/d/LJ-Schedule>
96  
97 =item * RT: CPAN's request tracker
98  
99 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=LJ-Schedule>
100  
101 =item * Search CPAN
102  
103 L<http://search.cpan.org/dist/LJ-Schedule>
104  
105 =back
106  
107 =head1 ACKNOWLEDGEMENTS
108  
109 =head1 COPYRIGHT & LICENSE
110  
111 Copyright 2006 Ben Evans, all rights reserved.
112  
113 This program is free software; you can redistribute it and/or modify it
114 under the same terms as Perl itself.
115  
116 =cut
117  
118 0 ▶use LJ::Schedule::Vcal;
Subroutine BEGIN: called CC=1 SCAR=2.6
119 use LJ::Schedule::Post;
120  
121 use Config::Simple;
122  
123 # This package stores our global variables which are largely used by the other
124 # modules. These are deliberately public to alow the user to alter them as s/he
125 # sees fit
126  
127 our $CONFIG;
128 our $ALIAS;
129  
130 our $DATE_FMT = '%o %b: ';
131  
132 # FIXME config file
133  
134 our $TAGS = [];
135  
136 sub get_config {
137 my $fname = shift;
138 $fname ||= '.lj_cfg.ini';
139  
140 my %cfg;
141  
142 # Open the config
143 Config::Simple->import_from($fname, \%cfg) or die Config::Simple->error();
144 $CONFIG = \%cfg;
145  
146 my @keys = keys(%$CONFIG);
147 foreach my $k (@keys) {
148 next unless $k =~ /^alias\.(.*)/;
149 my $name = $1;
150  
151 $ALIAS->{$name} = $CONFIG->{'alias.'.$name}
152 }
153  
154 $DATE_FMT = $CONFIG->{'global.date_format'} if $CONFIG->{'global.date_format'};
155 }
156  
157 1;
158  
159  
160  
161 1; # End of LJ::Schedule
↑ Summary Schedule/Post.pm »