@@ -5,7 +5,28 @@ use 5.008_001; # For the utf-8 stuff.
use Module::Build;
-Module::Build -> new
+# -----------------------------------------------
+
+my $class = Module::Build->subclass(code => <<'EOF');
+
+sub ACTION_authortest
+{
+ my($self) = @_;
+
+ $self->depends_on('build');
+ $self->depends_on('manifest');
+ $self->depends_on('distmeta');
+
+ $self->test_files( qw< t xt/author > );
+ $self->recursive_test_files(1);
+
+ $self->depends_on('test');
+
+ return;
+}
+EOF
+
+$class -> new
(
module_name => 'Tree::DAG_Node',
license => 'artistic_2',
@@ -28,4 +49,10 @@ Module::Build -> new
'strict' => 0,
'warnings' => 0,
},
+ resources =>
+ {
+ bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Tree-DAG_Node',
+ license => 'http://opensource.org/licenses/Artistic-2.0',
+ repository => 'https://github.com/ronsavage/Tree-DAG_Node',
+ },
) -> create_build_script();
@@ -3,6 +3,19 @@ Name=Tree::DAG_Node
Changelog.Creator=Module::Metadata::Changes V 2.05
Changelog.Parser=Config::IniFiles V 2.83
+[V 1.24]
+Date=2014-01-25T14:17:00
+Comments= <<EOT
+- Clean up discussion in docs of original author's reluctance to allow parameters to new().
+- Rewrite bareword filehandles (INX) to use a variable (my $fh).
+- Rename github repo from Tree--DAG_Node to Tree-DAG_Node - My new standard.
+Update Build.PL and Makefile.PL to match.
+- Reformat the docs, and this file, slighty, to be <= 100 chars per line - My new standard.
+- Change horizontal indentation used by node2string() to add 1 space, so '|' lines up underneath
+the first char of the previous node's name. Use scripts/cut.and.paste.subtrees.pl
+to see the difference.
+EOT
+
[V 1.23]
Date=2014-10-20T18:12:00
Comments= <<EOT
@@ -35,7 +48,8 @@ Comments=- Switch from File::Slurp to File::Slurp::Tiny, on the advice of Karen
Date=2014-01-31T09:46:00
Comments= <<EOT
- After a private email from Paul Howarth (yea!) I see I need File::Temp V 0.19 because that's
-the version which introduced the newdir() method, as used in the test suite. Sorry for the churn.
+the version which introduced the newdir() method, as used in the test suite. Sorry for the
+churn.
EOT
[V 1.19]
@@ -48,9 +62,10 @@ EOT
[V 1.18]
Date=2013-09-19T14:24:00
Comments= <<EOT
-- No changes, code or otherwise, except for the version # in the *.pm, this file, and Changelog.ini.
-- Somehow a corrupted version got uploaded to search.cpan.org, so I've just changed the version #.
-The file on MetaCPAN was fine.
+- No changes, code or otherwise, except for the version # in the *.pm, this file, and
+Changelog.ini.
+- Somehow a corrupted version got uploaded to search.cpan.org, so I've just changed the
+version #. The file on MetaCPAN was fine.
- Thanx to Rob (Sisyphus) for reporting this.
EOT
@@ -70,7 +85,7 @@ EOT
[V 1.15]
Date=2013-09-06T11:10:00
Comments= <<EOT
-- Replace Path::Tiny with File::Spec, because the former's list of dependencies is soooo long :-(.
+- Replace Path::Tiny with File::Spec, because the former's list of dependencies is soooo long.
Changed files: t/read.tree.t, Build.PL and Makefile.PL.
See: RT#88435 for an explanation.
- Move t/pod.t to xt/author/pod.t.
@@ -94,14 +109,15 @@ Date=2013-08-12T17:16:00
Comments= <<EOT
- Change the values accepted for the no_attributes option from undef and 1 to 0 and 1.
If undef is used, it becomes 0, so pre-existing code will not change behaviour.
-This makes it easier to pass 0 or 1 from the command line, since there is no default value available.
+This makes it easier to pass 0 or 1 from the command line, since there is no default value
+available.
EOT
[V 1.12]
Date=2013-07-03T16:38:00
Comments= <<EOT
-- Change text in README referring to licence to match text in body of source, since it was in conflict
-with the Artistic Licence V 2.0.
+- Change text in README referring to licence to match text in body of source, since it was in
+conflict with the Artistic Licence V 2.0.
This was requested by Petr Pisar who packages stuff for Red Hat.
- Rename CHANGES to Changes as per CPAN::Changes::SPEC.
- Various spelling fixes in the docs, as kindly reported by dsteinbrunner.
@@ -118,15 +134,17 @@ EOT
[V 1.10]
Date=2013-02-01T08:53:00
Comments= <<EOT
-- Change t/pod.t to look for Test::Pod 1.45, but comment out Test::Pod in Build.PL and Makefile.PL.
-This means Test::Pod is not used at all if it is not installed. As per RT#83077.
+- Change t/pod.t to look for Test::Pod 1.45, but comment out Test::Pod in Build.PL and
+Makefile.PL. This means Test::Pod is not used at all if it is not installed.
+As per RT#83077.
EOT
[V 1.09]
Date=2012-11-08T12:38:00
Comments= <<EOT
- No code changes.
-- Oops. The changes in V 1.08 we made in the other 10 distros, but not in this one. My apologies.
+- Oops. The changes in V 1.08 we made in the other 10 distros, but not in this one.
+My apologies.
EOT
[V 1.08]
@@ -141,17 +159,19 @@ EOT
Date=2012-11-01T12:47:00
Comments= <<EOT
- New maintainer: Ron Savage
-- Pre-emptive apologies for any changes which are not back-compat. No such problems are expected, but the
-introduction of new methods may disconcert some viewers.
+- Pre-emptive apologies for any changes which are not back-compat. No such problems are
+expected, but the introduction of new methods may disconcert some viewers.
- Fix RT#78858, reported by Gene Boggs. Audit code for similar problems.
- Fix RT#79506. reported by Ron Savage.
- Rename ChangeLog to CHANGES, and add Changelog.ini.
- Replace all uses of cyclicity_fault() and Carp::croak with die.
-- Remove unused methods: decommission_root(), cyclicity_allowed(), cyclicity_fault(), inaugurate_root(),
-no_cyclicity() and _update_links(). OK - cyclicity_fault() was called once. It just died.
+- Remove unused methods: decommission_root(), cyclicity_allowed(), cyclicity_fault(),
+inaugurate_root(), no_cyclicity() and _update_links(). OK - cyclicity_fault() was called
+once. It just died.
- Add methods: format_node(), hashref2string(), is_root(), node2string(), tree2string().
-tree2string($opts, $node) - unlike draw_ascii_tree() - can optionally print the tree starting at any node.
-Override format_node(), hashref2string(), and node2string() if desired.
+tree2string($opts, $node) - unlike draw_ascii_tree() - can optionally print the tree
+starting at any node. Override format_node(), hashref2string(), and node2string() if
+desired.
- Reformat the POD big-time.
- Add Build.PL.
- Re-write Makefile.PL.
@@ -1,5 +1,15 @@
Revision history for Perl module Tree::DAG_Node.
+1.24 Sun Jan 25 14:17:00 2014
+ - Clean up discussion in docs of original author's reluctance to allow parameters to new().
+ - Rewrite bareword filehandles (INX) to use a variable (my $fh).
+ - Rename github repo from Tree--DAG_Node to Tree-DAG_Node - My new standard.
+ Update Build.PL and Makefile.PL to match.
+ - Reformat the docs, and this file, slighty, to be <= 100 chars per line - My new standard.
+ - Change horizontal indentation used by node2string() to add 1 space, so '|' lines up underneath
+ the first char of the previous node's name. Use scripts/cut.and.paste.subtrees.pl
+ to see the difference.
+
1.23 Mon Oct 20 18:12:00 2014
- Change output format when using node2string(), which is called by tree2string().
Indentation which used to be '|---' is now '|--- '. So, a tree which used to be printed as:
@@ -25,16 +35,18 @@ Revision history for Perl module Tree::DAG_Node.
1.20 Fri Jan 31 09:46:00 2014
- After a private email from Paul Howarth (yea!) I see I need File::Temp V 0.19 because that's
- the version which introduced the newdir() method, as used in the test suite. Sorry for the churn.
+ the version which introduced the newdir() method, as used in the test suite. Sorry for the
+ churn.
1.19 Thu Jan 30 09:24:00 2014
- Set pre-req File::Temp version # to 0 (back from 0.2301). See D A Golden's blog entry:
http://www.dagolden.com/index.php/2293/why-installing-distzilla-is-slow-and-what-you-can-do-about-it/.
1.18 Thu Sep 19 14:24:00 2013
- - No changes, code or otherwise, except for the version # in the *.pm, this file, and Changelog.ini.
- - Somehow a corrupted version got uploaded to search.cpan.org, so I've just changed the version #.
- The file on MetaCPAN was fine.
+ - No changes, code or otherwise, except for the version # in the *.pm, this file, and
+ Changelog.ini.
+ - Somehow a corrupted version got uploaded to search.cpan.org, so I've just changed the
+ version #. The file on MetaCPAN was fine.
- Thanx to Rob (Sisyphus) for reporting this.
1.17 Mon Sep 16 15:24:00 2013
@@ -49,7 +61,7 @@ Revision history for Perl module Tree::DAG_Node.
Fix docs where I'd erroneously said File::Slurp didn't support utf8.
1.15 Fri Sep 6 11:10:00 2013
- - Replace Path::Tiny with File::Spec, because the former's list of dependencies is soooo long :-(.
+ - Replace Path::Tiny with File::Spec, because the former's list of dependencies is soooo long.
Changed files: t/read.tree.t, Build.PL and Makefile.PL.
See: RT#88435 for an explanation.
- Move t/pod.t to xt/author/pod.t.
@@ -67,11 +79,12 @@ Revision history for Perl module Tree::DAG_Node.
1.13 Mon Aug 12 17:16:00 2013
- Change the values accepted for the no_attributes option from undef and 1 to 0 and 1.
If undef is used, it becomes 0, so pre-existing code will not change behaviour.
- This makes it easier to pass 0 or 1 from the command line, since there is no default value available.
+ This makes it easier to pass 0 or 1 from the command line, since there is no default value
+ available.
1.12 Wed Jul 3 16:38:00 2013
- - Change text in README referring to licence to match text in body of source, since it was in conflict
- with the Artistic Licence V 2.0.
+ - Change text in README referring to licence to match text in body of source, since it was in
+ conflict with the Artistic Licence V 2.0.
This was requested by Petr Pisar who packages stuff for Red Hat.
- Rename CHANGES to Changes as per CPAN::Changes::SPEC.
- Various spelling fixes in the docs, as kindly reported by dsteinbrunner.
@@ -82,12 +95,14 @@ Revision history for Perl module Tree::DAG_Node.
which now matches what it says in Build.PL and Makefile.PL. Resolves RT#83088.
1.10 Fri Feb 1 08:53:00 2013
- - Change t/pod.t to look for Test::Pod 1.45, but comment out Test::Pod in Build.PL and Makefile.PL.
- This means Test::Pod is not used at all if it is not installed. As per RT#83077.
+ - Change t/pod.t to look for Test::Pod 1.45, but comment out Test::Pod in Build.PL and
+ Makefile.PL. This means Test::Pod is not used at all if it is not installed.
+ As per RT#83077.
1.09 Thu Nov 8 12:38:00 2012
- No code changes.
- - Oops. The changes in V 1.08 we made in the other 10 distros, but not in this one. My apologies.
+ - Oops. The changes in V 1.08 we made in the other 10 distros, but not in this one.
+ My apologies.
1.08 Thu Nov 8 12:38:00 2012
- No code changes.
@@ -96,17 +111,19 @@ Revision history for Perl module Tree::DAG_Node.
1.07 Thu Nov 1 12:47:00 2012
- New maintainer: Ron Savage
- - Pre-emptive apologies for any changes which are not back-compat. No such problems are expected, but the
- introduction of new methods may disconcert some viewers.
+ - Pre-emptive apologies for any changes which are not back-compat. No such problems are
+ expected, but the introduction of new methods may disconcert some viewers.
- Fix RT#78858, reported by Gene Boggs. Audit code for similar problems.
- Fix RT#79506. reported by Ron Savage.
- Rename ChangeLog to CHANGES, and add Changelog.ini.
- Replace all uses of cyclicity_fault() and Carp::croak with die.
- - Remove unused methods: decommission_root(), cyclicity_allowed(), cyclicity_fault(), inaugurate_root(),
- no_cyclicity() and _update_links(). OK - cyclicity_fault() was called once. It just died.
+ - Remove unused methods: decommission_root(), cyclicity_allowed(), cyclicity_fault(),
+ inaugurate_root(), no_cyclicity() and _update_links(). OK - cyclicity_fault() was called
+ once. It just died.
- Add methods: format_node(), hashref2string(), is_root(), node2string(), tree2string().
- tree2string($opts, $node) - unlike draw_ascii_tree() - can optionally print the tree starting at any node.
- Override format_node(), hashref2string(), and node2string() if desired.
+ tree2string($opts, $node) - unlike draw_ascii_tree() - can optionally print the tree
+ starting at any node. Override format_node(), hashref2string(), and node2string() if
+ desired.
- Reformat the POD big-time.
- Add Build.PL.
- Re-write Makefile.PL.
@@ -4,7 +4,7 @@
"Sean M. Burke <sburke@cpan.org>"
],
"dynamic_config" : 1,
- "generated_by" : "Module::Build version 0.421",
+ "generated_by" : "Module::Build version 0.4211",
"license" : [
"artistic_2"
],
@@ -37,14 +37,14 @@
"provides" : {
"Tree::DAG_Node" : {
"file" : "lib/Tree/DAG_Node.pm",
- "version" : "1.23"
+ "version" : "1.24"
}
},
"release_status" : "stable",
"resources" : {
"license" : [
- "http://opensource.org/licenses/artistic-license-2.0.php"
+ "http://www.perlfoundation.org/artistic_license_2_0"
]
},
- "version" : "1.23"
+ "version" : "1.24"
}
@@ -7,7 +7,7 @@ build_requires:
configure_requires:
Module::Build: '0.38'
dynamic_config: 1
-generated_by: 'Module::Build version 0.421, CPAN::Meta::Converter version 2.142060'
+generated_by: 'Module::Build version 0.4211, CPAN::Meta::Converter version 2.142060'
license: artistic_2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -16,7 +16,7 @@ name: Tree-DAG_Node
provides:
Tree::DAG_Node:
file: lib/Tree/DAG_Node.pm
- version: '1.23'
+ version: '1.24'
requires:
File::Slurp::Tiny: '0.003'
File::Spec: '3.4'
@@ -24,5 +24,5 @@ requires:
strict: '0'
warnings: '0'
resources:
- license: http://opensource.org/licenses/artistic-license-2.0.php
-version: '1.23'
+ license: http://www.perlfoundation.org/artistic_license_2_0
+version: '1.24'
@@ -5,10 +5,12 @@ use 5.008_001; # For the utf-8 stuff.
use ExtUtils::MakeMaker;
+# -----------------------------------------------
+
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
-WriteMakefile
+my(%params) =
(
ABSTRACT => 'An N-ary tree',
AUTHOR => 'Sean M. Burke <sburke@cpan.org>',
@@ -37,3 +39,32 @@ WriteMakefile
},
VERSION_FROM => 'lib/Tree/DAG_Node.pm',
);
+
+if ( ($ExtUtils::MakeMaker::VERSION =~ /^\d\.\d\d$/) && ($ExtUtils::MakeMaker::VERSION > 6.30) )
+{
+ $params{LICENSE} = 'artistic_2';
+}
+
+if ($ExtUtils::MakeMaker::VERSION ge '6.46')
+{
+ $params{META_MERGE} =
+ {
+ 'meta-spec' =>
+ {
+ version => 2,
+ },
+ resources =>
+ {
+ bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Tree-DAG_Node',
+ license => 'http://opensource.org/licenses/Artistic-2.0',
+ repository =>
+ {
+ type => 'git',
+ url => 'https://github.com/ronsavage/Tree-DAG_Node.git',
+ web => 'https://github.com/ronsavage/Tree-DAG_Node',
+ },
+ },
+ };
+}
+
+WriteMakefile(%params);
@@ -5,7 +5,7 @@ use warnings;
use warnings qw(FATAL utf8); # Fatalize encoding glitches.
our $Debug = 0;
-our $VERSION = '1.23';
+our $VERSION = '1.24';
use File::Slurp::Tiny 'read_lines';
@@ -973,23 +973,23 @@ sub new_daughter_left {
sub node2string
{
- my($self, $options, $t, $vert_dashes) = @_;
- my($depth) = scalar($t -> ancestors) || 0;
- my($sibling_count) = defined $t -> mother ? scalar $t -> self_and_sisters : 1;
- my($offset) = ' ' x 4;
+ my($self, $options, $node, $vert_dashes) = @_;
+ my($depth) = scalar($node -> ancestors) || 0;
+ my($sibling_count) = defined $node -> mother ? scalar $node -> self_and_sisters : 1;
+ my($offset) = ' ' x 5;
my(@indent) = map{$$vert_dashes[$_] || $offset} 0 .. $depth - 1;
@$vert_dashes =
(
@indent,
- ($sibling_count == 1 ? $offset : ' |'),
+ ($sibling_count == 1 ? $offset : ' |'),
);
- if ($sibling_count == ($t -> my_daughter_index + 1) )
+ if ($sibling_count == ($node -> my_daughter_index + 1) )
{
$$vert_dashes[$depth] = $offset;
}
- return join('' => @indent[1 .. $#indent]) . ($depth ? ' |--- ' : '') . $self -> format_node($options, $t);
+ return join('' => @indent[1 .. $#indent]) . ($depth ? ' |--- ' : '') . $self -> format_node($options, $node);
} # End of node2string.
@@ -1672,7 +1672,7 @@ Tree::DAG_Node - An N-ary tree
=head1 SYNOPSIS
-Using as a base class:
+=head2 Using as a base class
package Game::Tree::Node;
@@ -1680,23 +1680,35 @@ Using as a base class:
# Now add your own methods overriding/extending the methods in C<Tree::DAG_Node>...
-Using as a class of its own:
+=head2 Using as a class of its own
use Tree::DAG_Node;
- my $root = Tree::DAG_Node->new();
+ my($root) = Tree::DAG_Node -> new({name => 'root', attributes => {uid => 0} });
- $root->name("I'm the tops");
- my $new_daughter = $root->new_daughter;
- $new_daughter->name("More");
+ $root -> add_daughter(Tree::DAG_Node -> new({name => 'one', attributes => {uid => 1} }) );
+ $root -> add_daughter(Tree::DAG_Node -> new({name => 'two', attributes => {} }) );
+ $root -> add_daughter(Tree::DAG_Node -> new({name => 'three'}) ); # Attrs default to {}.
+
+Or:
+
+ my $root = Tree::DAG_Node -> new();
+
+ $root -> name("I'm the tops");
+ $root -> attributes({uid => 0});
+
+ my $new_daughter = $root -> new_daughter;
+
+ $new_daughter -> name('Another node');
+ $new_daughter -> attributes({uid => 1});
...
-Using with utf-8 data:
+=head2 Using with utf-8 data
read_tree($file_name) works with utf-8 data. See t/read.tree.t and t/tree.utf8.attributes.txt.
Such a file can be created by redirecting the output of tree2string() to a file of type utf-8.
-See the docs for Encode for the difference between utf8 and utf-8. In brief, use utf-8.
+See the docs for L<Encode> for the difference between utf8 and utf-8. In brief, use utf-8.
=head1 DESCRIPTION
@@ -1858,47 +1870,9 @@ daughters, 'attributes' setting of a new empty hashref), and returns
the object created. (If you just said "CLASS->new()" or "CLASS->new",
then it pretends you called "CLASS->new({})".)
-Currently no options for putting in hashref $options are part
-of the documented interface, but the options is here in case
-you want to add such behavior in a derived class.
-
-Read on if you plan on using Tree::DAG_New as a base class.
-(Otherwise feel free to skip to the description of _init.)
-
-There are, in my mind, two ways to do object construction:
+See also the comments under L</new($hashref)> for options supported in the call to new().
-Way 1: create an object, knowing that it'll have certain uninteresting
-sane default values, and then call methods to change those values to
-what you want. Example:
-
- $node = Tree::DAG_Node->new;
- $node->name('Supahnode!');
- $root->add_daughter($node);
- $node->add_daughters(@some_others)
-
-Way 2: be able to specify some/most/all the object's attributes in
-the call to the constructor. Something like:
-
- $node = Tree::DAG_Node->new({
- name => 'Supahnode!',
- mother => $root,
- daughters => \@some_others
- });
-
-After some deliberation, I've decided that the second way is a Bad
-Thing. First off, it is B<not> markedly more concise than the first
-way. Second off, it often requires subtly different syntax (e.g.,
-\@some_others vs @some_others). It just complicates things for the
-programmer and the user, without making either appreciably happier.
-
-See however the comments under L</new($hashref)> for options newly supported in the call to new().
-
-(This is not to say that options in general for a constructor are bad
--- L</random_network($options)>, discussed far below, necessarily takes options.
-But note that those are not options for the default values of
-attributes.)
-
-Anyway, if you use C<Tree::DAG_Node> as a superclass, and you add
+If you use C<Tree::DAG_Node> as a superclass, and you add
attributes that need to be initialized, what you need to do is provide
an _init method that calls $this->SUPER::_init($options) to use its
superclass's _init method, and then initializes the new attributes:
@@ -1912,48 +1886,6 @@ superclass's _init method, and then initializes the new attributes:
$this->{'amigos'} = []; # for example
}
-...or, as I prefer when I'm being a neat freak:
-
- sub _init {
- my($this, $options) = @_[0,1];
- $this->SUPER::_init($options);
-
- $this->_init_amigos($options);
- }
-
- sub _init_amigos {
- my $this = $_[0];
- # Or my($this,$options) = @_[0,1]; if I'm using $options
- $this->{'amigos'} = [];
- }
-
-
-In other words, I like to have each attribute initialized thru a
-method named _init_[attribute], which should expect the object as
-$_[0] and the options hashref (or {} if none was given) as $_[1].
-If you insist on having your _init recognize options for setting
-attributes, you might as well have them dealt with by the appropriate
-_init_[attribute] method, like this:
-
- sub _init {
- my($this, $options) = @_[0,1];
- $this->SUPER::_init($options);
-
- $this->_init_amigos($options);
- }
-
- sub _init_amigos {
- my($this,$options) = @_[0,1]; # I need options this time
- $this->{'amigos'} = [];
- $this->amigos(@{$options->{'amigos'}}) if $options->{'amigos'};
- }
-
-All this bookkeeping looks silly with just one new attribute in a
-class derived straight from C<Tree::DAG_Node>, but if there's lots of new
-attributes running around, and if you're deriving from a class derived
-from a class derived from C<Tree::DAG_Node>, then tidy
-stratification/modularization like this can keep you sane.
-
=item the constructor $obj->new() or $obj->new($options)
Just another way to get at the L</new($hashref)> method. This B<does not copy>
@@ -2165,7 +2097,7 @@ that'll be undef if $node is root.
=head2 copy($option)
-Returns a copy the calling node (the invocant). E.g.: my($copy) = $node -> copy;
+Returns a copy of the calling node (the invocant). E.g.: my($copy) = $node -> copy;
$option is a hashref of options, with these (key => value) pairs:
@@ -2357,7 +2289,7 @@ I<draw_ascii_tree()> tries to save vertical space. Defaults to 1.
The code occasionally returns trees that are a bit cock-eyed in parts; if
anyone can suggest a better drawing algorithm, I'd be appreciative.
-See also L</tree2string([$options], [$some_tree])>.
+See also L</tree2string($options, [$some_tree])>.
=head2 dump_names($options)
@@ -2370,8 +2302,8 @@ and continuing under it. Options are:
=item o _depth -- A nonnegative number
-Indicating the depth to consider $node as being at (and so the generation under that is that plus one,
-etc.). You may choose to use set _depth => scalar($node->ancestors).
+Indicating the depth to consider $node as being at (and so the generation under that is that plus
+one, etc.). You may choose to use set _depth => scalar($node->ancestors).
Default: 0.
@@ -2395,9 +2327,7 @@ item is a line, with a "\n" at the end.
Note: Names are converted to a printable form using the undocumented function _dump_quote().
-=head2 format_node([$options], [$node])
-
-Here, [] represent optional parameters.
+=head2 format_node($options, $node)
Returns a string consisting of the node's name and, optionally, it's attributes.
@@ -2415,7 +2345,7 @@ Default: 0 (include attributes).
Calls L</hashref2string($hashref)>.
-Called by L</node2string([$options], [$node])>.
+Called by L</node2string($options, $node, $vert_dashes)>.
You would not normally call this method.
@@ -2457,11 +2387,11 @@ $node->generation_under($node) returns just $node.
If you call $node->generation_under($node) but NODE2 is not $node or an
ancestor of $node, it behaves as if you called just $node->generation().
-head2 hashref2string($hashref)
+=head2 hashref2string($hashref)
Returns the given hashref as a string.
-Called by L</format_node([$options], [$node])>.
+Called by L</format_node($options, $node)>.
=head2 is_daughter_of($node2)
@@ -2625,9 +2555,9 @@ daughter list, etc.
As you'd expect for a constructor, it returns the node-object created.
-# Note that if you radically change 'mother'/'daughters' bookkeeping,
-# you may have to change this routine, since it's one of the places
-# that directly writes to 'daughters' and 'mother'.
+Note that if you radically change 'mother'/'daughters' bookkeeping,
+you may have to change this routine, since it's one of the places
+that directly writes to 'daughters' and 'mother'.
=head2 new_daughter_left()
@@ -2636,11 +2566,11 @@ As you'd expect for a constructor, it returns the node-object created.
This is just like $mother->new_daughter, but adds the new daughter
to the left (start) of $mother's daughter list.
-# Note that if you radically change 'mother'/'daughters' bookkeeping,
-# you may have to change this routine, since it's one of the places
-# that directly writes to 'daughters' and 'mother'.
+Note that if you radically change 'mother'/'daughters' bookkeeping,
+you may have to change this routine, since it's one of the places
+that directly writes to 'daughters' and 'mother'.
-=head2 node2string($options, $t, $vert_dashes)
+=head2 node2string($options, $node, $vert_dashes)
Returns a string of the node's name and attributes, with a leading indent, suitable for printing.
@@ -2656,9 +2586,11 @@ Default: 0 (include attributes).
=back
-Calls L</format_node([$options], [$node])>.
+Ignore the parameter $vert_dashes. The code uses it as temporary storage.
+
+Calls L</format_node($options, $node)>.
-Called by L</tree2string([$options], [$some_tree])>.
+Called by L</tree2string($options, [$some_tree])>.
=head2 random_network($options)
@@ -2681,7 +2613,8 @@ It takes four options:
=over 4
-=item o max_node_count -- maximum number of nodes this tree will be allowed to have (counting the root)
+=item o max_node_count -- maximum number of nodes this tree will be allowed to have (counting the
+root)
Default: 25.
@@ -2707,9 +2640,9 @@ Default: 4.
=head2 read_attributes($s)
Parses the string $s and extracts the name and attributes, assuming the format is as generated by
-L</tree2string([$options], [$some_tree])>.
+L</tree2string($options, [$some_tree])>.
-This bascially means the string was generated by L</hashref2string($hashref)>.
+This bascially means the attribute string was generated by L</hashref2string($hashref)>.
Attributes may be absent, in which case they default to {}.
@@ -2723,14 +2656,15 @@ See t/tree.without.attributes.txt and t/tree.with.attributes.txt for sample data
Returns the root of the tree read from $file_name.
-The file must have been written by re-directing the output of L</tree2string([$options], [$some_tree])> to a file,
-since it makes assumptions about the format of the stringified attributes.
+The file must have been written by re-directing the output of
+L</tree2string($options, [$some_tree])> to a file, since it makes assumptions about the format
+of the stringified attributes.
read_tree() works with utf-8 data. See t/read.tree.t and t/tree.utf8.attributes.txt.
-Note: To call this method you need a caller. It'll be a tree of 1 node. The reason is that inside this method it
-calls various other methods, and for these calls it needs $self. That way, those methods can be called from
-anywhere, and not just from within read_tree().
+Note: To call this method you need a caller. It'll be a tree of 1 node. The reason is that inside
+this method it calls various other methods, and for these calls it needs $self. That way, those
+methods can be called from anywhere, and not just from within read_tree().
For reading and writing trees to databases, see L<Tree::DAG_Node::Persist>.
@@ -2753,7 +2687,7 @@ and replacing it with the items in LIST. This returns a list consisting
of $node followed by LIST, i.e., the nodes that replaced it.
LIST can include $node itself (presumably at most once). LIST can
-also be empty-list. However, if any items in LIST are sisters to
+also be the empty list. However, if any items in LIST are sisters to
$node, they are ignored, and are not in the copy of LIST passed as the
return value.
@@ -2808,9 +2742,9 @@ $node->replace_with_daughters is a more common operation in
tree-wrangling than $node->replace_with(LIST), so deserves a named
method of its own, but that's just me.)
-# Note that if you radically change 'mother'/'daughters' bookkeeping,
-# you may have to change this routine, since it's one of the places
-# that directly writes to 'daughters' and 'mother'.
+Note that if you radically change 'mother'/'daughters' bookkeeping,
+you may have to change this routine, since it's one of the places
+that directly writes to 'daughters' and 'mother'.
=head2 right_sister()
@@ -2897,7 +2831,8 @@ this returns empty-list.
Returns a hashref built from the string.
-The string is expected to be something like '{AutoCommit => '1', PrintError => "0", ReportError => 1}'.
+The string is expected to be something like
+'{AutoCommit => '1', PrintError => "0", ReportError => 1}'.
The empty string is returned as {}.
@@ -2960,9 +2895,9 @@ same options.
Note: Names are converted to a printable form using the undocumented function _dump_quote().
-=head2 tree2string([$options], [$some_tree])
+=head2 tree2string($options, [$some_tree])
-Here, the [] represent optional parameters.
+Here, the [] represent an optional parameter.
Returns an arrayref of lines, suitable for printing.
@@ -3046,7 +2981,7 @@ Default: 0 (include attributes).
=back
-Calls L</node2string($options, $t, $vert_dashes)>.
+Calls L</node2string($options, $node, $vert_dashes)>.
See also L</draw_ascii_tree([$options])>.
@@ -3110,7 +3045,7 @@ Note that if you don't specify I<_depth>, it effectively defaults to
0. You should set it to scalar($node->ancestors) if you want
I<_depth> to reflect the true depth-in-the-tree for the nodes called,
instead of just the depth below $node. (If $node is the root, there's
-difference, of course.)
+no difference, of course.)
And B<by the way>, it's a bad idea to modify the tree from the callback.
Unpredictable things may happen. I instead suggest having your callback
@@ -3363,16 +3298,20 @@ Programs>.)
The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
+=head1 REPOSITORY
+
+L<https://github.com/ronsavage/Tree-DAG_Node>
+
=head1 SUPPORT
Email the author, or log a bug on RT:
-L<https://rt.cpan.org/Public/Dist/Display.html?Name=Tree::DAG_Node>.
+L<https://rt.cpan.org/Public/Dist/Display.html?Name=Tree-DAG_Node>.
=head1 ACKNOWLEDGEMENTS
-The code to print the tree, in tree2string(), was adapted from L<Forest::Tree::Writer::ASCIIWithBranches>
-by the dread Stevan Little.
+The code to print the tree, in tree2string(), was adapted from
+L<Forest::Tree::Writer::ASCIIWithBranches> by the dread Stevan Little.
=head1 MAINTAINER
@@ -173,26 +173,26 @@ ok($drawing_1 eq $expected_1, '2: draw_ascii_tree() before cut-and-paste returne
my($drawing_2) = join('', map{s/\s+$//; "$_\n"} @{$tree -> tree2string});
my($expected_2) = <<'EOS';
Root. Attributes: {# => "0"}
- |--- I. Attributes: {# => "1"}
- | |--- J. Attributes: {# => "1"}
- |--- H. Attributes: {# => "2"}
- | |--- J. Attributes: {# => "2"}
- |--- J. Attributes: {# => "3"}
- | |--- K. Attributes: {# => "3"}
- |--- J. Attributes: {# => "4"}
- | |--- L. Attributes: {# => "4"}
- |--- L. Attributes: {# => "5"}
- | |--- M. Attributes: {# => "5"}
- | |--- N. Attributes: {# => "5"}
- | |--- O. Attributes: {# => "5"}
- |--- D. Attributes: {# => "6"}
- | |--- F. Attributes: {# => "6"}
- |--- E. Attributes: {# => "7"}
- | |--- F. Attributes: {# => "7"}
- |--- F. Attributes: {# => "8"}
- | |--- G. Attributes: {# => "8"}
- |--- B. Attributes: {# => "9"}
- |--- C. Attributes: {# => "9"}
+ |--- I. Attributes: {# => "1"}
+ | |--- J. Attributes: {# => "1"}
+ |--- H. Attributes: {# => "2"}
+ | |--- J. Attributes: {# => "2"}
+ |--- J. Attributes: {# => "3"}
+ | |--- K. Attributes: {# => "3"}
+ |--- J. Attributes: {# => "4"}
+ | |--- L. Attributes: {# => "4"}
+ |--- L. Attributes: {# => "5"}
+ | |--- M. Attributes: {# => "5"}
+ | |--- N. Attributes: {# => "5"}
+ | |--- O. Attributes: {# => "5"}
+ |--- D. Attributes: {# => "6"}
+ | |--- F. Attributes: {# => "6"}
+ |--- E. Attributes: {# => "7"}
+ | |--- F. Attributes: {# => "7"}
+ |--- F. Attributes: {# => "8"}
+ | |--- G. Attributes: {# => "8"}
+ |--- B. Attributes: {# => "9"}
+ |--- C. Attributes: {# => "9"}
EOS
ok($drawing_2 eq $expected_2, '3: tree2string() before cut-and-paste returned expected string'); $count++;
@@ -226,30 +226,30 @@ ok($drawing_3 eq $expected_3, '5: draw_ascii_tree() after cut-and-paste returned
my($drawing_4) = join('', map{s/\s+$//; "$_\n"} @{$tree -> tree2string});
my($expected_4) = <<'EOS';
Root. Attributes: {# => "0"}
- |--- I. Attributes: {# => "1"}
- | |--- J. Attributes: {replaced => "1"}
- | | |--- K. Attributes: {}
- | |--- J. Attributes: {replaced => "1"}
- | |--- L. Attributes: {replaced => "1"}
- | |--- M. Attributes: {}
- | |--- N. Attributes: {}
- | |--- O. Attributes: {}
- |--- H. Attributes: {# => "2"}
- | |--- J. Attributes: {replaced => "1"}
- | | |--- K. Attributes: {}
- | |--- J. Attributes: {replaced => "1"}
- | |--- L. Attributes: {replaced => "1"}
- | |--- M. Attributes: {}
- | |--- N. Attributes: {}
- | |--- O. Attributes: {}
- |--- D. Attributes: {# => "6"}
- | |--- F. Attributes: {replaced => "1"}
- | |--- G. Attributes: {}
- |--- E. Attributes: {# => "7"}
- | |--- F. Attributes: {replaced => "1"}
- | |--- G. Attributes: {}
- |--- B. Attributes: {# => "9"}
- |--- C. Attributes: {# => "9"}
+ |--- I. Attributes: {# => "1"}
+ | |--- J. Attributes: {replaced => "1"}
+ | | |--- K. Attributes: {}
+ | |--- J. Attributes: {replaced => "1"}
+ | |--- L. Attributes: {replaced => "1"}
+ | |--- M. Attributes: {}
+ | |--- N. Attributes: {}
+ | |--- O. Attributes: {}
+ |--- H. Attributes: {# => "2"}
+ | |--- J. Attributes: {replaced => "1"}
+ | | |--- K. Attributes: {}
+ | |--- J. Attributes: {replaced => "1"}
+ | |--- L. Attributes: {replaced => "1"}
+ | |--- M. Attributes: {}
+ | |--- N. Attributes: {}
+ | |--- O. Attributes: {}
+ |--- D. Attributes: {# => "6"}
+ | |--- F. Attributes: {replaced => "1"}
+ | |--- G. Attributes: {}
+ |--- E. Attributes: {# => "7"}
+ | |--- F. Attributes: {replaced => "1"}
+ | |--- G. Attributes: {}
+ |--- B. Attributes: {# => "9"}
+ |--- C. Attributes: {# => "9"}
EOS
ok($drawing_4 eq $expected_4, '6: tree2string() after cut-and-paste returned expected string'); $count++;
@@ -24,9 +24,9 @@ sub process
my($root) = $node -> read_tree($input_file_name);
my($no_attr) = $file_name =~ /without/ ? 1 : 0;
- open(OUT, '> :raw:encoding(utf-8)', $test_file_name);
- print OUT "$_\n" for @{$root -> tree2string({no_attributes => $no_attr})};
- close OUT;
+ open(my $fh, '> :encoding(utf-8)', $test_file_name);
+ print $fh "$_\n" for @{$root -> tree2string({no_attributes => $no_attr})};
+ close $fh;
is(read_file("$input_file_name", binmode => ':encoding(utf-8)'), read_file("$test_file_name", binmode => ':encoding(utf-8)'), "\u$file_name attributes: Output tree matches shipped tree");
@@ -1,9 +1,9 @@
Root. Attributes: {}
- |--- Â. Attributes: {# => "ÂÂ"}
- |--- â. Attributes: {# => "ââ"}
- | |--- É. Attributes: {# => "ÉÉ"}
- |--- é. Attributes: {# => "éé"}
- |--- Ñ. Attributes: {# => "ÑÑ"}
- |--- ñ. Attributes: {# => "ññ"}
- |--- Ô. Attributes: {# => "ÔÔ"}
- |--- ô. Attributes: {# => "ôô"}
+ |--- Â. Attributes: {# => "ÂÂ"}
+ |--- â. Attributes: {# => "ââ"}
+ | |--- É. Attributes: {# => "ÉÉ"}
+ |--- é. Attributes: {# => "éé"}
+ |--- Ñ. Attributes: {# => "ÑÑ"}
+ |--- ñ. Attributes: {# => "ññ"}
+ |--- Ô. Attributes: {# => "ÔÔ"}
+ |--- ô. Attributes: {# => "ôô"}
@@ -1,134 +1,134 @@
statements
- |--- :default
- | |--- ::=
- | |--- action
- | |--- =>
- | |--- [values]
- |--- :start
- | |--- ::=
- | |--- graph_grammar
- |--- graph_grammar
- | |--- ::=
- | |--- graph_definition
- | |--- action
- | |--- =>
- | |--- graph
- |--- graph_definition
- | |--- ::=
- | |--- node_definition
- | |--- |
- | |--- edge_definition
- |--- node_definition
- | |--- ::=
- | |--- node_statement
- | |--- |
- | |--- node_statement
- | |--- graph_definition
- |--- node_statement
- | |--- ::=
- | |--- node_name
- | |--- |
- | |--- node_name
- | |--- attribute_definition
- | |--- |
- | |--- node_statement
- | |--- (',')
- | |--- node_statement
- |--- node_name
- | |--- ::=
- | |--- start_node
- | |--- end_node
- |--- :lexeme
- | |--- ~
- | |--- start_node
- | |--- pause
- | |--- =>
- | |--- before
- | |--- event
- | |--- =>
- | |--- start_node
- |--- start_node
- | |--- ~
- | |--- '['
- |--- :lexeme
- | |--- ~
- | |--- end_node
- |--- end_node
- | |--- ~
- | |--- ']'
- |--- edge_definition
- | |--- ::=
- | |--- edge_statement
- | |--- |
- | |--- edge_statement
- | |--- graph_definition
- |--- edge_statement
- | |--- ::=
- | |--- edge_name
- | |--- |
- | |--- edge_name
- | |--- attribute_definition
- | |--- |
- | |--- edge_statement
- | |--- (',')
- | |--- edge_statement
- |--- edge_name
- | |--- ::=
- | |--- directed_edge
- | |--- |
- | |--- undirected_edge
- |--- :lexeme
- | |--- ~
- | |--- directed_edge
- | |--- pause
- | |--- =>
- | |--- before
- | |--- event
- | |--- =>
- | |--- directed_edge
- |--- directed_edge
- | |--- ~
- | |--- '->'
- |--- :lexeme
- | |--- ~
- | |--- undirected_edge
- | |--- pause
- | |--- =>
- | |--- before
- | |--- event
- | |--- =>
- | |--- undirected_edge
- |--- undirected_edge
- | |--- ~
- | |--- '--'
- |--- attribute_definition
- | |--- ::=
- | |--- attribute_statement
- |--- attribute_statement
- | |--- ::=
- | |--- start_attributes
- | |--- end_attributes
- |--- :lexeme
- | |--- ~
- | |--- start_attributes
- | |--- pause
- | |--- =>
- | |--- before
- | |--- event
- | |--- =>
- | |--- start_attributes
- |--- start_attributes
- | |--- ~
- | |--- '{'
- |--- :lexeme
- | |--- ~
- | |--- end_attributes
- |--- end_attributes
- | |--- ~
- | |--- '}'
- |--- :discard
- | |--- =>
- | |--- whitespace
- |--- whitespace
- |--- ~
- |--- [\s]
+ |--- :default
+ | |--- ::=
+ | |--- action
+ | |--- =>
+ | |--- [values]
+ |--- :start
+ | |--- ::=
+ | |--- graph_grammar
+ |--- graph_grammar
+ | |--- ::=
+ | |--- graph_definition
+ | |--- action
+ | |--- =>
+ | |--- graph
+ |--- graph_definition
+ | |--- ::=
+ | |--- node_definition
+ | |--- |
+ | |--- edge_definition
+ |--- node_definition
+ | |--- ::=
+ | |--- node_statement
+ | |--- |
+ | |--- node_statement
+ | |--- graph_definition
+ |--- node_statement
+ | |--- ::=
+ | |--- node_name
+ | |--- |
+ | |--- node_name
+ | |--- attribute_definition
+ | |--- |
+ | |--- node_statement
+ | |--- (',')
+ | |--- node_statement
+ |--- node_name
+ | |--- ::=
+ | |--- start_node
+ | |--- end_node
+ |--- :lexeme
+ | |--- ~
+ | |--- start_node
+ | |--- pause
+ | |--- =>
+ | |--- before
+ | |--- event
+ | |--- =>
+ | |--- start_node
+ |--- start_node
+ | |--- ~
+ | |--- '['
+ |--- :lexeme
+ | |--- ~
+ | |--- end_node
+ |--- end_node
+ | |--- ~
+ | |--- ']'
+ |--- edge_definition
+ | |--- ::=
+ | |--- edge_statement
+ | |--- |
+ | |--- edge_statement
+ | |--- graph_definition
+ |--- edge_statement
+ | |--- ::=
+ | |--- edge_name
+ | |--- |
+ | |--- edge_name
+ | |--- attribute_definition
+ | |--- |
+ | |--- edge_statement
+ | |--- (',')
+ | |--- edge_statement
+ |--- edge_name
+ | |--- ::=
+ | |--- directed_edge
+ | |--- |
+ | |--- undirected_edge
+ |--- :lexeme
+ | |--- ~
+ | |--- directed_edge
+ | |--- pause
+ | |--- =>
+ | |--- before
+ | |--- event
+ | |--- =>
+ | |--- directed_edge
+ |--- directed_edge
+ | |--- ~
+ | |--- '->'
+ |--- :lexeme
+ | |--- ~
+ | |--- undirected_edge
+ | |--- pause
+ | |--- =>
+ | |--- before
+ | |--- event
+ | |--- =>
+ | |--- undirected_edge
+ |--- undirected_edge
+ | |--- ~
+ | |--- '--'
+ |--- attribute_definition
+ | |--- ::=
+ | |--- attribute_statement
+ |--- attribute_statement
+ | |--- ::=
+ | |--- start_attributes
+ | |--- end_attributes
+ |--- :lexeme
+ | |--- ~
+ | |--- start_attributes
+ | |--- pause
+ | |--- =>
+ | |--- before
+ | |--- event
+ | |--- =>
+ | |--- start_attributes
+ |--- start_attributes
+ | |--- ~
+ | |--- '{'
+ |--- :lexeme
+ | |--- ~
+ | |--- end_attributes
+ |--- end_attributes
+ | |--- ~
+ | |--- '}'
+ |--- :discard
+ | |--- =>
+ | |--- whitespace
+ |--- whitespace
+ |--- ~
+ |--- [\s]