Acme-Pinoko

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Pinoko is a Japanese manga character. She speaks with a lisp and
    therefore her spoken Japanese is slightly different from standard
    Japanese.

METHODS
  $pinoko = Acme::Pinoko->new(%config)
    Creates a new Acme::Pinoko instance.

      my $pinoko = Acme::Pinoko->new(
          parser        => 'Text::MeCab' or 'Text::KyTea',  # default is 'Text::MeCab'
          parser_config => \%parser_config,                 # default is undef
      );

  $pinoko_ish_text = $pinoko->say($text)
    Pinoko says $text.

AUTHOR
    pawa <pawapawa@cpan.org>

SEE ALSO
    <https://en.wikipedia.org/wiki/Black_Jack_%28manga%29#Characters>

inc/Module/Install.pm  view on Meta::CPAN

BEGIN {
	# All Module::Install core packages now require synchronised versions.
	# This will be used to ensure we don't accidentally load old or
	# different versions of modules.
	# This is not enforced yet, but will be some time in the next few
	# releases once we can make sure it won't clash with custom
	# Module::Install extensions.
	$VERSION = '1.06';

	# Storage for the pseudo-singleton
	$MAIN    = undef;

	*inc::Module::Install::VERSION = *VERSION;
	@inc::Module::Install::ISA     = __PACKAGE__;

}

sub import {
	my $class = shift;
	my $self  = $class->new(@_);
	my $who   = $self->_caller;

inc/Module/Install.pm  view on Meta::CPAN

}

# Cloned from Params::Util::_CLASS
sub _CLASS ($) {
	(
		defined $_[0]
		and
		! ref $_[0]
		and
		$_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s
	) ? $_[0] : undef;
}

1;

# Copyright 2008 - 2012 Adam Kennedy.

inc/Module/Install/Can.pm  view on Meta::CPAN


int boot_sanexs() {
    return 1;
}

END_C
	close $FH;

	# Can the C compiler access the same headers XS does
	my @libs   = ();
	my $object = undef;
	eval {
		local $^W = 0;
		$object = $builder->compile(
			source => $tmpfile,
		);
		@libs = $builder->link(
			objects     => $object,
			module_name => 'sanexs',
		);
	};

inc/Module/Install/Makefile.pm  view on Meta::CPAN

		foreach my $bundle (@{ $self->bundles }) {
			my ($mod_name, $dist_dir) = @$bundle;
			delete $prereq->{$mod_name};
			$dist_dir = File::Basename::basename($dist_dir); # dir for building this module
			if (not exists $processed{$dist_dir}) {
				if (-d $dist_dir) {
					# List as sub-directory to be processed by make
					push @$subdirs, $dist_dir;
				}
				# Else do nothing: the module is already present on the system
				$processed{$dist_dir} = undef;
			}
		}
	}

	unless ( $self->makemaker('6.55_03') ) {
		%$prereq = (%$prereq,%$build_prereq);
		delete $args->{BUILD_REQUIRES};
	}

	if ( my $perl_version = $self->perl_version ) {

inc/Module/Install/Metadata.pm  view on Meta::CPAN

    artistic_2   => 'http://opensource.org/licenses/artistic-license-2.0.php',
    lgpl         => 'http://opensource.org/licenses/lgpl-license.php',
    lgpl2        => 'http://opensource.org/licenses/lgpl-2.1.php',
    lgpl3        => 'http://opensource.org/licenses/lgpl-3.0.html',
    bsd          => 'http://opensource.org/licenses/bsd-license.php',
    gpl          => 'http://opensource.org/licenses/gpl-license.php',
    gpl2         => 'http://opensource.org/licenses/gpl-2.0.php',
    gpl3         => 'http://opensource.org/licenses/gpl-3.0.html',
    mit          => 'http://opensource.org/licenses/mit-license.php',
    mozilla      => 'http://opensource.org/licenses/mozilla1.1.php',
    open_source  => undef,
    unrestricted => undef,
    restrictive  => undef,
    unknown      => undef,
);

sub license {
	my $self = shift;
	return $self->{values}->{license} unless @_;
	my $license = shift or die(
		'Did not provide a value to license()'
	);
	$license = __extract_license($license) || lc $license;
	$self->{values}->{license} = $license;

inc/Module/Install/Metadata.pm  view on Meta::CPAN

	Module::Install::_write(
		'MYMETA.json',
		JSON->new->pretty(1)->canonical->encode($meta),
	);
}

sub _write_mymeta_data {
	my $self = shift;

	# If there's no existing META.yml there is nothing we can do
	return undef unless -f 'META.yml';

	# We need Parse::CPAN::Meta to load the file
	unless ( eval { require Parse::CPAN::Meta; 1; } ) {
		return undef;
	}

	# Merge the perl version into the dependencies
	my $val  = $self->Meta->{values};
	my $perl = delete $val->{perl_version};
	if ( $perl ) {
		$val->{requires} ||= [];
		my $requires = $val->{requires};

		# Canonize to three-dot version after Perl 5.6

lib/Acme/Pinoko.pm  view on Meta::CPAN

my %HIRAGANA_INVALID_POS;
@HIRAGANA_INVALID_POS{qw/助詞 語尾 副詞 動詞 助動詞 形容詞 形状詞 連体詞 接頭詞 接頭辞 代名詞/} = ();

my %TERMINATOR_CHAR;
@TERMINATOR_CHAR{ split(//, "。。..  \n\t…‥!!") } = ();

sub _options
{
    return {
        parser        => 'Text::MeCab',
        parser_config => undef,
    };
}

sub new
{
    my $class = shift;
    my %args  = (ref $_[0] eq 'HASH' ? %{$_[0]} : @_);

    my $options = $class->_options;

lib/Acme/Pinoko.pm  view on Meta::CPAN

therefore her spoken Japanese is slightly different from standard Japanese.

=head1 METHODS

=head2 $pinoko = Acme::Pinoko->new(%config)

Creates a new Acme::Pinoko instance.

  my $pinoko = Acme::Pinoko->new(
      parser        => 'Text::MeCab' or 'Text::KyTea',  # default is 'Text::MeCab'
      parser_config => \%parser_config,                 # default is undef
  );

=head2 $pinoko_ish_text = $pinoko->say($text)

Pinoko says $text.

=head1 AUTHOR

pawa E<lt>pawapawa@cpan.orgE<gt>

t/01_basic.t  view on Meta::CPAN

use Test::Fatal;

can_ok('Acme::Pinoko', qw/new say/);

subtest 'valid new' => sub {
    my $pinoko;

    SKIP: {
        eval { require Text::MeCab; };
        skip 'Text::MeCab not installed', 1 if $@;
        is( exception{ $pinoko = Acme::Pinoko->new; }, undef, 'parser: default' );
        isa_ok($pinoko, 'Acme::Pinoko');
    }

    SKIP: {
        eval { require Text::MeCab; };
        skip 'Text::MeCab not installed', 1 if $@;
        is( exception{ $pinoko = Acme::Pinoko->new(parser => 'Text::MeCab'); }, undef, 'parser: mecab' );
        isa_ok($pinoko, 'Acme::Pinoko');
    }

    SKIP: {
        eval { require Text::KyTea; };
        skip 'Text::KyTea not installed', 1 if $@;
        is( exception{ $pinoko = Acme::Pinoko->new(parser => 'Text::KyTea'); }, undef, 'parser: kytea' );
        isa_ok($pinoko, 'Acme::Pinoko');
    }
};

subtest 'invalid new' => sub {
    my $exception = exception { Acme::Pinoko->new(parser => 'Text::ChaSen'); };
    like($exception, qr/Invalid parser: 'Text::ChaSen'/, 'Invalid parser');

    $exception = exception { Acme::Pinoko->new(parse => 'Text::MeCab'); };
    like($exception, qr/Unknown option: 'parse'/, 'Unknown option');

t/02_say.t  view on Meta::CPAN

use Acme::Pinoko;
use Test::More;


SKIP: {
    eval { require Text::MeCab; };
    skip 'Text::MeCab not installed', 1 if $@;

    my $pinoko = Acme::Pinoko->new;
    is($pinoko->say('ABC'), 'ABC', 'normal text');
    is($pinoko->say(undef), undef, 'undefined text');
    is($pinoko->say(''),    '',    'empty text');
    is($pinoko->say(0),     '0',   'zero');
    is($pinoko->say("\n"),  "\n",  '\n');
    is($pinoko->say("\t"),  "\t",  '\t');
}

SKIP: {
    eval { require Text::KyTea; };
    skip 'Text::KyTea not installed', 1 if $@;

    my $pinoko = Acme::Pinoko->new(parser => 'Text::KyTea');
    is($pinoko->say('ABC'), 'ABC', 'normal text');
    is($pinoko->say(undef), undef, 'undefined text');
    is($pinoko->say(''),    '',    'empty text');
    is($pinoko->say(0),     '0',   'zero');
    is($pinoko->say("\n"),  "\n",  '\n');
    is($pinoko->say("\t"),  "\t",  '\t');
}

done_testing;

t/05_parser_config.t  view on Meta::CPAN

use strict;
use warnings;
use Acme::Pinoko;
use Test::More;
use Test::Fatal;

subtest 'mecab' => sub {
    eval { require Text::MeCab; };
    plan skip_all => 'Text::MeCab not installed' if $@;

    is( exception { Acme::Pinoko->new(parser_config => { unk_format => 'hoge' }) }, undef );
};

subtest 'kytea' => sub {
    eval { require Text::KyTea; };
    plan skip_all => 'Text::KyTea not installed' if $@;

    is(
        exception {
            Acme::Pinoko->new(
                parser        => 'Text::KyTea',
                parser_config => { tagmax => 3 })
        },
        undef
    );

    my $exception = exception { Acme::Pinoko->new(parser => 'Text::KyTea', parser_config => { hogehoge => 1 }); };
    like($exception, qr/Unknown option/, 'Unknown option');
};

done_testing;



( run in 2.007 seconds using v1.01-cache-2.11-cpan-d80b1682f3f )