App-JIRAPrint

 view release on metacpan or  search on metacpan

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

package App::JIRAPrint;
# ABSTRACT: Print JIRA Tickets on Postit sheets
$App::JIRAPrint::VERSION = '0.003';
use Moose;
use Log::Any qw/$log/;

use WWW::Shorten 'TinyURL', ':short';

=head1 NAME

App::JIRAPrint - Print JIRA Tickets on PostIt sheets

=head1 INSTALLATION

On system perl:

  cpan -i App::JIRAPrint

Or in your favourite cpan minus place:

  cpanm App::JIRAPrint

=head1 SYNOPSIS

  jiraprint --help

=head1 BUILDING

=for HTML <a href="https://travis-ci.org/jeteve/App-JIRAPrint"><img src="https://travis-ci.org/jeteve/App-JIRAPrint.svg?branch=master"></a>

=cut

use autodie qw/:all/;
use Cwd;
use Data::Dumper;
use File::Spec;
use Hash::Merge;
use JIRA::REST;
use LaTeX::Encode;
use Template;

BEGIN{
    # The test compatible File::Share
    eval{ require File::Share; File::Share->import('dist_dir'); };
    if( $@ ){
        # The production only File::ShareDir
        require File::ShareDir;
        File::ShareDir->import('dist_dir');
    }
};


# Config stuff.
has 'config' => ( is => 'ro', isa => 'HashRef', lazy_build => 1);
has 'config_files' => ( is => 'ro' , isa => 'ArrayRef[Str]' , lazy_build => 1);

has 'shared_directory' => ( is => 'ro', isa => 'Str', lazy_build => 1);
has 'template_file' => ( is => 'ro', isa => 'Str', lazy_build => 1);


# Operation properties
has 'url' => ( is => 'ro', isa => 'Str', lazy_build => 1 );
has 'username' => ( is => 'ro', isa => 'Str' , lazy_build => 1);
has 'password' => ( is => 'ro', isa => 'Str' , lazy_build => 1);

has 'project' => ( is => 'ro', isa => 'Str' , lazy_build => 1 );
has 'sprint'  => ( is => 'ro', isa => 'Str' , lazy_build => 1 );
has 'maxissues' => ( is => 'ro', isa => 'Int' , lazy_build => 1);

has 'jql' => ( is => 'ro', isa => 'Str', lazy_build => 1);
has 'fields' => ( is => 'ro', isa => 'ArrayRef[Str]', lazy_build => 1 );

# Objects
has 'jira' => ( is => 'ro', isa => 'JIRA::REST', lazy_build => 1);

has 'tt' => ( is => 'ro', isa => 'Template', lazy_build => 1);

sub _build_jira{
    my ($self) = @_;
    $log->info("Accessing JIRA At ".$self->url()." as '".$self->username()."' (+password)");
    return JIRA::REST->new( $self->url() , $self->username() , $self->password() );
}

sub _build_fields{
    my ($self) = @_;
    return $self->config()->{fields} // [ qw/key status summary assignee issuetype/ ];
}

sub _build_maxissues{
    my ($self) = @_;
    return $self->config()->{maxissues} // 100;
}

sub _build_url{
    my ($self) = @_;
    return $self->config()->{url} // die "Missing url ".$self->config_place()."\n";
}

sub _build_username{
    my ($self) = @_;
    return $self->config()->{username} // die "Missing username ".$self->config_place()."\n";
}

sub _build_password{
    my ($self) = @_;
    return $self->config()->{password} // die "Missing password ".$self->config_place()."\n";
}

sub _build_project{
    my ($self) = @_;
    return $self->config()->{project} // die "Missing project ".$self->config_place()."\n";
}

sub _build_sprint{
    my ($self) = @_;
    return $self->config()->{sprint} // die "Missing sprint ".$self->config_place()."\n";
}

sub _build_jql{
    my ($self) = @_;
    return $self->config()->{jql} //
        'project = "'.$self->project().'" and Sprint = "'.$self->sprint().'" ORDER BY status, assignee, created'
}

sub _build_template_file{
    my ($self) = @_;
    return $self->config()->{template_file} //
        File::Spec->catfile( $self->shared_directory() , 'std_tickets.tex.tt' );
}

sub config_place{

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.361 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )