META6
NAME
META6 - Read, Parse, Generate Raku META files.
SYNOPSIS
The below will generate the META.info
for this module.
use META6;
my $m = META6.new( name => 'META6',
version => Version.new('0.0.1'),
auth => 'github:jonathanstowe',
api => '1.0',
description => 'Work with Raku META files',
raku-version => Version.new('6.*'),
depends => ['JSON::Class:ver<0.0.15+>', 'JSON::Name' ],
test-depends => <Test JSON::Fast>,
tags => <devel meta utils>,
authors => ['Jonathan Stowe <[email protected]>'],
source-url => 'https://github.com/jonathanstowe/META6.git',
support => META6::Support.new(
source => 'https://github.com/jonathanstowe/META6.git'
),
provides => {
META6 => 'lib/META6.pm',
},
license => 'Artistic',
production => False,
meta-version => 1,
);
print $m.to-json;
my $m = META6.new(file => './META6.json');
$m<version description> = v0.0.2, 'Work with Raku META files even better';
spurt('./META6.json', $m.to-json);
DESCRIPTION
This provides a representation of the Raku META files specification - the META file data can be read, created , parsed and written in a manner that is conformant with the specification.
Where they are known about it also makes allowance for "customary" usage in existing software (such as installers and so forth.)
The intent of this is allow the generation and testing of META files for module authors, so it can provide meta-information whether the attributes are mandatory as per the spec and where known the places that "customary" attributes are used, though this doesn't preclude it being used for other purposes.
METHODS
All of the available attributes are documented in the specification so I won't duplicate here, only documenting the methods provided by the module.
method new
multi method new(Str :$file!)
multi method new(IO::Path :$file!)
multi method new(IO::Handle :$file!)
multi method new(Str:D :$json!)
multi method new(*%items)
This is the contructor of the class, it can take a named argument file
which can be the name of a file, an IO::Path representing or a
IO::Handle opened to a file containing the META json. Alternatively an
argument json
can be supplied which should contain the JSON string to
be parsed as META info.
If the file doesn't exist, cannot be opened, cannot be read or does not contain valid JSON and exception will be thrown.
Additionally there still is the default constructor (as shown in the SYNOPSIS,) that allows the population of the attributes directly (which may be useful when generating a META file.)
method to-json
method to-json() returns Str
This is provided by JSON::Class. It will return the JSON string representation of the META info. The class should prevent there being anything that can't be represented as JSON so it shouldn't throw an exception.
method AT-KEY
method AT-KEY($key)
Support method to allow subscripts on META6 objects.
method EXISTS-KEY
method EXISTS-KEY($key)
Support method to allow subscripts on META6 objects.