Imported Upstream version 0.46
Nuno Carvalho
11 years ago
0 | --- | |
1 | version: 0.46 | |
2 | date: Wed Jul 25 17:35:44 PDT 2012 | |
3 | changes: | |
4 | - Re-releasing to reclaim indexing from Alt-IO-All-new | |
5 | --- | |
6 | version: 0.45 | |
7 | date: Wed Jul 18 22:15:04 EDT 2012 | |
8 | changes: | |
9 | - Added an example for ->assert and fixed the \E warnings on 5.16, courtesy shlomi fish | |
0 | 10 | --- |
1 | 11 | version: 0.44 |
2 | 12 | date: Wed Oct 5 18:11:27 EDT 2011 |
0 | This software is copyright (c) 2011 by Ingy döt Net <ingy@cpan.org>. | |
0 | This software is copyright (c) 2012 by Ingy döt Net <ingy@cpan.org>. | |
1 | 1 | |
2 | 2 | This is free software; you can redistribute it and/or modify it under |
3 | 3 | the same terms as the Perl 5 programming language system itself. |
11 | 11 | |
12 | 12 | --- The GNU General Public License, Version 1, February 1989 --- |
13 | 13 | |
14 | This software is Copyright (c) 2011 by Ingy döt Net <ingy@cpan.org>. | |
14 | This software is Copyright (c) 2012 by Ingy döt Net <ingy@cpan.org>. | |
15 | 15 | |
16 | 16 | This is free software, licensed under: |
17 | 17 | |
18 | 18 | The GNU General Public License, Version 1, February 1989 |
19 | 19 | |
20 | GNU GENERAL PUBLIC LICENSE | |
21 | Version 1, February 1989 | |
20 | GNU GENERAL PUBLIC LICENSE | |
21 | Version 1, February 1989 | |
22 | 22 | |
23 | 23 | Copyright (C) 1989 Free Software Foundation, Inc. |
24 | 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA | |
24 | 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA | |
25 | ||
25 | 26 | Everyone is permitted to copy and distribute verbatim copies |
26 | 27 | of this license document, but changing it is not allowed. |
27 | 28 | |
28 | Preamble | |
29 | Preamble | |
29 | 30 | |
30 | 31 | The license agreements of most software companies try to keep users |
31 | 32 | at the mercy of those companies. By contrast, our General Public |
66 | 67 | The precise terms and conditions for copying, distribution and |
67 | 68 | modification follow. |
68 | 69 | |
69 | GNU GENERAL PUBLIC LICENSE | |
70 | GNU GENERAL PUBLIC LICENSE | |
70 | 71 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
71 | 72 | |
72 | 73 | 0. This License Agreement applies to any program or other work which |
184 | 185 | of preserving the free status of all derivatives of our free software and |
185 | 186 | of promoting the sharing and reuse of software generally. |
186 | 187 | |
187 | NO WARRANTY | |
188 | NO WARRANTY | |
188 | 189 | |
189 | 190 | 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
190 | 191 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
206 | 207 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
207 | 208 | POSSIBILITY OF SUCH DAMAGES. |
208 | 209 | |
209 | END OF TERMS AND CONDITIONS | |
210 | ||
211 | Appendix: How to Apply These Terms to Your New Programs | |
210 | END OF TERMS AND CONDITIONS | |
211 | ||
212 | Appendix: How to Apply These Terms to Your New Programs | |
212 | 213 | |
213 | 214 | If you develop a new program, and you want it to be of the greatest |
214 | 215 | possible use to humanity, the best way to achieve this is to make it |
234 | 235 | GNU General Public License for more details. |
235 | 236 | |
236 | 237 | You should have received a copy of the GNU General Public License |
237 | along with this program; if not, write to the Free Software Foundation, | |
238 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | |
238 | along with this program; if not, write to the Free Software | |
239 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA | |
240 | ||
239 | 241 | |
240 | 242 | Also add information on how to contact you by electronic and paper mail. |
241 | 243 | |
269 | 271 | |
270 | 272 | --- The Artistic License 1.0 --- |
271 | 273 | |
272 | This software is Copyright (c) 2011 by Ingy döt Net <ingy@cpan.org>. | |
274 | This software is Copyright (c) 2012 by Ingy döt Net <ingy@cpan.org>. | |
273 | 275 | |
274 | 276 | This is free software, licensed under: |
275 | 277 |
0 | 0 | Changes |
1 | examples/create-cat-to.pl | |
1 | 2 | inc/Module/Install.pm |
2 | 3 | inc/Module/Install/Base.pm |
3 | 4 | inc/Module/Install/Can.pm |
27 | 28 | Makefile.PL |
28 | 29 | MANIFEST This list of files |
29 | 30 | META.yml |
31 | Notes/Design.md | |
30 | 32 | Notes/Design.st |
31 | 33 | README |
32 | 34 | t/absolute.t |
2 | 2 | author: |
3 | 3 | - 'Ingy döt Net <ingy@cpan.org>' |
4 | 4 | build_requires: |
5 | ExtUtils::MakeMaker: 6.42 | |
5 | ExtUtils::MakeMaker: 6.59 | |
6 | 6 | configure_requires: |
7 | ExtUtils::MakeMaker: 6.42 | |
7 | ExtUtils::MakeMaker: 6.59 | |
8 | 8 | distribution_type: module |
9 | generated_by: 'Module::Install version 1.01' | |
9 | dynamic_config: 1 | |
10 | generated_by: 'Module::Install version 1.06' | |
10 | 11 | license: perl |
11 | 12 | meta-spec: |
12 | 13 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
15 | 16 | name: IO-All |
16 | 17 | no_index: |
17 | 18 | directory: |
19 | - examples | |
18 | 20 | - inc |
19 | 21 | - t |
20 | 22 | recommends: |
23 | 25 | IO::String: 1.08 |
24 | 26 | perl: 5.6.1 |
25 | 27 | resources: |
26 | homepage: http://github.com/ingydotnet/io-all-pm/tree | |
28 | homepage: https://github.com/ingydotnet/io-all-pm/tree | |
27 | 29 | license: http://dev.perl.org/licenses/ |
28 | repository: git://github.com/ingydotnet/io-all-pm.git | |
29 | version: 0.44 | |
30 | repository: | |
31 | type: git | |
32 | url: git://github.com/ingydotnet/io-all-pm.git | |
33 | web: https://github.com/ingydotnet/io-all-pm/tree | |
34 | version: 0.46 |
0 | use inc::Module::Package 'Ingy:modern 0.17'; | |
0 | use inc::Module::Package 'Ingy:modern 0.20'; | |
1 | 1 | |
2 | 2 | requires 'IO::String' => '1.08'; |
3 | 3 | recommends 'File::ReadBackwards'; |
0 | # Introduction | |
1 | ||
2 | This is a design document for an upcoming version of IO::All. | |
3 | ||
4 | IO::All is a Perl module that attempts to make all Input/Output operations in | |
5 | Perl, as simple and normal as possible. IO::All has been in existence since | |
6 | 2005. It is useful and somewhat extensible, but has a number of | |
7 | inconsistencies, flaws and misgivings. | |
8 | ||
9 | This document will propose a better way to do it, and will also discuss how to | |
10 | move the current API forward to the new API. | |
11 | ||
12 | # Basic Principles of how IO::All should work | |
13 | ||
14 | * IO::All provides a single entry point function called `io`. | |
15 | * `use IO::All` should make this function available in a lexical scope. | |
16 | * Currently this scope is 'package' scope. | |
17 | * Would be nice, but maybe not possible to have true lexical scope. | |
18 | * The `io` function is custom to its scope | |
19 | * The behavior it provides depends on the state of the scope | |
20 | * The behavior it provides also depends on the arguments passed to `use | |
21 | IO::All` | |
22 | * `io` returns an IO::All object | |
23 | * The IO::All object has no I/O capabilities | |
24 | * Further method calls invoke a context, causing the IO::All object to | |
25 | rebless itself it something useful like IO::All::File. | |
26 | * Certain methods force a rebless | |
27 | * `file(...), dir(...), socket(...), etc | |
28 | * These methods are more or less hard-coded currently | |
29 | * Options to `use IO::All` that begin with a `-`, cause a method to be called | |
30 | on each new IO::All object. | |
31 | * use IO::All -strict, -encoding => 'big5'; # causes: | |
32 | * io('foo')->print('hi'); # to mean: | |
33 | * io('foo')->strict->encoding('big5')->print('hi'); | |
34 | * IO::All operations generally return other IO::All objects | |
35 | * Often they return themselves ($self) for chaining | |
36 | * IO::All needs to be completely and consistently extensible | |
37 | * The extensions that ship with IO-All should be the same as third party | |
38 | extensions | |
39 | * Extensions register capabilities with IO::All (tied to a scope) | |
40 | * IO::All operations can be strict or loose. Strict always throws errors on | |
41 | any possible error condition. Strict or loose should be determined by the | |
42 | presence of `use strict` in the scope (possibly). | |
43 | * IO::All currently uses a big set of overloaded operations by default. This | |
44 | is loved by some and hated by others. It should probably be off by default | |
45 | for 2.0. | |
46 | ||
47 | # IO::All Extensions | |
48 | ||
49 | Currently the extension API is fairly muddy. I would like the new API to | |
50 | require something like this: | |
51 | ||
52 | { | |
53 | use strict; | |
54 | use IO::All -overload; | |
55 | use IO::All::PrintingPress; | |
56 | ||
57 | my $io = io('path:to:printing:press#1'); | |
58 | # is ref($io), 'IO::All'; | |
59 | $io->print('IO::All'); # calls IO::All::PrintingPress::print | |
60 | # is ref($io), 'IO::All::PrintingPress'; | |
61 | } | |
62 | ||
63 | So you need to load any extensions that you want to use, within the scope that | |
64 | you want them in. Exceptions are IO::All::File and IO::All::Dir, which are | |
65 | automatically loaded, unless you say: | |
66 | ||
67 | use IO::All -none; | |
68 | ||
69 | Extensions can register 2 things: | |
70 | ||
71 | 1. Register a method (or methods) that will force a rebless in that class. | |
72 | 2. Register a regexp (or function) that will cause a rebless when the input | |
73 | to io(...) matches. | |
74 | ||
75 | These things are register according to the scope of the IO::All, so that the | |
76 | `io` function will do the right things. | |
77 | ||
78 | # Transition to the new API | |
79 | ||
80 | It needs to be determined if the changes that need to be made are too | |
81 | destructive to coexist with the current IO::All. That determination obviously | |
82 | cannot be made until the new design is complete. | |
83 | ||
84 | If it is not too destructive, IO::All and its extensions can be brought | |
85 | forward. | |
86 | ||
87 | If it is too destructive, here is one proposed solution: | |
88 | ||
89 | Support IO::All 2 <options>; | |
90 | ||
91 | The version '2' will load IO::All2 (or something) and no version will load the | |
92 | old code. | |
93 | ||
94 | It is important to assure that the old and new interfaces can coexist in the | |
95 | same process space. | |
96 | ||
97 | In the IO::All2 scenario, we would need to figure out if the current IO::All | |
98 | extensions also needed forwarding. | |
99 |
156 | 156 | |
157 | 157 | with this: |
158 | 158 | |
159 | my $stuff < io "./mystuff"; | |
159 | my $stuff < io './mystuff'; | |
160 | 160 | |
161 | 161 | And that is a good thing! |
162 | 162 | |
684 | 684 | exists before the file is open. If the path does not exist, it is |
685 | 685 | created. |
686 | 686 | |
687 | For example, here is a program called "create-cat-to" that outputs | |
688 | to a file that it creates. | |
689 | ||
690 | #!/usr/bin/perl | |
691 | ||
692 | # create-cat-to.pl | |
693 | # cat to a file that can be created. | |
694 | ||
695 | use strict; | |
696 | use warnings; | |
697 | ||
698 | use IO::All; | |
699 | ||
700 | my $filename = shift(@ARGV); | |
701 | ||
702 | # Create a file called $filename, including all leading components. | |
703 | io('-') > io->file($filename)->assert; | |
704 | ||
705 | Here's an example use of it: | |
706 | ||
707 | $ ls -l | |
708 | total 0 | |
709 | $ echo "Hello World" | create-cat-to one/two/three/four.txt | |
710 | $ ls -l | |
711 | total 4 | |
712 | drwxr-xr-x 3 shlomif shlomif 4096 2010-10-14 18:03 one/ | |
713 | $ cat one/two/three/four.txt | |
714 | Hello World | |
715 | $ | |
716 | ||
687 | 717 | * autoclose |
688 | 718 | |
689 | 719 | By default, IO::All will close an object opened for input when EOF |
0 | #!/usr/bin/perl | |
1 | ||
2 | # create-cat-to.pl | |
3 | # cat to a file that can be created. | |
4 | ||
5 | use strict; | |
6 | use warnings; | |
7 | ||
8 | use IO::All; | |
9 | ||
10 | my $filename = shift(@ARGV); | |
11 | ||
12 | # Create a file called $filename, including all leading components. | |
13 | io('-') > io->file($filename)->assert; |
3 | 3 | use strict 'vars'; |
4 | 4 | use vars qw{$VERSION}; |
5 | 5 | BEGIN { |
6 | $VERSION = '1.01'; | |
6 | $VERSION = '1.06'; | |
7 | 7 | } |
8 | 8 | |
9 | 9 | # Suspend handler for "redefined" warnings |
2 | 2 | |
3 | 3 | use strict; |
4 | 4 | use Config (); |
5 | use File::Spec (); | |
6 | 5 | use ExtUtils::MakeMaker (); |
7 | 6 | use Module::Install::Base (); |
8 | 7 | |
9 | 8 | use vars qw{$VERSION @ISA $ISCORE}; |
10 | 9 | BEGIN { |
11 | $VERSION = '1.01'; | |
10 | $VERSION = '1.06'; | |
12 | 11 | @ISA = 'Module::Install::Base'; |
13 | 12 | $ISCORE = 1; |
14 | 13 | } |
28 | 27 | eval { require $mod; $pkg->VERSION($ver || 0); 1 }; |
29 | 28 | } |
30 | 29 | |
31 | # check if we can run some command | |
30 | # Check if we can run some command | |
32 | 31 | sub can_run { |
33 | 32 | my ($self, $cmd) = @_; |
34 | 33 | |
37 | 36 | |
38 | 37 | for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { |
39 | 38 | next if $dir eq ''; |
40 | my $abs = File::Spec->catfile($dir, $_[1]); | |
39 | require File::Spec; | |
40 | my $abs = File::Spec->catfile($dir, $cmd); | |
41 | 41 | return $abs if (-x $abs or $abs = MM->maybe_command($abs)); |
42 | 42 | } |
43 | 43 | |
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
47 | # can we locate a (the) C compiler | |
47 | # Can our C compiler environment build XS files | |
48 | sub can_xs { | |
49 | my $self = shift; | |
50 | ||
51 | # Ensure we have the CBuilder module | |
52 | $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); | |
53 | ||
54 | # Do we have the configure_requires checker? | |
55 | local $@; | |
56 | eval "require ExtUtils::CBuilder;"; | |
57 | if ( $@ ) { | |
58 | # They don't obey configure_requires, so it is | |
59 | # someone old and delicate. Try to avoid hurting | |
60 | # them by falling back to an older simpler test. | |
61 | return $self->can_cc(); | |
62 | } | |
63 | ||
64 | # Do we have a working C compiler | |
65 | my $builder = ExtUtils::CBuilder->new( | |
66 | quiet => 1, | |
67 | ); | |
68 | unless ( $builder->have_compiler ) { | |
69 | # No working C compiler | |
70 | return 0; | |
71 | } | |
72 | ||
73 | # Write a C file representative of what XS becomes | |
74 | require File::Temp; | |
75 | my ( $FH, $tmpfile ) = File::Temp::tempfile( | |
76 | "compilexs-XXXXX", | |
77 | SUFFIX => '.c', | |
78 | ); | |
79 | binmode $FH; | |
80 | print $FH <<'END_C'; | |
81 | #include "EXTERN.h" | |
82 | #include "perl.h" | |
83 | #include "XSUB.h" | |
84 | ||
85 | int main(int argc, char **argv) { | |
86 | return 0; | |
87 | } | |
88 | ||
89 | int boot_sanexs() { | |
90 | return 1; | |
91 | } | |
92 | ||
93 | END_C | |
94 | close $FH; | |
95 | ||
96 | # Can the C compiler access the same headers XS does | |
97 | my @libs = (); | |
98 | my $object = undef; | |
99 | eval { | |
100 | local $^W = 0; | |
101 | $object = $builder->compile( | |
102 | source => $tmpfile, | |
103 | ); | |
104 | @libs = $builder->link( | |
105 | objects => $object, | |
106 | module_name => 'sanexs', | |
107 | ); | |
108 | }; | |
109 | my $result = $@ ? 0 : 1; | |
110 | ||
111 | # Clean up all the build files | |
112 | foreach ( $tmpfile, $object, @libs ) { | |
113 | next unless defined $_; | |
114 | 1 while unlink; | |
115 | } | |
116 | ||
117 | return $result; | |
118 | } | |
119 | ||
120 | # Can we locate a (the) C compiler | |
48 | 121 | sub can_cc { |
49 | 122 | my $self = shift; |
50 | 123 | my @chunks = split(/ /, $Config::Config{cc}) or return; |
77 | 150 | |
78 | 151 | __END__ |
79 | 152 | |
80 | #line 156 | |
153 | #line 236 |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.01'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
6 | 6 | use base qw(Module::Install::Base); |
7 | 7 | use vars qw($VERSION); |
8 | 8 | |
9 | $VERSION = '0.10'; | |
9 | $VERSION = '0.16'; | |
10 | 10 | |
11 | 11 | sub githubmeta { |
12 | 12 | my $self = shift; |
13 | 13 | return unless $Module::Install::AUTHOR; |
14 | 14 | return unless _under_git(); |
15 | 15 | return unless $self->can_run('git'); |
16 | return unless my ($git_url) = `git remote show -n origin` =~ /URL: (.*)$/m; | |
16 | my $remote = shift || 'origin'; | |
17 | return unless my ($git_url) = `git remote show -n $remote` =~ /URL: (.*)$/m; | |
17 | 18 | return unless $git_url =~ /github\.com/; # Not a Github repository |
18 | 19 | my $http_url = $git_url; |
19 | 20 | $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!; |
20 | $http_url =~ s![\w\-]+\@([^:]+):!http://$1/!; | |
21 | $http_url =~ s![\w\-]+\@([^:]+):!https://$1/!; | |
21 | 22 | $http_url =~ s!\.git$!/tree!; |
22 | $self->repository( $git_url ); | |
23 | $self->repository( | |
24 | { | |
25 | type => 'git', | |
26 | url => $git_url, | |
27 | web => $http_url, | |
28 | }, | |
29 | ); | |
23 | 30 | $self->homepage( $http_url ) unless $self->homepage(); |
24 | 31 | return 1; |
25 | 32 | } |
46 | 53 | 'Github'; |
47 | 54 | __END__ |
48 | 55 | |
49 | #line 108 | |
56 | #line 117 |
7 | 7 | |
8 | 8 | use vars qw{$VERSION @ISA $ISCORE}; |
9 | 9 | BEGIN { |
10 | $VERSION = '1.01'; | |
10 | $VERSION = '1.06'; | |
11 | 11 | @ISA = 'Module::Install::Base'; |
12 | 12 | $ISCORE = 1; |
13 | 13 | } |
214 | 214 | require ExtUtils::MakeMaker; |
215 | 215 | |
216 | 216 | if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { |
217 | # MakeMaker can complain about module versions that include | |
218 | # an underscore, even though its own version may contain one! | |
219 | # Hence the funny regexp to get rid of it. See RT #35800 | |
220 | # for details. | |
221 | my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/; | |
222 | $self->build_requires( 'ExtUtils::MakeMaker' => $v ); | |
223 | $self->configure_requires( 'ExtUtils::MakeMaker' => $v ); | |
217 | # This previous attempted to inherit the version of | |
218 | # ExtUtils::MakeMaker in use by the module author, but this | |
219 | # was found to be untenable as some authors build releases | |
220 | # using future dev versions of EU:MM that nobody else has. | |
221 | # Instead, #toolchain suggests we use 6.59 which is the most | |
222 | # stable version on CPAN at time of writing and is, to quote | |
223 | # ribasushi, "not terminally fucked, > and tested enough". | |
224 | # TODO: We will now need to maintain this over time to push | |
225 | # the version up as new versions are released. | |
226 | $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); | |
227 | $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); | |
224 | 228 | } else { |
225 | 229 | # Allow legacy-compatibility with 5.005 by depending on the |
226 | 230 | # most recent EU:MM that supported 5.005. |
227 | $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 ); | |
228 | $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 ); | |
231 | $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); | |
232 | $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); | |
229 | 233 | } |
230 | 234 | |
231 | 235 | # Generate the MakeMaker params |
240 | 244 | 'all_from' if you prefer) in Makefile.PL. |
241 | 245 | EOT |
242 | 246 | |
243 | $DB::single = 1; | |
244 | 247 | if ( $self->tests ) { |
245 | 248 | my @tests = split ' ', $self->tests; |
246 | 249 | my %seen; |
411 | 414 | |
412 | 415 | __END__ |
413 | 416 | |
414 | #line 541 | |
417 | #line 544 |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.01'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
150 | 150 | sub install_as_vendor { $_[0]->installdirs('vendor') } |
151 | 151 | |
152 | 152 | sub dynamic_config { |
153 | my $self = shift; | |
154 | unless ( @_ ) { | |
155 | warn "You MUST provide an explicit true/false value to dynamic_config\n"; | |
156 | return $self; | |
157 | } | |
158 | $self->{values}->{dynamic_config} = $_[0] ? 1 : 0; | |
153 | my $self = shift; | |
154 | my $value = @_ ? shift : 1; | |
155 | if ( $self->{values}->{dynamic_config} ) { | |
156 | # Once dynamic we never change to static, for safety | |
157 | return 0; | |
158 | } | |
159 | $self->{values}->{dynamic_config} = $value ? 1 : 0; | |
159 | 160 | return 1; |
161 | } | |
162 | ||
163 | # Convenience command | |
164 | sub static_config { | |
165 | shift->dynamic_config(0); | |
160 | 166 | } |
161 | 167 | |
162 | 168 | sub perl_version { |
15 | 15 | use Module::Install::Base; |
16 | 16 | use vars qw'@ISA $VERSION'; |
17 | 17 | @ISA = 'Module::Install::Base'; |
18 | $VERSION = '0.29'; | |
18 | $VERSION = '0.30'; | |
19 | 19 | |
20 | 20 | #-----------------------------------------------------------------------------# |
21 | 21 | # XXX BOOTBUGHACK |
53 | 53 | # plugin directive: |
54 | 54 | my $module_install_plugin; |
55 | 55 | my $module_package_plugin; |
56 | my $module_package_dist_plugin; | |
56 | 57 | # XXX ARGVHACK This @argv thing is a temporary fix for an ugly bug somewhere in the |
57 | 58 | # Wikitext module usage. |
58 | 59 | my @argv; |
65 | 66 | $module_package_plugin = $self->_load_plugin($plugin_spec); |
66 | 67 | $module_package_plugin->mi($module_install_plugin); |
67 | 68 | $module_package_plugin->version_check($VERSION); |
69 | } | |
70 | else { | |
71 | $module_package_dist_plugin = $self->_load_dist_plugin($plugin_spec); | |
72 | $module_package_dist_plugin->mi($module_install_plugin) if ref $module_package_dist_plugin; | |
68 | 73 | } |
69 | 74 | # NOTE - This is the point in time where the body of Makefile.PL runs... |
70 | 75 | return; |
79 | 84 | } |
80 | 85 | else { |
81 | 86 | $module_install_plugin->_initial(); |
87 | $module_package_dist_plugin->_initial() if ref $module_package_dist_plugin; | |
82 | 88 | $module_install_plugin->_main(); |
89 | $module_package_dist_plugin->_main() if ref $module_package_dist_plugin; | |
83 | 90 | } |
84 | 91 | }; |
85 | 92 | if ($@) { |
100 | 107 | $module_package_plugin->final; |
101 | 108 | $module_package_plugin->replicate_module_package; |
102 | 109 | } |
103 | : $module_install_plugin->_final; | |
110 | : do { | |
111 | $module_install_plugin->_final; | |
112 | $module_package_dist_plugin->_final() if ref $module_package_dist_plugin; | |
113 | } | |
104 | 114 | } |
105 | 115 | } |
106 | 116 | |
122 | 132 | |
123 | 133 | # Find and load the author side plugin: |
124 | 134 | sub _load_plugin { |
125 | my ($self, $spec) = @_; | |
135 | my ($self, $spec, $namespace) = @_; | |
126 | 136 | $spec ||= ''; |
137 | $namespace ||= 'Module::Package'; | |
127 | 138 | my $version = ''; |
128 | 139 | $Module::Package::plugin_version = 0; |
129 | 140 | if ($spec =~ s/\s+(\S+)\s*//) { |
136 | 147 | ($spec =~ /^:(\w+)$/) ? ('Plugin', "Plugin::$1") : |
137 | 148 | ($spec =~ /^(\S*\w):(\w+)$/) ? ($1, "$1::$2") : |
138 | 149 | die "$spec is invalid"; |
139 | $module = "Module::Package::$module"; | |
140 | $plugin = "Module::Package::$plugin"; | |
150 | $module = "${namespace}::${module}"; | |
151 | $plugin = "${namespace}::${plugin}"; | |
141 | 152 | eval "use $module $version (); 1" or die $@; |
142 | 153 | return $plugin->new(); |
154 | } | |
155 | ||
156 | # Find and load the user side plugin: | |
157 | sub _load_dist_plugin { | |
158 | my ($self, $spec, $namespace) = @_; | |
159 | $spec ||= ''; | |
160 | $namespace ||= 'Module::Package::Dist'; | |
161 | my $r = eval { $self->_load_plugin($spec, $namespace); }; | |
162 | return $r if ref $r; | |
163 | return; | |
143 | 164 | } |
144 | 165 | |
145 | 166 | #-----------------------------------------------------------------------------# |
216 | 237 | return if $WriteAll++; |
217 | 238 | $self->WriteAll(@_); |
218 | 239 | } |
240 | ||
241 | # Base package for Module::Package plugin distributed components. | |
242 | package Module::Package::Dist; | |
243 | ||
244 | sub new { | |
245 | my ($class, %args) = @_; | |
246 | bless \%args, $class; | |
247 | } | |
248 | ||
249 | sub mi { | |
250 | @_ > 1 ? ($_[0]->{mi}=$_[1]) : $_[0]->{mi}; | |
251 | } | |
252 | ||
253 | sub _initial { | |
254 | my ($self) = @_; | |
255 | } | |
256 | ||
257 | sub _main { | |
258 | my ($self) = @_; | |
259 | } | |
260 | ||
261 | sub _final { | |
262 | my ($self) = @_; | |
263 | } | |
264 | ||
265 | 1; | |
219 | 266 | |
220 | 267 | #-----------------------------------------------------------------------------# |
221 | 268 | # Take a guess at the primary .pm and .pod files for 'all_from', and friends. |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.01'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.01'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = qw{Module::Install::Base}; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
30 | 30 | # This is not enforced yet, but will be some time in the next few |
31 | 31 | # releases once we can make sure it won't clash with custom |
32 | 32 | # Module::Install extensions. |
33 | $VERSION = '1.01'; | |
33 | $VERSION = '1.06'; | |
34 | 34 | |
35 | 35 | # Storage for the pseudo-singleton |
36 | 36 | $MAIN = undef; |
450 | 450 | } |
451 | 451 | |
452 | 452 | sub _cmp ($$) { |
453 | _version($_[0]) <=> _version($_[1]); | |
453 | _version($_[1]) <=> _version($_[2]); | |
454 | 454 | } |
455 | 455 | |
456 | 456 | # Cloned from Params::Util::_CLASS |
466 | 466 | |
467 | 467 | 1; |
468 | 468 | |
469 | # Copyright 2008 - 2011 Adam Kennedy. | |
469 | # Copyright 2008 - 2012 Adam Kennedy. |
14 | 14 | use strict; |
15 | 15 | |
16 | 16 | BEGIN { |
17 | $Module::Package::VERSION = '0.29'; | |
17 | $Module::Package::VERSION = '0.30'; | |
18 | 18 | $inc::Module::Package::VERSION ||= $Module::Package::VERSION; |
19 | 19 | @inc::Module::Package::ISA = __PACKAGE__; |
20 | 20 | } |
12 | 12 | use Symbol(); |
13 | 13 | use Fcntl; |
14 | 14 | |
15 | our $VERSION = '0.44'; | |
15 | our $VERSION = '0.46'; | |
16 | 16 | our @EXPORT = qw(io); |
17 | 17 | |
18 | 18 | #=============================================================================== |
72 | 72 | my $self = shift; |
73 | 73 | my $method = shift; |
74 | 74 | my $class_id = $self->autoload->{$method} || $method; |
75 | return "IO::All::\u$class_id" if $INC{"IO/All/\u$class_id\E.pm"}; | |
75 | my $ucfirst_class_name = 'IO::All::' . ucfirst($class_id); | |
76 | my $ucfirst_class_fn = "IO/All/" . ucfirst($class_id) . ".pm"; | |
77 | return $ucfirst_class_name if $INC{$ucfirst_class_fn}; | |
76 | 78 | return "IO::All::\U$class_id" if $INC{"IO/All/\U$class_id\E.pm"}; |
77 | 79 | require IO::All::Temp; |
78 | if (eval "require IO::All::\u$class_id; 1") { | |
79 | my $class = "IO::All::\u$class_id"; | |
80 | if (eval "require $ucfirst_class_name; 1") { | |
81 | my $class = $ucfirst_class_name; | |
80 | 82 | my $return = $class->can('new') |
81 | 83 | ? $class |
82 | 84 | : do { # (OS X hack) |
83 | my $value = $INC{"IO/All/\u$class_id\E.pm"}; | |
84 | delete $INC{"IO/All/\u$class_id\E.pm"}; | |
85 | my $value = $INC{$ucfirst_class_fn}; | |
86 | delete $INC{$ucfirst_class_fn}; | |
85 | 87 | $INC{"IO/All/\U$class_id\E.pm"} = $value; |
86 | 88 | "IO::All::\U$class_id"; |
87 | 89 | }; |
160 | 160 | |
161 | 161 | with this: |
162 | 162 | |
163 | my $stuff < io "./mystuff"; | |
163 | my $stuff < io './mystuff'; | |
164 | 164 | |
165 | 165 | And that is a B<good thing>! |
166 | 166 | |
706 | 706 | This method ensures that the path for a file or directory actually exists |
707 | 707 | before the file is open. If the path does not exist, it is created. |
708 | 708 | |
709 | For example, here is a program called "create-cat-to" that outputs to a file | |
710 | that it creates. | |
711 | ||
712 | #!/usr/bin/perl | |
713 | ||
714 | # create-cat-to.pl | |
715 | # cat to a file that can be created. | |
716 | ||
717 | use strict; | |
718 | use warnings; | |
719 | ||
720 | use IO::All; | |
721 | ||
722 | my $filename = shift(@ARGV); | |
723 | ||
724 | # Create a file called $filename, including all leading components. | |
725 | io('-') > io->file($filename)->assert; | |
726 | ||
727 | Here's an example use of it: | |
728 | ||
729 | $ ls -l | |
730 | total 0 | |
731 | $ echo "Hello World" | create-cat-to one/two/three/four.txt | |
732 | $ ls -l | |
733 | total 4 | |
734 | drwxr-xr-x 3 shlomif shlomif 4096 2010-10-14 18:03 one/ | |
735 | $ cat one/two/three/four.txt | |
736 | Hello World | |
737 | $ | |
738 | ||
709 | 739 | =item * autoclose |
710 | 740 | |
711 | 741 | By default, IO::All will close an object opened for input when EOF is |