Skip to content

Commit

Permalink
Remove support for URN namespaces
Browse files Browse the repository at this point in the history
They can never really work unless specifying every single field
ala Text-Foo:myauth:*:* which defeats the purpose of constructing
a universal distribution filename format. It also slowed down
parsing of identities due to requiring being checked before more
common namespace formats.
  • Loading branch information
ugexe committed Feb 25, 2019
1 parent 2550c15 commit 42eea88
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 87 deletions.
8 changes: 1 addition & 7 deletions README.pod
Expand Up @@ -83,7 +83,7 @@ C<install A>, and A required module B: both would be downloaded, potentially bui
if both passed all their tests. For example: if module A failed its tests, then module B would not be installed
(even if it passed its own tests) unless forced.

[C<@identities>] can take the form of a file path (starting with B<.> or B</>), URNs, URLs, paths, or identities:
[C<@identities>] can take the form of a file path (starting with B<.> or B</>), URLs, paths, or identities:

# IDENTITY
zef install CSV::Parser
Expand All @@ -98,15 +98,9 @@ if both passed all their tests. For example: if module A failed its tests, then
zef -v install https://github.com/ugexe/zef/archive/master.tar.gz
zef -v install https://github.com/ugexe/zef.git@v0.1.22

# URN
zef install github:tony-o:CSV--Parser:0.1.2

A request may contain any number and combination of these. Paths and URLs will be resolved first so they are available
to fulfill any dependencies of other requested identities.

Note: In the name portion of the B<URN> style, a double I<--> indicates a I<::>. This is because modules can have I<->
as part of their name. I<--> is probably valid too, but this makes my life a lot easier for now!

B<Options>

# Install to a custom locations
Expand Down
31 changes: 0 additions & 31 deletions lib/Zef/Identity.pm6
Expand Up @@ -7,21 +7,6 @@ class Zef::Identity {

method CALL-ME($id) { try self.new(|$id) }

my grammar URN {
token TOP { <auth> ':' <name> ':' <version> [':' <api>]? }

token name { <token>+ }

token auth { <cs> ':' <owner> }
token cs { <.token>+ }
token owner { <.token>+ }
token version { <.token>+ }
token api { <.token>+ }

token token { <-restricted> }
token restricted { < : > }
}

my grammar REQUIRE {
regex TOP { ^^ <name> [':' <key> <value>]* $$ }

Expand Down Expand Up @@ -56,15 +41,6 @@ class Zef::Identity {
from => '',
);
}
elsif $id !~~ /':ver' | ':auth' | ':api' | ':from'/ and URN.parse($id) -> $urn {
self.bless(
name => ~($urn<name>.subst('--','::') // ''),
version => ~($urn<version> // ''),
auth => ~($urn<auth> // ''),
api => ~($urn<api> // ''),
from => ~($urn<from> // 'Perl6'),
);
}
elsif REQUIRE.parse($id, :actions(REQUIRE::Actions.new)).ast -> $ident {
self.bless(
name => ~($ident<name> // ''),
Expand All @@ -76,13 +52,6 @@ class Zef::Identity {
}
}

# cpan:UGEXE:Acme--Foo:1.0 # Module/Distrution Acme::Foo
# cpan:UGEXE:Acme-Foo:1.0 # Module/Distrution Acme-Foo
method urn {
return "{$!auth}:{$!name.subst('::', '--')}:{$!version}{$!api ?? ':$!api' !! ''}"
if ($!auth.?chars && $!name.?chars && $!version.?chars);
}

# Acme::Foo::SomeModule:auth<cpan:ugexe>:ver('1.0')
method identity {
$!name
Expand Down
50 changes: 1 addition & 49 deletions t/identity.t
@@ -1,37 +1,10 @@
use v6;
use Test;
plan 8;
plan 6;

use Zef::Identity;


subtest {
subtest {
my $ident = Zef::Identity.new("github:ugexe:Net--HTTP:1.0");

is $ident.auth, 'github:ugexe';
is $ident.name, 'Net::HTTP';
is $ident.version, '1.0';
}, 'github:ugexe:Net--HTTP:1.0';

subtest {
my $ident = Zef::Identity.new("github:ugexe:Net--HTTP:*");

is $ident.auth, 'github:ugexe';
is $ident.name, 'Net::HTTP';
is $ident.version, '*';
}, 'github:ugexe:Net-HTTP:*';

subtest {
my $ident = Zef::Identity.new("github:ugexe:Net--HTTP:1.0+");

is $ident.auth, 'github:ugexe';
is $ident.name, 'Net::HTTP';
is $ident.version, '1.0+';
}, 'github:ugexe:Net-HTTP:1.0+';
}, 'Distribution URN';


subtest {
my @variations = (
"Net::HTTP:ver<1.0>:auth<github:ugexe>",
Expand Down Expand Up @@ -79,33 +52,15 @@ subtest {
}, 'Require spec - range +';


subtest {
my $require = "Net::HTTP:ver<1.0+>:auth<github:ugexe>";
my $urn = "github:ugexe:Net--HTTP:1.0+";

ok ?Zef::Identity("***not valid***");

my $i-require = Zef::Identity.new($require);
my $i-urn = Zef::Identity.new($urn);

ok $i-require.hash eqv $i-urn.hash;
is $i-require.urn, $i-urn.urn;
is $i-require.identity, $i-urn.identity;
}, 'methods';


subtest {
ok ?str2identity("***not valid***");

subtest {
my $expected = "Net::HTTP:ver<1.0+>:auth<github:ugexe>";
my $require = "Net::HTTP:ver<1.0+>:auth<github:ugexe>:api<>";
my $urn = "github:ugexe:Net--HTTP:1.0+";
my $i-require = str2identity($require);
my $i-urn = str2identity($urn);

is $i-require, $expected;
is $i-require, $i-urn;
}, 'exact';

subtest {
Expand All @@ -126,17 +81,14 @@ subtest {

subtest {
my $require = "Net::HTTP:ver<1.0+>:auth<github:ugexe>";
my $urn = "github:ugexe:Net--HTTP:1.0+";
my %hash = %( :name<Net::HTTP>, :ver<1.0+>, :auth<github:ugexe> );
ok ?identity2hash("***not valid***");

my %i-require = identity2hash($require);
my %i-urn = identity2hash($urn);

is %i-require<name>, 'Net::HTTP';
is %i-require<ver>, '1.0+';
is %i-require<auth>, 'github:ugexe';
ok %i-require eqv %i-urn;
}, 'identity2hash';


Expand Down

0 comments on commit 42eea88

Please sign in to comment.