Changeset 11749 for lang/perl/Punc

Show
Ignore:
Timestamp:
05/17/08 17:20:45 (6 months ago)
Author:
mizzy
Message:

use strict;use warnings;を全部use Moose;に置き換えた

Location:
lang/perl/Punc/trunk
Files:
19 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Punc/trunk/Makefile.PL

    r11734 r11749  
    2424                   /); 
    2525 
    26 build_requires 'Test::More'; 
     26build_requires $_ for (qw/ 
     27                             Test::More 
     28                             File::Temp 
     29                         /); 
     30 
    2731use_test_base; 
    2832auto_include; 
  • lang/perl/Punc/trunk/lib/Punc.pm

    r11215 r11749  
    11package Punc; 
    22 
    3 use strict; 
    4 use warnings; 
    53our $VERSION = '0.01'; 
    6  
    74use Pfacter; 
    85use UNIVERSAL::require; 
     6use Moose; 
     7use MooseX::ClassAttribute; 
    98 
    10 my $context; 
    11 sub context { 
    12     $context = $_[1] if $_[1]; 
    13     return $context; 
    14 } 
     9class_has context => ( 
     10    is      => 'rw', 
     11    isa     => 'Punc', 
     12    lazy    => 1, 
     13    default => sub { Punc->new }, 
     14); 
    1515 
    16 sub new { 
    17     my $class = shift; 
    18     my $self = bless {}, $class; 
    19     $self->context($self); 
     16sub logger { 
     17    my $self = shift; 
     18    require Punc::Logger::StdErr; 
     19    $self->{logger} ||= 'Punc::Logger::StdErr'; 
    2020} 
    2121 
     
    4343    chomp $pfact; 
    4444    return $pfact; 
    45 } 
    46  
    47 sub logger { 
    48     my $self = shift; 
    49     require Punc::Logger::StdErr; 
    50     $self->{logger} ||= 'Punc::Logger::StdErr'; 
    5145} 
    5246 
     
    9185  # ./bin/puncd 
    9286 
    93 puncmasterdとは別ホスト上で動かす場合、./etc/puncd.yaml の puncmaster_host を適宜変更してから puncd を起動してください。 
     87puncmasterd とは別ホスト上で動かす場合、./etc/puncd.yaml の puncmaster_host を適宜変更してから puncd を起動してください。 
    9488 
    9589=head2 puncmaster-ca コマンドによる証明書への署名 
  • lang/perl/Punc/trunk/lib/Punc/Client.pm

    r11152 r11749  
    11package Punc::Client; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54our $VERSION = '0.01'; 
    65our $AUTOLOAD; 
     
    98use UNIVERSAL::require; 
    109use FindBin; 
     10 
     11has 'hosts' => ( is => 'rw', isa => 'ArrayRef' ); 
     12has 'conf'  => ( is => 'rw', isa => 'HashRef' ); 
    1113 
    1214sub new { 
     
    4648 
    47491; 
    48 __END__ 
    49  
    50 =encoding utf8 
    51  
    52 =head1 NAME 
    53  
    54 Punc - 
    55  
    56 =head1 SYNOPSIS 
    57  
    58   use Punc; 
    59  
    60 =head1 DESCRIPTION 
    61  
    62 Punc is 
    63  
    64 =head1 AUTHOR 
    65  
    66 Gosuke Miyashita E<lt>gosukenator@gmail.comE<gt> 
    67  
    68 =head1 SEE ALSO 
    69  
    70 =head1 REPOSITORY 
    71  
    72   svn co http://svn.coderepos.org/share/lang/perl/Punc/trunk Punc 
    73  
    74 Punc is Subversion repository is hosted at L<http://coderepos.org/share/>. 
    75 patches and collaborators are welcome. 
    76  
    77 =head1 LICENSE 
    78  
    79 This library is free software; you can redistribute it and/or modify 
    80 it under the same terms as Perl itself. 
    81  
    82 =cut 
  • lang/perl/Punc/trunk/lib/Punc/Client/Request.pm

    r11181 r11749  
    11package Punc::Client::Request; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54use JSON; 
    65use JSON::RPC::Client; 
  • lang/perl/Punc/trunk/lib/Punc/Client/Response.pm

    r11518 r11749  
    11package Punc::Client::Response; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54use Punc::Client::Result; 
    65 
    7 sub new { 
    8     my $self = { 
    9         index => 0, 
    10         results => [], 
    11     }; 
    12     bless $self, shift; 
    13 } 
     6has 'index' => ( isa => 'Int', is => 'rw', default => 0 ); 
     7 
     8has 'results' => ( 
     9    isa     => 'ArrayRef[Punc::Client::Result]', 
     10    is      => 'rw', 
     11    default => sub { [] }, 
     12); 
    1413 
    1514sub add { 
    1615    my ( $self, $args ) = @_; 
    17     push @{$self->{results}}, Punc::Client::Result->new($args); 
     16    push @{$self->results}, Punc::Client::Result->new($args); 
    1817} 
    1918 
    2019sub next { 
    2120    my $self = shift; 
    22     return $self->{results}->[ $self->{index}++ ]; 
     21    my $current = $self->results->[ $self->index ]; 
     22    $self->index( $self->index + 1 ); 
     23    return $current; 
    2324} 
    2425 
  • lang/perl/Punc/trunk/lib/Punc/Client/Result.pm

    r11726 r11749  
    11package Punc::Client::Result; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54our $AUTOLOAD; 
    65 
    7 sub new { 
    8     my ( $class, $args ) = @_; 
    9     bless $args, $class; 
     6has 'response' => ( is => 'rw' ); 
     7 
     8sub result { 
     9    shift->{response}->{result}; 
     10} 
     11 
     12sub error { 
     13    shift->{response}->{error}; 
    1014} 
    1115 
    1216sub as_hash { 
    1317  my $self = shift; 
    14   my %hash = %$self;  
     18  my %hash = %$self; 
    1519  return \%hash; 
    16 } 
    17  
    18 sub result { 
    19     my $self = shift; 
    20     return $self->{response}->{result}; 
    21 } 
    22  
    23 sub error { 
    24     my $self = shift; 
    25     return $self->{response}->{error};     
    2620} 
    2721 
  • lang/perl/Punc/trunk/lib/Punc/ConfigLoader.pm

    r11215 r11749  
    11package Punc::ConfigLoader; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54use YAML; 
    6  
    7 sub new { 
    8     my $class = shift; 
    9     bless {}, $class; 
    10 } 
    115 
    126sub load { 
  • lang/perl/Punc/trunk/lib/Punc/Daemon.pm

    r11215 r11749  
    11package Punc::Daemon; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54 
    65use HTTP::Daemon::SSL; 
     
    6160} 
    6261 
     62package Punc::Daemon::Role; 
     63 
     64use Moose::Role; 
     65 
     66requires 'handle_request'; 
     67 
    63681; 
  • lang/perl/Punc/trunk/lib/Punc/Hosts.pm

    r11215 r11749  
    77use Moose::Role; 
    88 
    9 require 'get_hosts'; 
     9requires 'get_hosts'; 
    1010 
    11111; 
  • lang/perl/Punc/trunk/lib/Punc/Master/CA.pm

    r11518 r11749  
    11package Punc::Master::CA; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54use File::Spec; 
    65use File::Path; 
     6 
     7has 'ssldir'  => ( is => 'rw', isa => 'Str' ); 
     8has 'csrdir'  => ( is => 'rw', isa => 'Str' ); 
     9has 'certdir' => ( is => 'rw', isa => 'Str' ); 
     10has 'cadir'   => ( is => 'rw', isa => 'Str' ); 
    711 
    812sub new { 
     
    2933    my $hostname = $self->get_hostname_from_csr($csr); 
    3034 
    31     my $csrdir = $self->{csrdir}; 
     35    my $csrdir = $self->csrdir; 
    3236    mkpath($csrdir) unless -f $csrdir; 
    3337 
     
    4145    my ( $self, $csr ) = @_; 
    4246    my $hostname = $self->get_hostname_from_csr($csr); 
    43     return -f File::Spec->catfile($self->{certdir}, "${hostname}.cert"); 
     47    return -f File::Spec->catfile($self->certdir, "${hostname}.cert"); 
    4448} 
    4549 
    4650sub sign { 
    4751    my ( $self, $hostname ) = @_; 
    48     my $cakey    = File::Spec->catfile($self->{cadir}, 'ca.key'); 
    49     my $cacert   = File::Spec->catfile($self->{cadir}, 'ca.cert'); 
    50     my $caserial = File::Spec->catfile($self->{cadir}, 'ca.srl'); 
    51  
    52     my $certdir = $self->{certdir}; 
     52    my $cakey    = File::Spec->catfile($self->cadir, 'ca.key'); 
     53    my $cacert   = File::Spec->catfile($self->cadir, 'ca.cert'); 
     54    my $caserial = File::Spec->catfile($self->cadir, 'ca.srl'); 
     55    my $certdir = $self->certdir; 
    5356    mkpath($certdir) unless -f $certdir; 
    5457    my $cert = File::Spec->catfile($certdir, "${hostname}.cert"); 
    5558 
    56     my $csr = File::Spec->catfile($self->{csrdir}, "${hostname}.csr"); 
     59    my $csr = File::Spec->catfile($self->csrdir, "${hostname}.csr"); 
    5760    die "no csr of $hostname\n" unless -f $csr; 
    5861 
     
    6467sub list { 
    6568    my $self = shift; 
    66     my @csrs = glob(File::Spec->catfile($self->{csrdir}, '*.csr')); 
     69    my @csrs = glob(File::Spec->catfile($self->csrdir, '*.csr')); 
    6770    for my $csr ( @csrs ) { 
    6871        my ( $host ) = ( $csr =~ m!([^/]+)\.csr$! ); 
  • lang/perl/Punc/trunk/lib/Punc/Master/Daemon.pm

    r11734 r11749  
    11package Punc::Master::Daemon; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54use base qw( Punc::Daemon ); 
    65use File::Spec; 
     
    98use Crypt::OpenSSL::CA; 
    109use Crypt::OpenSSL::RSA; 
     10 
     11extends 'Punc::Daemon'; 
     12with    'Punc::Daemon::Role'; 
    1113 
    1214sub new { 
  • lang/perl/Punc/trunk/lib/Punc/Slave/Daemon.pm

    r11518 r11749  
    11package Punc::Slave::Daemon; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54use File::Spec; 
    65use Crypt::OpenSSL::PKCS10 qw( :const ); 
     
    98use File::Path; 
    109 
    11 use base qw( Punc::Daemon ); 
     10extends 'Punc::Daemon'; 
     11with 'Punc::Daemon::Role'; 
    1212 
    1313sub new { 
  • lang/perl/Punc/trunk/lib/Punc/Slave/Module/File.pm

    r11518 r11749  
    11package Punc::Slave::Module::File; 
    22 
    3 use strict; 
    4 use warnings; 
    53use Path::Class qw( dir file ); 
    64use Punc::Slave::Module { operatingsystem => [ qw/ .* / ] }; 
     5use Moose; 
    76 
    87sub md5sum { 
  • lang/perl/Punc/trunk/lib/Punc/Slave/Module/Punc.pm

    r11184 r11749  
    11package Punc::Slave::Module::Punc; 
    22 
    3 use strict; 
    4 use warnings; 
     3use Moose; 
    54use Path::Class qw( dir ); 
    65use Punc::Slave::Module { operatingsystem => [ qw/ .* / ] }; 
     
    87sub info { 
    98    my ( $self, $args ) = @_; 
    10  
    119    return { punc_path => dir(`perldoc -l Punc`)->parent->stringify }; 
    1210} 
  • lang/perl/Punc/trunk/lib/Punc/Slave/Module/Service/Debian.pm

    r11521 r11749  
    11package Punc::Slave::Module::Service::Debian; 
    22 
    3 use strict; 
    4 use warnings; 
    53use Punc::Slave::Module::Service { operatingsystem => [ qw / debian ubuntu / ] }; 
    64use Moose; 
  • lang/perl/Punc/trunk/lib/Punc/Slave/Module/Service/RedHat.pm

    r11518 r11749  
    11package Punc::Slave::Module::Service::RedHat; 
    22 
    3 use strict; 
    4 use warnings; 
    53use Punc::Slave::Module::Service { operatingsystem => [ qw / redhat centos fedora / ] }; 
    64use Moose; 
  • lang/perl/Punc/trunk/t/00_compile.t

    r8509 r11749  
    11use strict; 
    2 use Test::More tests => 1; 
     2use Test::More tests => 3; 
    33 
    4 BEGIN { use_ok 'Punc' } 
     4BEGIN { 
     5    use_ok 'Punc'; 
     6    use_ok 'Punc::Master::Daemon'; 
     7    use_ok 'Punc::Slave::Daemon'; 
     8} 
  • lang/perl/Punc/trunk/t/97_podspell.t

    r10103 r11749  
    1414puncmaster 
    1515puncmasterd 
     16puncd 
     17md5sum 
  • lang/perl/Punc/trunk/t/98_perlcritic.t

    r8509 r11749  
    11use strict; 
    22use Test::More; 
    3 eval { use Test::Perl::Critic -profile => 't/perlcriticrc' }; 
     3eval q{ use Test::Perl::Critic -profile => 't/perlcriticrc' }; 
    44plan skip_all => "Test::Perl::Critic is not installed." if $@; 
    55all_critic_ok('lib');