Rinci::Upgrading(3pm)

πŸ“¦
version 1.1.104 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Rinci::Upgrading β€” bestie, this is the glow-up guide for moving your metadata from the old version to the new one ✨


🌸 VERSION 🌸

This doc describes version 1.1.104 of Rinci::Upgrading, straight out of the Perl distribution Rinci, and it dropped on 2023-09-30. She's not new-new but she's iconic πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so this is literally your step-by-step for converting your metadata from an older version. Glow-up time πŸ’…

The examples are written in Perl, but like... don't feel locked in? They're not limited to this language 🫢


πŸ‘‘ UPGRADING FROM SUB::SPEC 1.0 TO RINCI 1.1 πŸ‘‘

✨ Upgrading function metadata ✨

If you're in Perl, you can just let Perinci::Sub::Wrapper do the heavy lifting β€” and fun fact, Perinci::Access uses that same thing internally β€” to automatically convert Sub::Spec 1.0 metadata to 1.1. So if you want, you can literally skip this whole document. No cap 😌

Terminology change, part one: (sub) spec is now called metadata. Why? Because there's now metadata for functions and for other code entities like variables, packages, etc. She's versatile πŸ’β€β™€οΈ

Terminology change, part two: clause is now called property. The reason is to avoid confusion with Data::Sah's clause. Different word, different vibe, no crossover episodes 🚫

The v (spec version) property is required, so add this:

v => 1.1

to your function metadata. Don't forget, bestie, it's mandatory πŸ‘€

Each argument in the args property is now a hash, instead of a schema. So:

  • Move the schema to the schema key of the hash.
  • To specify a required argument, add req set to 1 to the hash key.
  • Move the arg_pos Sah clause to the pos hash key.
  • Move the arg_greedy Sah clause to the greedy hash key.
  • Move the arg_completion Sah clause to the completion hash key.

Example time πŸ“ β€” change this:

args => {
    # a required argument
    arg1 => ['int*', {
        summary => 'Blah ...',
        min => 1, max => 100,
        arg_pos => 0,
    }],

    # an optional argument
    arg2 => ['bool', {
        summary => 'Blah ...',
        default => 0,
    }],
}

Into this:

args => {
    arg1 => {
        summary => 'Blah ...',
        schema => ['int*', {min=>1, max=>100}],
        req => 1,
        pos => 0,
    },

    arg2 => {
        summary => 'Blah ...',
        schema => [bool => {default=>0}],
    },
}

And here's a lil bonus that's lowkey a big deal: it's now possible to give summary and description to the schema as well as to the argument. Double the slay πŸ’…βœ¨

So accordingly, the result property is also now a hash, instead of a schema. Move the schema into the schema hash key. Same energy, different shape 🧚

🌈 Sub::Spec::HTTP 🌈

For the most part? You only need to upgrade your client and server library. That's it, that's the whole assignment 🫢

  • The client library is now Perinci::CmdLine and Perinci::Access.
  • The server library is now Perinci::Access::HTTP::Server.

The specification is now Riap and Riap::HTTP. Terminology changes abound, bestie:

  • An SS request now becomes a Riap request.
  • Some key names changed β€” specifically, they got shortened.
  • Special headers are now prefixed with X-Riap-* instead of X-SS-Req-*.
  • Log levels are now numeric only (1-6) instead of numeric/string. Pick a number, any number πŸ”’

πŸ’œ HOMEPAGE πŸ’œ

Please visit the project's homepage at <https://metacpan.org/release/Rinci>. Go say hi πŸ‘‹


⭐ SOURCE ⭐

Source repository is at <https://github.com/perlancar/perl-Rinci>. Peek the code, it's giving main character energy πŸ”₯


πŸŽ€ AUTHOR πŸŽ€

perlancar <perlancar@cpan.org> β€” the icon, the legend πŸ‘‘


🌸 CONTRIBUTING 🌸

Wanna help out? Obsessed. Here's how: you can send patches by email/via RT, or send pull requests on GitHub. Pick your fighter πŸ’–

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you do want to build the distribution (like, say, to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me. Fr fr πŸ™ˆ


This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>. That's a lot of years and honestly? Respect 😭

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Rinci>. Tell them everything πŸ—£οΈ

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. Help them help you, bestie 🫢


And that's the whole page, babes ✨ This was Rinci::Upgrading(3pm) from perl v5.38.2, dated 2024-01-20 β€” go forth and upgrade your metadata, you absolute legend πŸ’…πŸŽ€πŸ’–

πŸ“¦ where this page comes from