Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depends as a List of Str may be to stupid #7

Open
gfldex opened this issue Apr 23, 2017 · 2 comments
Open

depends as a List of Str may be to stupid #7

gfldex opened this issue Apr 23, 2017 · 2 comments

Comments

@gfldex
Copy link
Contributor

gfldex commented Apr 23, 2017

I am checking if a dep is already in a META6.json and with "Git::Config:ver<0.1.1>" that failed.

note BOLD "Dependency to $add-dep already in META6.json."; return) if $add-dep ∈ $meta6<depends>

Module descriptors may need their own type that know how to sort by version

@gfldex
Copy link
Contributor Author

gfldex commented Apr 23, 2017

I solved it but am not happy with the .split(':ver') part

multi sub MAIN(Str :$add-dep, Str :$base-dir = '.', Str :$meta6-file-name = 'META6.json') {
   my IO::Path $meta6-file = ($base-dir ~ '/' ~ $meta6-file-name).IO;
   my $meta6 = read-meta6($meta6-file) or die RED "Failed to process ⟨$meta6-file⟩.";

   sub simple-version(Str $s is copy) {
       my ($n, $v) = $s.split(':ver');
       with $v {
           $v = Version.new($v) if $v;
           $s = $n;
       } else {
           $v = Version.new(*);
       }
       $s but role :: { method version { $v } }
   }

   if my $stored-dep = ($meta6<depends>.grep: *.&simple-version eq $add-dep.&simple-version).first {
       if $stored-dep.&simple-version.version > $add-dep.&simple-version.version {
           note BOLD "Dependency to $add-dep younger then version already in META6.json.";
           return
       } else {
           $meta6<depends> = ($meta6<depends>.grep: *.&simple-version !eq $add-dep.&simple-version).Array;
       }
   }

   # (note BOLD "Dependency to $add-dep already in META6.json."; return) if $add-dep.&simple-version ∈ $meta6<depends>».&simple-version;

   $meta6<depends>.push($add-dep);
   dd $meta6<depends>;
   exit 0;
   $meta6-file.spurt($meta6.to-json);
}

@niner
Copy link

niner commented Apr 22, 2018

depends may be a list, but it may also be a matrix of (build/test/runtime)/(requires/suggests/recommends) in the form of nested hashes. Individual entries may be strings or hashes with a "name" key and optionally additional information.

We are making progress on getting meta-version 1 as specified by S22 into the toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants