Codebase list libjifty-dbi-perl / 618e9e4
[svn-upgrade] Integrating new upstream version, libjifty-dbi-perl (0.59) Yves Agostini 14 years ago
20 changed file(s) with 565 addition(s) and 253 deletion(s). Raw diff Collapse all Expand all
00 Revision history for Perl extension Jifty::DBI.
1
2 0.59 Wed Nov 18 20:12:57 EST 2009
3 - Features:
4 * Support a special value of "all" in set_page_info
5
6 - Fixes:
7 * Make "default is ''" propagate correctly to ALTER and CREATE TABLE
8 statements
9
10 - Installation:
11 * Our Module::Install was hilariously out of date
112
213 0.58 Tue Jul 14 03:21:21 EST 2009
314 - Possible incompatibilities:
11 author: ~
22 build_requires:
33 DBD::SQLite: 1.14
4 ExtUtils::MakeMaker: 6.42
45 Test::More: 0.52
56 Test::Warn: 0.1
7 configure_requires:
8 ExtUtils::MakeMaker: 6.42
69 distribution_type: module
7 generated_by: 'Module::Install version 0.79'
10 generated_by: 'Module::Install version 0.91'
811 license: perl
912 meta-spec:
1013 url: http://module-build.sourceforge.net/META-spec-v1.4.html
4043 version: 0
4144 resources:
4245 license: http://dev.perl.org/licenses/
43 version: 0.53
46 version: 0.59
1414 Hash: SHA1
1515
1616 SHA1 f29ac6543498d1b0e81f387b7284a039f83e7d29 .gitignore
17 SHA1 64906601c4115e5507dd41021127384db33a1e62 Changes
17 SHA1 81b8e2df34131211193bf3b935b5a036dc051ec4 Changes
1818 SHA1 006b044e48cc925d04f620f317a907d459b2d128 MANIFEST
19 SHA1 d3897bc376b40669acb9171adfd51f321d184fd8 META.yml
19 SHA1 2f7ef1c4bb35edf899145b1c291924200fcac09f META.yml
2020 SHA1 48bd6ca8a37ec79b7cae91028d7e9489ad33a03b Makefile.PL
2121 SHA1 ae8407c841f230c353f683bd5c257815aed9b9f0 README
2222 SHA1 82d6ac3f6def48558d09f8b6e3b53ed4194d8c81 ROADMAP
2929 SHA1 584c0f6cdebcbf760dfca8413c94783586120214 ex/Example/Model/Address.pm
3030 SHA1 7cea1a5289f79c2a87837924a83feb583f6e8890 ex/Example/Model/Employee.pm
3131 SHA1 a9d62e4f5b43b2f78066172a4771238ee7df6339 ex/create_tables.pl
32 SHA1 603bb9de29fb8cba7f13409c546750972eff645d inc/Module/AutoInstall.pm
33 SHA1 ae018c4565c1277089ca8f1b28f888d95430cb7f inc/Module/Install.pm
34 SHA1 0a6f29536bedea3bb94744a7d43ffe39da7e4819 inc/Module/Install/AutoInstall.pm
35 SHA1 4552acdfca8b78f8015d8449e1325616259095f5 inc/Module/Install/Base.pm
36 SHA1 7fb663fff161fb45882b52edd62857bf15359658 inc/Module/Install/Can.pm
37 SHA1 8b1d3db746faa6faf2d967a48d3812ec1f44b4c6 inc/Module/Install/Fetch.pm
38 SHA1 d7ce736cdd05d5156d379ef39cca93beeeeba828 inc/Module/Install/Include.pm
39 SHA1 9f6beaa2f4749ceb5dd0c9b0c647d0f3289c7b46 inc/Module/Install/Makefile.pm
40 SHA1 7ad1da4fff7a1e7a634c9d734111c8292be08884 inc/Module/Install/Metadata.pm
41 SHA1 e9aa83f3e8b16ccfce544a90a57b63b70a497759 inc/Module/Install/Win32.pm
42 SHA1 ade2ac0b0246d4d8e28fa46942e53f6925abda46 inc/Module/Install/WriteAll.pm
43 SHA1 dd7c0df4e3dd9ff7112ff0ea2fbe501b8d786246 lib/Jifty/DBI.pm
44 SHA1 79cb88cd57d1194370a6a5beab9dcd2baf5eb7b3 lib/Jifty/DBI/Collection.pm
32 SHA1 e5fb92ac217988bfc7a6af739b0459627020a27e inc/Module/AutoInstall.pm
33 SHA1 fd5f3c4f0418efee3b9b16cf8c3902e8374909df inc/Module/Install.pm
34 SHA1 5c529e96420d964b192f011b121283a4916f7331 inc/Module/Install/AutoInstall.pm
35 SHA1 7cd7c349afdf3f012e475507b1017bdfa796bfbd inc/Module/Install/Base.pm
36 SHA1 ba186541bbf6439111f01fc70769cf24d22869bf inc/Module/Install/Can.pm
37 SHA1 aaa50eca0d7751db7a4d953fac9bc72c6294e238 inc/Module/Install/Fetch.pm
38 SHA1 219da5a95c290312a81477b226f005997d97dcfd inc/Module/Install/Include.pm
39 SHA1 3e83972921d54198d1246f7278f08664006cd65d inc/Module/Install/Makefile.pm
40 SHA1 12bf1867955480d47d5171a9e9c6a96fabe0b58f inc/Module/Install/Metadata.pm
41 SHA1 f7ee667e878bd2faf22ee9358a7b5a2cc8e91ba4 inc/Module/Install/Win32.pm
42 SHA1 8ed29d6cf217e0977469575d788599cbfb53a5ca inc/Module/Install/WriteAll.pm
43 SHA1 2d4ea93c0b624bc5939d882d9c7f0d897fdc63b1 lib/Jifty/DBI.pm
44 SHA1 09c42f022a1b2ca5dab645fe9fe6e50ea1fa82b4 lib/Jifty/DBI/Collection.pm
4545 SHA1 639ef9c81f03fb084b312a5f9a6f6a3ff63b36b7 lib/Jifty/DBI/Collection/Union.pm
4646 SHA1 bcba77fd2bacf0475aea1de97f57365c8de92ca6 lib/Jifty/DBI/Collection/Unique.pm
4747 SHA1 6d59ec1286f3ed887494753d01ed1f4760fd0a9b lib/Jifty/DBI/Column.pm
5858 SHA1 67ffe7188a1f529d7594f4fa3803bcbe15ba6485 lib/Jifty/DBI/Filter/YAML.pm
5959 SHA1 9a6fd17e677321904436fefec4d434e17a4685b1 lib/Jifty/DBI/Filter/base64.pm
6060 SHA1 deb33fa7b35f3542aac3e2d7fb4b5d3070dc3917 lib/Jifty/DBI/Filter/utf8.pm
61 SHA1 64d39ed536e8cb5465b0e1aa0f40f7bb9ae5e47a lib/Jifty/DBI/Handle.pm
61 SHA1 99a22e6954200e1bf3901cf963b88c2a830e460f lib/Jifty/DBI/Handle.pm
6262 SHA1 bcc7c456e1c4d0dddd5564f03c8bb03a6c7e261f lib/Jifty/DBI/Handle/Informix.pm
6363 SHA1 338116a45f8eb6bfca5e76e8d3be78fb61fffe81 lib/Jifty/DBI/Handle/ODBC.pm
6464 SHA1 960fd0b63f3de11924c5d47a3c0c6d1db105ed5b lib/Jifty/DBI/Handle/Oracle.pm
6868 SHA1 cf80896a175702a157770f64ae469430678c3357 lib/Jifty/DBI/Handle/mysql.pm
6969 SHA1 f2cc4fcce79c9a88a023d4e6bd96c2089eef1ced lib/Jifty/DBI/Handle/mysqlPP.pm
7070 SHA1 45d653e3a223599b50850010826bd835b80368d7 lib/Jifty/DBI/HasFilters.pm
71 SHA1 fc176a04f20301b698a390a014eda349d139d94f lib/Jifty/DBI/Record.pm
72 SHA1 3853ce268985b129f2175251fb369d9689837f39 lib/Jifty/DBI/Record/Cachable.pm
71 SHA1 24de085d41bfa49b1a6588311e675cff0615c8f0 lib/Jifty/DBI/Record.pm
72 SHA1 663978b31373520d1e2deec87e957d1dbfd1347c lib/Jifty/DBI/Record/Cachable.pm
7373 SHA1 1aac77960c508d3b2e5188e15825ad5b04391d76 lib/Jifty/DBI/Record/Memcached.pm
7474 SHA1 53834b3315a509ba33a8647681f472d3ae7b0557 lib/Jifty/DBI/Record/Plugin.pm
7575 SHA1 13b7e19a9ce99323f0ad41ce36422acb46ff07f9 lib/Jifty/DBI/Schema.pm
76 SHA1 a4d1a953ea4a29fe169b1c4c043ffff15b24c077 lib/Jifty/DBI/SchemaGenerator.pm
76 SHA1 30684592748a10ac2d775ea95a858e8699d46688 lib/Jifty/DBI/SchemaGenerator.pm
7777 SHA1 32834b7c4cf5a8d131382fccc8db341be8768291 t/00.load.t
7878 SHA1 9aa7fed2b2409faa4c71d2a45db210721f47403e t/01-version_checks.t
7979 SHA1 13c9fe3eeec0d000a7c86ea2474e30186cbc37e2 t/01basics.t
117117 -----BEGIN PGP SIGNATURE-----
118118 Version: GnuPG v1.4.7 (Darwin)
119119
120 iD8DBQFKXDOCsxfQtHhyRPoRAst4AJ99hkuLonvmHzyX1MeoUiuuZkTIQQCdF9Cd
121 uX0sd4zMEnoWm3En9My0mLw=
122 =tpG0
120 iD8DBQFLBJv7sxfQtHhyRPoRAog4AKCIv7JYxk/gyfUsKD1I6AwLS1tSfwCfeY18
121 jZQ6G3H6abFEj8XNr5+p6TQ=
122 =ao3T
123123 -----END PGP SIGNATURE-----
1717
1818 # various lexical flags
1919 my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS );
20 my ( $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly );
20 my (
21 $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps
22 );
2123 my ( $PostambleActions, $PostambleUsed );
2224
2325 # See if it's a testing or non-interactive session
7173 }
7274 elsif ( $arg =~ /^--test(?:only)?$/ ) {
7375 $TestOnly = 1;
76 }
77 elsif ( $arg =~ /^--all(?:deps)?$/ ) {
78 $AllDeps = 1;
7479 }
7580 }
7681 }
114119 )[0]
115120 );
116121
122 # We want to know if we're under CPAN early to avoid prompting, but
123 # if we aren't going to try and install anything anyway then skip the
124 # check entirely since we don't want to have to load (and configure)
125 # an old CPAN just for a cosmetic message
126
127 $UnderCPAN = _check_lock(1) unless $SkipInstall;
128
117129 while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) {
118130 my ( @required, @tests, @skiptests );
119131 my $default = 1;
162174 }
163175
164176 # XXX: check for conflicts and uninstalls(!) them.
165 if (
166 defined( my $cur = _version_check( _load($mod), $arg ||= 0 ) ) )
177 my $cur = _load($mod);
178 if (_version_cmp ($cur, $arg) >= 0)
167179 {
168180 print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n";
169181 push @Existing, $mod => $arg;
170182 $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
171183 }
172184 else {
173 print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n";
185 if (not defined $cur) # indeed missing
186 {
187 print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n";
188 }
189 else
190 {
191 # no need to check $arg as _version_cmp ($cur, undef) would satisfy >= above
192 print "too old. ($cur < $arg)\n";
193 }
194
174195 push @required, $mod => $arg;
175196 }
176197 }
183204 !$SkipInstall
184205 and (
185206 $CheckOnly
207 or ($mandatory and $UnderCPAN)
208 or $AllDeps
186209 or _prompt(
187210 qq{==> Auto-install the }
188211 . ( @required / 2 )
213236 }
214237 }
215238
216 $UnderCPAN = _check_lock(); # check for $UnderCPAN
217
218239 if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
219240 require Config;
220241 print
233254 *{'main::WriteMakefile'} = \&Write if caller(0) eq 'main';
234255 }
235256
257 sub _running_under {
258 my $thing = shift;
259 print <<"END_MESSAGE";
260 *** Since we're running under ${thing}, I'll just let it take care
261 of the dependency's installation later.
262 END_MESSAGE
263 return 1;
264 }
265
236266 # Check to see if we are currently running under CPAN.pm and/or CPANPLUS;
237267 # if we are, then we simply let it taking care of our dependencies
238268 sub _check_lock {
239 return unless @Missing;
269 return unless @Missing or @_;
270
271 my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING};
240272
241273 if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) {
242 print <<'END_MESSAGE';
243
244 *** Since we're running under CPANPLUS, I'll just let it take care
245 of the dependency's installation later.
246 END_MESSAGE
247 return 1;
248 }
249
250 _load_cpan();
274 return _running_under($cpan_env ? 'CPAN' : 'CPANPLUS');
275 }
276
277 require CPAN;
278
279 if ($CPAN::VERSION > '1.89') {
280 if ($cpan_env) {
281 return _running_under('CPAN');
282 }
283 return; # CPAN.pm new enough, don't need to check further
284 }
285
286 # last ditch attempt, this -will- configure CPAN, very sorry
287
288 _load_cpan(1); # force initialize even though it's already loaded
251289
252290 # Find the CPAN lock-file
253291 my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" );
283321 while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) {
284322
285323 # grep out those already installed
286 if ( defined( _version_check( _load($pkg), $ver ) ) ) {
324 if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
287325 push @installed, $pkg;
288326 }
289327 else {
312350 @modules = @newmod;
313351 }
314352
315 if ( _has_cpanplus() ) {
353 if ( _has_cpanplus() and not $ENV{PERL_AUTOINSTALL_PREFER_CPAN} ) {
316354 _install_cpanplus( \@modules, \@config );
317355 } else {
318356 _install_cpan( \@modules, \@config );
322360
323361 # see if we have successfully installed them
324362 while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
325 if ( defined( _version_check( _load($pkg), $ver ) ) ) {
363 if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
326364 push @installed, $pkg;
327365 }
328366 elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) {
377415 my $success;
378416 my $obj = $modtree->{$pkg};
379417
380 if ( $obj and defined( _version_check( $obj->{version}, $ver ) ) ) {
418 if ( $obj and _version_cmp( $obj->{version}, $ver ) >= 0 ) {
381419 my $pathname = $pkg;
382420 $pathname =~ s/::/\\W/;
383421
470508 my $obj = CPAN::Shell->expand( Module => $pkg );
471509 my $success = 0;
472510
473 if ( $obj and defined( _version_check( $obj->cpan_version, $ver ) ) ) {
511 if ( $obj and _version_cmp( $obj->cpan_version, $ver ) >= 0 ) {
474512 my $pathname = $pkg;
475513 $pathname =~ s/::/\\W/;
476514
534572 my $ver = shift;
535573
536574 return
537 if defined( _version_check( _load($class), $ver ) ); # no need to upgrade
575 if _version_cmp( _load($class), $ver ) >= 0; # no need to upgrade
538576
539577 if (
540578 _prompt( "==> A newer version of $class ($ver) is required. Install?",
631669
632670 # Load CPAN.pm and it's configuration
633671 sub _load_cpan {
634 return if $CPAN::VERSION;
672 return if $CPAN::VERSION and $CPAN::Config and not @_;
635673 require CPAN;
636674 if ( $CPAN::HandleConfig::VERSION ) {
637675 # Newer versions of CPAN have a HandleConfig module
643681 }
644682
645683 # compare two versions, either use Sort::Versions or plain comparison
646 sub _version_check {
684 # return values same as <=>
685 sub _version_cmp {
647686 my ( $cur, $min ) = @_;
648 return unless defined $cur;
687 return -1 unless defined $cur; # if 0 keep comparing
688 return 1 unless $min;
649689
650690 $cur =~ s/\s+$//;
651691
656696 ) {
657697
658698 # use version.pm if it is installed.
659 return (
660 ( version->new($cur) >= version->new($min) ) ? $cur : undef );
699 return version->new($cur) <=> version->new($min);
661700 }
662701 elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) )
663702 {
664703
665704 # use Sort::Versions as the sorting algorithm for a.b.c versions
666 return ( ( Sort::Versions::versioncmp( $cur, $min ) != -1 )
667 ? $cur
668 : undef );
705 return Sort::Versions::versioncmp( $cur, $min );
669706 }
670707
671708 warn "Cannot reliably compare non-decimal formatted versions.\n"
674711
675712 # plain comparison
676713 local $^W = 0; # shuts off 'not numeric' bugs
677 return ( $cur >= $min ? $cur : undef );
714 return $cur <=> $min;
678715 }
679716
680717 # nothing; this usage is deprecated.
705742 if $Config;
706743
707744 $PostambleActions = (
708 $missing
745 ($missing and not $UnderCPAN)
709746 ? "\$(PERL) $0 --config=$config --installdeps=$missing"
710747 : "\$(NOECHO) \$(NOOP)"
711748 );
745782 sub postamble {
746783 $PostambleUsed = 1;
747784
748 return << ".";
785 return <<"END_MAKE";
749786
750787 config :: installdeps
751788 \t\$(NOECHO) \$(NOOP)
756793 installdeps ::
757794 \t$PostambleActions
758795
759 .
796 END_MAKE
760797
761798 }
762799
764801
765802 __END__
766803
767 #line 1003
804 #line 1056
11 package Module::Install::AutoInstall;
22
33 use strict;
4 use Module::Install::Base;
4 use Module::Install::Base ();
55
6 use vars qw{$VERSION $ISCORE @ISA};
6 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.79';
8 $VERSION = '0.91';
9 @ISA = 'Module::Install::Base';
910 $ISCORE = 1;
10 @ISA = qw{Module::Install::Base};
1111 }
1212
1313 sub AutoInstall { $_[0] }
00 #line 1
11 package Module::Install::Base;
22
3 $VERSION = '0.79';
3 use strict 'vars';
4 use vars qw{$VERSION};
5 BEGIN {
6 $VERSION = '0.91';
7 }
48
59 # Suspend handler for "redefined" warnings
610 BEGIN {
812 $SIG{__WARN__} = sub { $w };
913 }
1014
11 ### This is the ONLY module that shouldn't have strict on
12 # use strict;
13
14 #line 41
15 #line 42
1516
1617 sub new {
17 my ($class, %args) = @_;
18
19 foreach my $method ( qw(call load) ) {
20 *{"$class\::$method"} = sub {
21 shift()->_top->$method(@_);
22 } unless defined &{"$class\::$method"};
23 }
24
25 bless( \%args, $class );
18 my $class = shift;
19 unless ( defined &{"${class}::call"} ) {
20 *{"${class}::call"} = sub { shift->_top->call(@_) };
21 }
22 unless ( defined &{"${class}::load"} ) {
23 *{"${class}::load"} = sub { shift->_top->load(@_) };
24 }
25 bless { @_ }, $class;
2626 }
2727
2828 #line 61
2929
3030 sub AUTOLOAD {
31 my $self = shift;
32 local $@;
33 my $autoload = eval { $self->_top->autoload } or return;
34 goto &$autoload;
31 local $@;
32 my $func = eval { shift->_top->autoload } or return;
33 goto &$func;
3534 }
3635
37 #line 76
36 #line 75
3837
39 sub _top { $_[0]->{_top} }
38 sub _top {
39 $_[0]->{_top};
40 }
4041
41 #line 89
42 #line 90
4243
4344 sub admin {
44 $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new;
45 $_[0]->_top->{admin}
46 or
47 Module::Install::Base::FakeAdmin->new;
4548 }
4649
47 #line 101
50 #line 106
4851
4952 sub is_admin {
50 $_[0]->admin->VERSION;
53 $_[0]->admin->VERSION;
5154 }
5255
5356 sub DESTROY {}
5457
5558 package Module::Install::Base::FakeAdmin;
5659
57 my $Fake;
58 sub new { $Fake ||= bless(\@_, $_[0]) }
60 my $fake;
61
62 sub new {
63 $fake ||= bless(\@_, $_[0]);
64 }
5965
6066 sub AUTOLOAD {}
6167
6874
6975 1;
7076
71 #line 146
77 #line 154
11 package Module::Install::Can;
22
33 use strict;
4 use Module::Install::Base;
5 use Config ();
6 ### This adds a 5.005 Perl version dependency.
7 ### This is a bug and will be fixed.
8 use File::Spec ();
9 use ExtUtils::MakeMaker ();
4 use Config ();
5 use File::Spec ();
6 use ExtUtils::MakeMaker ();
7 use Module::Install::Base ();
108
11 use vars qw{$VERSION $ISCORE @ISA};
9 use vars qw{$VERSION @ISA $ISCORE};
1210 BEGIN {
13 $VERSION = '0.79';
11 $VERSION = '0.91';
12 @ISA = 'Module::Install::Base';
1413 $ISCORE = 1;
15 @ISA = qw{Module::Install::Base};
1614 }
1715
1816 # check if we can load some module
7977
8078 __END__
8179
82 #line 158
80 #line 156
11 package Module::Install::Fetch;
22
33 use strict;
4 use Module::Install::Base;
4 use Module::Install::Base ();
55
6 use vars qw{$VERSION $ISCORE @ISA};
6 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.79';
8 $VERSION = '0.91';
9 @ISA = 'Module::Install::Base';
910 $ISCORE = 1;
10 @ISA = qw{Module::Install::Base};
1111 }
1212
1313 sub get_file {
11 package Module::Install::Include;
22
33 use strict;
4 use Module::Install::Base;
4 use Module::Install::Base ();
55
6 use vars qw{$VERSION $ISCORE @ISA};
6 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.79';
8 $VERSION = '0.91';
9 @ISA = 'Module::Install::Base';
910 $ISCORE = 1;
10 @ISA = qw{Module::Install::Base};
1111 }
1212
1313 sub include {
11 package Module::Install::Makefile;
22
33 use strict 'vars';
4 use Module::Install::Base;
5 use ExtUtils::MakeMaker ();
6
7 use vars qw{$VERSION $ISCORE @ISA};
4 use ExtUtils::MakeMaker ();
5 use Module::Install::Base ();
6
7 use vars qw{$VERSION @ISA $ISCORE};
88 BEGIN {
9 $VERSION = '0.79';
9 $VERSION = '0.91';
10 @ISA = 'Module::Install::Base';
1011 $ISCORE = 1;
11 @ISA = qw{Module::Install::Base};
1212 }
1313
1414 sub Makefile { $_[0] }
113113 my $self = shift;
114114 die "&Makefile->write() takes no arguments\n" if @_;
115115
116 # Make sure we have a new enough
116 # Check the current Perl version
117 my $perl_version = $self->perl_version;
118 if ( $perl_version ) {
119 eval "use $perl_version; 1"
120 or die "ERROR: perl: Version $] is installed, "
121 . "but we need version >= $perl_version";
122 }
123
124 # Make sure we have a new enough MakeMaker
117125 require ExtUtils::MakeMaker;
118126
119 # MakeMaker can complain about module versions that include
120 # an underscore, even though its own version may contain one!
121 # Hence the funny regexp to get rid of it. See RT #35800
122 # for details.
123
124 $self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
125
126 # Generate the
127 if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) {
128 # MakeMaker can complain about module versions that include
129 # an underscore, even though its own version may contain one!
130 # Hence the funny regexp to get rid of it. See RT #35800
131 # for details.
132 $self->build_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
133 $self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
134 } else {
135 # Allow legacy-compatibility with 5.005 by depending on the
136 # most recent EU:MM that supported 5.005.
137 $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 );
138 $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 );
139 }
140
141 # Generate the MakeMaker params
127142 my $args = $self->makemaker_args;
128143 $args->{DISTNAME} = $self->name;
129144 $args->{NAME} = $self->module_name || $self->name;
132147 if ( $self->tests ) {
133148 $args->{test} = { TESTS => $self->tests };
134149 }
135 if ($] >= 5.005) {
150 if ( $] >= 5.005 ) {
136151 $args->{ABSTRACT} = $self->abstract;
137152 $args->{AUTHOR} = $self->author;
138153 }
146161 delete $args->{SIGN};
147162 }
148163
149 # merge both kinds of requires into prereq_pm
164 # Merge both kinds of requires into prereq_pm
150165 my $prereq = ($args->{PREREQ_PM} ||= {});
151166 %$prereq = ( %$prereq,
152167 map { @$_ }
249264
250265 __END__
251266
252 #line 379
267 #line 394
11 package Module::Install::Metadata;
22
33 use strict 'vars';
4 use Module::Install::Base;
5
6 use vars qw{$VERSION $ISCORE @ISA};
4 use Module::Install::Base ();
5
6 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.79';
8 $VERSION = '0.91';
9 @ISA = 'Module::Install::Base';
910 $ISCORE = 1;
10 @ISA = qw{Module::Install::Base};
11 }
11 }
12
13 my @boolean_keys = qw{
14 sign
15 };
1216
1317 my @scalar_keys = qw{
1418 name
3640 repository
3741 };
3842
43 my @array_keys = qw{
44 keywords
45 };
46
3947 sub Meta { shift }
48 sub Meta_BooleanKeys { @boolean_keys }
4049 sub Meta_ScalarKeys { @scalar_keys }
4150 sub Meta_TupleKeys { @tuple_keys }
4251 sub Meta_ResourceKeys { @resource_keys }
52 sub Meta_ArrayKeys { @array_keys }
53
54 foreach my $key ( @boolean_keys ) {
55 *$key = sub {
56 my $self = shift;
57 if ( defined wantarray and not @_ ) {
58 return $self->{values}->{$key};
59 }
60 $self->{values}->{$key} = ( @_ ? $_[0] : 1 );
61 return $self;
62 };
63 }
4364
4465 foreach my $key ( @scalar_keys ) {
4566 *$key = sub {
4667 my $self = shift;
47 return $self->{values}{$key} if defined wantarray and !@_;
48 $self->{values}{$key} = shift;
68 return $self->{values}->{$key} if defined wantarray and !@_;
69 $self->{values}->{$key} = shift;
70 return $self;
71 };
72 }
73
74 foreach my $key ( @array_keys ) {
75 *$key = sub {
76 my $self = shift;
77 return $self->{values}->{$key} if defined wantarray and !@_;
78 $self->{values}->{$key} ||= [];
79 push @{$self->{values}->{$key}}, @_;
4980 return $self;
5081 };
5182 }
5485 *$key = sub {
5586 my $self = shift;
5687 unless ( @_ ) {
57 return () unless $self->{values}{resources};
88 return () unless $self->{values}->{resources};
5889 return map { $_->[1] }
5990 grep { $_->[0] eq $key }
60 @{ $self->{values}{resources} };
61 }
62 return $self->{values}{resources}{$key} unless @_;
91 @{ $self->{values}->{resources} };
92 }
93 return $self->{values}->{resources}->{$key} unless @_;
6394 my $uri = shift or die(
6495 "Did not provide a value to $key()"
6596 );
6899 };
69100 }
70101
71 foreach my $key ( grep {$_ ne "resources"} @tuple_keys) {
102 foreach my $key ( grep { $_ ne "resources" } @tuple_keys) {
72103 *$key = sub {
73104 my $self = shift;
74 return $self->{values}{$key} unless @_;
105 return $self->{values}->{$key} unless @_;
75106 my @added;
76107 while ( @_ ) {
77108 my $module = shift or last;
78109 my $version = shift || 0;
79110 push @added, [ $module, $version ];
80111 }
81 push @{ $self->{values}{$key} }, @added;
112 push @{ $self->{values}->{$key} }, @added;
82113 return map {@$_} @added;
83114 };
84115 }
99130 if ( $name eq lc $name and ! $lc_resource{$name} ) {
100131 die("Unsupported reserved lowercase resource '$name'");
101132 }
102 $self->{values}{resources} ||= [];
103 push @{ $self->{values}{resources} }, [ $name, $value ];
104 }
105 $self->{values}{resources};
133 $self->{values}->{resources} ||= [];
134 push @{ $self->{values}->{resources} }, [ $name, $value ];
135 }
136 $self->{values}->{resources};
106137 }
107138
108139 # Aliases for build_requires that will have alternative
109140 # meanings in some future version of META.yml.
110 sub test_requires { shift->build_requires(@_) }
111 sub install_requires { shift->build_requires(@_) }
141 sub test_requires { shift->build_requires(@_) }
142 sub install_requires { shift->build_requires(@_) }
112143
113144 # Aliases for installdirs options
114 sub install_as_core { $_[0]->installdirs('perl') }
115 sub install_as_cpan { $_[0]->installdirs('site') }
116 sub install_as_site { $_[0]->installdirs('site') }
117 sub install_as_vendor { $_[0]->installdirs('vendor') }
118
119 sub sign {
120 my $self = shift;
121 return $self->{values}{sign} if defined wantarray and ! @_;
122 $self->{values}{sign} = ( @_ ? $_[0] : 1 );
123 return $self;
124 }
145 sub install_as_core { $_[0]->installdirs('perl') }
146 sub install_as_cpan { $_[0]->installdirs('site') }
147 sub install_as_site { $_[0]->installdirs('site') }
148 sub install_as_vendor { $_[0]->installdirs('vendor') }
125149
126150 sub dynamic_config {
127151 my $self = shift;
129153 warn "You MUST provide an explicit true/false value to dynamic_config\n";
130154 return $self;
131155 }
132 $self->{values}{dynamic_config} = $_[0] ? 1 : 0;
156 $self->{values}->{dynamic_config} = $_[0] ? 1 : 0;
133157 return 1;
134158 }
135159
136160 sub perl_version {
137161 my $self = shift;
138 return $self->{values}{perl_version} unless @_;
162 return $self->{values}->{perl_version} unless @_;
139163 my $version = shift or die(
140164 "Did not provide a value to perl_version()"
141165 );
148172 die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n";
149173 }
150174
151 $self->{values}{perl_version} = $version;
152 }
175 $self->{values}->{perl_version} = $version;
176 }
177
178 #Stolen from M::B
179 my %license_urls = (
180 perl => 'http://dev.perl.org/licenses/',
181 apache => 'http://apache.org/licenses/LICENSE-2.0',
182 artistic => 'http://opensource.org/licenses/artistic-license.php',
183 artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
184 lgpl => 'http://opensource.org/licenses/lgpl-license.php',
185 lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
186 lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
187 bsd => 'http://opensource.org/licenses/bsd-license.php',
188 gpl => 'http://opensource.org/licenses/gpl-license.php',
189 gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
190 gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
191 mit => 'http://opensource.org/licenses/mit-license.php',
192 mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
193 open_source => undef,
194 unrestricted => undef,
195 restrictive => undef,
196 unknown => undef,
197 );
153198
154199 sub license {
155200 my $self = shift;
156 return $self->{values}{license} unless @_;
201 return $self->{values}->{license} unless @_;
157202 my $license = shift or die(
158203 'Did not provide a value to license()'
159204 );
160 $self->{values}{license} = $license;
205 $self->{values}->{license} = $license;
161206
162207 # Automatically fill in license URLs
163 if ( $license eq 'perl' ) {
164 $self->resources( license => 'http://dev.perl.org/licenses/' );
208 if ( $license_urls{$license} ) {
209 $self->resources( license => $license_urls{$license} );
165210 }
166211
167212 return 1;
203248
204249 sub provides {
205250 my $self = shift;
206 my $provides = ( $self->{values}{provides} ||= {} );
251 my $provides = ( $self->{values}->{provides} ||= {} );
207252 %$provides = (%$provides, @_) if @_;
208253 return $provides;
209254 }
232277 sub feature {
233278 my $self = shift;
234279 my $name = shift;
235 my $features = ( $self->{values}{features} ||= [] );
280 my $features = ( $self->{values}->{features} ||= [] );
236281 my $mods;
237282
238283 if ( @_ == 1 and ref( $_[0] ) ) {
260305 while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
261306 $self->feature( $name, @$mods );
262307 }
263 return $self->{values}{features}
264 ? @{ $self->{values}{features} }
308 return $self->{values}->{features}
309 ? @{ $self->{values}->{features} }
265310 : ();
266311 }
267312
268313 sub no_index {
269314 my $self = shift;
270315 my $type = shift;
271 push @{ $self->{values}{no_index}{$type} }, @_ if $type;
272 return $self->{values}{no_index};
316 push @{ $self->{values}->{no_index}->{$type} }, @_ if $type;
317 return $self->{values}->{no_index};
273318 }
274319
275320 sub read {
393438 /ixms ) {
394439 my $license_text = $1;
395440 my @phrases = (
396 'under the same (?:terms|license) as perl itself' => 'perl', 1,
397 'GNU general public license' => 'gpl', 1,
398 'GNU public license' => 'gpl', 1,
399 'GNU lesser general public license' => 'lgpl', 1,
400 'GNU lesser public license' => 'lgpl', 1,
401 'GNU library general public license' => 'lgpl', 1,
402 'GNU library public license' => 'lgpl', 1,
403 'BSD license' => 'bsd', 1,
404 'Artistic license' => 'artistic', 1,
405 'GPL' => 'gpl', 1,
406 'LGPL' => 'lgpl', 1,
407 'BSD' => 'bsd', 1,
408 'Artistic' => 'artistic', 1,
409 'MIT' => 'mit', 1,
410 'proprietary' => 'proprietary', 0,
441 'under the same (?:terms|license) as (?:perl|the perl programming language) itself' => 'perl', 1,
442 'GNU general public license' => 'gpl', 1,
443 'GNU public license' => 'gpl', 1,
444 'GNU lesser general public license' => 'lgpl', 1,
445 'GNU lesser public license' => 'lgpl', 1,
446 'GNU library general public license' => 'lgpl', 1,
447 'GNU library public license' => 'lgpl', 1,
448 'BSD license' => 'bsd', 1,
449 'Artistic license' => 'artistic', 1,
450 'GPL' => 'gpl', 1,
451 'LGPL' => 'lgpl', 1,
452 'BSD' => 'bsd', 1,
453 'Artistic' => 'artistic', 1,
454 'MIT' => 'mit', 1,
455 'proprietary' => 'proprietary', 0,
411456 );
412457 while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
413458 $pattern =~ s{\s+}{\\s+}g;
422467 return 'unknown';
423468 }
424469
470 sub _extract_bugtracker {
471 my @links = $_[0] =~ m#L<(\Qhttp://rt.cpan.org/\E[^>]+)>#g;
472 my %links;
473 @links{@links}=();
474 @links=keys %links;
475 return @links;
476 }
477
425478 sub bugtracker_from {
426479 my $self = shift;
427480 my $content = Module::Install::_read($_[0]);
428 my @links = $content =~ m/L\<(http\:\/\/rt\.cpan\.org\/[^>]+)\>/g;
481 my @links = _extract_bugtracker($content);
429482 unless ( @links ) {
430483 warn "Cannot determine bugtracker info from $_[0]\n";
431484 return 0;
438491 # Set the bugtracker
439492 bugtracker( $links[0] );
440493 return 1;
494 }
495
496 sub requires_from {
497 my $self = shift;
498 my $content = Module::Install::_readperl($_[0]);
499 my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
500 while ( @requires ) {
501 my $module = shift @requires;
502 my $version = shift @requires;
503 $self->requires( $module => $version );
504 }
505 }
506
507 sub test_requires_from {
508 my $self = shift;
509 my $content = Module::Install::_readperl($_[0]);
510 my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
511 while ( @requires ) {
512 my $module = shift @requires;
513 my $version = shift @requires;
514 $self->test_requires( $module => $version );
515 }
441516 }
442517
443518 # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to
445520 # Also, convert double-part versions (eg, 5.8)
446521 sub _perl_version {
447522 my $v = $_[-1];
448 $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e;
523 $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e;
449524 $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e;
450525 $v =~ s/(\.\d\d\d)000$/$1/;
451526 $v =~ s/_.+$//;
452527 if ( ref($v) ) {
453 $v = $v + 0; # Numify
528 # Numify
529 $v = $v + 0;
454530 }
455531 return $v;
456532 }
460536
461537
462538 ######################################################################
463 # MYMETA.yml Support
539 # MYMETA Support
464540
465541 sub WriteMyMeta {
466 $_[0]->write_mymeta;
467 }
468
469 sub write_mymeta {
470 my $self = shift;
471
542 die "WriteMyMeta has been deprecated";
543 }
544
545 sub write_mymeta_yaml {
546 my $self = shift;
547
548 # We need YAML::Tiny to write the MYMETA.yml file
549 unless ( eval { require YAML::Tiny; 1; } ) {
550 return 1;
551 }
552
553 # Generate the data
554 my $meta = $self->_write_mymeta_data or return 1;
555
556 # Save as the MYMETA.yml file
557 print "Writing MYMETA.yml\n";
558 YAML::Tiny::DumpFile('MYMETA.yml', $meta);
559 }
560
561 sub write_mymeta_json {
562 my $self = shift;
563
564 # We need JSON to write the MYMETA.json file
565 unless ( eval { require JSON; 1; } ) {
566 return 1;
567 }
568
569 # Generate the data
570 my $meta = $self->_write_mymeta_data or return 1;
571
572 # Save as the MYMETA.yml file
573 print "Writing MYMETA.json\n";
574 Module::Install::_write(
575 'MYMETA.json',
576 JSON->new->pretty(1)->canonical->encode($meta),
577 );
578 }
579
580 sub _write_mymeta_data {
581 my $self = shift;
582
472583 # If there's no existing META.yml there is nothing we can do
473 return unless -f 'META.yml';
584 return undef unless -f 'META.yml';
585
586 # We need Parse::CPAN::Meta to load the file
587 unless ( eval { require Parse::CPAN::Meta; 1; } ) {
588 return undef;
589 }
474590
475591 # Merge the perl version into the dependencies
476592 my $val = $self->Meta->{values};
487603 }
488604
489605 # Load the advisory META.yml file
490 require YAML::Tiny;
491 my @yaml = YAML::Tiny::LoadFile('META.yml');
606 my @yaml = Parse::CPAN::Meta::LoadFile('META.yml');
492607 my $meta = $yaml[0];
493608
494609 # Overwrite the non-configure dependency hashs
502617 $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } };
503618 }
504619
505 # Save as the MYMETA.yml file
506 YAML::Tiny::DumpFile('MYMETA.yml', $meta);
620 return $meta;
507621 }
508622
509623 1;
11 package Module::Install::Win32;
22
33 use strict;
4 use Module::Install::Base;
4 use Module::Install::Base ();
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.79';
9 @ISA = qw{Module::Install::Base};
8 $VERSION = '0.91';
9 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
1212
11 package Module::Install::WriteAll;
22
33 use strict;
4 use Module::Install::Base;
4 use Module::Install::Base ();
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.79';
8 $VERSION = '0.91';;
99 @ISA = qw{Module::Install::Base};
1010 $ISCORE = 1;
1111 }
2121 );
2222
2323 $self->sign(1) if $args{sign};
24 $self->Meta->write if $args{meta};
2524 $self->admin->WriteAll(%args) if $self->is_admin;
2625
2726 $self->check_nmake if $args{check_nmake};
2928 $self->makemaker_args( PL_FILES => {} );
3029 }
3130
31 # Until ExtUtils::MakeMaker support MYMETA.yml, make sure
32 # we clean it up properly ourself.
33 $self->realclean_files('MYMETA.yml');
34
3235 if ( $args{inline} ) {
3336 $self->Inline->write;
3437 } else {
3538 $self->Makefile->write;
3639 }
40
41 # The Makefile write process adds a couple of dependencies,
42 # so write the META.yml files after the Makefile.
43 if ( $args{meta} ) {
44 $self->Meta->write;
45 }
46
47 # Experimental support for MYMETA
48 if ( $ENV{X_MYMETA} ) {
49 if ( $ENV{X_MYMETA} eq 'JSON' ) {
50 $self->Meta->write_mymeta_json;
51 } else {
52 $self->Meta->write_mymeta_yaml;
53 }
54 }
55
56 return 1;
3757 }
3858
3959 1;
1616 # 3. The ./inc/ version of Module::Install loads
1717 # }
1818
19 BEGIN {
20 require 5.004;
21 }
19 use 5.005;
2220 use strict 'vars';
2321
24 use vars qw{$VERSION};
22 use vars qw{$VERSION $MAIN};
2523 BEGIN {
2624 # All Module::Install core packages now require synchronised versions.
2725 # This will be used to ensure we don't accidentally load old or
2927 # This is not enforced yet, but will be some time in the next few
3028 # releases once we can make sure it won't clash with custom
3129 # Module::Install extensions.
32 $VERSION = '0.79';
30 $VERSION = '0.91';
31
32 # Storage for the pseudo-singleton
33 $MAIN = undef;
3334
3435 *inc::Module::Install::VERSION = *VERSION;
3536 @inc::Module::Install::ISA = __PACKAGE__;
6869 # again. This is bad. Rather than taking action to touch it (which
6970 # is unreliable on some platforms and requires write permissions)
7071 # for now we should catch this and refuse to run.
71 if ( -f $0 and (stat($0))[9] > time ) { die <<"END_DIE" }
72
73 Your installer $0 has a modification time in the future.
72 if ( -f $0 ) {
73 my $s = (stat($0))[9];
74
75 # If the modification time is only slightly in the future,
76 # sleep briefly to remove the problem.
77 my $a = $s - time;
78 if ( $a > 0 and $a < 5 ) { sleep 5 }
79
80 # Too far in the future, throw an error.
81 my $t = time;
82 if ( $s > $t ) { die <<"END_DIE" }
83
84 Your installer $0 has a modification time in the future ($s > $t).
7485
7586 This is known to create infinite loops in make.
7687
7788 Please correct this, then run $0 again.
7889
7990 END_DIE
91 }
8092
8193
8294
120132 $sym->{$cwd} = sub {
121133 my $pwd = Cwd::cwd();
122134 if ( my $code = $sym->{$pwd} ) {
123 # delegate back to parent dirs
135 # Delegate back to parent dirs
124136 goto &$code unless $cwd eq $pwd;
125137 }
126138 $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
127 unless ( uc($1) eq $1 ) {
128 unshift @_, ( $self, $1 );
129 goto &{$self->can('call')};
139 my $method = $1;
140 if ( uc($method) eq $method ) {
141 # Do nothing
142 return;
143 } elsif ( $method =~ /^_/ and $self->can($method) ) {
144 # Dispatch to the root M:I class
145 return $self->$method(@_);
130146 }
147
148 # Dispatch to the appropriate plugin
149 unshift @_, ( $self, $1 );
150 goto &{$self->can('call')};
131151 };
132152 }
133153
152172 delete $INC{"$self->{file}"};
153173 delete $INC{"$self->{path}.pm"};
154174
175 # Save to the singleton
176 $MAIN = $self;
177
155178 return 1;
156179 }
157180
165188
166189 my @exts = @{$self->{extensions}};
167190 unless ( @exts ) {
168 my $admin = $self->{admin};
169 @exts = $admin->load_all_extensions;
191 @exts = $self->{admin}->load_all_extensions;
170192 }
171193
172194 my %seen;
249271 sub load_extensions {
250272 my ($self, $path, $top) = @_;
251273
252 unless ( grep { !ref $_ and lc $_ eq lc $self->{prefix} } @INC ) {
274 unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) {
253275 unshift @INC, $self->{prefix};
254276 }
255277
313335
314336
315337 #####################################################################
316 # Utility Functions
338 # Common Utility Functions
317339
318340 sub _caller {
319341 my $depth = 0;
327349
328350 sub _read {
329351 local *FH;
330 open FH, "< $_[0]" or die "open($_[0]): $!";
331 my $str = do { local $/; <FH> };
352 if ( $] >= 5.006 ) {
353 open( FH, '<', $_[0] ) or die "open($_[0]): $!";
354 } else {
355 open( FH, "< $_[0]" ) or die "open($_[0]): $!";
356 }
357 my $string = do { local $/; <FH> };
332358 close FH or die "close($_[0]): $!";
333 return $str;
359 return $string;
360 }
361
362 sub _readperl {
363 my $string = Module::Install::_read($_[0]);
364 $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg;
365 $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s;
366 $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg;
367 return $string;
368 }
369
370 sub _readpod {
371 my $string = Module::Install::_read($_[0]);
372 $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg;
373 return $string if $_[0] =~ /\.pod\z/;
374 $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg;
375 $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg;
376 $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg;
377 $string =~ s/^\n+//s;
378 return $string;
334379 }
335380
336381 sub _write {
337382 local *FH;
338 open FH, "> $_[0]" or die "open($_[0]): $!";
339 foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!" }
383 if ( $] >= 5.006 ) {
384 open( FH, '>', $_[0] ) or die "open($_[0]): $!";
385 } else {
386 open( FH, "> $_[0]" ) or die "open($_[0]): $!";
387 }
388 foreach ( 1 .. $#_ ) {
389 print FH $_[$_] or die "print($_[0]): $!";
390 }
340391 close FH or die "close($_[0]): $!";
341392 }
342393
343394 # _version is for processing module versions (eg, 1.03_05) not
344395 # Perl versions (eg, 5.8.1).
345
346396 sub _version ($) {
347397 my $s = shift || 0;
348 $s =~ s/^(\d+)\.?//;
398 my $d =()= $s =~ /(\.)/g;
399 if ( $d >= 2 ) {
400 # Normalise multipart versions
401 $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg;
402 }
403 $s =~ s/^(\d+)\.?//;
349404 my $l = $1 || 0;
350 my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g;
351 $l = $l . '.' . join '', @v if @v;
405 my @v = map {
406 $_ . '0' x (3 - length $_)
407 } $s =~ /(\d{1,3})\D?/g;
408 $l = $l . '.' . join '', @v if @v;
352409 return $l + 0;
410 }
411
412 sub _cmp ($$) {
413 _version($_[0]) <=> _version($_[1]);
353414 }
354415
355416 # Cloned from Params::Util::_CLASS
359420 and
360421 ! ref $_[0]
361422 and
362 $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*$/s
423 $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s
363424 ) ? $_[0] : undef;
364425 }
365426
18091809 C<first_row> and C<rows_per_page> so that queries return values from
18101810 the selected page.
18111811
1812 If a C<current_page> of C<all> is passed, then paging is basically disabled
1813 (by setting C<per_page> to the number of entries, and C<current_page> to 1)
1814
18121815 =cut
18131816
18141817 sub set_page_info {
18231826 my $weakself = $self;
18241827 weaken($weakself);
18251828
1826 $self->pager->total_entries( lazy { $weakself->count_all } )
1829 my $total_entries = lazy { $weakself->count_all };
1830
1831 if ($args{'current_page'} eq 'all') {
1832 $args{'current_page'} = 1;
1833 $args{'per_page'} = $total_entries;
1834 }
1835
1836 $self->pager->total_entries($total_entries)
18271837 ->entries_per_page( $args{'per_page'} )
18281838 ->current_page( $args{'current_page'} );
18291839
21812191 );
21822192 }
21832193
2194 =head2 each CALLBACK
2195
2196 Executes the callback for each item in the collection. The callback receives as
2197 arguments each record, its zero-based index, and the collection. The return
2198 value of C<each> is the original collection.
2199
2200 If the callback returns zero, the iteration ends.
2201
2202 =cut
2203
2204 sub each {
2205 my $self = shift;
2206 my $cb = shift;
2207
2208 my $idx = 0;
2209 $self->goto_first_item;
2210
2211 while (my $record = $self->next) {
2212 my $ret = $cb->($record, $idx++, $self);
2213 last if defined($ret) && !$ret;
2214 }
2215
2216 return $self;
2217 }
2218
21842219 1;
21852220 __END__
21862221
813813 if ($force) {
814814 $TRANSDEPTH = 0;
815815
816 Jifty::DBI::Record->flush_cache
817 if Jifty::DBI::Record->can('flush_cache');
818
819816 return ( $dbh->rollback );
820817 }
821818
829826 $TRANSDEPTH--;
830827 return $TRANSDEPTH;
831828 }
832
833 Jifty::DBI::Record->flush_cache
834 if Jifty::DBI::Record->can('flush_cache');
835829
836830 my $rv = $dbh->rollback;
837831 if ($rv) {
8686
8787 }
8888
89 sub _is_in_transaction {
90 my $self = shift;
91 $Jifty::DBI::Handle::TRANSDEPTH > 0;
92 }
93
8994 =head2 load_from_hash
9095
9196 Overrides the implementation from L<Jifty::DBI::Record> to add caching.
103108 ( $rvalue, $msg ) = $self->SUPER::load_from_hash(@_);
104109
105110 ## Check the return value, if its good, cache it!
106 $self->_store() if ($rvalue);
111 $self->_store() if ($rvalue && !$self->_is_in_transaction);
107112 return ( $rvalue, $msg );
108113 } else { # Called as a class method;
109114 $self = $self->SUPER::load_from_hash(@_);
110115 ## Check the return value, if its good, cache it!
111 $self->_store() if ( $self->id );
116 $self->_store() if ( $self->id && !$self->_is_in_transaction );
112117 return ($self);
113118 }
114119
143148 ## Fetch from the DB!
144149 my ( $rvalue, $msg ) = $self->SUPER::load_by_cols(%attr);
145150 ## Check the return value, if its good, cache it!
146 if ($rvalue) {
151 if ($rvalue && !$self->_is_in_transaction) {
147152 ## Only cache the object if its okay to do so.
148153 $self->_store();
149154 $self->_key_cache->set(
8888 my ($flag) = @_;
8989 if ( $class->isa(__PACKAGE__) and defined $flag and $flag eq '-base' ) {
9090 my $descendant = (caller)[0];
91 no strict 'refs';
92 push @{ $descendant . '::ISA' }, $class;
91 unless ( $descendant->isa($class) ) {
92 no strict 'refs';
93 push @{ $descendant . '::ISA' }, $class
94 }
9395 shift;
9496
9597 # run the schema callback
603605
604606 =head2 readable_attributes
605607
606 Returns a list this table's readable columns
608 Returns the list of this table's readable columns. They are first sorted so
609 that primary keys come first, and then they are sorted in alphabetical order.
607610
608611 =cut
609612
610613 sub readable_attributes {
611614 my $self = shift;
612 return @{
613 $self->_READABLE_COLS_CACHE() || $self->_READABLE_COLS_CACHE(
614 [ sort map { $_->name } grep { $_->readable } $self->columns ]
615 )
616 };
615
616 my %is_primary = map { $_ => 1 } @{ $self->_primary_keys };
617
618 return @{ $self->_READABLE_COLS_CACHE() || $self->_READABLE_COLS_CACHE([
619 map { $_->name }
620 sort { do {
621 no warnings 'uninitialized';
622 ($is_primary{$b->name} <=> $is_primary{$a->name})
623 ||
624 ($a->name cmp $b->name)
625 } }
626 grep { $_->readable }
627 $self->columns
628 ])};
617629 }
618630
619631 =head2 serialize_metadata
286286 column => $column,
287287 value_ref => \$default,
288288 );
289 $default = \"''" if defined $default and not length $default;
289290 $model->_handle(undef);
290291 } else {
291292 $default = '';
11 use warnings;
22 use strict;
33
4 $Jifty::DBI::VERSION = '0.58';
4 $Jifty::DBI::VERSION = '0.59';
55
66 =head1 NAME
77