Changeset 348
- Timestamp:
- 03/10/08 17:57:49 (2 months ago)
- Files:
-
- trunk/src/ingy/JS/Changes (modified) (1 diff)
- trunk/src/ingy/JS/MANIFEST (modified) (1 diff)
- trunk/src/ingy/JS/README (modified) (1 diff)
- trunk/src/ingy/JS/js-cpan (modified) (1 diff)
- trunk/src/ingy/JS/lib/JS.pm (modified) (4 diffs)
- trunk/src/ingy/JS/t/TestJS.pm (added)
- trunk/src/ingy/JS/t/test.t (modified) (1 diff)
- trunk/src/ingy/JS/t/testlib (added)
- trunk/src/ingy/JS/t/testlib/JS (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo.js (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo.pm (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo.pod (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo/Bar-min.js (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo/Bar-min.js.gz (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo/Bar-pack.js (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo/Bar.js (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo/Bar.pm (added)
- trunk/src/ingy/JS/t/testlib/JS/Foo/Bar.pod (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/ingy/JS/Changes
r306 r348 1 --- 2 version: 0.12 3 date: Tue Mar 11 02:50:09 EET 2008 4 changes: 5 - Add tests. 6 - Add wildcarding. 1 7 --- 2 8 version: 0.11 trunk/src/ingy/JS/MANIFEST
r306 r348 31 31 README 32 32 t/test.t 33 t/TestJS.pm 34 t/testlib/JS/Foo.js 35 t/testlib/JS/Foo.pm 36 t/testlib/JS/Foo.pod 37 t/testlib/JS/Foo/Bar-min.js 38 t/testlib/JS/Foo/Bar-min.js.gz 39 t/testlib/JS/Foo/Bar-pack.js 40 t/testlib/JS/Foo/Bar.js 41 t/testlib/JS/Foo/Bar.pm 42 t/testlib/JS/Foo/Bar.pod trunk/src/ingy/JS/README
r304 r348 4 4 SYSNOPSIS 5 5 > js-cpan 6 > js-cpan Foo* 6 7 > js-cpan Foo.Bar 7 8 > ln -s `js-cpan Foo.Bar` Foo.Bar.js trunk/src/ingy/JS/js-cpan
r295 r348 1 1 #!/usr/bin/perl 2 use JS;3 2 use strict; 4 3 use warnings; 4 use JS; 5 5 6 JS->new->run ;6 JS->new->run(@ARGV); trunk/src/ingy/JS/lib/JS.pm
r305 r348 5 5 use 5.005.003; 6 6 7 our $VERSION = '0.1 1';7 our $VERSION = '0.12'; 8 8 9 9 sub new { … … 14 14 sub run { 15 15 my $self = shift; 16 my @args = @_; 16 17 17 if (! @ ARGV) {18 if (! @args) { 18 19 return $self->list_all(); 19 20 } 20 for my $js_module (@ ARGV) {21 for my $js_module (@args) { 21 22 $js_module =~ s/\.js$//; 22 my $path = $self->find_js_path($js_module)23 or warn "*** Can't find $js_module\n";24 print "$path\n";23 my @path = $self->find_js_path($js_module) 24 or warn("*** Can't find $js_module\n"), next; 25 print join "\n", sort(@path), ""; 25 26 } 26 27 } … … 46 47 my $module = shift; 47 48 $module =~ s/(::|\.)/\//g; 49 $module =~ s/\*$/.*/; 48 50 $module .= '.js'; 49 51 50 52 my $found = {}; 51 my $module_path;53 my @module_path; 52 54 find { 53 55 wanted => sub { 54 56 my $path = $File::Find::name; 55 return unless $path =~ / \Q$module\E$/;57 return unless $path =~ /$module(\.gz)?$/i; 56 58 return if $found->{$path}++; 57 $module_path =$path;59 push @module_path, $path; 58 60 }, 59 61 }, grep {-d $_ and $_ ne '.'} @INC; 60 return $module_path;62 return @module_path; 61 63 } 62 64 … … 70 72 71 73 > js-cpan 74 > js-cpan Foo* 72 75 > js-cpan Foo.Bar 73 76 > ln -s `js-cpan Foo.Bar` Foo.Bar.js trunk/src/ingy/JS/t/test.t
r295 r348 1 use Test::More tests => 1; 1 # use XXX; 2 # use YAML; 3 # use YAML::Dumper; 4 use t::TestJS tests => 4; 2 5 3 pass 'No tests yet... :('; 6 filters { 7 cli => [qw(run_js eval_all join)], 8 }; 9 10 run_is cli => 'output'; 11 12 __DATA__ 13 === Basic 14 --- cli: js-cpan Foo 15 --- output 16 t/testlib/JS/Foo.js 17 18 === Wildcard 19 --- cli: js-cpan Foo* 20 --- output 21 t/testlib/JS/Foo.js 22 t/testlib/JS/Foo/Bar-min.js 23 t/testlib/JS/Foo/Bar-min.js.gz 24 t/testlib/JS/Foo/Bar-pack.js 25 t/testlib/JS/Foo/Bar.js 26 27 === Specific 28 --- cli: js-cpan Foo.Bar.js 29 --- output 30 t/testlib/JS/Foo/Bar.js 31 32 === Case Insensitivity 33 --- cli: js-cpan FoO::bAr-MiN 34 --- output 35 t/testlib/JS/Foo/Bar-min.js 36 t/testlib/JS/Foo/Bar-min.js.gz
