Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

s/to_string/as_string/ to better match the HTTP::* classes

  • Loading branch information...
commit 372d023d0a15f48cc4e4fd08bb1d404e02fc6899 1 parent 580346a
Stevan Little authored
View
6 lib/HTTP/Headers/ActionPack/Core/Base.pm
@@ -4,7 +4,7 @@ package HTTP::Headers::ActionPack::Core::Base;
use strict;
use warnings;
-use overload '""' => 'to_string', fallback => 1;
+use overload '""' => 'as_string', fallback => 1;
sub new {
my $class = shift;
@@ -22,7 +22,7 @@ sub CREATE {
sub BUILD {}
-sub to_string {
+sub as_string {
my $self = shift;
"$self"
}
@@ -49,7 +49,7 @@ There is no real user servicable parts in here.
=item C<BUILD>
-=item C<to_string>
+=item C<as_string>
=back
View
6 lib/HTTP/Headers/ActionPack/Core/BaseHeaderList.pm
@@ -18,9 +18,9 @@ sub new_from_string {
$list;
}
-sub to_string {
+sub as_string {
my $self = shift;
- join ', ' => map { blessed $_ ? $_->to_string : $_ } $self->iterable;
+ join ', ' => map { blessed $_ ? $_->as_string : $_ } $self->iterable;
}
sub add { die "Abstract method" }
@@ -47,7 +47,7 @@ user servicable parts in here.
This accepts a HTTP header string which get parsed
and loaded accordingly.
-=item C<to_string>
+=item C<as_string>
=back
View
4 lib/HTTP/Headers/ActionPack/Core/BaseHeaderType.pm
@@ -41,7 +41,7 @@ sub new_from_string {
$class->new( @{ (split_header_words( $header_string ))[0] } );
}
-sub to_string {
+sub as_string {
my $self = shift;
join_header_words( $self->subject, $self->params_in_order );
}
@@ -99,7 +99,7 @@ Accessor for the unordered hash-ref of params.
This will take an HTTP header string
and parse it into and object.
-=item C<to_string>
+=item C<as_string>
This stringifys the link respecting the
parameter order.
View
4 lib/HTTP/Headers/ActionPack/DateHeader.pm
@@ -21,7 +21,7 @@ sub new_from_string {
$class->new( header_to_date( $header_string ) );
}
-sub to_string { date_to_header( (shift)->{'date'} ) }
+sub as_string { date_to_header( (shift)->{'date'} ) }
# implement a simple API
sub second { (shift)->{'date'}->second }
@@ -76,7 +76,7 @@ Returns the underlying L<Time::Piece> object.
This will take an HTTP header Date string
and parse it into and object.
-=item C<to_string>
+=item C<as_string>
=item C<second>
View
4 lib/HTTP/Headers/ActionPack/Link.pm
@@ -53,7 +53,7 @@ sub relation_matches {
}
}
-sub to_string {
+sub as_string {
my $self = shift;
my @params;
@@ -123,7 +123,7 @@ object.
This will take an HTTP header Link string
and parse it into and object.
-=item C<to_string>
+=item C<as_string>
This stringifys the link respecting the
parameter order.
View
4 lib/HTTP/Headers/ActionPack/MediaTypeList.pm
@@ -28,9 +28,9 @@ sub add_header_value {
$self->add( $q, $mt );
}
-sub to_string {
+sub as_string {
my $self = shift;
- join ', ' => map { $_->[1]->to_string } $self->iterable;
+ join ', ' => map { $_->[1]->as_string } $self->iterable;
}
sub iterable {
View
2  lib/HTTP/Headers/ActionPack/PriorityList.pm
@@ -32,7 +32,7 @@ sub new_from_string {
$list;
}
-sub to_string {
+sub as_string {
my $self = shift;
join ', ' => map {
my ($q, $subject) = @{ $_ };
View
4 t/001-basic.t
@@ -16,11 +16,11 @@ isa_ok($pack, 'HTTP::Headers::ActionPack');
my $media_type = $pack->create( 'Content-Type' => 'application/xml;charset=UTF-8' );
isa_ok($media_type, 'HTTP::Headers::ActionPack::MediaType');
-is($media_type->to_string, 'application/xml; charset="UTF-8"', '... got the right string');
+is($media_type->as_string, 'application/xml; charset="UTF-8"', '... got the right string');
my $links = $pack->create( 'Link' => '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"');
isa_ok($links, 'HTTP::Headers::ActionPack::LinkList');
-is($links->to_string, '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"', '... got the right string');
+is($links->as_string, '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"', '... got the right string');
done_testing;
View
18 t/010-media-type.t
@@ -25,11 +25,11 @@ sub test_media_type {
is($media_type->major, 'application', '... got the right major portion');
is($media_type->minor, 'xml', '... got the right minor portion');
- is($media_type->to_string, 'application/xml; charset="UTF-8"', '... the string representation');
+ is($media_type->as_string, 'application/xml; charset="UTF-8"', '... the string representation');
my $media_type_2 = HTTP::Headers::ActionPack::MediaType->new('application/xml', => ( 'charset' => 'UTF-8' ));
isa_ok($media_type_2, 'HTTP::Headers::ActionPack::MediaType');
- is($media_type_2->to_string, 'application/xml; charset="UTF-8"', '... the string representation');
+ is($media_type_2->as_string, 'application/xml; charset="UTF-8"', '... the string representation');
ok($media_type->equals( $media_type_2 ), '... these types are equal');
ok($media_type->equals('application/xml; charset=UTF-8'), '... these types are equal');
@@ -70,7 +70,7 @@ test_media_type(
'... got the right params'
);
- is($matches_all->to_string, '*/*', '... the string representation');
+ is($matches_all->as_string, '*/*', '... the string representation');
ok($matches_all->matches_all, '... this type does match all');
}
@@ -86,7 +86,7 @@ boundary=----------------------------2c46a7bec2b9]);
'... got the right params'
);
- is($multiline->to_string, 'multipart/form-data; boundary="----------------------------2c46a7bec2b9"', '... the string representation');
+ is($multiline->as_string, 'multipart/form-data; boundary="----------------------------2c46a7bec2b9"', '... the string representation');
}
# test multiple params ...
@@ -100,7 +100,7 @@ boundary=----------------------------2c46a7bec2b9]);
'... got the right params'
);
- is($mt->to_string, 'application/json; v="3"; foo="bar"', '... got the right string representation');
+ is($mt->as_string, 'application/json; v="3"; foo="bar"', '... got the right string representation');
}
# test a lot of params ...
@@ -114,7 +114,7 @@ boundary=----------------------------2c46a7bec2b9]);
'... got the right params'
);
- is($mt->to_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="123"', '... got the right string representation');
+ is($mt->as_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="123"', '... got the right string representation');
}
# test with quoted strings
@@ -128,7 +128,7 @@ boundary=----------------------------2c46a7bec2b9]);
'... got the right params'
);
- is($mt->to_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="1,23"', '... got the right string representation');
+ is($mt->as_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="1,23"', '... got the right string representation');
}
{
my $mt = HTTP::Headers::ActionPack::MediaType->new_from_string('application/json; v=3; foo=bar; q=0.25; testing="1;23"');
@@ -140,7 +140,7 @@ boundary=----------------------------2c46a7bec2b9]);
'... got the right params'
);
- is($mt->to_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="1;23"', '... got the right string representation');
+ is($mt->as_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="1;23"', '... got the right string representation');
}
{
my $mt = HTTP::Headers::ActionPack::MediaType->new_from_string('application/json; v=3; foo=bar; q=0.25; testing="12\"3\""');
@@ -152,7 +152,7 @@ boundary=----------------------------2c46a7bec2b9]);
'... got the right params'
);
- is($mt->to_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="12\"3\""', '... got the right string representation');
+ is($mt->as_string, 'application/json; v="3"; foo="bar"; q="0.25"; testing="12\"3\""', '... got the right string representation');
}
done_testing;
View
6 t/020-priority-list.t
@@ -33,7 +33,7 @@ sub test_priority_list {
);
is(
- $q->to_string,
+ $q->as_string,
'baz; q="3", foobaz; q="3", gorch; q="2.5", bar; q="2", foo; q="1"',
'... got the right string form'
);
@@ -81,7 +81,7 @@ test_priority_list(
);
is(
- $q->to_string,
+ $q->as_string,
'application/xml; q="0.7"',
'... got the right string form'
);
@@ -99,7 +99,7 @@ test_priority_list(
);
is(
- $q->to_string,
+ $q->as_string,
'en-US; q="1", es; q="1"',
'... got the right string form'
);
View
16 t/030-media-type-list.t
@@ -18,7 +18,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'audio/basic; q="1", audio/*; q="0.2"',
'... got the expected string back'
);
@@ -32,7 +32,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'audio/basic, audio/*; q="0.2"',
'... got the expected string back'
);
@@ -45,7 +45,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'audio/basic, audio/*; q="0.2"',
'... got the expected string back'
);
@@ -58,7 +58,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'text/html, text/x-c, text/x-dvi; q="0.8", text/plain; q="0.5"',
'... got the expected string back'
);
@@ -71,7 +71,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'text/html; level="1", text/html, text/*, */*',
'... got the expected string back'
);
@@ -84,7 +84,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'text/html; charset="iso8859-1", application/xml',
'... got the expected string back'
);
@@ -97,7 +97,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'text/html, */*, application/xml; q="0.7"',
'... got the expected string back'
);
@@ -110,7 +110,7 @@ BEGIN {
isa_ok($list, 'HTTP::Headers::ActionPack::MediaTypeList');
is(
- $list->to_string,
+ $list->as_string,
'application/json; v="2", application/json; v="3"; foo="bar"',
'... got the expected string back'
);
View
8 t/040-link.t
@@ -35,7 +35,7 @@ sub test_link {
ok($link->relation_matches('PREVIOUS'), '... relation matching works');
is(
- $link->to_string,
+ $link->as_string,
'<http://example.com/TheBook/chapter2>; rel="previous"; title="previous chapter"',
'... got the string we expected'
);
@@ -83,7 +83,7 @@ test_link(
ok(!$link->relation_matches('HTTP://example.net/foo'), '... relation matching works');
is(
- $link->to_string,
+ $link->as_string,
'</>; rel="http://example.net/foo"',
'... got the string we expected'
);
@@ -111,7 +111,7 @@ test_link(
);
is(
- $link->to_string,
+ $link->as_string,
q{</TheBook/chapter2>; rel="previous"; title*="UTF-8'de'letztes%20Kapitel"},
'... got the string we expected'
);
@@ -139,7 +139,7 @@ test_link(
);
is(
- $link->to_string,
+ $link->as_string,
q{</TheBook/chapter4>; rel="next"; title*="UTF-8'de'n%C3%A4chstes%20Kapitel"},
'... got the string we expected'
);
View
2  t/050-date.t
@@ -23,7 +23,7 @@ sub test_date {
is( $h->minute, 14, '... got the minute');
is( $h->second, 19, '... got the second');
- is( $h->to_string, 'Mon, 23 Apr 2012 14:14:19 GMT', '... got the expected string');
+ is( $h->as_string, 'Mon, 23 Apr 2012 14:14:19 GMT', '... got the expected string');
}
test_date(
Please sign in to comment.
Something went wrong with that request. Please try again.