Skip to content

Commit

Permalink
deprecated Mojo::Home->slurp_rel_file in favor of Mojo::Util->slurp
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 14, 2013
1 parent 622e241 commit c2f218e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@
- Deprecated Mojo::Util->html_escape in favor of Mojo::Util->xml_escape.
- Deprecated Mojo::ByteStream->html_escape in favor of
Mojo::ByteStream->xml_escape.
- Deprecated Mojo::Home->slurp_rel_file in favor of Mojo::Util->slurp.
- Improved documentation.
- Fixed support for multi byte entities in Mojo::Util.

Expand Down
16 changes: 7 additions & 9 deletions lib/Mojo/Home.pm
Expand Up @@ -80,7 +80,13 @@ sub parse {
sub rel_dir { catdir(@{shift->{parts} || []}, split '/', shift) }
sub rel_file { catfile(@{shift->{parts} || []}, split '/', shift) }

sub slurp_rel_file { slurp shift->rel_file(@_) }
# DEPRECATED in Rainbow!
sub slurp_rel_file {
warn <<EOF;
Mojo::Home->slurp_rel_file is DEPRECATED in favor of Mojo::Util->slurp!!!
EOF
slurp shift->rel_file(@_);
}

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

Expand Down Expand Up @@ -166,14 +172,6 @@ directory.
Portably generate an absolute path for a file relative to the home directory.
=head2 slurp_rel_file
my $content = $home->slurp_rel_file('foo/bar.html');
Portably read all data at once from file relative to the home directory.
my $content = $home->slurp_rel_file($home->list_files('public')->[1]);
=head2 to_string
my $string = $home->to_string;
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -6,7 +6,7 @@ use Mojo::Cache;
use Mojo::JSON;
use Mojo::Home;
use Mojo::Loader;
use Mojo::Util 'encode';
use Mojo::Util qw(encode slurp);

has cache => sub { Mojo::Cache->new };
has classes => sub { ['main'] };
Expand All @@ -20,7 +20,7 @@ has paths => sub { [] };
my $HOME = Mojo::Home->new;
$HOME->parse(
$HOME->parse($HOME->mojo_lib_dir)->rel_dir('Mojolicious/templates'));
my %TEMPLATES = map { $_ => $HOME->slurp_rel_file($_) } @{$HOME->list_files};
my %TEMPLATES = map { $_ => slurp $HOME->rel_file($_) } @{$HOME->list_files};

sub new {
my $self = shift->SUPER::new(@_);
Expand Down
8 changes: 0 additions & 8 deletions t/mojo/home.t
Expand Up @@ -56,12 +56,4 @@ is first(sub {/Base2\.pm$/}, @{$home->list_files('lib')}),
is first(sub {/Base3\.pm$/}, @{$home->list_files('lib')}),
'Mojo/BaseTest/Base3.pm', 'right result';

# Slurp files
like $home->slurp_rel_file('lib/Mojo/BaseTest/Base1.pm'), qr/Base1/,
'right content';
like $home->slurp_rel_file('lib/Mojo/BaseTest/Base2.pm'), qr/Base2/,
'right content';
like $home->slurp_rel_file('lib/Mojo/BaseTest/Base3.pm'), qr/Base3/,
'right content';

done_testing();
2 changes: 1 addition & 1 deletion t/pod_coverage.t
Expand Up @@ -8,7 +8,7 @@ plan skip_all => 'Test::Pod::Coverage 1.04 required for this test!'
unless eval 'use Test::Pod::Coverage 1.04; 1';

# DEPRECATED in Rainbow!
my @rainbow = qw(html_escape namespace start);
my @rainbow = qw(html_escape namespace slurp_rel_file start);

# False positive constants
all_pod_coverage_ok({also_private => [@rainbow, qw(IPV6 TLS)]});

0 comments on commit c2f218e

Please sign in to comment.