Skip to content

Commit

Permalink
removed class_to_file and class_to_path from Mojo::ByteStream again
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 23, 2012
1 parent acd645f commit 3099d86
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
20 changes: 4 additions & 16 deletions lib/Mojo/ByteStream.pm
Expand Up @@ -9,10 +9,10 @@ our @EXPORT_OK = ('b');

# Turn most functions from Mojo::Util into methods
my @UTILS = (
qw(b64_decode b64_encode camelize class_to_file class_to_path decamelize),
qw(hmac_md5_sum hmac_sha1_sum html_escape html_unescape md5_bytes md5_sum),
qw(punycode_decode punycode_encode qp_decode qp_encode quote sha1_bytes),
qw(sha1_sum trim unquote url_escape url_unescape xml_escape)
qw(b64_decode b64_encode camelize decamelize hmac_md5_sum hmac_sha1_sum),
qw(html_escape html_unescape md5_bytes md5_sum punycode_decode),
qw(punycode_encode qp_decode qp_encode quote sha1_bytes sha1_sum trim),
qw(unquote url_escape url_unescape xml_escape)
);
{
no strict 'refs';
Expand Down Expand Up @@ -149,18 +149,6 @@ Alias for L<Mojo::Util/"b64_encode">.
Alias for L<Mojo::Util/"camelize">.
=head2 C<class_to_file>
$stream = $stream->class_to_file;
Alias for L<Mojo::Util/"class_to_file">.
=head2 C<class_to_path>
$stream = $stream->class_to_path;
Alias for L<Mojo::Util/"class_to_path">.
=head2 C<clone>
my $stream2 = $stream->clone;
Expand Down
7 changes: 3 additions & 4 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -100,9 +100,6 @@ sub peer {
return $self->_proxy($tx, $self->endpoint($tx));
}

# "America's health care system is second only to Japan...
# Canada, Sweden, Great Britain... well, all of Europe.
# But you can thank your lucky stars we don't live in Paraguay!"
sub proxy_connect {
my ($self, $old) = @_;

Expand Down Expand Up @@ -152,7 +149,9 @@ sub redirect {
return $new->previous($old);
}

# "If he is so smart, how come he is dead?"
# "America's health care system is second only to Japan...
# Canada, Sweden, Great Britain... well, all of Europe.
# But you can thank your lucky stars we don't live in Paraguay!"
sub tx {
my $self = shift;

Expand Down
19 changes: 1 addition & 18 deletions t/mojo/bytestream.t
Expand Up @@ -5,7 +5,7 @@ use utf8;
# "Homer, we're going to ask you a few simple yes or no questions.
# Do you understand?
# Yes. *lie dectector blows up*"
use Test::More tests => 159;
use Test::More tests => 146;

# Need to be loaded first to trigger edge case
use MIME::Base64;
Expand Down Expand Up @@ -48,23 +48,6 @@ is $stream->decamelize, $result, 'right decamelized result';
isnt "$stream", $original, 'decamelized result is different';
is $stream->camelize, $original, 'successful roundtrip again';

# class_to_file
is b('Foo::Bar')->class_to_file, 'foo_bar', 'right file';
is b('FooBar')->class_to_file, 'foo_bar', 'right file';
is b('FOOBar')->class_to_file, 'foobar', 'right file';
is b('FOOBAR')->class_to_file, 'foobar', 'right file';
is b('FOO::Bar')->class_to_file, 'foobar', 'right file';
is b('FooBAR')->class_to_file, 'foo_bar', 'right file';
is b('Foo::BAR')->class_to_file, 'foo_bar', 'right file';

# class_to_path
is b('Foo::Bar')->class_to_path, 'Foo/Bar.pm', 'right path';
is b("Foo'Bar")->class_to_path, 'Foo/Bar.pm', 'right path';
is b("Foo'Bar::Baz")->class_to_path, 'Foo/Bar/Baz.pm', 'right path';
is b("Foo::Bar'Baz")->class_to_path, 'Foo/Bar/Baz.pm', 'right path';
is b("Foo::Bar::Baz")->class_to_path, 'Foo/Bar/Baz.pm', 'right path';
is b("Foo'Bar'Baz")->class_to_path, 'Foo/Bar/Baz.pm', 'right path';

# b64_encode
$stream = b('foobar$%^&3217');
is $stream->b64_encode, "Zm9vYmFyJCVeJjMyMTc=\n",
Expand Down
33 changes: 33 additions & 0 deletions t/mojo/util.t
@@ -0,0 +1,33 @@
use Mojo::Base -strict;

use Test::More tests => 20;

# "If he is so smart, how come he is dead?"
use Mojo::Util qw(class_to_file class_to_path get_line);

# class_to_file
is class_to_file('Foo::Bar'), 'foo_bar', 'right file';
is class_to_file('FooBar'), 'foo_bar', 'right file';
is class_to_file('FOOBar'), 'foobar', 'right file';
is class_to_file('FOOBAR'), 'foobar', 'right file';
is class_to_file('FOO::Bar'), 'foobar', 'right file';
is class_to_file('FooBAR'), 'foo_bar', 'right file';
is class_to_file('Foo::BAR'), 'foo_bar', 'right file';

# class_to_path
is class_to_path('Foo::Bar'), 'Foo/Bar.pm', 'right path';
is class_to_path("Foo'Bar"), 'Foo/Bar.pm', 'right path';
is class_to_path("Foo'Bar::Baz"), 'Foo/Bar/Baz.pm', 'right path';
is class_to_path("Foo::Bar'Baz"), 'Foo/Bar/Baz.pm', 'right path';
is class_to_path("Foo::Bar::Baz"), 'Foo/Bar/Baz.pm', 'right path';
is class_to_path("Foo'Bar'Baz"), 'Foo/Bar/Baz.pm', 'right path';

# get_line
my $buffer = "foo\x0d\x0abar\x0dbaz\x0ayada\x0d\x0a";
is get_line(\$buffer), 'foo', 'right line';
is $buffer, "bar\x0dbaz\x0ayada\x0d\x0a", 'right buffer content';
is get_line(\$buffer), "bar\x0dbaz", 'right line';
is $buffer, "yada\x0d\x0a", 'right buffer content';
is get_line(\$buffer), 'yada', 'right line';
is $buffer, '', 'no buffer content';
is get_line(\$buffer), undef, 'no line';

0 comments on commit 3099d86

Please sign in to comment.