Skip to content

Commit

Permalink
check if init() is called(only testcode fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsucchi committed Dec 13, 2014
1 parent ae266e1 commit 4ade26f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
31 changes: 12 additions & 19 deletions Build.PL
Expand Up @@ -12,8 +12,6 @@ use utf8;
use Module::Build;
use File::Basename;
use File::Spec;
use CPAN::Meta;
use CPAN::Meta::Prereqs;

my %args = (
license => 'perl',
Expand Down Expand Up @@ -53,20 +51,15 @@ my $builder = Module::Build->subclass(
)->new(%args);
$builder->create_build_script();

my $mbmeta = CPAN::Meta->load_file('MYMETA.json');
my $meta = CPAN::Meta->load_file('META.json');
my $prereqs_hash = CPAN::Meta::Prereqs->new(
$meta->prereqs
)->with_merged_prereqs(
CPAN::Meta::Prereqs->new($mbmeta->prereqs)
)->as_string_hash;
my $mymeta = CPAN::Meta->new(
{
%{$meta->as_struct},
prereqs => $prereqs_hash
}
);
print "Merging cpanfile prereqs to MYMETA.yml\n";
$mymeta->save('MYMETA.yml', { version => 1.4 });
print "Merging cpanfile prereqs to MYMETA.json\n";
$mymeta->save('MYMETA.json', { version => 2 });
use File::Copy;

print "cp META.json MYMETA.json\n";
copy("META.json","MYMETA.json") or die "Copy failed(META.json): $!";

if (-f 'META.yml') {
print "cp META.yml MYMETA.yml\n";
copy("META.yml","MYMETA.yml") or die "Copy failed(META.yml): $!";
} else {
print "There is no META.yml... You may install this module from the repository...\n";
}

2 changes: 1 addition & 1 deletion META.json
Expand Up @@ -4,7 +4,7 @@
"Takuya Tsuchida <tsucchi@cpan.org>"
],
"dynamic_config" : 0,
"generated_by" : "Minilla/v1.0.0, CPAN::Meta::Converter version 2.141170",
"generated_by" : "Minilla/v2.3.0, CPAN::Meta::Converter version 2.141170",
"license" : [
"perl_5"
],
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/tsucchi/p5-Otogiri-Plugin.png?branch=master)](https://travis-ci.org/tsucchi/p5-Otogiri-Plugin) [![Coverage Status](https://coveralls.io/repos/tsucchi/p5-Otogiri-Plugin/badge.png?branch=master)](https://coveralls.io/r/tsucchi/p5-Otogiri-Plugin?branch=master)
[![Build Status](https://travis-ci.org/tsucchi/p5-Otogiri-Plugin.svg?branch=master)](https://travis-ci.org/tsucchi/p5-Otogiri-Plugin) [![Coverage Status](https://img.shields.io/coveralls/tsucchi/p5-Otogiri-Plugin/master.svg)](https://coveralls.io/r/tsucchi/p5-Otogiri-Plugin?branch=master)
# NAME

Otogiri::Plugin - make Otogiri to pluggable
Expand Down
2 changes: 2 additions & 0 deletions t/01_plugin.t
Expand Up @@ -13,4 +13,6 @@ my $db = Otogiri->new( connect_info => ["dbi:SQLite:dbname=$dbfile", '', ''] );
ok( $db->can('test_method') );
is( $db->test_method('a', 'b', 'c'), 'this is test_method a:b:c' );

is( Otogiri::Plugin::TestPlugin::_get_init_called(), 1);

done_testing;
11 changes: 11 additions & 0 deletions t/lib/Otogiri/Plugin/TestPlugin.pm
Expand Up @@ -3,6 +3,13 @@ use strict;
use warnings;
our @EXPORT = qw(test_method very_useful_method_but_has_so_long_name);

my $init_called = 0;

sub init {
my ($self) = @_;
$init_called = 1;
}

sub test_method {
my ($self, @args) = @_;
return 'this is test_method ' . join(':', @args);
Expand All @@ -13,4 +20,8 @@ sub very_useful_method_but_has_so_long_name {
return 'long method name desune';
}

sub _get_init_called {
return $init_called;
}

1;

0 comments on commit 4ade26f

Please sign in to comment.