Skip to content

Commit

Permalink
scalar context does not need to be enforced anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 7, 2015
1 parent c39a167 commit 8deaf7e
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 22 deletions.
16 changes: 8 additions & 8 deletions lib/Mojo/Home.pm
Expand Up @@ -15,7 +15,7 @@ sub detect {
my $self = shift;

# Environment variable
return $self->parts([splitdir(abs_path $ENV{MOJO_HOME})]) if $ENV{MOJO_HOME};
return $self->parts([splitdir abs_path $ENV{MOJO_HOME}]) if $ENV{MOJO_HOME};

# Try to find home from lib directory
if (my $class = @_ ? shift : 'Mojo::HelloWorld') {
Expand All @@ -28,7 +28,7 @@ sub detect {
pop @home while @home && ($home[-1] =~ /^b?lib$/ || $home[-1] eq '');

# Turn into absolute path
return $self->parts([splitdir(abs_path(catdir(@home) || '.'))]);
return $self->parts([splitdir abs_path catdir(@home) || '.']);
}
}

Expand All @@ -44,12 +44,12 @@ sub lib_dir {
sub list_files {
my ($self, $dir) = @_;

$dir = catdir @{$self->parts}, split '/', ($dir // '');
$dir = catdir @{$self->parts}, split('/', $dir // '');
return [] unless -d $dir;
my @files;
find {
wanted => sub {
my @parts = splitdir(abs2rel($File::Find::name, $dir));
my @parts = splitdir abs2rel($File::Find::name, $dir);
push @files, join '/', @parts unless grep {/^\./} @parts;
},
no_chdir => 1
Expand All @@ -58,16 +58,16 @@ sub list_files {
return [sort @files];
}

sub mojo_lib_dir { catdir(dirname(__FILE__), '..') }
sub mojo_lib_dir { catdir dirname(__FILE__), '..' }

sub new { @_ > 1 ? shift->SUPER::new->parse(@_) : shift->SUPER::new }

sub parse { shift->parts([splitdir shift]) }

sub rel_dir { catdir(@{shift->parts}, split '/', shift) }
sub rel_file { catfile(@{shift->parts}, split '/', shift) }
sub rel_dir { catdir @{shift->parts}, split('/', shift) }
sub rel_file { catfile @{shift->parts}, split('/', shift) }

sub to_string { catdir(@{shift->parts}) }
sub to_string { catdir @{shift->parts} }

1;

Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -142,10 +142,10 @@ sub _listen {
my $options = {
address => $url->host,
backlog => $self->backlog,
reuse => scalar $query->param('reuse'),
reuse => $query->param('reuse')
};
if (my $port = $url->port) { $options->{port} = $port }
$options->{"tls_$_"} = scalar $query->param($_) for qw(ca cert ciphers key);
$options->{"tls_$_"} = $query->param($_) for qw(ca cert ciphers key);
my $verify = $query->param('verify');
$options->{tls_verify} = hex $verify if defined $verify;
delete $options->{address} if $options->{address} eq '*';
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Util.pm
Expand Up @@ -80,7 +80,7 @@ sub class_to_file {
return decamelize($class);
}

sub class_to_path { join '.', join('/', split /::|'/, shift), 'pm' }
sub class_to_path { join '.', join('/', split(/::|'/, shift)), 'pm' }

sub decamelize {
my $str = shift;
Expand Down Expand Up @@ -139,7 +139,7 @@ sub punycode_decode {
my @output;

# Consume all code points before the last delimiter
push @output, split '', $1 if $input =~ s/(.*)\x2d//s;
push @output, split('', $1) if $input =~ s/(.*)\x2d//s;

while (length $input) {
my $oldi = $i;
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojolicious/Command.pm
Expand Up @@ -53,9 +53,8 @@ sub extract_usage {

sub help { print shift->usage }

sub rel_dir { catdir(getcwd(), split '/', pop) }

sub rel_file { catfile(getcwd(), split '/', pop) }
sub rel_dir { catdir getcwd(), split('/', pop) }
sub rel_file { catfile getcwd(), split('/', pop) }

sub render_data {
my ($self, $name) = (shift, shift);
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/generate/plugin.pm
Expand Up @@ -15,7 +15,7 @@ sub run {
my $class = $name =~ /^[a-z]/ ? camelize($name) : $name;
$class = "Mojolicious::Plugin::$class";
my $app = class_to_path $class;
my $dir = join '-', split '::', $class;
my $dir = join '-', split('::', $class);
$self->render_to_rel_file('class', "$dir/lib/$app", $class, $name);

# Test
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -1093,7 +1093,7 @@ C<register> is called.
my ($self, $app) = @_;

# Append "templates" and "public" directories
my $base = catdir(dirname(__FILE__), 'AlertAssets');
my $base = catdir dirname(__FILE__), 'AlertAssets';
push @{$app->renderer->paths}, catdir($base, 'templates');
push @{$app->static->paths}, catdir($base, 'public');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Lite.pm
Expand Up @@ -13,7 +13,7 @@ sub import {
$ENV{MOJO_EXE} ||= (caller)[1];

# Reuse home directory if possible
local $ENV{MOJO_HOME} = catdir(split '/', dirname $ENV{MOJO_EXE})
local $ENV{MOJO_HOME} = catdir split('/', dirname $ENV{MOJO_EXE})
unless $ENV{MOJO_HOME};

# Initialize application class
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugin/PODRenderer.pm
Expand Up @@ -80,7 +80,7 @@ sub _perldoc {
my $c = shift;

# Find module or redirect to CPAN
my $module = join '::', split '/', scalar $c->param('module');
my $module = join '::', split('/', $c->param('module'));
my $path
= Pod::Simple::Search->new->find($module, map { $_, "$_/pods" } @INC);
return $c->redirect_to("https://metacpan.org/pod/$module")
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Renderer.pm
Expand Up @@ -199,7 +199,7 @@ sub template_path {

# Search all paths
for my $path (@{$self->paths}) {
my $file = catfile($path, split '/', $name);
my $file = catfile $path, split('/', $name);
return $file if -r $file;
}

Expand Down
3 changes: 1 addition & 2 deletions t/mojolicious/dispatch.t
Expand Up @@ -76,8 +76,7 @@ is_deeply $c->every_param('bar'), [], 'no values';
is $c->param(foo => undef)->param('foo'), undef, 'no value';
is $c->param(foo => Mojo::Upload->new(name => 'bar'))->param('foo')->name,
'bar', 'right value';
is scalar $c->param(foo => ['ba;r', 'baz'])->param('foo'), 'baz',
'right value';
is $c->param(foo => ['ba;r', 'baz'])->param('foo'), 'baz', 'right value';
is_deeply $c->every_param('foo'), ['ba;r', 'baz'], 'right values';

# Reserved stash values are hidden
Expand Down

0 comments on commit 8deaf7e

Please sign in to comment.