Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Merge pull request #11 from masaki/support-git-url"

This reverts commit 3f3a58f, reversing
changes made to 56863c6.

Conflicts:
	t/requirement.t
  • Loading branch information...
commit 5c5e3f509f06348a9d7d03c6e55bde79dd1db6e4 1 parent b5b904b
@miyagawa authored
Showing with 8 additions and 158 deletions.
  1. +8 −56 lib/Module/CPANfile.pm
  2. +0 −102 t/requirement.t
View
64 lib/Module/CPANfile.pm
@@ -255,41 +255,28 @@ sub feature {
sub osname { die "TODO" }
-sub requirement_for {
- my ($self, $module, @args) = @_;
-
- my $requirement = 0;
- $requirement = shift @args if @args % 2;
-
- return Module::CPANfile::Requirement->new(
- name => $module,
- version => $requirement,
- @args,
- );
-}
-
sub requires {
- my($self, $module, @args) = @_;
+ my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
- ->{$self->{phase}}{requires}{$module} = $self->requirement_for($module, @args);
+ ->{$self->{phase}}{requires}{$module} = $requirement || 0;
}
sub recommends {
- my($self, $module, @args) = @_;
+ my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
- ->{$self->{phase}}{recommends}{$module} = $self->requirement_for($module, @args);
+ ->{$self->{phase}}{recommends}{$module} = $requirement || 0;
}
sub suggests {
- my($self, $module, @args) = @_;
+ my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
- ->{$self->{phase}}{suggests}{$module} = $self->requirement_for($module, @args);
+ ->{$self->{phase}}{suggests}{$module} = $requirement || 0;
}
sub conflicts {
- my($self, $module, @args) = @_;
+ my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
- ->{$self->{phase}}{conflicts}{$module} = $self->requirement_for($module, @args);
+ ->{$self->{phase}}{conflicts}{$module} = $requirement || 0;
}
# Module::Install compatible shortcuts
@@ -314,41 +301,6 @@ sub author_requires {
$self->on(develop => sub { $self->requires(@args) });
}
-package Module::CPANfile::Requirement;
-use strict;
-use overload '""' => \&as_string, fallback => 1;
-
-sub as_string { shift->{version} }
-
-sub as_hashref {
- my $self = shift;
- return +{ %$self };
-}
-
-sub new {
- my ($class, %args) = @_;
-
- # requires 'Plack';
- # requires 'Plack', '0.9970';
- # requires 'Plack', git => 'git://github.com/plack/Plack.git', rev => '0.9970';
- # requires 'Plack', '0.9970', git => 'git://github.com/plack/Plack.git', rev => '0.9970';
-
- $args{version} ||= 0;
-
- bless +{
- name => $args{name},
- version => $args{version},
- (exists $args{git} ? (git => $args{git}) : ()),
- (exists $args{rev} ? (rev => $args{rev}) : ()),
- }, $class;
-}
-
-sub name { shift->{name} }
-sub version { shift->{version} }
-
-sub git { shift->{git} }
-sub rev { shift->{rev} }
-
package Module::CPANfile;
1;
View
102 t/requirement.t
@@ -1,102 +0,0 @@
-use strict;
-use Module::CPANfile;
-use Test::More;
-use t::Utils;
-
-subtest 'full set' => sub {
- my $r = write_cpanfile(<<FILE);
-requires 'Plack', '0.9970',
- git => 'git://github.com/plack/Plack.git', rev => '0.9970';
-FILE
-
- my $file = Module::CPANfile->load;
-
- # backword compatibility
- is_deeply $file->prereq_specs, {
- runtime => {
- requires => { 'Plack' => '0.9970' },
- },
- };
-
- my $got = $file->prereq_specs->{runtime}->{requires}->{Plack};
- isa_ok $got, 'Module::CPANfile::Requirement';
- is_deeply $got->as_hashref, {
- name => 'Plack',
- version => '0.9970',
- git => 'git://github.com/plack/Plack.git',
- rev => '0.9970',
- };
-};
-
-subtest 'drop version' => sub {
- my $r = write_cpanfile(<<FILE);
-requires 'Plack', # drop version
- git => 'git://github.com/plack/Plack.git', rev => '0.9970';
-FILE
-
- my $file = Module::CPANfile->load;
-
- # backword compatibility
- is_deeply $file->prereq_specs, {
- runtime => {
- requires => { 'Plack' => 0 },
- },
- };
-
- my $got = $file->prereq_specs->{runtime}->{requires}->{Plack};
- isa_ok $got, 'Module::CPANfile::Requirement';
- is_deeply $got->as_hashref, {
- name => 'Plack',
- version => '0',
- git => 'git://github.com/plack/Plack.git',
- rev => '0.9970',
- };
-};
-
-subtest 'no revision' => sub {
- my $r = write_cpanfile(<<FILE);
-requires 'Plack', '0.9970', git => 'git://github.com/plack/Plack.git';
-FILE
-
- my $file = Module::CPANfile->load;
-
- # backword compatibility
- is_deeply $file->prereq_specs, {
- runtime => {
- requires => { 'Plack' => '0.9970' },
- },
- };
-
- my $got = $file->prereq_specs->{runtime}->{requires}->{Plack};
- isa_ok $got, 'Module::CPANfile::Requirement';
- is_deeply $got->as_hashref, {
- name => 'Plack',
- version => '0.9970',
- git => 'git://github.com/plack/Plack.git',
- };
-};
-
-subtest 'name and git' => sub {
- my $r = write_cpanfile(<<FILE);
-requires 'Plack', git => 'git://github.com/plack/Plack.git';
-FILE
-
- my $file = Module::CPANfile->load;
-
- # backword compatibility
- is_deeply $file->prereq_specs, {
- runtime => {
- requires => { 'Plack' => 0 },
- },
- };
-
- my $got = $file->prereq_specs->{runtime}->{requires}->{Plack};
- isa_ok $got, 'Module::CPANfile::Requirement';
- is_deeply $got->as_hashref, {
- name => 'Plack',
- version => 0,
- git => 'git://github.com/plack/Plack.git',
- };
-};
-
-done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.