Permalink
Browse files

[URI] renamed to November::URI

To avoid a name collision between the november project and the uri project.
  • Loading branch information...
1 parent d598e32 commit 95134d49a4d5e168ad17244bbcfd9927cf684cf4 @masak masak committed Feb 2, 2010
Showing with 29 additions and 22 deletions.
  1. +3 −3 lib/November/CGI.pm
  2. +14 −7 lib/{ → November}/URI.pm
  3. +1 −1 lib/{ → November}/URI/Grammar.pm
  4. +2 −2 t/integration/01-view_page.t
  5. +9 −9 t/uri/01.t
View
@@ -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]";
@@ -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
@@ -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:
@@ -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 = $/;
@@ -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;
@@ -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>]? };
@@ -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 >;
@@ -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" );
View
@@ -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');
@@ -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');
@@ -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');

0 comments on commit 95134d4

Please sign in to comment.