Changeset 348

Show
Ignore:
Timestamp:
03/10/08 17:57:49 (2 months ago)
Author:
ingy
Message:
v0.12
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/ingy/JS/Changes

    r306 r348  
     1--- 
     2version: 0.12 
     3date:    Tue Mar 11 02:50:09 EET 2008 
     4changes: 
     5- Add tests. 
     6- Add wildcarding. 
    17--- 
    28version: 0.11 
  • trunk/src/ingy/JS/MANIFEST

    r306 r348  
    3131README 
    3232t/test.t 
     33t/TestJS.pm 
     34t/testlib/JS/Foo.js 
     35t/testlib/JS/Foo.pm 
     36t/testlib/JS/Foo.pod 
     37t/testlib/JS/Foo/Bar-min.js 
     38t/testlib/JS/Foo/Bar-min.js.gz 
     39t/testlib/JS/Foo/Bar-pack.js 
     40t/testlib/JS/Foo/Bar.js 
     41t/testlib/JS/Foo/Bar.pm 
     42t/testlib/JS/Foo/Bar.pod 
  • trunk/src/ingy/JS/README

    r304 r348  
    44SYSNOPSIS 
    55        > js-cpan 
     6        > js-cpan Foo* 
    67        > js-cpan Foo.Bar 
    78        > ln -s `js-cpan Foo.Bar` Foo.Bar.js 
  • trunk/src/ingy/JS/js-cpan

    r295 r348  
    11#!/usr/bin/perl 
    2 use JS; 
    32use strict; 
    43use warnings; 
     4use JS; 
    55 
    6 JS->new->run
     6JS->new->run(@ARGV)
  • trunk/src/ingy/JS/lib/JS.pm

    r305 r348  
    55use 5.005.003; 
    66 
    7 our $VERSION = '0.11'; 
     7our $VERSION = '0.12'; 
    88 
    99sub new { 
     
    1414sub run { 
    1515    my $self = shift; 
     16    my @args = @_; 
    1617 
    17     if (! @ARGV) { 
     18    if (! @args) { 
    1819        return $self->list_all(); 
    1920    } 
    20     for my $js_module (@ARGV) { 
     21    for my $js_module (@args) { 
    2122        $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), ""; 
    2526    } 
    2627} 
     
    4647    my $module = shift; 
    4748    $module =~ s/(::|\.)/\//g; 
     49    $module =~ s/\*$/.*/; 
    4850    $module .= '.js'; 
    4951 
    5052    my $found = {}; 
    51     my $module_path; 
     53    my @module_path; 
    5254    find { 
    5355        wanted => sub { 
    5456            my $path = $File::Find::name; 
    55             return unless $path =~ /\Q$module\E$/
     57            return unless $path =~ /$module(\.gz)?$/i
    5658            return if $found->{$path}++; 
    57             $module_path = $path; 
     59            push @module_path, $path; 
    5860        }, 
    5961    }, grep {-d $_ and $_ ne '.'} @INC; 
    60     return $module_path; 
     62    return @module_path; 
    6163} 
    6264 
     
    7072 
    7173    > js-cpan 
     74    > js-cpan Foo* 
    7275    > js-cpan Foo.Bar 
    7376    > 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; 
     4use t::TestJS tests => 4; 
    25 
    3 pass 'No tests yet... :('; 
     6filters { 
     7    cli => [qw(run_js eval_all join)], 
     8}; 
     9 
     10run_is cli => 'output'; 
     11 
     12__DATA__ 
     13=== Basic 
     14--- cli: js-cpan Foo 
     15--- output 
     16t/testlib/JS/Foo.js 
     17 
     18=== Wildcard 
     19--- cli: js-cpan Foo* 
     20--- output 
     21t/testlib/JS/Foo.js 
     22t/testlib/JS/Foo/Bar-min.js 
     23t/testlib/JS/Foo/Bar-min.js.gz 
     24t/testlib/JS/Foo/Bar-pack.js 
     25t/testlib/JS/Foo/Bar.js 
     26 
     27=== Specific 
     28--- cli: js-cpan Foo.Bar.js 
     29--- output 
     30t/testlib/JS/Foo/Bar.js 
     31 
     32=== Case Insensitivity 
     33--- cli: js-cpan FoO::bAr-MiN 
     34--- output 
     35t/testlib/JS/Foo/Bar-min.js 
     36t/testlib/JS/Foo/Bar-min.js.gz