App-Maisha

 view release on metacpan or  search on metacpan

lib/App/Maisha.pm  view on Meta::CPAN

    my $config = $self->config;
    my $shell  = $self->shell(App::Maisha::Shell->new);

    my $debug   = $config->{CONFIG}{debug}   || 0;
    my $history = $config->{CONFIG}{history} || '';

    my $tag = $config->{CONFIG}{tag};
    $tag ||= '[from maisha]';
    $tag   = '' if($tag eq '.');

    my $prompt = $config->{CONFIG}{prompt};
    $prompt ||= 'maisha>';
    $prompt =~ s/\s*$/ /;


    $shell->debug($debug);
    $shell->history($history);
    $shell->prompt_str($prompt);
    $shell->tag_str($tag);
    $shell->pager( defined $config->{CONFIG}{pager}  ? $config->{CONFIG}{pager}  : 1 );
    $shell->order( defined $config->{CONFIG}{order}  ? $config->{CONFIG}{order}  : 'descending');
    $shell->limit( defined $config->{CONFIG}{limit}  ? $config->{CONFIG}{limit}  : 0);
    $shell->chars( defined $config->{CONFIG}{chars}  ? $config->{CONFIG}{chars}  : 80);
    $shell->format(defined $config->{CONFIG}{format} ? $config->{CONFIG}{format} : '[%U] %M');

    my $home = File::HomeDir->my_home();

    # connect to the available sites

lib/App/Maisha/Plugin/Identica.pm  view on Meta::CPAN

=head1 AUTHENTICATION

As Twitter has now disabled Basic Authentication to access their API, to be 
consistent Maisha now requires that access to both Twitter and Identica uses
OAuth.

With this new method of authentication, the application will provide a URL,
which the user needs to cut-n-paste into a browser to logging in to the 
service, using your regular username/password, then 'Allow' Maisha to access 
your account. This will then allow Maisha to post to your account. You will 
then be given a PIN, which should then be entered at the prompt on the Maisha
command line.

Once you have completed authentication, the application will then store your 
access tokens permanently under your profile on your computer. Then when you
next use the application it will retrieve these access tokens automatically and
you will no longer need to register the application.

For further information please see the Identica FAQ - 
L<http://status.net/wiki/TwitterCompatibleAPI>

lib/App/Maisha/Plugin/Twitter.pm  view on Meta::CPAN

On 31st August 2010, Twitter disabled Basic Authentication to access their API.
Instead they have introduce the OAuth method of authrntication, which now 
requires application developers to request the user to authenticate themselves 
and provide a PIN (Personal Identification Number) to allow the application to
retrieve access tokens.

With this new method of authentication, the application will provide a URL,
which the user needs to cut-n-paste into a browser to logging in to the 
service, using your regular username/password, then 'Allow' Maisha to access 
your account. This will then allow Maisha to post to your account. You will 
then be given a PIN, which should then be entered at the prompt on the Maisha
command line.

Once you have completed authentication, the application will then store your 
access tokens permanently under your profile on your computer. Then when you
next use the application it will retrieve these access tokens automatically and
you will no longer need to register the application.

=head1 SEE ALSO

For further information regarding the commands and configuration, please see

lib/App/Maisha/Shell.pm  view on Meta::CPAN

    user_timeline   => { limit => 3200, count =>  200 },    # specific user timelines
    search_tweets   => { limit =>  800, count =>  100 },    # search lists
    home_timeline   => { limit =>  800, count =>  200 },    # generic timelines
    user_lists      => { limit => 5000, count => 5000 },    # user lists
);

#----------------------------------------------------------------------------
# Accessors

sub networks   { shift->_elem('networks',       @_) }
sub prompt_str { shift->_elem('prompt_str',     @_) }
sub tag_str    { shift->_elem('tag_str',        @_) }
sub order      { shift->_elem('order',          @_) }
sub limit      { shift->_elem('limit',          @_) }
sub services   { shift->_elem('services',       @_) }
sub pager      { shift->_elem('pager',          @_) }
sub format     { shift->_elem('format',         @_) }
sub chars      { shift->_elem('chars',          @_) }
sub history    { shift->_elem('historyfile',    @_) }
sub debug      { shift->_elem('debug',          @_) }
sub error      { shift->_elem('error',          @_) }

lib/App/Maisha/Shell.pm  view on Meta::CPAN

display messages in descending order, with the most recent first and the oldest
last.

To reverse this order, set the 'order' as 'ascending' (or 'asc') in your
configuration file. (case insensitive).

=item * networks

Sets the networks list that will appear above the command line.

=item * prompt_str

Sets the prompt string that will appear on the command line.

=item * tag_str

Sets the text that will appear at the end of your message.

In order to suppress the tag string set the 'tag' option to '.' in your
configuration file.

=item * services

script/maisha  view on Meta::CPAN

'.maisha.yml' or '.maisha.yaml'.

=head2 Application Configuration

The configuration for the application itself are contained within a 'CONFIG' 
section in your configuration file. All settings are optional, and will default
to sensible values should they not be user defined.

=over 4

=item * prompt

The prompt you wish to see on the command line. This will default to 'maisha>'
if not configured.

=item * tag

The tag you wish to have added to the end of an update/say command. This will 
default to '[from maisha]' if not configured. If you do not wish a tag to
be added at all, set the tag to '.' in the configuration file.

=item * order

t/20attributes.t  view on Meta::CPAN

    }
}

# App::Maisha::Shell attributes

{
    ok( my $obj = App::Maisha::Shell->new(), "got object" );

    for my $k ( qw/
        networks
        prompt_str
        tag_str
        order
        limit
        services
        pager
        format
        chars
        history
        debug
        error

t/24config.t  view on Meta::CPAN

use strict;

use Test::More tests => 66;
use App::Maisha;
use App::Maisha::Shell;

my $CONFIG = {
    'CONFIG' => {
        'order' => 'asc',
        'tag' => 'tag:',
        'prompt' => 'prompt:'
    }
};

my $app;

# App::Maisha configuration

{
    my $config = 't/data/config.ini';
    eval { $app = App::Maisha->new(config => $config) };
    SKIP: { 
        skip "Config for INI files not installed", 11   if($@);

        isa_ok( $app => 'App::Maisha', "got object" );

        #use Data::Dumper;
        #diag(Dumper($app->config));

        is_deeply($app->config,$CONFIG,   'loaded config file');
        is($app->shell->prompt_str, 'prompt: ',     'correct prompt string');
        is($app->shell->tag_str,    'tag:',         'correct tag string');
        is($app->shell->pager,      '1',            'correct pager');
        is($app->shell->order,      'asc',          'correct order');
        is($app->shell->limit,      '0',            'correct character limit');
        is($app->shell->chars,      '80',           'correct character wrap');
        is($app->shell->format,     '[%U] %M',      'correct format string');
        is($app->shell->debug,      '0',            'correct debug flag');
        is($app->shell->history,    '',             'correct history setting');
    }
}

{
    eval { $app = App::Maisha->new(config => $CONFIG) };
    SKIP: { 
        skip "Config for Perl hashes not installed", 11   if($@);

        isa_ok( $app => 'App::Maisha', "got object" );

        is_deeply($app->config,$CONFIG,   'loaded config file');
        is($app->shell->prompt_str, 'prompt: ',     'correct prompt string');
        is($app->shell->tag_str,    'tag:',         'correct tag string');
        is($app->shell->pager,      '1',            'correct pager');
        is($app->shell->order,      'asc',          'correct order');
        is($app->shell->limit,      '0',            'correct character limit');
        is($app->shell->chars,      '80',           'correct character wrap');
        is($app->shell->format,     '[%U] %M',      'correct format string');
        is($app->shell->debug,      '0',            'correct debug flag');
        is($app->shell->history,    '',             'correct history setting');
    }
}

{
    my $config = 't/data/config.json';
    eval { $app = App::Maisha->new(config => $config) };
    SKIP: { 
        skip "Config for JSON files not installed", 11   if($@);

        isa_ok( $app => 'App::Maisha', "got object" );

        isnt($app->config->{CONFIG},undef,          'loaded config file');
        is($app->shell->prompt_str, 'maisha> ',     'correct prompt string');
        is($app->shell->tag_str,    '[from maisha]','correct tag string');
        is($app->shell->pager,      '1',            'correct pager');
        is($app->shell->order,      'desc',         'correct order');
        is($app->shell->limit,      '0',            'correct character limit');
        is($app->shell->chars,      '80',           'correct character wrap');
        is($app->shell->format,     '[%U] %M',      'correct format string');
        is($app->shell->debug,      '0',            'correct debug flag');
        is($app->shell->history,    '',             'correct history setting');
    }
}

{
    my $config = 't/data/config.pl';
    eval { $app = App::Maisha->new(config => $config) };
    SKIP: { 
        skip "Config for Perl code files not installed", 11   if($@);

        isa_ok( $app => 'App::Maisha', "got object" );

        isnt($app->config->{CONFIG},undef,          'loaded config file');
        is($app->shell->prompt_str, 'maisha> ',     'correct prompt string');
        is($app->shell->tag_str,    '[from maisha]','correct tag string');
        is($app->shell->pager,      '1',            'correct pager');
        is($app->shell->order,      'descending',   'correct order');
        is($app->shell->limit,      '0',            'correct character limit');
        is($app->shell->chars,      '80',           'correct character wrap');
        is($app->shell->format,     '[%U] %M',      'correct format string');
        is($app->shell->debug,      '0',            'correct debug flag');
        is($app->shell->history,    '',             'correct history setting');
    }
}

{
    my $config = 't/data/config.xml';
    eval { $app = App::Maisha->new(config => $config) };
    SKIP: { 
        skip "Config for XML files not installed", 11   if($@);

        isa_ok( $app => 'App::Maisha', "got object" );

        isnt($app->config->{CONFIG},undef,          'loaded config file');
        is($app->shell->prompt_str, 'maisha> ',     'correct prompt string');
        is($app->shell->tag_str,    '',             'correct tag string');
        is($app->shell->pager,      '1',            'correct pager');
        is($app->shell->order,      'descending',   'correct order');
        is($app->shell->limit,      '0',            'correct character limit');
        is($app->shell->chars,      '80',           'correct character wrap');
        is($app->shell->format,     '[%U] %M',      'correct format string');
        is($app->shell->debug,      '1',            'correct debug flag');
        is($app->shell->history,    'history.log',  'correct history setting');
    }
}

{
    my $config = 't/data/config.yml';
    eval { $app = App::Maisha->new(config => $config) };
    SKIP: { 
        skip "Config for YAML files not installed", 11   if($@);

        isa_ok( $app => 'App::Maisha', "got object" );

        isnt($app->config->{CONFIG},undef,          'loaded config file');
        is($app->shell->prompt_str, 'maisha> ',     'correct prompt string');
        is($app->shell->tag_str,    '',             'correct tag string');
        is($app->shell->pager,      '0',            'correct pager');
        is($app->shell->order,      'descending',   'correct order');
        is($app->shell->limit,      '100',          'correct character limit');
        is($app->shell->chars,      '72',           'correct character wrap');
        is($app->shell->format,     '[%t,%U] %M',   'correct format string');
        is($app->shell->debug,      '0',            'correct debug flag');
        is($app->shell->history,    '',             'correct history setting');
    }
}

t/data/config.ini  view on Meta::CPAN

[CONFIG]
order=asc
tag=tag:
prompt=prompt:



( run in 1.484 second using v1.01-cache-2.11-cpan-6aa56a78535 )