NAME
Data::Walk::Print - A data printing function
SYNOPSIS
#! C:/Perl/bin/perl
use Modern::Perl;
use YAML::Any;
use Moose::Util qw( with_traits );
use lib '../lib';
use Data::Walk::Extracted v0.05;
use Data::Walk::Print v0.05;
$| = 1;
#Use YAML to compress writing the data ref
my $firstref = Load(
'---
Someotherkey:
value
Parsing:
HashRef:
LOGGER:
run: INFO
Helping:
- Somelevel
- MyKey:
MiddleKey:
LowerKey1: lvalue1
LowerKey2:
BottomKey1: 12345
BottomKey2:
- bavalue1
- bavalue2
- bavalue3'
);
my $secondref = Load(
'---
Someotherkey:
value
Helping:
- Somelevel
- MyKey:
MiddleKey:
LowerKey1: lvalue1
LowerKey2:
BottomKey1: 12346
BottomKey2:
- bavalue1
- bavalue3'
);
# Apply the role
my $newclass = with_traits( 'Data::Walk::Extracted', ( 'Data::Walk::Print' ) );
# Use the combined class to build an instance
my $AT_ST = $newclass->new(
match_highlighting => 1,#This is the default
sort_HASH => 1,#To force order for demo purposes
);
# Walk the data with the Data walker
$AT_ST->walk_the_data(
primary_ref => $firstref,
secondary_ref => $secondref,
);
#######################################
# Output of SYNOPSIS
# 01:{#<--- Ref Type Match
# 02: Helping => [#<--- Secondary Key Match - Ref Type Match
# 03: 'Somelevel',#<--- Secondary Position Exists - Secondary Value Matches
# 04: {#<--- Secondary Position Exists - Ref Type Match
# 05: MyKey => {#<--- Secondary Key Match - Ref Type Match
# 06: MiddleKey => {#<--- Secondary Key Match - Ref Type Match
# 07: LowerKey1 => 'lvalue1',#<--- Secondary Key Match - Secondary Value Matches
# 08: LowerKey2 => {#<--- Secondary Key Match - Ref Type Match
# 09: BottomKey1 => '12345',#<--- Secondary Key Match - Secondary Value Does NOT Match
# 10: BottomKey2 => [#<--- Secondary Key Match - Ref Type Match
# 11: 'bavalue1',#<--- Secondary Position Exists - Secondary Value Matches
# 12: 'bavalue2',#<--- Secondary Position Exists - Secondary Value Does NOT Match
# 13: 'bavalue3',#<--- Secondary Position Does NOT Exist - Secondary Value Does NOT Match
# 14: ],
# 15: },
# 16: },
# 17: },
# 18: },
# 19: ],
# 20: Parsing => {#<--- Secondary Key Mismatch - Ref Type Mismatch
# 21: HashRef => {#<--- Secondary Key Mismatch - Ref Type Mismatch
# 22: LOGGER => {#<--- Secondary Key Mismatch - Ref Type Mismatch
# 23: run => 'INFO',#<--- Secondary Key Mismatch - Secondary Value Does NOT Match
# 24: },
# 25: },
# 26: },
# 27: Someotherkey => 'value',#<--- Secondary Key Match - Secondary Value Matches
# 28:},
#######################################
DESCRIPTION
This Moose::Role is the default behaviour for Data::Walk::Extracted. It provides the methods "before_method" and "after_method" used by Data::Walk::Extracted. Both Data::Dumper - Dump and YAML - Dump functions are more mature than the printing function included here. This is largely a demonstation module.
If this Role is used with another Module it requires a '_has_secondary' Attribute in the class. This attribute is currently implemented in Data::Walk::Extracted
v0.05
- State This code is still in Beta state and therefore is subject to change. I like the basics and will try to add rather than modify whenever possible in the future. The goal of future development will be focused on supporting additional branch types.
- Included ArrayRefs and HashRefs are supported nodes for printing. Strings and Numbers are all currently treated as base states and printed as strings.
- Excluded Objects and CodeRefs are not currently handled and may cause the code to croak.
Use
This is an object oriented Moose Role and generally behaves that way.
Attributes
Data passed to ->new when creating an instance using a class. For modification of these attributes see "Methods". The ->new function will either accept fat comma lists or a complete hash ref that has the possible appenders as the top keys.
match_highlighting
- Definition: this determines if a comments string is added after each printed row that indicates how the primary_ref matches the secondary_ref (or not).
- Default True (1)
- Range This is a Boolean data type and generally accepts 1 or 0
Methods
set_match_highlighting( $bool )
- Definition: this is a way to change the match_highlighting attribute
- Accepts: a Boolean value
- Returns: 1
before_method( $passed_ref )
- Definition: this performs actions based on the current data state and position of the data walker prior to walking the current node.
- Accepts: the standard passed ref defined in Data::Walk::Extracted
- Returns: The $passed_ref intact
after_method( $passed_ref )
- Definition: this performs actions based on the current data state and position of the data walker after walking the current node.
- Accepts: the standard passed ref defined in Data::Walk::Extracted
- Returns: The the current instance of this package (not the full $passed_ref)
BUGS
TODO
SUPPORT
AUTHOR
COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Dependancies
- Data::Walk::Extracted
- version
- Moose::Role
- MooseX::Types::Moose
- Smart::Comments - With the -ENV variable set
SEE ALSO
- Data::Walk
- Data::Walker
- Data::Dumper - Dump
- YAML - Dump