Skip to content

Commit

Permalink
[URI] renamed to November::URI
Browse files Browse the repository at this point in the history
To avoid a name collision between the november project and the uri project.
  • Loading branch information
Carl Masak committed Feb 2, 2010
1 parent d598e32 commit 95134d4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
6 changes: 3 additions & 3 deletions lib/November/CGI.pm
@@ -1,11 +1,11 @@
use v6;
use URI;
use November::URI;

class November::CGI {
has %.params;
has %.cookie;
has @.keywords;
has URI $.uri;
has November::URI $.uri;

has $!crlf = "\x[0D]\x[0A]";

Expand Down Expand Up @@ -38,7 +38,7 @@ class November::CGI {
$uri_str ~= ':' ~ %*ENV<SERVER_PORT> if %*ENV<SERVER_PORT>;
$uri_str ~= %*ENV<MODPERL6> ?? %*ENV<PATH_INFO> !! %*ENV<REQUEST_URI>;

$!uri = URI.new( uri => $uri_str );
$!uri = November::URI.new( uri => $uri_str );
}

# For debugging
Expand Down
21 changes: 14 additions & 7 deletions lib/URI.pm → lib/November/URI.pm
@@ -1,6 +1,13 @@
class URI;
class November::URI;

use URI::Grammar;
# This class used to be called just 'URI', but there was a collision with
# the eponymous class in the 'uri' project. Arguably, that class has more
# rights to that name, so this one was renamed. Since the 'uri' project
# ought to cover the same functionality as this class, maybe long-term we
# could switch to using that instead. One more dependency, but less code
# duplication across projects.

use November::URI::Grammar;
# RAKUDO: Match object does not do assignment properly :(
#my Match $.parts; dies in init with 'Type mismatch in assignment';
# workaround:
Expand All @@ -14,7 +21,7 @@ submethod BUILD(:$uri) {
$c_str .= subst(/^ \s* ['<' | '"'] /, '');
$c_str .= subst(/ ['>' | '"'] \s* $/, '');

URI::Grammar.parse($c_str);
November::URI::Grammar.parse($c_str);
unless $/ { die "Could not parse URI: $uri" }

$!uri = $/;
Expand Down Expand Up @@ -84,13 +91,13 @@ method Str() {
=head NAME
URI — Uniform Resource Identifiers (absolute and relative)
November::URI — Uniform Resource Identifiers (absolute and relative)
=head SYNOPSYS
use URI;
my $u = URI.new;
$u.init('http://her.com/foo/bar?tag=woow#bla');
use November::URI;
my $u = November::URI.new;
$u.init('http://example.com/foo/bar?tag=woow#bla');
my $scheme = $u.scheme;
my $authority = $u.authority;
Expand Down
2 changes: 1 addition & 1 deletion lib/URI/Grammar.pm → lib/November/URI/Grammar.pm
@@ -1,5 +1,5 @@
use v6;
grammar URI::Grammar {
grammar November::URI::Grammar {
token TOP { ^ [<scheme> ':']? [ '//' <authority>]? <path> ['?' <query>]? ['#' <fragment>]? $ };
token scheme { <-[:/&?#]>+ };
token authority { <host> [':' <port>]? };
Expand Down
4 changes: 2 additions & 2 deletions t/integration/01-view_page.t
Expand Up @@ -4,7 +4,7 @@ use Test;
use November;
use Test::CGI;
use November::Config;
use URI;
use November::URI;

my @markups = < Text::Markup::Wiki::MediaWiki >;
my @skins = < CleanAndSoft >;
Expand All @@ -26,7 +26,7 @@ for @markups X @skins -> $m, $s {
my $c = November::Config.new( markup => $m, skin => $s );
my $w = November.new( config => $c );
for %gets.kv -> $page, $description {
my $uri = URI.new( 'http://testserver' ~ $page );
my $uri = November::URI.new( 'http://testserver' ~ $page );
my $cgi = Test::CGI.new( uri => $uri );
$cgi.parse_params( $page );
lives_ok( { $w.handle_request( $cgi ) }, "$m, $s, $description" );
Expand Down
18 changes: 9 additions & 9 deletions t/uri/01.t
Expand Up @@ -2,10 +2,10 @@ use v6;
use Test;
plan 28;

use URI;
use November::URI;
ok(1,'We use URI and we are still alive');

my $u = URI.new(uri => 'http://example.com:80/about/us?foo#bar');
my $u = November::URI.new(uri => 'http://example.com:80/about/us?foo#bar');

is($u.scheme, 'http', 'scheme');
is($u.host, 'example.com', 'host');
Expand All @@ -20,20 +20,20 @@ is($u.chunks[1], 'us', 'second chunk');
is( ~$u, 'http://example.com:80/about/us?foo#bar',
'Complete path stringification');

$u = URI.new(uri => 'https://eXAMplE.COM');
$u = November::URI.new(uri => 'https://eXAMplE.COM');

is($u.scheme, 'https', 'scheme');
is($u.host, 'example.com', 'host');
is( "$u", 'https://example.com',
'https://eXAMplE.COM stringifies to https://example.com');

$u = URI.new(uri => '/foo/bar/baz');
$u = November::URI.new(uri => '/foo/bar/baz');

is($u.chunks, 'foo bar baz', 'chunks from absolute path');
ok($u.absolute, 'absolute path');
nok($u.relative, 'not relative path');

$u = URI.new(uri => 'foo/bar/baz');
$u = November::URI.new(uri => 'foo/bar/baz');

is($u.chunks, 'foo bar baz', 'chunks from relative path');
ok( $u.relative, 'relative path');
Expand All @@ -43,17 +43,17 @@ is($u.chunks[0], 'foo', 'first chunk');
is($u.chunks[1], 'bar', 'second chunk');
is($u.chunks[*-1], 'baz', 'last chunk');

$u = URI.new(uri => 'http://foo.com');
$u = November::URI.new(uri => 'http://foo.com');

ok($u.chunks.list.perl eq '[""]', ".chunks return [''] for empty path");
ok($u.absolute, 'http://foo.com has an absolute path');
nok($u.relative, 'http://foo.com does not have a relative path');

# test URI parsing with <> or "" and spaces
$u = URI.new(uri => "<http://foo.com> ");
# test November::URI parsing with <> or "" and spaces
$u = November::URI.new(uri => "<http://foo.com> ");
is("$u", 'http://foo.com', '<> removed from str');

$u = URI.new(uri => ' "http://foo.com"');
$u = November::URI.new(uri => ' "http://foo.com"');
is("$u", 'http://foo.com', '"" removed from str');


Expand Down

0 comments on commit 95134d4

Please sign in to comment.