line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Maisha; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
976135
|
use strict; |
|
8
|
|
|
|
|
32
|
|
|
8
|
|
|
|
|
205
|
|
4
|
8
|
|
|
8
|
|
34
|
use warnings; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
331
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=encoding utf8 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
App::Maisha - A command line social micro-blog networking tool. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use App::Maisha; |
19
|
|
|
|
|
|
|
my $maisha = App::Maisha->new(config => $file)->run; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This distribution provides the ability to micro-blog via social networking |
24
|
|
|
|
|
|
|
websites and services, such as Identica and Twitter. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
For further information regarding the commands and configuration, please see |
27
|
|
|
|
|
|
|
the 'maisha' script included with this distribution. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
32
|
|
|
|
|
|
|
# Library Modules |
33
|
|
|
|
|
|
|
|
34
|
8
|
|
|
8
|
|
37
|
use base qw(Class::Accessor::Fast); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
3253
|
|
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
8
|
|
23759
|
use Carp qw(croak); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
355
|
|
37
|
8
|
|
|
8
|
|
3004
|
use Config::Any; |
|
8
|
|
|
|
|
72649
|
|
|
8
|
|
|
|
|
239
|
|
38
|
8
|
|
|
8
|
|
3590
|
use App::Maisha::Shell; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
284
|
|
39
|
8
|
|
|
8
|
|
54
|
use File::Basename; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
467
|
|
40
|
8
|
|
|
8
|
|
3626
|
use File::HomeDir; |
|
8
|
|
|
|
|
36018
|
|
|
8
|
|
|
|
|
4078
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
43
|
|
|
|
|
|
|
# Accessors |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors($_) for qw(shell config); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
48
|
|
|
|
|
|
|
# Public API |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
7
|
|
|
7
|
1
|
26756
|
my $class = shift; |
52
|
7
|
|
|
|
|
65
|
my $self = $class->SUPER::new(); |
53
|
7
|
|
|
|
|
58
|
my $config = $self->load_config(@_); |
54
|
4
|
|
|
|
|
140
|
$self->config($config); |
55
|
4
|
|
|
|
|
51
|
$self->setup(); |
56
|
4
|
|
|
|
|
3144
|
$self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub load_config { |
60
|
7
|
|
|
7
|
1
|
28
|
my ($self,%hash) = @_; |
61
|
7
|
|
|
|
|
17
|
my $config = $hash{config}; |
62
|
|
|
|
|
|
|
|
63
|
7
|
100
|
66
|
|
|
46
|
if ($config && ! ref $config) { |
64
|
6
|
|
|
|
|
13
|
my $filename = $config; |
65
|
|
|
|
|
|
|
# In the future, we may support multiple configs, but for now |
66
|
|
|
|
|
|
|
# just load a single file via Config::Any |
67
|
6
|
|
|
|
|
81
|
my $list = Config::Any->load_files( { files => [ $filename ], use_ext => 1 } ); |
68
|
3
|
|
|
|
|
12007
|
($config) = $list->[0]->{$filename}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
4
|
50
|
|
|
|
25
|
croak("Could not load configuration file") if(!$config); |
72
|
4
|
50
|
|
|
|
47
|
croak("Maisha expectes a config file that can be decoded to a HASH") if(ref $config ne 'HASH'); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# some systems use a broken pager, so force the internal parser to be used |
75
|
4
|
|
|
|
|
52
|
$self->{pager} = $ENV{PAGER}; |
76
|
4
|
|
|
|
|
42
|
$ENV{PAGER} = ''; |
77
|
|
|
|
|
|
|
|
78
|
4
|
|
|
|
|
45
|
return $config; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub setup { |
82
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
83
|
4
|
|
|
|
|
71
|
my $config = $self->config; |
84
|
4
|
|
|
|
|
99
|
my $shell = $self->shell(App::Maisha::Shell->new); |
85
|
|
|
|
|
|
|
|
86
|
4
|
|
50
|
|
|
47232
|
my $debug = $config->{CONFIG}{debug} || 0; |
87
|
4
|
|
50
|
|
|
43
|
my $history = $config->{CONFIG}{history} || ''; |
88
|
|
|
|
|
|
|
|
89
|
4
|
|
|
|
|
14
|
my $tag = $config->{CONFIG}{tag}; |
90
|
4
|
|
100
|
|
|
51
|
$tag ||= '[from maisha]'; |
91
|
4
|
100
|
|
|
|
22
|
$tag = '' if($tag eq '.'); |
92
|
|
|
|
|
|
|
|
93
|
4
|
|
|
|
|
19
|
my $prompt = $config->{CONFIG}{prompt}; |
94
|
4
|
|
100
|
|
|
25
|
$prompt ||= 'maisha>'; |
95
|
4
|
|
|
|
|
47
|
$prompt =~ s/\s*$/ /; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
|
|
43
|
$shell->debug($debug); |
99
|
4
|
|
|
|
|
22
|
$shell->history($history); |
100
|
4
|
|
|
|
|
37
|
$shell->prompt_str($prompt); |
101
|
4
|
|
|
|
|
17
|
$shell->tag_str($tag); |
102
|
4
|
50
|
|
|
|
32
|
$shell->pager( defined $config->{CONFIG}{pager} ? $config->{CONFIG}{pager} : 1 ); |
103
|
4
|
100
|
|
|
|
36
|
$shell->order( defined $config->{CONFIG}{order} ? $config->{CONFIG}{order} : 'descending'); |
104
|
4
|
50
|
|
|
|
22
|
$shell->limit( defined $config->{CONFIG}{limit} ? $config->{CONFIG}{limit} : 0); |
105
|
4
|
50
|
|
|
|
25
|
$shell->chars( defined $config->{CONFIG}{chars} ? $config->{CONFIG}{chars} : 80); |
106
|
4
|
50
|
|
|
|
27
|
$shell->format(defined $config->{CONFIG}{format} ? $config->{CONFIG}{format} : '[%U] %M'); |
107
|
|
|
|
|
|
|
|
108
|
4
|
|
|
|
|
71
|
my $home = File::HomeDir->my_home(); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# connect to the available sites |
111
|
4
|
|
|
|
|
239
|
for my $plugin (keys %$config) { |
112
|
6
|
100
|
|
|
|
37
|
next if($plugin eq 'CONFIG'); |
113
|
2
|
|
|
|
|
17
|
$config->{$plugin}{home} = $home; |
114
|
2
|
|
|
|
|
48
|
$self->shell->connect($plugin,$config->{$plugin}); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# in some environments 'Wide Character' warnings are emited where unicode |
118
|
|
|
|
|
|
|
# strings are seen in status messages. This suppresses them. |
119
|
4
|
|
|
2
|
|
161
|
binmode STDOUT, ":encoding(UTF-8)"; |
|
2
|
|
|
|
|
29
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
28
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub run { |
123
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
124
|
0
|
|
|
|
|
0
|
my $shell = $self->shell; |
125
|
0
|
|
|
|
|
0
|
$shell->postcmd(); |
126
|
0
|
|
|
|
|
0
|
$shell->cmdloop(); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
$ENV{PAGER} = $self->{pager}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 METHODS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 Constructor |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * new |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 Process Methods |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=over 4 |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * load_config |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Loads the configuration file. See the 'maisha' script to see a fuller |
152
|
|
|
|
|
|
|
description of the configuration options. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * setup |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Prepares the interface and internal environment. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * run |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Starts the command loop shell, and awaits your command. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=back |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 WEBSITES |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over 4 |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * Main Site: L<http://maisha.grango.org> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * Git Repo: L<http://github.com/barbie/maisha/tree/master> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * RT Queue: L<RT: http://rt.cpan.org/Public/Dist/Display.html?Name=App-Maisha> |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=back |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 THANKS TO |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
My thanks go to the following people for suggestions and help when putting this |
179
|
|
|
|
|
|
|
application together. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Dave Cross, Robert Rothenberg and Steffen Müller. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 AUTHOR |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Barbie, <barbie@cpan.org> |
186
|
|
|
|
|
|
|
for Miss Barbell Productions <http://www.missbarbell.co.uk>. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Copyright (C) 2009-2019 by Barbie |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This distribution is free software; you can redistribute it and/or |
193
|
|
|
|
|
|
|
modify it under the Artistic License v2. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |