Skip to content

Commit

Permalink
removed a few deprecated functions and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 11, 2013
1 parent 0772343 commit 93179b2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 49 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,6 +1,8 @@

3.95 2013-04-11
- Added finished_ok method to Test::Mojo.
- Removed deprecated slurp_rel_file method from Mojo::Home.
- Removed deprecated html_escape function from Mojo::Util.
- Improved Mojo::Transaction::WebSocket with support for status codes.
- Improved documentation. (jberger, sri)
- Improved tests.
Expand Down
1 change: 0 additions & 1 deletion lib/Mojo/ByteStream.pm
Expand Up @@ -15,7 +15,6 @@ my @UTILS = (
qw(sha1_bytes sha1_sum slurp spurt squish trim unquote url_escape),
qw(url_unescape xml_escape xor_encode)
);
push @UTILS, 'html_escape'; # DEPRECATED in Rainbow!
for my $name (@UTILS) {
my $sub = Mojo::Util->can($name);
Mojo::Util::monkey_patch __PACKAGE__, $name, sub {
Expand Down
9 changes: 1 addition & 8 deletions lib/Mojo/Home.pm
Expand Up @@ -10,7 +10,7 @@ use File::Basename 'dirname';
use File::Find 'find';
use File::Spec::Functions qw(abs2rel catdir catfile splitdir);
use FindBin;
use Mojo::Util qw(class_to_path deprecated slurp);
use Mojo::Util qw(class_to_path slurp);

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

Expand Down Expand Up @@ -80,13 +80,6 @@ sub parse {
sub rel_dir { catdir(@{shift->{parts} || []}, split '/', shift) }
sub rel_file { catfile(@{shift->{parts} || []}, split '/', shift) }

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

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

1;
Expand Down
25 changes: 0 additions & 25 deletions lib/Mojo/Util.pm
Expand Up @@ -33,12 +33,6 @@ for my $line (split "\x0a", slurp(catfile dirname(__FILE__), 'entities.txt')) {
$ENTITIES{$1} = defined $3 ? (chr(hex $2) . chr(hex $3)) : chr(hex $2);
}

# DEPRECATED in Rainbow!
my %REVERSE = ("\x{0027}" => '#39;');
$REVERSE{$ENTITIES{$_}} //= $_
for sort { @{[$a =~ /[A-Z]/g]} <=> @{[$b =~ /[A-Z]/g]} }
sort grep {/;/} keys %ENTITIES;

# Encoding cache
my %CACHE;

Expand All @@ -51,9 +45,6 @@ our @EXPORT_OK = (
qw(xor_encode)
);

# DEPRECATED in Rainbow!
push @EXPORT_OK, 'html_escape';

sub b64_decode { decode_base64($_[0]) }

sub b64_encode { encode_base64($_[0], $_[1]) }
Expand Down Expand Up @@ -123,17 +114,6 @@ sub get_line {
sub hmac_md5_sum { _hmac(\&md5, @_) }
sub hmac_sha1_sum { _hmac(\&sha1, @_) }
# DEPRECATED in Rainbow!
sub html_escape {
deprecated 'Mojo::Util::html_escape is DEPRECATED in favor of '
. 'Mojo::Util::xml_escape';
my ($string, $pattern) = @_;
$pattern ||= '^\n\r\t !#$%(-;=?-~';
return $string unless $string =~ /[^$pattern]/;
$string =~ s/([$pattern])/_encode($1)/ge;
return $string;
}

sub html_unescape {
my $string = shift;
$string
Expand Down Expand Up @@ -385,11 +365,6 @@ sub _decode {
return "&$_[1]";
}

# DEPRECATED in Rainbow!
sub _encode {
return exists $REVERSE{$_[0]} ? "&$REVERSE{$_[0]}" : "&#@{[ord($_[0])]};";
}

sub _encoding {
$CACHE{$_[0]} //= find_encoding($_[0]) // croak "Unknown encoding '$_[0]'";
}
Expand Down
17 changes: 4 additions & 13 deletions lib/Test/Mojo.pm
Expand Up @@ -205,7 +205,7 @@ sub message_like {

sub message_ok {
my ($self, $desc) = @_;
return $self->_test('ok', !!$self->_wait(1), $desc, 'message received');
return $self->_test('ok', !!$self->_wait, $desc, 'message received');
}

sub message_unlike {
Expand Down Expand Up @@ -332,13 +332,13 @@ sub _get_content {
sub _json {
my ($self, $method, $p) = @_;
return Mojo::JSON::Pointer->new->$method(
Mojo::JSON->new->decode(@{$self->_wait || []}[1]), $p);
Mojo::JSON->new->decode(@{$self->message}[1]), $p);
}

sub _message {
my ($self, $name, $value, $desc) = @_;
local $Test::Builder::Level = $Test::Builder::Level + 1;
my ($type, $msg) = @{$self->_wait || ['']};
my ($type, $msg) = @{$self->message};

# Type check
if (ref $value eq 'HASH') {
Expand Down Expand Up @@ -377,16 +377,7 @@ sub _text {
}

sub _wait {
my ($self, $wait) = @_;

# DEPRECATED in Rainbow!
my $new = $self->{new} //= $wait;
deprecated
'Testing WebSocket messages without Test::Mojo::message_ok is DEPRECATED'
unless $new;
return $self->message if $new && !$wait;

# Wait for message
my $self = shift;
Mojo::IOLoop->one_tick while !$self->{finished} && !@{$self->{messages}};
return $self->message(shift @{$self->{messages}})->message;
}
Expand Down
4 changes: 2 additions & 2 deletions t/pod_coverage.t
Expand Up @@ -9,8 +9,8 @@ plan skip_all => 'Test::Pod::Coverage 1.04 required for this test!'

# DEPRECATED in Rainbow!
my @rainbow = (
qw(build_form_tx build_json_tx end form html_escape json post_form),
qw(post_form_ok post_json post_json_ok slurp_rel_file)
qw(build_form_tx build_json_tx end form json post_form post_form_ok),
qw(post_json post_json_ok)
);

# False positive constants
Expand Down

0 comments on commit 93179b2

Please sign in to comment.