Permalink
Browse files

retidy

  • Loading branch information...
1 parent 3461e08 commit a73a3755854308f18007f254ac752e91b2b3a078 @jonswar committed Oct 7, 2012
View
@@ -8,8 +8,9 @@
^lib/Pod
^release
^t/make
+^tidyall\.ini
^tmp
-^weaver.ini
+^weaver\.ini
^NOTES
^TODO
@@ -12,19 +12,17 @@ sub weave_section {
for ( my $i = 0 ; $i < $idc->length ; $i++ ) {
next unless my $para = $idc->[$i];
return
- if $para->can('command')
- && $para->command eq 'head1'
- && $para->content eq 'SEE ALSO';
+ if $para->can('command')
+ && $para->command eq 'head1'
+ && $para->content eq 'SEE ALSO';
}
$document->children->push(
Pod::Elemental::Element::Nested->new(
{
command => 'head1',
content => 'SEE ALSO',
children => [
- Pod::Elemental::Element::Pod5::Ordinary->new(
- { content => "L<Poet|Poet>" }
- ),
+ Pod::Elemental::Element::Pod5::Ordinary->new( { content => "L<Poet|Poet>" } ),
],
}
),
@@ -8,8 +8,7 @@ has 'app_name' => ( isa => 'Poet::Types::AppName', is => 'rw', traits => [ 'NoGe
has 'dir' => ( isa => 'Str', traits => ['Getopt'], cmd_aliases => 'd', lazy_build => 1, documentation => 'Directory to create; will adapt from app-name if ommitted' );
has 'quiet' => ( isa => 'Bool', traits => ['Getopt'], cmd_aliases => 'q', documentation => 'Suppress most messages' );
-my $description =
- 'Generates a new Poet environment for an app with the provided name, which
+my $description = 'Generates a new Poet environment for an app with the provided name, which
should be suitable for use in Perl classnames (e.g. "MyFirstApp"). If not
provided, a directory is chosen by lowercasing and underscoring the app
name.
View
@@ -7,8 +7,7 @@ extends 'CHI';
method initialize_caching () {
my $default_config =
- { defaults => { driver => 'File', root_dir => $poet->data_path("cache") }
- };
+ { defaults => { driver => 'File', root_dir => $poet->data_path("cache") } };
my $config = $conf->get_hash( 'cache' => $default_config );
__PACKAGE__->config($config);
}
View
@@ -144,10 +144,8 @@ method merge_conf_data ($current_data, $new_data, $file) {
}
$assign_to_hash = $assign_to_hash->{$first};
if ( ref($assign_to_hash) ne 'HASH' ) {
- die sprintf(
- "error assigning to '%s' in '%s'; '%s' already has non-hash value",
- $orig_key, $file,
- substr( $orig_key, 0, -1 * length($rest) - 1 ) );
+ die sprintf( "error assigning to '%s' in '%s'; '%s' already has non-hash value",
+ $orig_key, $file, substr( $orig_key, 0, -1 * length($rest) - 1 ) );
}
$key = $rest;
}
@@ -209,9 +207,8 @@ method get_list ($key, $default) {
return $value;
}
else {
- my $error = sprintf(
- "list value expected for conf key '%s', got non-list '%s'",
- $key, $value );
+ my $error =
+ sprintf( "list value expected for conf key '%s', got non-list '%s'", $key, $value );
croak($error);
}
}
@@ -229,9 +226,8 @@ method get_hash ($key, $default) {
return $value;
}
else {
- my $error = sprintf(
- "hash value expected for conf key '%s', got non-hash '%s'",
- $key, $value );
+ my $error =
+ sprintf( "hash value expected for conf key '%s', got non-hash '%s'", $key, $value );
croak($error);
}
}
@@ -249,11 +245,7 @@ method get_boolean ($key) {
( !ref($value) && $value =~ /^(1|t|true|y|yes)$/i ) ? 1
: ( !ref($value) && $value =~ /^(0|f|false|n|no)$/i ) ? 0
: croak(
- sprintf(
- "boolean value expected for conf key '%s', got non-boolean '%s'",
- $key, $value
- )
- );
+ sprintf( "boolean value expected for conf key '%s', got non-boolean '%s'", $key, $value ) );
}
method set_local ($pairs) {
@@ -286,8 +278,8 @@ method get_secure ($key) {
method _get_secure_conf () {
if ( !$secure_confs{"$self"} ) {
- my $secure_conf_file = $self->get(
- 'conf.secure_conf_file' => $self->conf_dir . "/secure.cfg" );
+ my $secure_conf_file =
+ $self->get( 'conf.secure_conf_file' => $self->conf_dir . "/secure.cfg" );
$secure_confs{"$self"} =
( -f $secure_conf_file )
? $self->read_conf_file($secure_conf_file)
View
@@ -20,7 +20,7 @@ method app_class ($class_name) {
return
can_load($app_class_name) ? $app_class_name
: can_load($env_class_name) ? $env_class_name
- : die "cannot load $app_class_name or $class_name";
+ : die "cannot load $app_class_name or $class_name";
}
method generate_subdir_methods ($class:) {
@@ -42,8 +42,7 @@ method generate_subdir_methods ($class:) {
method initialize_current_environment ($class: %params) {
if ( defined($current_env) ) {
- die sprintf(
- "initialize_current_environment called when current_env already set (%s)",
+ die sprintf( "initialize_current_environment called when current_env already set (%s)",
$current_env->root_dir() );
}
$current_env = $params{env} || $class->new(%params);
@@ -19,12 +19,10 @@ method generate_environment_directory ($class: %params) {
die "invalid app_name '$app_name' - must be a valid Perl identifier"
unless $app_name =~ qr/[[:alpha:]_]\w*/;
- die
- "cannot generate environment in $root_dir - directory exists and is non-empty"
+ die "cannot generate environment in $root_dir - directory exists and is non-empty"
if ( -d $root_dir && @{ read_dir($root_dir) } );
- my $share_dir =
- realpath( $ENV{POET_SHARE_DIR} || File::ShareDir::dist_dir('Poet') );
+ my $share_dir = realpath( $ENV{POET_SHARE_DIR} || File::ShareDir::dist_dir('Poet') );
die "cannot find Poet share dir '$share_dir'" unless -d $share_dir;
my $comp_root = "$share_dir/generate.skel";
my $interp = Mason->new(
View
@@ -48,11 +48,8 @@ method export_var_to_level ($var, $level) {
*{ $caller . "\::$var" } = \$value;
}
else {
- croak sprintf(
- "unknown import var '\$$var': valid import vars are %s",
- join( ", ",
- map { "'\$$_'" } grep { $_ ne 'env' } @{ $self->valid_vars } )
- );
+ croak sprintf( "unknown import var '\$$var': valid import vars are %s",
+ join( ", ", map { "'\$$_'" } grep { $_ ne 'env' } @{ $self->valid_vars } ) );
}
}
View
@@ -68,8 +68,7 @@ method generate_log4perl_config ($class:) {
"\n",
$class->_generate_lines( 'log4perl.logger', 'default', \%defaults ),
map {
- $class->_generate_lines( "log4perl.logger.$_",
- $class->_flatten_class_name($_),
+ $class->_generate_lines( "log4perl.logger.$_", $class->_flatten_class_name($_),
$classes{$_} )
} sort( keys(%classes) ),
);
@@ -78,9 +77,9 @@ method generate_log4perl_config ($class:) {
method _generate_lines ($class: $logger, $appender, $set) {
my $full_appender = "log4perl.appender.$appender";
my @pairs = (
- [ $logger => join( ", ", uc( $set->{level} ), $appender ) ],
- [ $full_appender => $set->{appender_class} ],
- [ "$full_appender.layout" => 'Log::Log4perl::Layout::PatternLayout' ],
+ [ $logger => join( ", ", uc( $set->{level} ), $appender ) ],
+ [ $full_appender => $set->{appender_class} ],
+ [ "$full_appender.layout" => 'Log::Log4perl::Layout::PatternLayout' ],
[ "$full_appender.layout.ConversionPattern" => $set->{layout} ]
);
foreach my $key (qw(filename stderr)) {
View
@@ -59,11 +59,9 @@ method temp_env_dir ($class:) {
}
method share_dir () {
- my $dist_root =
- dirname( dirname( dirname( dirname( realpath(__FILE__) ) ) ) );
+ my $dist_root = dirname( dirname( dirname( dirname( realpath(__FILE__) ) ) ) );
my ($share_dir) =
- grep { -d $_ }
- ( "$dist_root/share", "$dist_root/lib/auto/share/dist/Poet" );
+ grep { -d $_ } ( "$dist_root/share", "$dist_root/lib/auto/share/dist/Poet" );
return $share_dir;
}
View
@@ -154,8 +154,7 @@ sub write_file {
#
{
my $write_fh;
- unless ( sysopen( $write_fh, $file, $Store_Flags, $file_create_mode ) )
- {
+ unless ( sysopen( $write_fh, $file, $Store_Flags, $file_create_mode ) ) {
croak "write_file '$file' - sysopen: $!";
}
my $size_left = length($data);
View
@@ -15,11 +15,10 @@ sub _dump_value_with_caller {
my ( $value, $func_name ) = @_;
my $dump =
- Data::Dumper->new( [$value] )->Indent(1)->Sortkeys(1)->Quotekeys(0)
- ->Terse(1)->Dump();
+ Data::Dumper->new( [$value] )->Indent(1)->Sortkeys(1)->Quotekeys(0)->Terse(1)->Dump();
my @caller = caller(1);
- return sprintf( "[%s at %s line %d.] [%d] %s\n",
- $func_name, $caller[1], $caller[2], $$, $dump );
+ return
+ sprintf( "[%s at %s line %d.] [%d] %s\n", $func_name, $caller[1], $caller[2], $$, $dump );
}
sub _define {
@@ -49,8 +48,7 @@ sub _define {
_define(
'dc',
sub {
- $console_log ||=
- Poet::Environment->current_env->logs_path("console.log");
+ $console_log ||= Poet::Environment->current_env->logs_path("console.log");
open( my $fh, ">>", $console_log );
$fh->print( $_[0] );
}
View
@@ -10,10 +10,9 @@ use base qw(Exporter);
File::Path->import( @File::Path::EXPORT, @File::Path::EXPORT_OK );
-our @EXPORT_OK = uniq(
- qw(abs2rel basename canonpath catdir catfile dirname read_file rel2abs write_file),
- @File::Path::EXPORT, @File::Path::EXPORT_OK
-);
+our @EXPORT_OK =
+ uniq( qw(abs2rel basename canonpath catdir catfile dirname read_file rel2abs write_file),
+ @File::Path::EXPORT, @File::Path::EXPORT_OK );
our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
1;
View
@@ -9,8 +9,7 @@ use base qw(Exporter);
our @EXPORT_OK = qw(html_escape js_escape make_uri uri_escape uri_unescape);
our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
-my %html_escape =
- ( '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' );
+my %html_escape = ( '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' );
my $html_escape = qr/([&<>"])/;
# Stolen from Javascript::Value::Escape
@@ -28,8 +27,7 @@ my %js_escape = (
"\x{2028}" => 'u2028',
"\x{2029}" => 'u2029',
);
-map { $js_escape{ pack( 'U', $_ ) } = sprintf( "u%04d", $_ ) }
- ( 0x00 .. 0x1f, 0x7f );
+map { $js_escape{ pack( 'U', $_ ) } = sprintf( "u%04d", $_ ) } ( 0x00 .. 0x1f, 0x7f );
sub html_escape {
my $text = $_[0];
@@ -39,8 +37,7 @@ sub html_escape {
sub js_escape {
my $text = shift;
- $text =~
- s!([\\"'<>&=\-;\+\x00-\x1f\x7f]|\x{2028}|\x{2029})!\\$js_escape{$1}!g;
+ $text =~ s!([\\"'<>&=\-;\+\x00-\x1f\x7f]|\x{2028}|\x{2029})!\\$js_escape{$1}!g;
return $text;
}
View
@@ -30,18 +30,16 @@ sub test_global : Tests {
my $poet = $self->temp_env( conf_files => $conf_files );
my $conf = $poet->conf();
while ( my ( $key, $value ) = each(%$expected_values) ) {
- is( $conf->get($key), $value,
- "$key = " . ( defined($value) ? $value : 'undef' ) );
+ is( $conf->get($key), $value, "$key = " . ( defined($value) ? $value : 'undef' ) );
}
}
sub test_duplicate : Tests {
my $self = shift;
throws_ok(
sub {
- $self->temp_env( conf_files =>
- { %$conf_files, 'global/fourth.cfg' => { j => 71, c => 72 } }
- );
+ $self->temp_env(
+ conf_files => { %$conf_files, 'global/fourth.cfg' => { j => 71, c => 72 } } );
},
qr/key 'c' defined in both '.*(first|fourth)\.cfg' and '.*(first|fourth)\.cfg'/,
'cannot define same key in multiple global config files'
@@ -50,8 +48,7 @@ sub test_duplicate : Tests {
sub test_set_local : Tests {
my $self = shift;
- my $poet = $self->temp_env(
- conf_files => { 'global/foo.cfg' => { a => 5, b => 6, c => 7 } } );
+ my $poet = $self->temp_env( conf_files => { 'global/foo.cfg' => { a => 5, b => 6, c => 7 } } );
my $conf = $poet->conf();
is( $conf->get('a'), 5, 'a = 5' );
@@ -123,8 +120,7 @@ e:
$check_expected->('initial');
throws_ok( sub { $conf->get('a.b.c.z') },
- qr/hash value expected for conf key 'a.b.c', got non-hash '6'/,
- "a.b.c.z" );
+ qr/hash value expected for conf key 'a.b.c', got non-hash '6'/, "a.b.c.z" );
$conf_files->{'layer/personal.cfg'} = { 'a' => { 'b' => 17 } };
throws_ok(
@@ -165,11 +161,7 @@ sub test_types : Tests {
foreach my $key (qw(scalar hash)) {
throws_ok( sub { $conf->get_list($key) }, qr/list value expected/ );
}
- cmp_deeply(
- $conf->get_hash('hash'),
- { size => 'large', flavor => 'chocolate' },
- 'hash ok'
- );
+ cmp_deeply( $conf->get_hash('hash'), { size => 'large', flavor => 'chocolate' }, 'hash ok' );
foreach my $key (qw(scalar list)) {
throws_ok( sub { $conf->get_hash($key) }, qr/hash value expected/ );
}
@@ -178,8 +170,7 @@ sub test_types : Tests {
is( $conf->get_boolean("falsity.$key"), 0, "$key = false" );
}
foreach my $key (qw(scalar list hash)) {
- throws_ok( sub { $conf->get_boolean($key) },
- qr/boolean value expected/ );
+ throws_ok( sub { $conf->get_boolean($key) }, qr/boolean value expected/ );
}
}
@@ -205,8 +196,7 @@ sub test_interpolation : Tests {
);
my $conf = $poet->conf();
is( $conf->get('c'), '/foo/bar/baz', 'substitution' );
- throws_ok { $conf->get('d') } qr/could not get conf for 'huh'/,
- 'bad substitution';
+ throws_ok { $conf->get('d') } qr/could not get conf for 'huh'/, 'bad substitution';
cmp_deeply(
$conf->get('deep'),
{
@@ -222,19 +212,12 @@ sub test_dynamic_conf : Tests {
my $self = shift;
my $poet = $self->temp_env();
write_file( $poet->conf_path("dynamic/foo.mc"), "<% 2+2 %>" );
- ok(
- !-d $poet->data_path("conf/dynamic"),
- "data/conf/dynamic does not exist"
- );
+ ok( !-d $poet->data_path("conf/dynamic"), "data/conf/dynamic does not exist" );
run( $poet->conf_path("dynamic/gen.pl") );
ok( -d $poet->data_path("conf/dynamic"), "data/conf/dynamic exists" );
ok( -f $poet->data_path("conf/dynamic/foo"), "conf/dynamic/foo exists" );
- is( read_file( $poet->data_path("conf/dynamic/foo") ),
- 4, "foo has correct content" );
- ok(
- !-f $poet->data_path("conf/dynamic/gen.pl"),
- "conf/dynamic/gen.pl does not exist"
- );
+ is( read_file( $poet->data_path("conf/dynamic/foo") ), 4, "foo has correct content" );
+ ok( !-f $poet->data_path("conf/dynamic/gen.pl"), "conf/dynamic/gen.pl does not exist" );
}
sub test_get_secure : Tests {
View
@@ -19,8 +19,7 @@ sub test_log_config : Tests {
is( $log_conf, $expected, encode_json($conf_settings) );
};
- my $default_layout =
- "%d{dd/MMM/yyyy:HH:mm:ss.SS} [%p] %c - %m - %F:%L - %P%n";
+ my $default_layout = "%d{dd/MMM/yyyy:HH:mm:ss.SS} [%p] %c - %m - %F:%L - %P%n";
rmtree($_) for ( $logs_dir, $other_dir );
$test->(
@@ -53,8 +52,7 @@ log4perl.appender.default.filename = $logs_dir/foo.log
log => {
'defaults' => { level => 'info', output => 'foo.log' },
'class' => {
- 'Bar' =>
- { level => 'warn', output => "$other_dir/bar.log" },
+ 'Bar' => { level => 'warn', output => "$other_dir/bar.log" },
'Bar.Errors' => { output => 'stderr' },
'Bar.NonErrors' => { output => 'stdout' },
}
Oops, something went wrong.

0 comments on commit a73a375

Please sign in to comment.