Skip to content

Replace Moose with Moo#33

Merged
worthmine merged 3 commits into
copilot/adopt-github-actions-from-travisfrom
copilot/replace-moose-to-moo
May 6, 2026
Merged

Replace Moose with Moo#33
worthmine merged 3 commits into
copilot/adopt-github-actions-from-travisfrom
copilot/replace-moose-to-moo

Conversation

Copilot AI commented May 6, 2026

Copy link
Copy Markdown
Contributor

Replaces the Moose/MooseX stack with the lighter Moo + Type::Tiny equivalents across all 20 library modules.

Dependency changes

  • Moose, Moose::Util::TypeConstraints, MooseX::Types::DateTime, MooseX::Types::Email → removed
  • Added: Moo, Type::Tiny, MooX::HandlesVia, Email::Valid, DateTime::TimeZone

Per-file migration pattern

  • use Mooseuse Moo
  • String type names (isa => 'Str') → Type::Tiny objects (isa => Str)
  • subtype/enum declarations → my/our variables via Type::Utils:
    # Before
    subtype 'UID' => as 'Str' => where { ... } => message { ... };
    has uid => ( is => 'rw', isa => 'UID' );
    
    # After
    our $UID = declare 'UID', as Str, where { ... }, message { ... };
    has uid => ( is => 'rw', isa => $UID );
  • coerce 'X', from 'Str'coerce $X, from Str
  • override 'method' => sub { super() }around 'method' => sub { my ($orig, $self) = @_; $self->$orig() }
  • traits => ['Array'] + elementshandles_via => 'Array' + all (via MooX::HandlesVia)
  • __PACKAGE__->meta->make_immutable() removed; no Mooseno Moo

Cross-package type sharing

Types shared across packages (e.g. $UID from V3.pm used in V4.pm) are declared with our and accessed via their fully-qualified package variable name. Type::Utils is imported explicitly (not -all) to avoid extends conflict with Moo.

Bug fix (pre-existing)

return \map { ... } @$_ in the Nodes coerce in V3.pm was returning a list of scalar references instead of an ArrayRef. Fixed to return [ map { ... } @$_ ].

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Text::vCard::Precisely codebase from the Moose/MooseX stack to Moo + Type::Tiny, updating type constraints/coercions and related attribute patterns across the vCard v3/v4 modules.

Changes:

  • Replaced use Moose / Moose::Util::TypeConstraints / MooseX type libs with use Moo, Type::Utils, and Types::Standard (Type::Tiny objects) throughout the library.
  • Updated coercions and shared cross-package type constraints to use declare/enum variables (including fully-qualified our $Type sharing between packages).
  • Updated collection handling to use MooX::HandlesVia, and updated distribution dependencies in cpanfile and META.json.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
META.json Updates runtime dependencies to Moo/Type::Tiny stack and new validation libs.
cpanfile Mirrors dependency migration (adds Moo/Type::Tiny/MooX::HandlesVia/Email::Valid/DateTime::TimeZone).
lib/Text/vCard/Precisely/V4/Node/Tel.pm Migrates to Moo + Type::Tiny types; converts override to plain method.
lib/Text/vCard/Precisely/V4/Node/Related.pm Replaces Moose subtypes/coercions with Type::Tiny declare + coercions.
lib/Text/vCard/Precisely/V4/Node/N.pm Switches to Moo; uses Types::Standard types.
lib/Text/vCard/Precisely/V4/Node/Member.pm Converts subtype declaration to Type::Tiny and updates attribute isa.
lib/Text/vCard/Precisely/V4/Node/Image.pm Uses cross-package shared Type::Tiny constraints from V3 Image node.
lib/Text/vCard/Precisely/V4/Node/Address.pm Switches to Moo; updates attribute type constraints.
lib/Text/vCard/Precisely/V4/Node.pm Converts enums/subtypes to Type::Tiny objects shared via our variables.
lib/Text/vCard/Precisely/V4.pm Replaces Moose coercion/type system with Type::Tiny equivalents; converts override to around where needed.
lib/Text/vCard/Precisely/V3/Node/URL.pm Switches to Moo + Type::Tiny; updates URL coercion/type usage.
lib/Text/vCard/Precisely/V3/Node/Tel.pm Migrates Tel node types/subtypes to Type::Tiny.
lib/Text/vCard/Precisely/V3/Node/SocialProfile.pm Migrates SocialProfile types/coercions to Type::Tiny.
lib/Text/vCard/Precisely/V3/Node/N.pm Migrates name content coercions/types to Type::Tiny.
lib/Text/vCard/Precisely/V3/Node/MultiContent.pm Migrates enum + array coercion to Type::Tiny.
lib/Text/vCard/Precisely/V3/Node/Image.pm Migrates image/base64 validation and media type constraints to Type::Tiny.
lib/Text/vCard/Precisely/V3/Node/Email.pm Replaces MooseX::Types::Email with Email::Valid-backed Type::Tiny constraint.
lib/Text/vCard/Precisely/V3/Node/Address.pm Switches to Moo; uses Types::Standard for address fields.
lib/Text/vCard/Precisely/V3/Node.pm Converts shared base node types ($Types, $Content, etc.) to Type::Tiny objects.
lib/Text/vCard/Precisely/V3.pm Replaces Moose types/coercions with Type::Tiny; includes the Nodes coercion arrayref fix described in PR body.
lib/Text/vCard/Precisely/Multiple.pm Migrates native array handling from Moose traits to MooX::HandlesVia.
lib/Text/vCard/Precisely.pm Switches to Moo and updates version enum typing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

use Types::Standard qw(Str Int ArrayRef HashRef Maybe Ref InstanceOf Object);

use Carp;
use Data::UUID;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5569a5f — added use DateTime::TimeZone; to V3.pm alongside the other imports. Also fixed the unescaped dot in the PIDNum regex in V4/Node.pm ((?:.\d)(?:\.\d)).

Comment thread lib/Text/vCard/Precisely/V4/Node.pm Outdated
subtype 'PIDNum' => as 'Num' => where {m/^\d(?:.\d)?$/s}
=> message {"The PID you provided, $_, was not supported"};
has pid => ( is => 'rw', isa => subtype 'PID' => as 'ArrayRef[PIDNum]' );
our $PIDNum = declare 'PIDNum', as Num, where {m/^\d(?:.\d)?$/s},

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed in 5569a5f — the dot is now escaped: m/^\d(?:\.\d)?$/s.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the errors on testing

@worthmine
worthmine marked this pull request as ready for review May 6, 2026 02:47
Copilot AI requested a review from worthmine May 6, 2026 11:46
@worthmine
worthmine merged commit 3f8a36d into copilot/adopt-github-actions-from-travis May 6, 2026
1 of 33 checks passed
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

Successfully merging this pull request may close these issues.

3 participants