NAME

Changes::Group - Group object class

SYNOPSIS

use Changes::Group;
my $g = Changes::Group->new(
    line => 12,
    name => 'Front-end',
    spacer => "\t",
    debug => 4,
) || die( Changes::Group->error, "\n" );
my $change = $g->add_change( $change_object );
# or
my $change = $g->add_change( text => 'Some comment here' );
$g->delete_change( $change );
say $g->as_string;

VERSION

v0.2.0

DESCRIPTION

This object class represents a Changes file group within a release section. It is completely optional.

METHODS

add_change

Provided with a Changes::Change object, or an hash or hash reference of options passed to the constructor of Changes::Change, and this will add the change object to the list of elements for this group object.

It returns the Changes::Change object, or an error if an error occurred.

as_string

Returns a scalar object of the change group. This is a group name enclosed in square brackets:

[my group]

It returns a scalar object

If an error occurred, it returns an error

The result of this method is cached so that the second time it is called, the cache is used unless there has been any change.

changes

Read only. This returns an array object containing all the change objects within this group object.

defaults

Sets or gets an hash of default values for the Changes::Change object when it is instantiated by the new_change method.

Default is undef, which means no default value is set.

my $ch = Changes->new(
    file => '/some/where/Changes',
    defaults => {
        spacer1 => "\t",
        spacer2 => ' ',
        marker => '-',
        max_width => 72,
        wrapper => $code_reference,
    }
);

delete_change

This takes a list of change to remove and returns an array object of those changes thus removed.

A change provided can only be a Changes::Change object.

If an error occurred, this will return an error

elements

Sets or gets an array object of all the elements within this group object. Those elements can be Changes::Change and Changes::NewLine objects.

line

Sets or gets an integer representing the line number where this line containing this group information was found in the original Changes file. If this object was instantiated separately, then obviously this value will be undef

name

Sets or gets the group name as a scalar object

new_change

Instantiates and returns a new Changes::Change, passing its constructor any argument provided.

my $change = $rel->new_change( text => 'Some change' ) ||
    die( $rel->error );

new_line

Returns a new Changes::NewLine object, passing it any parameters provided.

If an error occurred, it returns an error object

nl

Sets or gets the new line character, which defaults to \n

It returns a number object

raw

Sets or gets the raw version of the group as found in the Changes file. If set and nothing has been changed, this will be returned by "as_string" instead of computing the formatting of the group.

It returns a scalar object

remove_change

This is an alias for "delete_change"

spacer

Sets or gets the leading space, if any, found before the group.

It returns a scalar object

type

Sets or gets the type of group for this object. This can either be bracket, which is the default, or colon:

[My group]
# or
My group:

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Changes, Changes::Release, Changes::Change, Changes::Version, Changes::NewLine

COPYRIGHT & LICENSE

Copyright(c) 2022 DEGUEST Pte. Ltd.

All rights reserved

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