ack

 view release on metacpan or  search on metacpan

ack  view on Meta::CPAN

use App::Ack::Filter ();
use App::Ack::Filter::Default ();
use App::Ack::Filter::Extension ();
use App::Ack::Filter::FirstLineMatch ();
use App::Ack::Filter::Inverse ();
use App::Ack::Filter::Is ();
use App::Ack::Filter::IsPath ();
use App::Ack::Filter::Match ();
use App::Ack::Filter::Collection ();

# Global command-line options
our $opt_1;
our $opt_A;
our $opt_B;
our $opt_break;
our $opt_color;
our $opt_column;
our $opt_debug;
our $opt_c;
our $opt_f;
our $opt_g;

lib/App/Ack/ConfigFinder.pm  view on Meta::CPAN


App::Ack::ConfigFinder

=head1 DESCRIPTION

A module that contains the logic for locating the various configuration
files.

=head1 LOCATING CONFIG FILES

First, ack looks for a global ackrc.

=over

=item On Windows, this is `ackrc` in either COMMON_APPDATA or APPDATA.
If `ackrc` is present in both directories, ack uses both files in that
order.

=item On a non-Windows OS, this is `/etc/ackrc`.

=back

t/Util.pm  view on Meta::CPAN

use Cwd ();
use File::Next ();
use File::Spec ();
use File::Temp ();
use Scalar::Util qw( tainted );
use Term::ANSIColor ();
use Test::More;

our @EXPORT = qw(
    prep_environment
    create_globals
    clean_up_globals
    touch_ackrc

    has_io_pty
    is_windows
    is_cygwin

    is_empty_array
    is_nonempty_array

    first_line_like

t/ack-group.t  view on Meta::CPAN

    plan skip_all => q{You need to install IO::Pty to run this test};
    exit(0);
}

plan tests => 8;

prep_environment();

my ($bill_, $const, $getty) = map { reslash( "t/text/$_" ) } qw( bill-of-rights.txt constitution.txt gettysburg.txt );

my @TEXT_FILES = sort map { untaint($_) } glob( 't/text/*.txt' );


NO_GROUPING: {
    my @expected = line_split( <<"HERE" );
$bill_:4:or prohibiting the free exercise thereof; or abridging the freedom of
$bill_:10:A well regulated Militia, being necessary to the security of a free State,
$const:32:Number of free Persons, including those bound to Service for a Term
$getty:23:shall have a new birth of freedom -- and that government of the people,
HERE

t/ack-m.t  view on Meta::CPAN

use Test::More tests => 2;

use lib 't';
use Util;

prep_environment();

subtest 'Basic -m' => sub {
    plan tests => 2;

    my @text = sort map { untaint($_) } glob( 't/text/[bc]*.txt' );

    my $bill_ = reslash( 't/text/bill-of-rights.txt' );
    my $const = reslash( 't/text/constitution.txt' );

    my @expected = split( /\n/, <<"HERE" );
$bill_:4:or prohibiting the free exercise thereof; or abridging the freedom of
$bill_:5:speech, or of the press; or the right of the people peaceably to assemble,
$bill_:6:and to petition the Government for a redress of grievances.
$const:3:We the People of the United States, in Order to form a more perfect
$const:4:Union, establish Justice, insure domestic Tranquility, provide for the

t/config-finder.t  view on Meta::CPAN


plan tests => 26;

# Set HOME to a known value, so we get predictable results.
local $ENV{HOME} = realpath('t/home');

# Clear the user's ACKRC so it doesn't throw out expect_ackrcs().
delete $ENV{'ACKRC'};

my $finder;
my @global_filenames = create_globals();

my @global_files = map { +{ path => $_ } } @global_filenames;
my @std_files = (@global_files, { path => File::Spec->catfile($ENV{'HOME'}, '.ackrc') });

my $wd      = getcwd_clean();
my $tempdir = File::Temp->newdir;
safe_chdir( $tempdir->dirname );

$finder = App::Ack::ConfigFinder->new;
with_home( sub {
    expect_ackrcs( \@std_files, 'having no project file should return only the top level files' );
} );

no_home( sub {
    expect_ackrcs( \@global_files, 'only system-wide ackrc is returned if HOME is not defined with no project files' );
} );

safe_mkdir( 'foo' );
safe_mkdir( File::Spec->catdir('foo', 'bar') );
safe_mkdir( File::Spec->catdir('foo', 'bar', 'baz') );
safe_chdir( File::Spec->catdir('foo', 'bar', 'baz') );

touch_ackrc( '.ackrc' );
with_home( sub {
    expect_ackrcs( [ @std_files, { project => 1, path => File::Spec->rel2abs('.ackrc') }], 'a project file in the same directory should be detected' );
} );
no_home( sub {
    expect_ackrcs( [ @global_files, { project => 1, path => File::Spec->rel2abs('.ackrc') } ], 'a project file in the same directory should be detected' );
} );

unlink '.ackrc';

my $project_file = File::Spec->catfile($tempdir->dirname, 'foo', 'bar', '.ackrc');
touch_ackrc( $project_file );
with_home( sub {
    expect_ackrcs( [ @std_files, { project => 1, path => $project_file } ], 'a project file in the parent directory should be detected' );
} );
no_home( sub {
    expect_ackrcs( [ @global_files, { project => 1, path => $project_file } ], 'a project file in the parent directory should be detected' );
} );
unlink $project_file;

$project_file = File::Spec->catfile($tempdir->dirname, 'foo', '.ackrc');
touch_ackrc( $project_file );
with_home( sub {
    expect_ackrcs( [ @std_files, { project => 1, path => $project_file } ], 'a project file in the grandparent directory should be detected' );
} );
no_home( sub {
    expect_ackrcs( [ @global_files, { project => 1, path => $project_file } ], 'a project file in the grandparent directory should be detected' );
} );

touch_ackrc( '.ackrc' );

with_home( sub {
    expect_ackrcs( [ @std_files, { project => 1, path => File::Spec->rel2abs('.ackrc') } ], 'a project file in the same directory should be detected, even with another one above it' );
} );
no_home( sub {
    expect_ackrcs( [ @global_files, { project => 1, path => File::Spec->rel2abs('.ackrc') } ], 'a project file in the same directory should be detected, even with another one above it' );
} );

unlink '.ackrc';
unlink $project_file;

touch_ackrc( '_ackrc' );
with_home( sub {
    expect_ackrcs( [ @std_files, { project => 1, path => File::Spec->rel2abs('_ackrc') } ], 'a project file in the same directory should be detected' );
} );
no_home( sub {
    expect_ackrcs( [ @global_files, { project => 1, path => File::Spec->rel2abs('_ackrc') } ], 'a project file in the same directory should be detected' );
} );

unlink '_ackrc';

$project_file = File::Spec->catfile($tempdir->dirname, 'foo', '_ackrc');
touch_ackrc( $project_file );
with_home( sub {
    expect_ackrcs( [ @std_files, { project => 1, path => $project_file } ], 'a project file in the grandparent directory should be detected' );
} );
no_home( sub {
    expect_ackrcs( [ @global_files, { project => 1, path => $project_file } ], 'a project file in the grandparent directory should be detected' );
} );

touch_ackrc( '_ackrc' );
with_home( sub { expect_ackrcs( [ @std_files, { project => 1, path => File::Spec->rel2abs('_ackrc') } ], 'a project file in the same directory should be detected, even with another one above it' );
} );
no_home( sub {
    expect_ackrcs( [ @global_files, { project => 1, path => File::Spec->rel2abs('_ackrc') } ], 'a project file in the same directory should be detected, even with another one above it' );
} );

unlink $project_file;
touch_ackrc( '.ackrc' );

do {
    my $finder_fn = sub {
        my $ok = eval { $finder->find_config_files };
        my $err = $@;
        ok( !$ok, '.ackrc + _ackrc is error' );

t/noenv.t  view on Meta::CPAN

use Test::More tests => 3;

use lib 't';
use Util;

use App::Ack::ConfigLoader;
use Cwd qw( realpath );
use File::Spec ();
use File::Temp ();

sub is_global_file {
    my ( $filename ) = @_;

    return unless -f $filename;

    my ( undef, $dir ) = File::Spec->splitpath($filename);
    $dir = File::Spec->canonpath($dir);

    my (undef, $wd) = File::Spec->splitpath(getcwd_clean(), 1);
    $wd = File::Spec->canonpath($wd);

    return $wd !~ /^\Q$dir\E/;
}

sub remove_defaults_and_globals {
    my ( @sources ) = @_;

    return grep {
        $_->{name} ne 'Defaults' && !is_global_file($_->{name})
    } @sources;
}

prep_environment();

my $wd = getcwd_clean() or die;

my $tempdir = File::Temp->newdir;

safe_chdir( $tempdir->dirname );

t/swamp/Rakefile  view on Meta::CPAN


Hoe.new(PKG_NAME, PKG_VERSION) do |p|
  p.rubyforge_name  = PKG_NAME
  p.author          = 'Aaron Patterson'
  p.email           = 'aaronp@rubyforge.org'
  p.summary         = "Mechanize provides automated web-browsing"
  p.description     = p.paragraphs_of('README.txt', 3).join("\n\n")
  p.url             = p.paragraphs_of('README.txt', 1).first.strip
  p.changes         = p.paragraphs_of('CHANGELOG.txt', 0..2).join("\n\n")
  files = 
    (p.test_globs + ['test/**/tc_*.rb',
     "test/htdocs/**/*.{html,jpg}",
     'test/data/server.*']).map { |x|
    Dir.glob(x)
  }.flatten + ['test/data/htpasswd']
  p.extra_deps      = ['hpricot']
  p.spec_extras     = { :test_files => files }
end

task :update_version do
  announce "Updating Mechanize Version to #{PKG_VERSION}"
  File.open("lib/mechanize/mech_version.rb", "w") do |f|
    f.puts "module WWW"
    f.puts "  class Mechanize"

xt/coding-standards.t  view on Meta::CPAN

# Get all the ack component files.
my @files = ( 'ack' );
my $libs = File::Next::files( { descend_filter => sub { !/\Q.git/ }, file_filter => sub { /\.pm$/ } }, 'lib' );
while ( my $file = $libs->() ) {
    push @files, $file;
}
@files == 20 or die 'I should have exactly 20 modules + ack';

# Get all the test files.
for my $spec ( 't/*.t', 'xt/*.t' ) {
    my @these_files = glob( $spec ) or die "Couldn't find any $spec";
    push( @files, @these_files );
}

@files = grep { !/lowercase.t/ } @files; # lowercase.t has hi-bit and it's OK.

plan tests => scalar @files;

for my $file ( @files ) {
    subtest $file => sub {
        plan tests => 3;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.755 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )