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

Is there a way to extende META6? #20

Open
FCO opened this issue Jul 17, 2020 · 8 comments
Open

Is there a way to extende META6? #20

FCO opened this issue Jul 17, 2020 · 8 comments

Comments

@FCO
Copy link

FCO commented Jul 17, 2020

I trying to use META6 on https://github.com/FCO/6pm, but I need to add a new field on it, scripts. I've tried extending it using it as a parent class of my custom class

use META6;

unit class App::six-pm::Meta6 is META6;

has IO::Path $!file handles <f e d x> = "./META6.json".IO;
has Str %.provides is rw is specification(Optional) is json-skip-null;

method save() {$!file.spurt: $.to-json; self}

and augmenting it:

augment class META6 { has %.scripts = { "test" => "" } }
say META6.new: :file("./META6.json")

with no luck. Is there a way of doing it?

@jonathanstowe
Copy link
Owner

Let me think about that for a bit, the same issue may arise with anything that does JSON::Class TBH.

@jonathanstowe
Copy link
Owner

Hi,
Unless I'm completely missing something, inheritances does work, e.g:

use META6;

class Foo is META6 {
    has %.scripts;

}


say Foo.new( file => './META6.json').to-json;

And the scripts property is there. And amending your first example:

use META6;

use META6;

class Foo is META6 {
    has %.scripts;

    has IO::Path $!file handles <f e d x> = "./META6foo.json".IO;

    method save() {
        $!file.spurt: $.to-json;
        self
    }
}


my $f= Foo.new( file => './META6.json');

$f.scripts<test> = "Foo";

$f.save;

Seems to work as expected too. So I'm not sure where to go with this unless you have a specific example that isn't working as you expect.

@FCO
Copy link
Author

FCO commented Jul 22, 2020

I was thinking that custom traits would be needed, sorry.

@jonathanstowe
Copy link
Owner

The specification traits are only for informational purposes and used by Test::META, the json-skip-null and friends can be brought in with use JSON::Class if they're needed.

@FCO
Copy link
Author

FCO commented Jul 22, 2020

Thank you very much!

@JJ
Copy link
Contributor

JJ commented Sep 29, 2020

@FCO altermatively, you could try Pakku::Meta, a parser for the alternative package manager Pakku.

@JJ
Copy link
Contributor

JJ commented Sep 29, 2020

Also, my option would be to use a special "directory" for resources, such as "scripts/whatever".

@jonathanstowe
Copy link
Owner

On a related note, I'm thinking of ways of embedding an entire Oyatul layout in the META6.json so that Igo doesn't need a separate file.

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

3 participants