Layout-Manager-0.35/000755 000765 000024 00000000000 12270604667 014546 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/Changes000644 000765 000024 00000007731 12270604305 016036 0ustar00gphatstaff000000 000000 Revision history for Layout-Manager 0.34 _ Remove unnecessary dependency on MooseX::AttributeHelpers 0.33 - Tables will no longer expand vertically for no reason, nor will they unnecessarily squash their contents on re-layout. If the container's height is greater than the sum of it's row's minimums then the remainder will be split equally between all rows. This may cause problems, but I've not uncovered any in my tests so far. 0.32 - Fix error in docs (RT #60557) 0.31 - Fix another warning in Flow 0.30 - Fix warning in Flow 0.29 - Fix Flow's width and height not taking outside into consideration (argh!) 0.28 - Adjust Flow's height/width set style - Fix incorrect test values for compass/17 - layout sub-components earlier in Compass (not sure about this one) 0.27 - Fix busted minimum_width if north/south based Flows had no width set. 0.26 - Rewrite Flow, adding the ability to wrap it's contents. (east & west only) - POD overhaul 0.25 - POD fixes - Fix behavior of Compass' nested layout - Set minimum height & width in grid - Change order of Flow layout's super call 0.24 - Bump dep version of Graphics::Primitive 0.23 - Don't marked laid out components as prepared 0.22 - Teach Grid how to handle dynamic sizing. 0.21 - A few POD fixes - Add Grid layout manager 0.20 - Move pod tests to t/author 0.19 - Dependency Bumps 0.18 - Remove overflow attribute - Remove Moose Coverage dependency - Keep up with G:P api changes 0.17 - Dep bumps - Flow: Honor margins/padding/borders 0.16 - Fix broken tests stemming from changes in Graphics::Primitive's remove - Fix broken center in Compass with multiple center components - Add test for same 0.15 - Fix breakage with nested layout managers 0.14 - Modify all managers to work with Graphics::Primitive 0.18 - Mark components effectively in all managers 0.13 - Axis: skip center sizing if there are no center components to lay out - Fix container preparedness marking bug 0.12 - Check preparedness of a container before laying it out - Return zero from do_layout if layout was skipped. Return 1 if layout was executed. - POD 0.11 - Add Flow layout manager - Remove cruft from pre-Graphics::Primitive dependency days - Add overflow attribute to Manager - POD updates - Compass: Fix bug that shrank containers with multiple calls to do_layout 0.10 - POD - Remove some old cruft 0.09 - Bugfixes in Compass wrt padded containers - Add Absolute layout manager - Fix broken Single manager - Add a test container and make component actually be a component - pass the parent container to do_layout - (do_layout) Implement common logic in Manager.pm, implementations call super at top of their override. - (do_layout) if this container has no size, use the parent's inside_bounding_box, this is likely going to change - Comment Compass - Compass: Don't blindly set widths and heights for edges where we don't know the sizes yet, set them to 0 and set the values in the loops - Compass: North and South now run full width, screw that other way - Add Axis 0.08 - Remove draw method from Component role - Remove component management from Manager, leave that to Graphics::Primitive container - Remove component role - Respect container's insets and borders in Single and Compass - Fix Compass center positioning 0.07 - Add find_component to Manager 0.06 - Test visibility - Return number of components removed by remove_component - Watch for empty component slots in implementations - Fix warning by not checking components with no name in remove_component 0.05 - Honor Component's visible attribute. - Add make_immutable for moose 0.04 - Fix y positioning in Single 0.03 - Add MI version because Yuval yelled at me - More pod fixes 0.02 - Fix bug in center width calculations for Compass - Hide test package from CPAN 0.01 Date/time First version, released on an unsuspecting world. Layout-Manager-0.35/inc/000755 000765 000024 00000000000 12270604667 015317 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/lib/000755 000765 000024 00000000000 12270604667 015314 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/Makefile.PL000644 000765 000024 00000000465 12270604305 016512 0ustar00gphatstaff000000 000000 use inc::Module::Install 0.75; name 'Layout-Manager'; all_from 'lib/Layout/Manager.pm'; author 'Cory G Watson '; build_requires 'Test::More'; requires 'Moose' => '0.79'; requires 'Geometry::Primitive' => '0.16'; requires 'Graphics::Primitive' => '0.43'; tests_recursive; WriteAll; Layout-Manager-0.35/MANIFEST000644 000765 000024 00000003016 12270604305 015664 0ustar00gphatstaff000000 000000 Changes inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Layout/Manager.pm lib/Layout/Manager/Absolute.pm lib/Layout/Manager/Axis.pm lib/Layout/Manager/Compass.pm lib/Layout/Manager/Flow.pm lib/Layout/Manager/Grid.pm lib/Layout/Manager/Single.pm Makefile.PL MANIFEST This list of files META.yml README t/00-load.t t/10-compass/01-north.t t/10-compass/02-south.t t/10-compass/03-east.t t/10-compass/04-west.t t/10-compass/05-sane.t t/10-compass/06-east-west.t t/10-compass/06-north-east.t t/10-compass/06-north-west.t t/10-compass/06-south-east.t t/10-compass/07-clickeresque.t t/10-compass/08-click-invis.t t/10-compass/09-remove.t t/10-compass/10-nce.t t/10-compass/11-center.t t/10-compass/14-container-center.t t/10-compass/15-container-east.t t/10-compass/16-container-west.t t/10-compass/17-container-east-center.t t/10-compass/18-container-south.t t/10-compass/19-container-south-p2.t t/10-compass/19-container-south-p3.t t/10-compass/25-validity.t t/10-compass/50-complex.t t/11-flow/00-north.t t/11-flow/01-south.t t/11-flow/02-east.t t/11-flow/03-west.t t/11-flow/04-north-margin.t t/11-flow/05-west-margin.t t/11-flow/06-east-margin.t t/11-flow/07-south-margin.t t/11-flow/08-west-wrap.t t/11-flow/09-east-wrap.t t/15-axis/01-all.t t/20-grid/00-simple.t t/20-grid/01-no_height.t t/20-grid/02-no_width.t t/author/pod t/author/pod-coverage t/lib/DummyDriver.pm Layout-Manager-0.35/META.yml000644 000765 000024 00000001171 12270604662 016012 0ustar00gphatstaff000000 000000 --- abstract: '2D Layout Management' author: - 'Cory Watson, C<< >>' - 'Cory G Watson ' build_requires: ExtUtils::MakeMaker: 6.36 Test::More: 0 configure_requires: ExtUtils::MakeMaker: 6.36 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.06' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Layout-Manager no_index: directory: - inc - t requires: Geometry::Primitive: 0.16 Graphics::Primitive: 0.43 Moose: 0.79 resources: license: http://dev.perl.org/licenses/ version: 0.35 Layout-Manager-0.35/README000644 000765 000024 00000002277 12270604305 015423 0ustar00gphatstaff000000 000000 Layout::Manager - 2D Layout Management SYNOPSIS Layout::Manager provides a simple interface for creating layout managers, or classes that size and position components within a container. A few managers are provided for reference, but this module is primarily meant to serve as a base for outside implementations. use Layout::Manager; my $foo = Layout::Manager->new; $foo->do_layout($component); INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Layout::Manager You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Layout-Manager AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Layout-Manager CPAN Ratings http://cpanratings.perl.org/d/Layout-Manager Search CPAN http://search.cpan.org/dist/Layout-Manager COPYRIGHT AND LICENCE Copyright (C) 2008 - 2010 Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Layout-Manager-0.35/t/000755 000765 000024 00000000000 12270604667 015011 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/t/00-load.t000644 000765 000024 00000000233 12270604305 016315 0ustar00gphatstaff000000 000000 #!perl -T use Test::More tests => 1; BEGIN { use_ok( 'Layout::Manager' ); } diag( "Testing Layout::Manager $Layout::Manager::VERSION, Perl $], $^X" ); Layout-Manager-0.35/t/10-compass/000755 000765 000024 00000000000 12270604667 016674 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/t/11-flow/000755 000765 000024 00000000000 12270604667 016177 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/t/15-axis/000755 000765 000024 00000000000 12270604667 016200 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/t/20-grid/000755 000765 000024 00000000000 12270604667 016155 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/t/author/000755 000765 000024 00000000000 12270604667 016313 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/t/lib/000755 000765 000024 00000000000 12270604667 015557 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/t/lib/DummyDriver.pm000644 000765 000024 00000001342 12270604305 020351 0ustar00gphatstaff000000 000000 package # hide from the CPAN DummyDriver; use Moose; with 'Graphics::Primitive::Driver'; has 'draw_component_called' => ( is => 'rw', isa => 'Int', default => sub { 0 } ); sub _do_fill { } sub _do_stroke { } sub _draw_arc { } sub _draw_bezier { } sub _draw_canvas { } sub _draw_circle { } sub _draw_component { my ($self, $comp) = @_; $self->draw_component_called( $self->draw_component_called + 1 ); } sub _draw_ellipse { } sub _draw_line { } sub _draw_path { } sub _draw_polygon { } sub _draw_rectangle { } sub _draw_textbox { } sub _finish_page { } sub _resize { } sub data { } sub get_textbox_layout { } sub height { } sub reset { } sub width { } sub write { } no Moose; 1;Layout-Manager-0.35/t/author/pod000644 000765 000024 00000000350 12270604305 017003 0ustar00gphatstaff000000 000000 #!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); Layout-Manager-0.35/t/author/pod-coverage000644 000765 000024 00000001312 12270604305 020573 0ustar00gphatstaff000000 000000 use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; eval "use Pod::Coverage::Moose"; plan skip_all => "Pod::Coverage::Moose required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::Moose' }); Layout-Manager-0.35/t/20-grid/00-simple.t000644 000765 000024 00000004000 12270604305 020027 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 17; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Grid'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 100 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 100 ); my $foo3 = Graphics::Primitive::Component->new( name => 'three', minimum_height => 20, minimum_width => 100 ); my $foo4 = Graphics::Primitive::Component->new( name => 'four', minimum_height => 20, minimum_width => 100 ); my $cont = Graphics::Primitive::Container->new( width => 200, height => 160 ); $cont->add_component($foo, { row => 0, column => 0 }); $cont->add_component($foo2, { row => 0, column => 1 }); $cont->add_component($foo3, { row => 1, column => 0, height => 2 }); $cont->add_component($foo4, { row => 3, column => 0, width => 2 }); my $lm = Layout::Manager::Grid->new(rows => 4, columns => 2); $lm->do_layout($cont); cmp_ok($foo->height, '==', 45, 'left top component height'); cmp_ok($foo->width, '==', 100, 'left top component width'); cmp_ok($foo->origin->x, '==', 0, 'left top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left top component origin y'); cmp_ok($foo2->height, '==', 45, 'right top component height'); cmp_ok($foo2->width, '==', 100, 'right top component width'); cmp_ok($foo2->origin->x, '==', 100, 'right top component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'right top component origin y'); cmp_ok($foo3->height, '==', 70, 'middle component height'); cmp_ok($foo3->width, '==', 100, 'middle component width'); cmp_ok($foo3->origin->x, '==', 0, 'middle component origin x'); cmp_ok($foo3->origin->y, '==', 45, 'middle component origin y'); cmp_ok($foo4->height, '==', 45, 'bottom component height'); cmp_ok($foo4->width, '==', 200, 'bottom component width'); cmp_ok($foo4->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo4->origin->y, '==', 115, 'bottom component origin y'); Layout-Manager-0.35/t/20-grid/01-no_height.t000644 000765 000024 00000003760 12270604305 020517 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 17; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Grid'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 100 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 100 ); my $foo3 = Graphics::Primitive::Component->new( name => 'three', minimum_height => 20, minimum_width => 100 ); my $foo4 = Graphics::Primitive::Component->new( name => 'four', minimum_height => 20, minimum_width => 100 ); my $cont = Graphics::Primitive::Container->new( width => 200 ); $cont->add_component($foo, { row => 0, column => 0 }); $cont->add_component($foo2, { row => 0, column => 1 }); $cont->add_component($foo3, { row => 1, column => 0, height => 2 }); $cont->add_component($foo4, { row => 3, column => 0, width => 2 }); my $lm = Layout::Manager::Grid->new(rows => 4, columns => 2); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'left top component height'); cmp_ok($foo->width, '==', 100, 'left top component width'); cmp_ok($foo->origin->x, '==', 0, 'left top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left top component origin y'); cmp_ok($foo2->height, '==', 20, 'right top component height'); cmp_ok($foo2->width, '==', 100, 'right top component width'); cmp_ok($foo2->origin->x, '==', 100, 'right top component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'right top component origin y'); cmp_ok($foo3->height, '==', 20, 'middle component height'); cmp_ok($foo3->width, '==', 100, 'middle component width'); cmp_ok($foo3->origin->x, '==', 0, 'middle component origin x'); cmp_ok($foo3->origin->y, '==', 20, 'middle component origin y'); cmp_ok($foo4->height, '==', 20, 'bottom component height'); cmp_ok($foo4->width, '==', 200, 'bottom component width'); cmp_ok($foo4->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo4->origin->y, '==', 40, 'bottom component origin y'); Layout-Manager-0.35/t/20-grid/02-no_width.t000644 000765 000024 00000003762 12270604305 020371 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 17; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Grid'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 100 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 100 ); my $foo3 = Graphics::Primitive::Component->new( name => 'three', minimum_height => 20, minimum_width => 100 ); my $foo4 = Graphics::Primitive::Component->new( name => 'four', minimum_height => 20, minimum_width => 100 ); my $cont = Graphics::Primitive::Container->new( height => 200 ); $cont->add_component($foo, { row => 0, column => 0 }); $cont->add_component($foo2, { row => 0, column => 1 }); $cont->add_component($foo3, { row => 1, column => 0, height => 2 }); $cont->add_component($foo4, { row => 3, column => 0, width => 2 }); my $lm = Layout::Manager::Grid->new(rows => 4, columns => 2); $lm->do_layout($cont); cmp_ok($foo->height, '==', 55, 'left top component height'); cmp_ok($foo->width, '==', 100, 'left top component width'); cmp_ok($foo->origin->x, '==', 0, 'left top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left top component origin y'); cmp_ok($foo2->height, '==', 55, 'right top component height'); cmp_ok($foo2->width, '==', 100, 'right top component width'); cmp_ok($foo2->origin->x, '==', 100, 'right top component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'right top component origin y'); cmp_ok($foo3->height, '==', 90, 'middle component height'); cmp_ok($foo3->width, '==', 100, 'middle component width'); cmp_ok($foo3->origin->x, '==', 0, 'middle component origin x'); cmp_ok($foo3->origin->y, '==', 55, 'middle component origin y'); cmp_ok($foo4->height, '==', 55, 'bottom component height'); cmp_ok($foo4->width, '==', 200, 'bottom component width'); cmp_ok($foo4->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo4->origin->y, '==', 145, 'bottom component origin y'); Layout-Manager-0.35/t/15-axis/01-all.t000644 000765 000024 00000006240 12270604305 017342 0ustar00gphatstaff000000 000000 use Test::More tests => 29; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Axis'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 20 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 20 ); my $foo3 = Graphics::Primitive::Component->new( name => 'three', minimum_height => 10, minimum_width => 20 ); my $foo4 = Graphics::Primitive::Component->new( name => 'four', minimum_height => 10, minimum_width => 30 ); my $foo5 = Graphics::Primitive::Component->new( name => 'five', minimum_height => 10, minimum_width => 10 ); my $foo6 = Graphics::Primitive::Component->new( name => 'six', minimum_height => 10, minimum_width => 10 ); my $foo7 = Graphics::Primitive::Component->new( name => 'seven', minimum_height => 10, minimum_width => 10 ); my $cont = Graphics::Primitive::Container->new( width => 400, height => 200, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ) ); $cont->add_component($foo, 's'); $cont->add_component($foo2, 'w'); $cont->add_component($foo3, 'n'); $cont->add_component($foo4, 'e'); $cont->add_component($foo5, 'e'); $cont->add_component($foo6, 'c'); $cont->add_component($foo7, 'c'); my $lm = Layout::Manager::Axis->new; $lm->do_layout($cont); cmp_ok($foo->origin->x, '==', 24, 'bottom component origin x'); cmp_ok($foo->origin->y, '==', 178, 'bottom component origin y'); cmp_ok($foo->height, '==', 20, 'bottom component height'); cmp_ok($foo->width, '==', 333, 'bottom component width'); cmp_ok($foo2->origin->x, '==', 4, 'left component origin x'); cmp_ok($foo2->origin->y, '==', 15, 'left component origin y'); cmp_ok($foo2->height, '==', 163, 'left component height'); cmp_ok($foo2->width, '==', 20, 'left component width'); cmp_ok($foo3->origin->x, '==', 24, 'top component origin x'); cmp_ok($foo3->origin->y, '==', 5, 'top component origin y'); cmp_ok($foo3->height, '==', 10, 'top component height'); cmp_ok($foo3->width, '==', 333, 'top component width'); cmp_ok($foo4->origin->x, '==', 367, 'right component origin x'); cmp_ok($foo4->origin->y, '==', 15, 'right component origin y'); cmp_ok($foo4->height, '==', 163, 'right component height'); cmp_ok($foo4->width, '==', 30, 'right component width'); cmp_ok($foo5->origin->x, '==', 357, '2nd right component origin x'); cmp_ok($foo5->origin->y, '==', 15, '2nd right component origin y'); cmp_ok($foo5->height, '==', 163, '2nd right component height'); cmp_ok($foo5->width, '==', 10, '2nd right component width'); cmp_ok($foo6->origin->x, '==', 24, 'center component origin x'); cmp_ok($foo6->origin->y, '==', 15, 'center component origin y'); cmp_ok($foo6->height, '==', 81.5, 'center component height'); cmp_ok($foo6->width, '==', 333, 'center component width'); cmp_ok($foo7->origin->x, '==', 24, 'bottom center component origin x'); cmp_ok($foo7->origin->y, '==', 96.5, 'bottom center component origin y'); cmp_ok($foo7->height, '==', 81.5, 'bottom center component height'); cmp_ok($foo7->width, '==', 333, 'bottom center component width'); Layout-Manager-0.35/t/11-flow/00-north.t000644 000765 000024 00000002342 12270604305 017721 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 12; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Flow'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 100 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 100 ); my $cont = Graphics::Primitive::Container->new( height => 80 ); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'north'); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'top component height'); cmp_ok($foo->width, '==', 100, 'top component width'); cmp_ok($foo->origin->x, '==', 0, 'top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'top component origin y'); cmp_ok($foo2->height, '==', 20, 'bottom component height'); cmp_ok($foo2->width, '==', 100, 'bottom component width'); cmp_ok($foo2->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'bottom component origin y'); cmp_ok($cont->minimum_width, '==', 100, 'container width'); my $used = $lm->used; cmp_ok($used->[0], '==', 100, 'width used'); cmp_ok($used->[1], '==', 40, 'height used'); Layout-Manager-0.35/t/11-flow/01-south.t000644 000765 000024 00000002301 12270604305 017725 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 10; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; use Layout::Manager::Flow; my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 100 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 100 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 80 ); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'south'); $lm->do_layout($cont); cmp_ok($foo2->height, '==', 20, 'top component height'); cmp_ok($foo2->width, '==', 100, 'top component width'); cmp_ok($foo2->origin->x, '==', 0, 'top component origin x'); cmp_ok($foo2->origin->y, '==', 40, 'top component origin y'); cmp_ok($foo->height, '==', 20, 'bottom component height'); cmp_ok($foo->width, '==', 100, 'bottom component width'); cmp_ok($foo->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo->origin->y, '==', 60, 'bottom component origin y'); my $used = $lm->used; cmp_ok($used->[0], '==', 100, 'width used'); cmp_ok($used->[1], '==', 40, 'height used'); Layout-Manager-0.35/t/11-flow/02-east.t000644 000765 000024 00000002301 12270604305 017520 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 10; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; use Layout::Manager::Flow; my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 20 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 10 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 20 ); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'east'); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'right bottom component height'); cmp_ok($foo->width, '==', 20, 'right component width'); cmp_ok($foo->origin->x, '==', 80, 'right component origin x'); cmp_ok($foo->origin->y, '==', 0, 'right component origin y'); cmp_ok($foo2->height, '==', 20, 'left component height'); cmp_ok($foo2->width, '==', 10, 'left component width'); cmp_ok($foo2->origin->x, '==', 70, 'left component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'left component origin y'); my $used = $lm->used; cmp_ok($used->[0], '==', 30, 'width used'); cmp_ok($used->[1], '==', 20, 'height used'); Layout-Manager-0.35/t/11-flow/03-west.t000644 000765 000024 00000002270 12270604305 017554 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 10; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; use Layout::Manager::Flow; my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 30 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 15 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'west'); $lm->do_layout($cont); cmp_ok($foo->height, '==', 40, 'left component height'); cmp_ok($foo->width, '==', 30, 'left component width'); cmp_ok($foo->origin->x, '==', 0, 'left component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left component origin y'); cmp_ok($foo2->height, '==', 40, 'right component height'); cmp_ok($foo2->width, '==', 15, 'right component width'); cmp_ok($foo2->origin->x, '==', 30, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'right component origin y'); my $used = $lm->used; cmp_ok($used->[0], '==', 45, 'width used'); cmp_ok($used->[1], '==', 40, 'height used'); Layout-Manager-0.35/t/11-flow/04-north-margin.t000644 000765 000024 00000002377 12270604305 021210 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 11; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Flow'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 50 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 50 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 80 ); $cont->margins->left(10); $cont->margins->top(11); $cont->margins->right(12); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'north'); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'top component height'); cmp_ok($foo->width, '==', 78, 'top component width'); cmp_ok($foo->origin->x, '==', 10, 'top component origin x'); cmp_ok($foo->origin->y, '==', 11, 'top component origin y'); cmp_ok($foo2->height, '==', 20, 'bottom component height'); cmp_ok($foo2->width, '==', 78, 'bottom component width'); cmp_ok($foo2->origin->x, '==', 10, 'bottom component origin x'); cmp_ok($foo2->origin->y, '==', 31, 'bottom component origin y'); my $used = $lm->used; cmp_ok($used->[0], '==', 78, 'width used'); cmp_ok($used->[1], '==', 40, 'height used'); Layout-Manager-0.35/t/11-flow/05-west-margin.t000644 000765 000024 00000002376 12270604305 021040 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 11; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Flow'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 25 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 24 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 80 ); $cont->margins->left(10); $cont->margins->top(11); $cont->margins->right(12); $cont->margins->bottom(9); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'west'); $lm->do_layout($cont); cmp_ok($foo->height, '==', 60, 'component 1 height'); cmp_ok($foo->width, '==', 25, 'component 1 width'); cmp_ok($foo->origin->x, '==', 10, 'component 1 origin x'); cmp_ok($foo->origin->y, '==', 11, 'component 1 origin y'); cmp_ok($foo2->height, '==', 60, 'component 2 height'); cmp_ok($foo2->width, '==', 24, 'component 2 width'); cmp_ok($foo2->origin->x, '==', 35, 'component 2 origin x'); cmp_ok($foo2->origin->y, '==', 11, 'component 2 origin y'); my $used = $lm->used; cmp_ok($used->[0], '==', 49, 'width used'); cmp_ok($used->[1], '==', 60, 'height used'); Layout-Manager-0.35/t/11-flow/06-east-margin.t000644 000765 000024 00000002376 12270604305 021013 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 11; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Flow'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 25 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 24 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 80 ); $cont->margins->left(10); $cont->margins->top(11); $cont->margins->right(12); $cont->margins->bottom(9); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'east'); $lm->do_layout($cont); cmp_ok($foo->height, '==', 60, 'component 1 height'); cmp_ok($foo->width, '==', 25, 'component 1 width'); cmp_ok($foo->origin->x, '==', 63, 'component 1 origin x'); cmp_ok($foo->origin->y, '==', 11, 'component 1 origin y'); cmp_ok($foo2->height, '==', 60, 'component 2 height'); cmp_ok($foo2->width, '==', 24, 'component 2 width'); cmp_ok($foo2->origin->x, '==', 39, 'component 2 origin x'); cmp_ok($foo2->origin->y, '==', 11, 'component 2 origin y'); my $used = $lm->used; cmp_ok($used->[0], '==', 49, 'width used'); cmp_ok($used->[1], '==', 60, 'height used'); Layout-Manager-0.35/t/11-flow/07-south-margin.t000644 000765 000024 00000002377 12270604305 021223 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 11; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Flow'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 25 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 24 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 80 ); $cont->margins->left(10); $cont->margins->top(11); $cont->margins->right(12); $cont->margins->bottom(9); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'south'); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'component 1 height'); cmp_ok($foo->width, '==', 78, 'component 1 width'); cmp_ok($foo->origin->x, '==', 10, 'component 1 origin x'); cmp_ok($foo->origin->y, '==', 51, 'component 1 origin y'); cmp_ok($foo2->height, '==', 20, 'component 2 height'); cmp_ok($foo2->width, '==', 78, 'component 2 width'); cmp_ok($foo2->origin->x, '==', 10, 'component 2 origin x'); cmp_ok($foo2->origin->y, '==', 31, 'component 2 origin y'); my $used = $lm->used; cmp_ok($used->[0], '==', 78, 'width used'); cmp_ok($used->[1], '==', 40, 'height used'); Layout-Manager-0.35/t/11-flow/08-west-wrap.t000644 000765 000024 00000002364 12270604305 020534 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; use Layout::Manager::Flow; my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 30 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 30 ); my $cont = Graphics::Primitive::Container->new(width => 50); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'west', wrap => 1); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'left bottom component height'); cmp_ok($foo->width, '==', 30, 'left component width'); cmp_ok($foo->origin->x, '==', 0, 'left component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left component origin y'); cmp_ok($foo2->height, '==', 20, 'right component height'); cmp_ok($foo2->width, '==', 30, 'right component width'); cmp_ok($foo2->origin->x, '==', 0, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'right component origin y'); cmp_ok($cont->minimum_height, '==', 40, 'container height'); my $used = $lm->used; cmp_ok($used->[0], '==', 30, 'width used'); cmp_ok($used->[1], '==', 40, 'height used'); Layout-Manager-0.35/t/11-flow/09-east-wrap.t000644 000765 000024 00000002364 12270604305 020507 0ustar00gphatstaff000000 000000 use strict; use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; use Layout::Manager::Flow; my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 30 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 30 ); my $cont = Graphics::Primitive::Container->new(width => 50); $cont->add_component($foo); $cont->add_component($foo2); my $lm = Layout::Manager::Flow->new(anchor => 'east', wrap => 1); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'left bottom component height'); cmp_ok($foo->width, '==', 30, 'left component width'); cmp_ok($foo->origin->x, '==', 20, 'left component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left component origin y'); cmp_ok($foo2->height, '==', 20, 'right component height'); cmp_ok($foo2->width, '==', 30, 'right component width'); cmp_ok($foo2->origin->x, '==', 20, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'right component origin y'); cmp_ok($cont->minimum_height, '==', 40, 'minimum_height'); my $used = $lm->used; cmp_ok($used->[0], '==', 30, 'width used'); cmp_ok($used->[1], '==', 40, 'height used'); Layout-Manager-0.35/t/10-compass/01-north.t000644 000765 000024 00000002324 12270604305 020417 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 100 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 100 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'NORTH'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'north'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'top component height'); cmp_ok($foo->width, '==', 100, 'top component width'); cmp_ok($foo->origin->x, '==', 0, 'top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'top component origin y'); cmp_ok($foo2->height, '==', 20, 'bottom component height'); cmp_ok($foo2->width, '==', 100, 'bottom component width'); cmp_ok($foo2->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'bottom component origin y'); Layout-Manager-0.35/t/10-compass/02-south.t000644 000765 000024 00000002320 12270604305 020424 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 100 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 100 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'South'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'S'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo2->height, '==', 20, 'top component height'); cmp_ok($foo2->width, '==', 100, 'top component width'); cmp_ok($foo2->origin->x, '==', 0, 'top component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'top component origin y'); cmp_ok($foo->height, '==', 20, 'bottom component height'); cmp_ok($foo->width, '==', 100, 'bottom component width'); cmp_ok($foo->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo->origin->y, '==', 20, 'bottom component origin y'); Layout-Manager-0.35/t/10-compass/03-east.t000644 000765 000024 00000002322 12270604305 020221 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 50 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 50 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 20 ); $cont->add_component($foo, 'EaSt'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'e'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'right bottom component height'); cmp_ok($foo->width, '==', 50, 'right component width'); cmp_ok($foo->origin->x, '==', 50, 'right component origin x'); cmp_ok($foo->origin->y, '==', 0, 'right component origin y'); cmp_ok($foo2->height, '==', 20, 'left component height'); cmp_ok($foo2->width, '==', 50, 'left component width'); cmp_ok($foo2->origin->x, '==', 0, 'left component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'left component origin y'); Layout-Manager-0.35/t/10-compass/04-west.t000644 000765 000024 00000002313 12270604305 020250 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 50 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 50 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'WeSt'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'W'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->height, '==', 40, 'left component height'); cmp_ok($foo->width, '==', 50, 'left component width'); cmp_ok($foo->origin->x, '==', 0, 'left component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left component origin y'); cmp_ok($foo2->height, '==', 40, 'right component height'); cmp_ok($foo2->width, '==', 50, 'right component width'); cmp_ok($foo2->origin->x, '==', 50, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'right component origin y'); Layout-Manager-0.35/t/10-compass/05-sane.t000644 000765 000024 00000004056 12270604305 020223 0ustar00gphatstaff000000 000000 use Test::More tests => 22; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $north = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $south = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $east = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $west = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $center = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $cont = Graphics::Primitive::Container->new( width => 120, height => 100 ); $cont->add_component($north, 'n'); $cont->add_component($south, 's'); $cont->add_component($east, 'e'); $cont->add_component($west, 'w'); $cont->add_component($center, 'c'); cmp_ok($cont->component_count, '==', 5, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($north->origin->x, '==', 0, 'north origin x'); cmp_ok($north->origin->y, '==', 0, 'north origin y'); cmp_ok($north->width, '==', 120, 'north width'); cmp_ok($north->height, '==', 10, 'north height'); cmp_ok($south->origin->x, '==', 0, 'south origin x'); cmp_ok($south->origin->y, '==', 90, 'south origin y'); cmp_ok($south->width, '==', 120, 'south width'); cmp_ok($south->height, '==', 10, 'south height'); cmp_ok($east->origin->x, '==', 110, 'east origin x'); cmp_ok($east->origin->y, '==', 10, 'east origin y'); cmp_ok($east->width, '==', 10, 'east width'); cmp_ok($east->height, '==', 80, 'east height'); cmp_ok($west->origin->x, '==', 0, 'west origin x'); cmp_ok($west->origin->y, '==', 10, 'west origin y'); cmp_ok($west->width, '==', 10, 'west width'); cmp_ok($west->height, '==', 80, 'west height'); cmp_ok($center->origin->x, '==', 10, 'center origin x'); cmp_ok($center->origin->y, '==', 10, 'center origin y'); cmp_ok($center->width, '==', 100, 'center width'); cmp_ok($center->height, '==', 80, 'center height');Layout-Manager-0.35/t/10-compass/06-east-west.t000644 000765 000024 00000002310 12270604305 021201 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 19 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 10, minimum_width => 20 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'w'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'e'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->width, '==', 19, 'left component width'); cmp_ok($foo->height, '==', 40, 'left component height'); cmp_ok($foo->origin->x, '==', 0, 'left component origin x'); cmp_ok($foo->origin->y, '==', 0, 'left component origin y'); cmp_ok($foo2->width, '==', 20, 'right component width'); cmp_ok($foo2->height, '==', 40, 'right component height'); cmp_ok($foo2->origin->x, '==', 80, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'right component origin y'); Layout-Manager-0.35/t/10-compass/06-north-east.t000644 000765 000024 00000002306 12270604305 021356 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 20 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 20 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'n'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'e'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'top component height'); cmp_ok($foo->width, '==', 100, 'top component width'); cmp_ok($foo->origin->x, '==', 0, 'top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'top component origin y'); cmp_ok($foo2->height, '==', 20, 'right component height'); cmp_ok($foo2->width, '==', 20, 'right component width'); cmp_ok($foo2->origin->x, '==', 80, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'right component origin y'); Layout-Manager-0.35/t/10-compass/06-north-west.t000644 000765 000024 00000002304 12270604305 021402 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 20 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 20 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'n'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'w'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new(); $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'top component height'); cmp_ok($foo->width, '==', 100, 'top component width'); cmp_ok($foo->origin->x, '==', 00, 'top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'top component origin y'); cmp_ok($foo2->height, '==', 20, 'left component height'); cmp_ok($foo2->width, '==', 20, 'left component width'); cmp_ok($foo2->origin->x, '==', 0, 'left component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'left component origin y'); Layout-Manager-0.35/t/10-compass/06-south-east.t000644 000765 000024 00000002322 12270604305 021364 0ustar00gphatstaff000000 000000 use Test::More tests => 11; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 20 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 20 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 's'); cmp_ok($cont->component_count, '==', 1, 'component_count'); $cont->add_component($foo2, 'e'); cmp_ok($cont->component_count, '==', 2, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'bottom component height'); cmp_ok($foo->width, '==', 100, 'bottom component width'); cmp_ok($foo->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo->origin->y, '==', 20, 'bottom component origin y'); cmp_ok($foo2->height, '==', 20, 'right component height'); cmp_ok($foo2->width, '==', 20, 'right component width'); cmp_ok($foo2->origin->x, '==', 80, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 0, 'right component origin y'); Layout-Manager-0.35/t/10-compass/07-clickeresque.t000644 000765 000024 00000004316 12270604305 021755 0ustar00gphatstaff000000 000000 use Test::More tests => 22; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Layout::Manager::Single; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = new Graphics::Primitive::Component( minimum_height => 10, minimum_width => 10 ); my $yaxis = new Graphics::Primitive::Component( minimum_height => 10, minimum_width => 20 ); my $xaxis = new Graphics::Primitive::Component( minimum_height => 20, minimum_width => 10 ); my $plot = new Graphics::Primitive::Container( minimum_height => 10, minimum_width => 10, layout_manager => Layout::Manager::Single->new ); my $renderer = new Graphics::Primitive::Component( minimum_height => 10, minimum_width => 10, ); $plot->add_component($renderer); my $cont = new Graphics::Primitive::Container( width => 500, height => 300 ); $cont->add_component($legend, 's'); $cont->add_component($xaxis, 's'); $cont->add_component($yaxis, 'w'); $cont->add_component($plot, 'c'); cmp_ok($cont->component_count, '==', 4, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($legend->origin->x, '==', 0, 'legend origin x'); cmp_ok($legend->origin->y, '==', 290, 'legend origin y'); cmp_ok($legend->width, '==', 500, 'legend width'); cmp_ok($legend->height, '==', 10, 'north height'); cmp_ok($yaxis->origin->x, '==', 0, 'yaxis origin x'); cmp_ok($yaxis->origin->y, '==', 0, 'yaxis origin y'); cmp_ok($yaxis->width, '==', 20, 'yaxis width'); cmp_ok($yaxis->height, '==', 270, 'yaxis height'); cmp_ok($xaxis->origin->x, '==', 0, 'xaxis origin x'); cmp_ok($xaxis->origin->y, '==', 270, 'xaxis origin y'); cmp_ok($xaxis->width, '==', 500, 'xaxis width'); cmp_ok($xaxis->height, '==', 20, 'xaxis height'); cmp_ok($plot->origin->x, '==', 20, 'plot origin x'); cmp_ok($plot->origin->y, '==', 0, 'plot origin y'); cmp_ok($plot->width, '==', 480, 'plot width'); cmp_ok($plot->height, '==', 270, 'plot height'); cmp_ok($renderer->origin->x, '==', 0, 'renderer origin x'); cmp_ok($renderer->origin->y, '==', 0, 'renderer origin y'); cmp_ok($renderer->width, '==', $plot->width, 'renderer width'); cmp_ok($renderer->height, '==', $plot->height, 'renderer width');Layout-Manager-0.35/t/10-compass/08-click-invis.t000644 000765 000024 00000003355 12270604305 021514 0ustar00gphatstaff000000 000000 use Test::More tests => 18; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $yaxis = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 20, visible => 0 ); my $xaxis = Graphics::Primitive::Component->new( minimum_height => 20, minimum_width => 10 ); my $plot = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $cont = new Graphics::Primitive::Container( width => 500, height => 300 ); $cont->add_component($legend, 's'); $cont->add_component($xaxis, 's'); $cont->add_component($yaxis, 'w'); $cont->add_component($plot, 'c'); cmp_ok($cont->component_count, '==', 4, 'component_count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($legend->origin->x, '==', 0, 'legend origin x'); cmp_ok($legend->origin->y, '==', 290, 'legend origin y'); cmp_ok($legend->width, '==', 500, 'legend width'); cmp_ok($legend->height, '==', 10, 'north height'); cmp_ok($yaxis->origin->x, '==', 0, 'yaxis origin x'); cmp_ok($yaxis->origin->y, '==', 0, 'yaxys origin y'); cmp_ok($yaxis->width, '==', 0, 'yaxis width'); cmp_ok($yaxis->height, '==', 0, 'yaxis height'); cmp_ok($xaxis->origin->x, '==', 0, 'xaxis origin x'); cmp_ok($xaxis->origin->y, '==', 270, 'xaxis origin y'); cmp_ok($xaxis->width, '==', 500, 'xaxis width'); cmp_ok($xaxis->height, '==', 20, 'xaxis height'); cmp_ok($plot->origin->x, '==', 0, 'plot origin x'); cmp_ok($plot->origin->y, '==', 0, 'plot origin y'); cmp_ok($plot->width, '==', 500, 'plot width'); cmp_ok($plot->height, '==', 270, 'plot height'); Layout-Manager-0.35/t/10-compass/09-remove.t000644 000765 000024 00000003724 12270604305 020577 0ustar00gphatstaff000000 000000 use Test::More tests => 19; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $north = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10, name => 'north' ); my $south = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $east = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $west = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $center = Graphics::Primitive::Component->new( minimum_height => 10, minimum_width => 10 ); my $cont = Graphics::Primitive::Container->new( width => 120, height => 100 ); $cont->add_component($north, 'n'); $cont->add_component($south, 's'); $cont->add_component($east, 'e'); $cont->add_component($west, 'w'); $cont->add_component($center, 'c'); my $count = $cont->remove_component('north'); cmp_ok(scalar(@{ $count }), '==', 1, 'removed north'); cmp_ok($cont->component_count, '==', 5, 'component_count'); my $lm = Layout::Manager::Compass->new(); $lm->do_layout($cont); cmp_ok($south->origin->x, '==', 0, 'south origin x'); cmp_ok($south->origin->y, '==', 90, 'south origin y'); cmp_ok($south->width, '==', 120, 'south width'); cmp_ok($south->height, '==', 10, 'south height'); cmp_ok($east->origin->x, '==', 110, 'east origin x'); cmp_ok($east->origin->y, '==', 0, 'east origin y'); cmp_ok($east->width, '==', 10, 'east width'); cmp_ok($east->height, '==', 90, 'east height'); cmp_ok($west->origin->x, '==', 0, 'west origin x'); cmp_ok($west->origin->y, '==', 0, 'west origin y'); cmp_ok($west->width, '==', 10, 'west width'); cmp_ok($west->height, '==', 90, 'west height'); cmp_ok($center->origin->x, '==', 10, 'center origin x'); cmp_ok($center->origin->y, '==', 0, 'center origin y'); cmp_ok($center->width, '==', 100, 'center width'); cmp_ok($center->height, '==', 90, 'center height');Layout-Manager-0.35/t/10-compass/10-nce.t000644 000765 000024 00000002755 12270604305 020042 0ustar00gphatstaff000000 000000 use Test::More tests => 14; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 20 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 20 ); my $foo3 = Graphics::Primitive::Component->new( name => 'three', minimum_height => 20, minimum_width => 20 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'n'); $cont->add_component($foo2, 'e'); $cont->add_component($foo3, 'c'); cmp_ok($cont->component_count, '==', 3, 'component count'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->width, '==', 100, 'top component width'); cmp_ok($foo->height, '==', 20, 'top component height'); cmp_ok($foo->origin->x, '==', 0, 'top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'top component origin y'); cmp_ok($foo2->width, '==', 20, 'right component width'); cmp_ok($foo2->height, '==', 20, 'right component height'); cmp_ok($foo2->origin->x, '==', 80, 'right component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'right component origin y'); cmp_ok($foo3->origin->x, '==', 0, 'center origin x'); cmp_ok($foo3->origin->y, '==', 20, 'center origin y'); cmp_ok($foo3->width, '==', 80, 'center width'); cmp_ok($foo3->height, '==', 20, 'center height'); Layout-Manager-0.35/t/10-compass/11-center.t000644 000765 000024 00000002121 12270604305 020541 0ustar00gphatstaff000000 000000 use Test::More tests => 9; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 80 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 50 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'c'); $cont->add_component($foo2, 'c'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); cmp_ok($foo->height, '==', 20, 'top component height'); cmp_ok($foo->width, '==', 100, 'top component width'); cmp_ok($foo->origin->x, '==', 0, 'top component origin x'); cmp_ok($foo->origin->y, '==', 0, 'top component origin y'); cmp_ok($foo2->height, '==', 20, 'bottom component height'); cmp_ok($foo2->width, '==', 100, 'bottom component width'); cmp_ok($foo2->origin->x, '==', 0, 'bottom component origin x'); cmp_ok($foo2->origin->y, '==', 20, 'bottom component origin y'); Layout-Manager-0.35/t/10-compass/14-container-center.t000644 000765 000024 00000003473 12270604305 022537 0ustar00gphatstaff000000 000000 use Test::More tests => 15; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'e'); $legend->add_component($text2, 'w'); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ) ); my $text3 = Graphics::Primitive::Component->new( minimum_width => 13, minimum_height => 11); $cont->add_component($text3, 's'); $cont->add_component($legend, 'c'); cmp_ok($cont->component_count, '==', 2, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 4, 'legend origin x'); cmp_ok($legend->origin->y, '==', 5, 'legend origin y'); cmp_ok($legend->width, '==', 113, 'legend width'); cmp_ok($legend->height, '==', 82, 'legend height'); cmp_ok($text1->origin->x, '==', 103, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 10, 'text1 width'); cmp_ok($text1->height, '==', 82, 'text1 height'); cmp_ok($text2->origin->x, '==', 0, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 0, 'text2 origin y'); cmp_ok($text2->width, '==', 15, 'text2 width'); cmp_ok($text2->height, '==', 82, 'text2 height'); Layout-Manager-0.35/t/10-compass/15-container-east.t000644 000765 000024 00000004120 12270604305 022202 0ustar00gphatstaff000000 000000 use Test::More tests => 19; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( name => 'text1', minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( name => 'text2', minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'e'); $legend->add_component($text2, 'w'); my $text3 = Graphics::Primitive::Component->new( name => 'text3', minimum_width => 20, minimum_height => 10); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ), name => 'root' ); $cont->add_component($legend, 'e'); $cont->add_component($text3, 's'); cmp_ok($cont->component_count, '==', 2, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 92, 'legend origin x'); cmp_ok($legend->origin->y, '==', 5, 'legend origin y'); cmp_ok($legend->width, '==', 25, 'legend width'); cmp_ok($legend->height, '==', 83, 'legend height'); cmp_ok($text1->origin->x, '==', 15, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 10, 'text1 width'); cmp_ok($text1->height, '==', 83, 'text1 height'); cmp_ok($text2->origin->x, '==', 0, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 0, 'text2 origin y'); cmp_ok($text2->width, '==', 15, 'text2 width'); cmp_ok($text2->height, '==', 83, 'text2 height'); cmp_ok($text3->origin->x, '==', 4, 'text3 origin x'); cmp_ok($text3->origin->y, '==', 88, 'text3 origin y'); cmp_ok($text3->width, '==', 113, 'text3 width'); cmp_ok($text3->height, '==', 10, 'text3 height');Layout-Manager-0.35/t/10-compass/16-container-west.t000644 000765 000024 00000003270 12270604305 022236 0ustar00gphatstaff000000 000000 use Test::More tests => 15; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'e'); $legend->add_component($text2, 'w'); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ) ); $cont->add_component($legend, 'w'); cmp_ok($cont->component_count, '==', 1, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 4, 'legend origin x'); cmp_ok($legend->origin->y, '==', 5, 'legend origin y'); cmp_ok($legend->width, '==', 25, 'legend width'); cmp_ok($legend->height, '==', 93, 'legend height'); cmp_ok($text1->origin->x, '==', 15, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 10, 'text1 width'); cmp_ok($text1->height, '==', 93, 'text1 height'); cmp_ok($text2->origin->x, '==', 0, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 0, 'text2 origin y'); cmp_ok($text2->width, '==', 15, 'text2 width'); cmp_ok($text2->height, '==', 93, 'text2 height'); Layout-Manager-0.35/t/10-compass/17-container-east-center.t000644 000765 000024 00000004116 12270604305 023467 0ustar00gphatstaff000000 000000 use Test::More tests => 19; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( name => 'text1', minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( name => 'text2', minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'e'); $legend->add_component($text2, 'w'); my $text3 = Graphics::Primitive::Component->new( name => 'text3', minimum_width => 20, minimum_height => 10); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ), name => 'root' ); $cont->add_component($legend, 'e'); $cont->add_component($text3, 'c'); cmp_ok($cont->component_count, '==', 2, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 92, 'legend origin x'); cmp_ok($legend->origin->y, '==', 5, 'legend origin y'); cmp_ok($legend->width, '==', 25, 'legend width'); cmp_ok($legend->height, '==', 93, 'legend height'); cmp_ok($text1->origin->x, '==', 15, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 10, 'text1 width'); cmp_ok($text1->height, '==', 93, 'text1 height'); cmp_ok($text2->origin->x, '==', 0, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 0, 'text2 origin y'); cmp_ok($text2->width, '==', 15, 'text2 width'); cmp_ok($text2->height, '==', 93, 'text2 height'); cmp_ok($text3->origin->x, '==', 4, 'text3 origin x'); cmp_ok($text3->origin->y, '==', 5, 'text3 origin y'); cmp_ok($text3->width, '==', 88, 'text3 width'); cmp_ok($text3->height, '==', 93, 'text3 height');Layout-Manager-0.35/t/10-compass/18-container-south.t000644 000765 000024 00000004120 12270604305 022413 0ustar00gphatstaff000000 000000 use Test::More tests => 19; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( name => 'text1', minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( name => 'text2', minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'w'); $legend->add_component($text2, 'w'); my $text3 = Graphics::Primitive::Component->new( name => 'text3', minimum_width => 20, minimum_height => 10); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ), name => 'root' ); $cont->add_component($legend, 's'); $cont->add_component($text3, 'e'); cmp_ok($cont->component_count, '==', 2, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 4, 'legend origin x'); cmp_ok($legend->origin->y, '==', 83, 'legend origin y'); cmp_ok($legend->width, '==', 113, 'legend width'); cmp_ok($legend->height, '==', 15, 'legend height'); cmp_ok($text1->origin->x, '==', 0, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 10, 'text1 width'); cmp_ok($text1->height, '==', 15, 'text1 height'); cmp_ok($text2->origin->x, '==', 10, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 0, 'text2 origin y'); cmp_ok($text2->width, '==', 15, 'text2 width'); cmp_ok($text2->height, '==', 15, 'text2 height'); cmp_ok($text3->origin->x, '==', 97, 'text3 origin x'); cmp_ok($text3->origin->y, '==', 5, 'text3 origin y'); cmp_ok($text3->width, '==', 20, 'text3 width'); cmp_ok($text3->height, '==', 78, 'text3 height');Layout-Manager-0.35/t/10-compass/19-container-south-p2.t000644 000765 000024 00000004122 12270604305 022735 0ustar00gphatstaff000000 000000 use Test::More tests => 19; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( name => 'text1', minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( name => 'text2', minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'n'); $legend->add_component($text2, 's'); my $text3 = Graphics::Primitive::Component->new( name => 'text3', minimum_width => 20, minimum_height => 10); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ), name => 'root' ); $cont->add_component($legend, 'n'); $cont->add_component($text3, 'e'); cmp_ok($cont->component_count, '==', 2, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 4, 'legend origin x'); cmp_ok($legend->origin->y, '==', 5, 'legend origin y'); cmp_ok($legend->width, '==', 113, 'legend width'); cmp_ok($legend->height, '==', 25, 'legend height'); cmp_ok($text1->origin->x, '==', 0, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 113, 'text1 width'); cmp_ok($text1->height, '==', 15, 'text1 height'); cmp_ok($text2->origin->x, '==', 0, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 15, 'text2 origin y'); cmp_ok($text2->width, '==', 113, 'text2 width'); cmp_ok($text2->height, '==', 10, 'text2 height'); cmp_ok($text3->origin->x, '==', 97, 'text3 origin x'); cmp_ok($text3->origin->y, '==', 30, 'text3 origin y'); cmp_ok($text3->width, '==', 20, 'text3 width'); cmp_ok($text3->height, '==', 68, 'text3 height');Layout-Manager-0.35/t/10-compass/19-container-south-p3.t000644 000765 000024 00000004121 12270604305 022735 0ustar00gphatstaff000000 000000 use Test::More tests => 19; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( name => 'text1', minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( name => 'text2', minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'n'); $legend->add_component($text2, 'w'); my $text3 = Graphics::Primitive::Component->new( name => 'text3', minimum_width => 20, minimum_height => 10); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ), name => 'root' ); $cont->add_component($legend, 'n'); $cont->add_component($text3, 'e'); cmp_ok($cont->component_count, '==', 2, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 4, 'legend origin x'); cmp_ok($legend->origin->y, '==', 5, 'legend origin y'); cmp_ok($legend->width, '==', 113, 'legend width'); cmp_ok($legend->height, '==', 25, 'legend height'); cmp_ok($text1->origin->x, '==', 0, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 113, 'text1 width'); cmp_ok($text1->height, '==', 15, 'text1 height'); cmp_ok($text2->origin->x, '==', 0, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 15, 'text2 origin y'); cmp_ok($text2->width, '==', 15, 'text2 width'); cmp_ok($text2->height, '==', 10, 'text2 height'); cmp_ok($text3->origin->x, '==', 97, 'text3 origin x'); cmp_ok($text3->origin->y, '==', 30, 'text3 origin y'); cmp_ok($text3->width, '==', 20, 'text3 width'); cmp_ok($text3->height, '==', 68, 'text3 height');Layout-Manager-0.35/t/10-compass/25-validity.t000644 000765 000024 00000002620 12270604305 021117 0ustar00gphatstaff000000 000000 use Test::More tests => 4; use lib qw(t/lib lib); use DummyDriver; use Geometry::Primitive::Point; use Graphics::Primitive::Component; use Graphics::Primitive::Container; BEGIN { use_ok('Layout::Manager::Compass'); } my $foo = Graphics::Primitive::Component->new( name => 'one', minimum_height => 20, minimum_width => 20 ); my $foo2 = Graphics::Primitive::Component->new( name => 'two', minimum_height => 20, minimum_width => 20 ); my $foo3 = Graphics::Primitive::Component->new( name => 'three', minimum_height => 20, minimum_width => 20 ); my $cont = Graphics::Primitive::Container->new( width => 100, height => 40 ); $cont->add_component($foo, 'n'); $cont->add_component($foo2, 'e'); $cont->add_component($foo3, 'c'); cmp_ok($cont->component_count, '==', 3, 'component count'); my $driver = new DummyDriver; $driver->prepare($cont); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); my $cont2 = Graphics::Primitive::Container->new( width => 100, height => 40, layout_manager => Layout::Manager::Compass->new ); my $foo4 = Graphics::Primitive::Component->new( name => 'four', minimum_height => 20, minumim_width => 20 ); $cont2->add_component($foo4, 'c'); $cont->add_component($cont2, 'w'); my $ret2 = $lm->do_layout($cont); cmp_ok($ret2, '==', 1, 'layout executed'); $foo4->width(21); my $ret4 = $lm->do_layout($cont); cmp_ok($ret4, '==', 1, 'layout executed'); Layout-Manager-0.35/t/10-compass/50-complex.t000644 000765 000024 00000010360 12270604305 020737 0ustar00gphatstaff000000 000000 use Test::More tests => 43; use Graphics::Primitive::Insets; use Geometry::Primitive::Point; use Layout::Manager::Compass; use Graphics::Primitive::Container; use Graphics::Primitive::Component; BEGIN { use_ok('Layout::Manager::Compass'); } my $legend = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend' ); my $text1 = Graphics::Primitive::Component->new( minimum_width => 10, minimum_height => 15); my $text2 = Graphics::Primitive::Component->new( minimum_width => 15, minimum_height => 10); $legend->add_component($text1, 'e'); $legend->add_component($text2, 'w'); my $legend2 = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend2' ); my $text3 = Graphics::Primitive::Component->new( minimum_width => 10, minimum_height => 15); my $text4 = Graphics::Primitive::Component->new( minimum_width => 10, minimum_height => 10); $legend2->add_component($text3, 'n'); $legend2->add_component($text4, 'w'); my $legend3 = Graphics::Primitive::Container->new( layout_manager => Layout::Manager::Compass->new, name => 'legend3' ); my $text5 = Graphics::Primitive::Component->new( minimum_width => 10, minimum_height => 15); my $text6 = Graphics::Primitive::Component->new( minimum_width => 15, minimum_height => 10); my $text7 = Graphics::Primitive::Component->new( minimum_width => 10, minimum_height => 5); $legend3->add_component($text5, 'c'); $legend3->add_component($text6, 'e'); $legend3->add_component($text7, 'n'); my $cont = new Graphics::Primitive::Container( width => 120, height => 100, padding => Graphics::Primitive::Insets->new( top => 5, left => 4, right => 3, bottom => 2 ) ); $cont->add_component($legend, 's'); $cont->add_component($legend2, 'n'); $cont->add_component($legend3, 'w'); cmp_ok($cont->component_count, '==', 3, 'root component_count'); cmp_ok($legend->component_count, '==', 2, 'legend component_count'); cmp_ok($legend2->component_count, '==', 2, 'legend2 component_count'); cmp_ok($legend3->component_count, '==', 3, 'legend3 component_count'); my $lm = Layout::Manager::Compass->new; $cont->layout_manager($lm); $cont->do_layout($cont); cmp_ok($legend->origin->x, '==', 4, 'legend origin x'); cmp_ok($legend->origin->y, '==', 83, 'legend origin y'); cmp_ok($legend->width, '==', 113, 'legend width'); cmp_ok($legend->height, '==', 15, 'legend height'); # cmp_ok($text1->origin->x, '==', 107, 'text1 origin x'); cmp_ok($text1->origin->y, '==', 0, 'text1 origin y'); cmp_ok($text1->width, '==', 10, 'text1 width'); cmp_ok($text1->height, '==', 15, 'text1 height'); cmp_ok($text2->origin->x, '==', 0, 'text2 origin x'); cmp_ok($text2->origin->y, '==', 0, 'text2 origin y'); cmp_ok($text2->width, '==', 15, 'text2 width'); cmp_ok($text2->height, '==', 15, 'text2 height'); cmp_ok($legend2->origin->x, '==', 4, 'legend2 origin x'); cmp_ok($legend2->origin->y, '==', 5, 'legend2 origin y'); cmp_ok($legend2->width, '==', 113, 'legend2 width'); cmp_ok($legend2->height, '==', 25, 'legend2 height'); cmp_ok($text3->origin->x, '==', 0, 'text3 origin x'); cmp_ok($text3->origin->y, '==', 0, 'text3 origin y'); cmp_ok($text3->width, '==', 113, 'text3 width'); cmp_ok($text3->height, '==', 15, 'text3 height'); cmp_ok($text4->origin->x, '==', 0, 'text4 origin x'); cmp_ok($text4->origin->y, '==', 15, 'text4 origin y'); cmp_ok($text4->width, '==', 10, 'text4 width'); cmp_ok($text4->height, '==', 10, 'text4 height'); cmp_ok($legend3->origin->x, '==', 4, 'legend 3 origin x'); cmp_ok($legend3->origin->y, '==', 30, 'legend 3 origin y'); cmp_ok($legend3->width, '==', 25, 'legend 3 width'); # cmp_ok($legend3->height, '==', 25, 'legend 3 height'); cmp_ok($text5->origin->x, '==', 0, 'text5 origin x'); cmp_ok($text5->origin->y, '==', 5, 'text5 origin y'); cmp_ok($text5->width, '==', 10, 'text5 width'); cmp_ok($text5->height, '==', 48, 'text5 height'); cmp_ok($text6->origin->x, '==', 10, 'text6 origin x'); cmp_ok($text6->origin->y, '==', 5, 'text6 origin y'); cmp_ok($text6->width, '==', 15, 'text6 width'); cmp_ok($text6->height, '==', 48, 'text6 height'); cmp_ok($text7->origin->x, '==', 0, 'text7 origin x'); cmp_ok($text7->origin->y, '==', 0, 'text7 origin y'); cmp_ok($text7->width, '==', 25, 'text7 width'); cmp_ok($text7->height, '==', 5, 'text7 height');Layout-Manager-0.35/lib/Layout/000755 000765 000024 00000000000 12270604667 016571 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/lib/Layout/Manager/000755 000765 000024 00000000000 12270604667 020143 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/lib/Layout/Manager.pm000644 000765 000024 00000010455 12270604655 020503 0ustar00gphatstaff000000 000000 package Layout::Manager; use Moose; our $AUTHORITY = 'cpan:GPHAT'; our $VERSION = '0.35'; sub do_layout { my ($self, $container) = @_; die('Need a container') unless defined($container); return 0 unless $container->component_count; return 0 if $container->prepared && $self->_check_container($container); # Layout child containers first, since we can't fit them into this one # without knowing the sizes. foreach my $comp (@{ $container->components }) { next unless defined($comp) && $comp->visible; if($comp->can('do_layout')) { $comp->do_layout($comp); } } $container->prepared(1); return 1; } sub _check_container { my ($self, $cont) = @_; foreach my $comp (@{ $cont->components }) { unless($comp->prepared) { $cont->prepared(0); return 0; } if($comp->can('do_layout')) { if(!$self->_check_container($comp)) { $comp->prepared(0); return 0; } } } return 1; } __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Layout::Manager - 2D Layout Management =head1 SYNOPSIS Layout::Manager provides a simple interface for creating layout managers, or classes that size and position components within a container. A few managers are provided for reference, but this module is primarily meant to serve as a base for outside implementations. use Layout::Manager; my $foo = Layout::Manager->new; $foo->do_layout($component); =head1 USING A LAYOUT MANAGER Layout::Manager relies on L as a source for it's components. Various implementations of Layout::Manager will require you do add components with slightly different second arguments, but the general case will be: $lm->add_component($comp, $constraints); The contents of B<$constraints> must be discerned by reading the documentation for the layout manager you are using. The B<$comp> argument must be a L. Layout manager works hand-in-hand with Graphics::Primitive, so you'll want to check out the L documented in L. It will look something like this: $cont->add_component($foo, { some => metadata }); $driver->prepare($cont); my $lm = new Layout::Manager::SomeImplementation; $lm->do_layout($cont); $driver->pack($cont); $driver->draw($cont); When you are ready to lay out your container, you'll need to call the L method with a single argument: the component in which you are laying things out. When I returns all of the components should be resized and repositioned according to the rules of the Layout::Manager implementation. =head2 PREPARATION Subsequent calls to do_layout will be ignored if the Container is prepared. The Container's C flag and the flags of all it's children are checked, so any modifications to B child component will cause the entire container (and any container children) to be laid out again. =head1 WRITING A LAYOUT MANAGER Layout::Manager provides all the methods necessary for your implementation, save the I method. This method will be called when it is time to layout the components. The I method takes two arguments: the component and a second, abritrary piece of data. If your layout manager is simple, like L, you may only require a simple variable like "NORTH". If you create something more complex the second argument may be a hashref or an object. The value of the I method is an arrayref of hashrefs. The hashrefs have two keys: =over =item B The component to be laid out. =item B The argument provided to I. =back =head1 TIPS Layout manager implementations should honor the I attribute of a component, as those components need to be ignored. =head1 METHODS =head2 do_layout Lays out this manager's components in the specified container. =head1 AUTHOR Cory Watson, C<< >> =head1 SEE ALSO perl(1), L =head1 COPYRIGHT & LICENSE Copyright 2008 - 2010 Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Layout-Manager-0.35/lib/Layout/Manager/Absolute.pm000644 000765 000024 00000001362 12270604305 022246 0ustar00gphatstaff000000 000000 package Layout::Manager::Absolute; use Moose; extends 'Layout::Manager'; __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Layout::Manager::Absolute - No frills layout manager =head1 DESCRIPTION Does nothing. Expects that all components will be positioned already. =head1 SYNOPSIS $cont->add_component($comp1); $cont->add_component($comp2); my $lm = Layout::Manager::Absolute->new; $lm->do_layout($cont); =head1 METHODS =head2 do_layout Size and position the components in this layout. =head1 AUTHOR Cory Watson, C<< >> =head1 COPYRIGHT & LICENSE Copyright 2008-2010 by Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.Layout-Manager-0.35/lib/Layout/Manager/Axis.pm000644 000765 000024 00000017042 12270604305 021376 0ustar00gphatstaff000000 000000 package Layout::Manager::Axis; use Moose; extends 'Layout::Manager'; override('do_layout', sub { my ($self, $container) = @_; return 0 if $container->prepared && $self->_check_container($container); my $bbox = $container->inside_bounding_box; my $cwidth = $bbox->width; my $cheight = $bbox->height; my %edges = ( north => { components => [], width => $cwidth, height => 0 }, south => { components => [], width => $cwidth, height => 0 }, east => { components => [], width => 0, height => $cheight }, west => { components => [], width => 0, height => $cheight }, center => { components => [], width => $cwidth, height => $cheight } ); # This loop takes each component and adds it's width and height to the # 'edge' on which is positioned. At the end will know how much width and # height we need for each edge. for(my $i = 0; $i < scalar(@{ $container->components }); $i++) { my $comp = $container->get_component($i); next unless defined($comp) && $comp->visible; # Set each component to it's minimum size for now $comp->width($comp->minimum_width); $comp->height($comp->minimum_height); my $args = lc(substr($container->get_constraint($i), 0, 1)); if($comp->can('do_layout')) { $self->_layout_container($comp); } if(($args) eq 'c') { push(@{ $edges{center}->{components} }, $comp); } elsif($args eq 'n') { push(@{ $edges{north}->{components} }, $comp); $edges{north}->{height} += $comp->minimum_height; $edges{east}->{height} -= $comp->minimum_height; $edges{west}->{height} -= $comp->minimum_height; $edges{center}->{height} -= $comp->minimum_height; } elsif($args eq 's') { push(@{ $edges{south}->{components} }, $comp); $edges{south}->{height} += $comp->minimum_height; $edges{east}->{height} -= $comp->minimum_height; $edges{west}->{height} -= $comp->minimum_height; $edges{center}->{height} -= $comp->minimum_height; } elsif($args eq 'e') { push(@{ $edges{east}->{components} }, $comp); $edges{east}->{width} += $comp->minimum_width; $edges{north}->{width} -= $comp->minimum_width; $edges{south}->{width} -= $comp->minimum_width; $edges{center}->{width} -= $comp->minimum_width; } elsif($args eq 'w') { push(@{ $edges{west}->{components} }, $comp); $edges{west}->{width} += $comp->minimum_width; $edges{north}->{width} -= $comp->minimum_width; $edges{south}->{width} -= $comp->minimum_width; $edges{center}->{width} -= $comp->minimum_width; } else { die("Unknown direction '$args' for component $comp."); } } # Relayout the west my $x = $bbox->origin->x; my $y = $bbox->origin->y + $edges{north}->{height}; foreach my $comp (@{ $edges{west}->{components} }) { $comp->origin->x($x); $comp->origin->y($y); $comp->height($edges{center}->{height}); if($comp->can('do_layout')) { $comp->do_layout($comp); } $x += $comp->width; } # Relayout the east $x = $bbox->origin->x + $bbox->width; $y = $bbox->origin->y + $edges{north}->{height}; foreach my $comp (@{ $edges{east}->{components} }) { $x -= $comp->width; $comp->origin->x($x); $comp->origin->y($y); $comp->height($edges{center}->{height}); if($comp->can('do_layout')) { $comp->do_layout($comp); } } # Relayout the south $x = $bbox->origin->x + $edges{west}->{width}; $y = $bbox->origin->y + $cheight; foreach my $comp (@{ $edges{south}->{components} }) { $y -= $comp->height; $comp->origin->x($x); $comp->origin->y($y); $comp->width($edges{center}->{width}); if($comp->can('do_layout')) { $comp->do_layout($comp); } } # Relayout the north $x = $bbox->origin->x + $edges{west}->{width}; $y = $bbox->origin->y; foreach my $comp (@{ $edges{north}->{components} }) { $comp->origin->x($x); $comp->origin->y($y); $comp->width($edges{center}->{width}); if($comp->can('do_layout')) { $comp->do_layout($comp); } $y += $comp->width; } # Relayout the center $x = $bbox->origin->x + $edges{west}->{width}; $y = $bbox->origin->y + $edges{north}->{height}; my $ccount = scalar(@{ $edges{center}->{components} }); # Skip this if there are no center components. if($ccount) { my $per = $edges{center}->{height} / $ccount; my $i = 0; foreach my $comp (@{ $edges{center}->{components} }) { $comp->origin->x($x); $comp->origin->y($y + ($i * $per)); $comp->width($edges{center}->{width}); $comp->height($per); if($comp->can('do_layout')) { $comp->do_layout($comp); } $i++; } } # foreach my $comp (@{ $container->components }) { # $comp->prepared(1) if defined($comp); # } $container->prepared(1); return 1; }); sub _layout_container { my ($self, $comp) = @_; $comp->do_layout($comp, $self); if($comp->minimum_width > $comp->width) { $comp->width = $comp->minimum_width; } if($comp->minimum_height > $comp->height) { $comp->height = $comp->minimum_height; } } sub _geassign { $_[1] = $_[2] if $_[2] > $_[1]; }; __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Layout::Manager::Axis - Compass-like resizing managers =head1 DESCRIPTION Axis is I similar to L with one exception: Components added to the east and west consume space on the sides of of the north and south. Components at the north and south are resized when east and west components are added. +--------------------------------+ | x | north | x | +-----+--------------------+-----+ | | | | | w | | e | | e | center | a | | s | | s | | t | | t | | | | | +-----+--------------------+-----+ | x | south | x | +--------------------------------+ The B boxes above will effectively be dead-space. No components will occupy those areas. Why, you ask? Some components (such as axes on a chart, for which this manager is named) need to be the B same hight or with as the center component. If the chart area is represented by the center area and an axis is positioned to the west, it needs to know how big the center is to accurately draw tick marks. =head1 SYNOPSIS $cont->add_component($comp1, 'north'); $cont->add_component($comp2, 'east'); my $lm = Layout::Manager::Axis->new; $lm->do_layout($cont); =head1 POSITIONING When you add a component with I the second argument should be one of: north, south, east, west or center. Case doesn't matter. You can also just provide the first letter of the word and it will do the same thing. =head1 METHODS =head2 do_layout Size and position the components in this layout. =head1 AUTHOR Cory Watson, C<< >> =head1 COPYRIGHT & LICENSE Copyright 2008 - 2010 Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Layout-Manager-0.35/lib/Layout/Manager/Compass.pm000644 000765 000024 00000025570 12270604305 022104 0ustar00gphatstaff000000 000000 package Layout::Manager::Compass; use Moose; extends 'Layout::Manager'; override('do_layout', sub { my ($self, $container) = @_; return 0 if $container->prepared && $self->_check_container($container); super; my $bbox = $container->inside_bounding_box; my $bboxoy = $bbox->origin->y; my $bboxox = $bbox->origin->x; my $coheight = $container->outside_height; my $cowidth = $container->outside_width; my $cwidth = $bbox->width; my $cheight = $bbox->height; my %edges = ( north => { components => [], width => 0, height => 0 }, south => { components => [], width => 0, height => 0 }, east => { components => [], width => 0, height => 0 }, west => { components => [], width => 0, height => 0 }, center => { components => [], width => 0, height => 0 } ); # This loop takes each component and adds it's width and height to the # 'edge' on which is positioned. At the end will know how much width and # height we need for each edge. for(my $i = 0; $i < scalar(@{ $container->components }); $i++) { my $comp = $container->get_component($i); next unless defined($comp) && $comp->visible; # Set each component to it's minimum size for now $comp->width($comp->minimum_width); $comp->height($comp->minimum_height); my $args = lc(substr($container->get_constraint($i), 0, 1)); if(($args) eq 'c') { push(@{ $edges{center}->{components} }, $comp); $edges{center}->{height} += $comp->minimum_height; $self->_geassign($edges{center}->{width}, $comp->minimum_width); } elsif($args eq 'n') { push(@{ $edges{north}->{components} }, $comp); $edges{north}->{height} += $comp->minimum_height; $self->_geassign($edges{north}->{width}, $comp->minimum_width); } elsif($args eq 's') { push(@{ $edges{south}->{components} }, $comp); $edges{south}->{height} += $comp->minimum_height; $self->_geassign($edges{south}->{width}, $comp->minimum_width); } elsif($args eq 'e') { push(@{ $edges{east}->{components} }, $comp); $self->_geassign($edges{east}->{height}, $comp->minimum_height); $edges{east}->{width} += $comp->minimum_width; } elsif($args eq 'w') { push(@{ $edges{west}->{components} }, $comp); $self->_geassign($edges{west}->{height}, $comp->minimum_height); $edges{west}->{width} += $comp->minimum_width; } else { die("Unknown direction '$args' for component $comp."); } } # Resize the container to the bare minimum that we expect to need, if # it's not already that big... if(!$cheight) { $self->_geassign($cheight, $edges{north}->{height} + $edges{south}->{height} + $container->outside_height ); my $sheight = $edges{east}->{height}; $self->_geassign($sheight, $edges{west}->{height}); $self->_geassign($sheight, $edges{center}->{height}); $self->_geassign($cheight, $cheight + $sheight); } $self->_geassign($cwidth, $edges{east}->{width} + $edges{west}->{width} + $edges{center}->{width}); # Each of these loops iterate over their respective edge and 'fit' each # component in the order they were added. First they set either a height # or width (whatever they can). If the component is a container, then # that container will be laid out. After that adjustments will be made # to the container (if necessary) and the component will be positioned. ### NORTH #### my $yaccum = $bboxoy; $edges{north}->{height} = 0; foreach my $comp (@{ $edges{north}->{components} }) { $comp->width($cwidth); my $co = $comp->origin; $co->x($bboxox); $co->y($yaccum); # Give a sub-container a chance to size itself since we've given # it all the information we can. # TODO Check::ISA if($comp->can('do_layout')) { $self->_layout_container($comp); } $self->_geassign($cheight, $comp->height); $self->_geassign($cwidth, $comp->width); $edges{north}->{height} += $comp->height; $yaccum += $comp->height; } ### SOUTH #### $yaccum = $bboxoy + $cheight; $edges{south}->{height} = 0; foreach my $comp (@{ $edges{south}->{components} }) { $comp->width($cwidth) if $cwidth; $comp->origin->x($bboxox); # Give a sub-container a chance to size itself since we've given # it all the information we can. # TODO Check::ISA if($comp->can('do_layout')) { $self->_layout_container($comp); } $self->_geassign($cheight, $comp->height); $self->_geassign($cwidth, $comp->width); $edges{south}->{height} += $comp->height; $comp->origin->y($yaccum - $comp->height); $yaccum -= $comp->height; } # Compass layout uses a minimum of height and width for the 4 edges and # then allocates all leftover space equally to items in the center. my $cen_height = $cheight - $edges{north}->{height} - $edges{south}->{height}; my $cen_width = $cwidth - $edges{east}->{width} - $edges{west}->{width}; $self->_geassign($cen_height, $edges{east}->{height}); $self->_geassign($cen_height, $edges{west}->{height}); ### EAST ### # Prime our x position my $xaccum = $bboxox + $cwidth; # Reset the east width, since we're about to do it for reals $edges{east}->{width} = 0; foreach my $comp (@{ $edges{east}->{components} }) { # If the size we have available in the east slot is greater than the # minimum height of the component then we'll resize. $comp->height($cen_height);# if $cen_height; $comp->origin->y($bboxoy + $edges{north}->{height}); if($comp->can('do_layout')) { $self->_layout_container($comp); } $self->_geassign($cheight, $comp->height); $self->_geassign($cwidth, $comp->width); $edges{east}->{width} += $comp->width; $xaccum -= $comp->width; $comp->origin->x($xaccum); } ### WEST ### $xaccum = $bboxox; $edges{west}->{width} = 0; foreach my $comp (@{ $edges{west}->{components} }) { $comp->height($cen_height);# if $cen_height; $comp->origin->y($bboxoy + $edges{north}->{height}); # Give a sub-container a chance to size itself since we've given # it all the information we can. # TODO Check::ISA if($comp->can('do_layout')) { $self->_layout_container($comp); } $self->_geassign($cheight, $comp->height); $self->_geassign($cwidth, $comp->width); $edges{west}->{width} += $comp->width; $comp->origin->x($xaccum); $xaccum += $comp->width; } my $ccount = scalar(@{ $edges{center}->{components} }); if($ccount) { my $per_height = $cen_height / $ccount; my $i = 1; foreach my $comp (@{ $edges{center}->{components}}) { $comp->height($per_height); $comp->width($cen_width) if $cen_width; $comp->origin->x($bboxox + $edges{west}->{width}); $comp->origin->y($bboxoy + $edges{north}->{height} + ($per_height * ($i - 1))); # TODO Check::ISA if($comp->can('do_layout')) { $self->_layout_container($comp); } $i++; } } # Our 'side' width is the bigger of the south/north (they will be equal if # they both exist...) my $side_width = $edges{north}->{width}; $self->_geassign($side_width, $edges{south}->{width}); $self->_geassign($side_width, $edges{center}->{width} + $edges{east}->{width} + $edges{west}->{width}); $cheight += $coheight; # Increase the minimum height and width of the container to accomodate # the laid out components. $container->minimum_width($side_width); $container->minimum_height($cheight); # If the width and height of the container are not sufficient, expand # them. if($container->width < $container->minimum_width) { $container->width($container->minimum_width); } if($container->height < $container->minimum_height) { $container->height($container->minimum_height); } $container->prepared(1); return 1; }); sub _layout_container { my ($self, $comp) = @_; $comp->do_layout($comp, $self); if($comp->minimum_width > $comp->width) { $comp->width($comp->minimum_width); } if($comp->minimum_height > $comp->height) { $comp->height($comp->minimum_height); } } sub _geassign { $_[1] = $_[2] if $_[2] > $_[1]; }; __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Layout::Manager::Compass - Compass based layout =head1 DESCRIPTION Layout::Manager::Compass is a layout manager that takes hints based on the four cardinal directions (north, east, south and west) plus a center area that takes up all remaining space (vertically). In other words, the center area will expand to take up all space that is NOT used by components placed at the edges. Components at the north and south edges will take up the full width of the container. +--------------------------------+ | north | +-----+--------------------+-----+ | | | | | w | | e | | e | center | a | | s | | s | | t | | t | | | | | +-----+--------------------+-----+ | south | +--------------------------------+ Components are placed in the order they are added. If two items are added to the 'north' position then the first item will be rendered above the second. The height of the north edge will equal the height of both components combined. Items in the center split the available space, heightwise. Two center components will each take up 50% of the available height and 100% of the available width. Compass is basically an implementation of Java's L =head1 SYNOPSIS $cont->add_component($comp1, 'north'); $cont->add_component($comp2, 'east'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($cont); =head1 POSITIONING When you add a component with I the second argument should be one of: B, B, B, B or B
. Case doesn't matter. You can also just provide the first letter of the word and it will do the same thing. =head1 METHODS =head2 do_layout Size and position the components in this layout. =head1 AUTHOR Cory Watson, C<< >> =head1 COPYRIGHT & LICENSE Copyright 2008 - 2010 Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.Layout-Manager-0.35/lib/Layout/Manager/Flow.pm000644 000765 000024 00000020060 12270604655 021403 0ustar00gphatstaff000000 000000 package Layout::Manager::Flow; use Moose; extends 'Layout::Manager'; use Moose::Util::TypeConstraints; enum 'Layout::Manager::Flow::Anchors', [qw(north south east west)]; has 'anchor' => ( is => 'rw', isa => 'Layout::Manager::Flow::Anchors', default => sub { 'north' } ); has 'expand' => ( is => 'rw', isa => 'Bool', default => sub { 1 } ); has 'used' => ( is => 'rw', isa => 'ArrayRef', default => sub { [0, 0] } ); has 'wrap' => ( is => 'rw', isa => 'Bool', default => sub { 0 } ); override('do_layout', sub { my ($self, $container) = @_; my $bbox = $container->inside_bounding_box; my $cwidth = $bbox->width; my $cheight = $bbox->height; my $ox = $bbox->origin->x; my $oy = $bbox->origin->y; my $anch = $self->anchor; my @lines; my $yused = $oy; my $xused = $ox; my $line = 0; foreach my $comp (@{ $container->components }) { next unless defined($comp) && $comp->visible; $comp->width($comp->minimum_width); $comp->height($comp->minimum_height); # If we aren't wrapping, expand to fill the whole space if(($anch eq 'north') || ($anch eq 'south')) { unless($self->wrap) { $comp->width($cwidth) if $cwidth; } } else { unless($self->wrap) { $comp->height($cheight) if $cheight; } } my $comp_height = $comp->height; my $comp_width = $comp->width; unless(defined($lines[$line])) { $lines[$line] = { tallest => $comp_height || 0, widest => $comp_width || 0, height => 0, width => 0, components => [] }; } # Keep up with the tallest component we find if(!($lines[$line]->{tallest}) || $comp_height > $lines[$line]->{tallest}) { $lines[$line]->{tallest} = $comp_height; } # Keep up with the widest component we find if(!($lines[$line]->{widest}) || $comp_width > $lines[$line]->{widest}) { $lines[$line]->{widest} = $comp_width; } my $co = $comp->origin; if($anch eq 'north') { # No wrapping $co->x($ox); $co->y($oy + $lines[$line]->{height}); $lines[$line]->{height} += $comp_height; unless($lines[$line]->{width}) { $lines[$line]->{width} = $comp_width; } } elsif($anch eq 'south') { # No wrapping $co->x($ox); $co->y($oy + $cheight - $comp_height - $lines[$line]->{height}); $lines[$line]->{height} += $comp_height; unless($lines[$line]->{width}) { $lines[$line]->{width} = $comp_width; } } elsif($anch eq 'east') { if( # It doesn't matter if we are supposed to wrap if we have # no width, we'll make this thing as big as it needs to be ($cwidth > 0) && # if we are wrapping ($self->wrap) && # and the current component would overflow... ($lines[$line]->{width} + $comp_width > $cwidth) && scalar(@{ $lines[$line]->{components} }) ) { # We've been asked to wrap and this component is too wide # to fit. Move down by the height of the tallest component # then reset the tallest variable. $yused += $lines[$line]->{tallest}; $co->x($cwidth - $comp_width - $ox); $co->y($oy + $yused); $line++; $lines[$line]->{width} = $ox + $comp_width; $lines[$line]->{tallest} = $comp_height; } else { $co->x($ox + $cwidth - $comp_width - $lines[$line]->{width}); $co->y($yused); $lines[$line]->{width} += $comp_width; } } else { # WEST if( # It doesn't matter if we are supposed to wrap if we have # no width, we'll make this thing as big as it needs to be ($cwidth > 0) && # if we are wrapping ($self->wrap) && # and the current component would overflow... ($lines[$line]->{width} + $comp_width > $cwidth) && scalar(@{ $lines[$line]->{components} }) ) { # We've been asked to wrap and this component is too wide # to fit. Move down by the height of the tallest component # then reset the tallest variable. $yused += $lines[$line]->{tallest}; $co->x($ox); $co->y($yused); $line++; $lines[$line]->{width} = $ox + $comp_width; $lines[$line]->{tallest} = $comp_height; } else { $co->x($ox + $lines[$line]->{width}); $co->y($yused); $lines[$line]->{width} += $comp_width; } } push(@{ $lines[$line]->{components} }, $comp); } my $fwidth = 0; my $fheight = 0; foreach my $l (@lines) { unless($l->{height}) { $l->{height} = $l->{tallest}; } $fheight += $l->{height}; if($l->{width} > $fwidth) { $fwidth = $l->{width}; } } $self->used([$fwidth, $fheight]); $container->minimum_width($fwidth + $container->outside_width); $container->minimum_height($fheight + $container->outside_height); # Size our container, now that everything is done. if($container->width < $container->minimum_width) { $container->width($container->minimum_width); } if($container->height < $container->minimum_height) { $container->height($container->minimum_height); } super; return 1; }); __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Layout::Manager::Flow - Directional layout manager =head1 DESCRIPTION Layout::Manager::Flow is a layout manager that anchors components in one of the four cardinal directions. When you instantiate a Flow manager, you may supply it with an anchor value which may be one of north, south, east or west. The example below shows how the default anchor value of north works when you add two components. north +--------------------------------+ | component 1 | +--------------------------------+ | component 2 | +--------------------------------+ | | | | | | +--------------------------------+ Components are placed in the order they are added. If two items are added with a 'north' anchor then the first item will be rendered above the second. Components will be expanded to take up all space perpendicular to their anchor. North and south will expand widths while east and west will expand heights. Flow is similar to Java's L. It does not, however, center components. This features may be added in the future if they are needed. =head1 SYNOPSIS $cont->add_component($comp1); $cont->add_component($comp2); my $lm = Layout::Manager::Flow->new(anchor => 'north'); $lm->do_layout($cont); =head1 ATTRIBUTES =head2 anchor The direction this manager is anchored. Valid values are north, south, east and west. =head2 used Returns the amount of space used an arrayref in the form of C<[ $width, $height ]>. =head2 wrap If set to a true value, then component will be 'wrapped' when they do not fit. B =head1 METHODS =head2 do_layout Size and position the components in this layout. =head1 AUTHOR Cory Watson, C<< >> =head1 COPYRIGHT & LICENSE Copyright 2008 by Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Layout-Manager-0.35/lib/Layout/Manager/Grid.pm000644 000765 000024 00000020443 12270604305 021356 0ustar00gphatstaff000000 000000 package Layout::Manager::Grid; use Moose; extends 'Layout::Manager'; use Carp qw(croak); use List::Util qw(max); has 'rows' => ( is => 'rw', isa => 'Int', required => 1 ); has 'columns' => ( is => 'rw', isa => 'Int', required => 1 ); override('do_layout', sub { my ($self, $container) = @_; my $bbox = $container->inside_bounding_box; my $cwidth = $bbox->width; my $cheight = $bbox->height; my @row_maxes; my @col_maxes; # If either the width or height is undefined, we'll need to compute it. for(my $i = 0; $i < scalar(@{ $container->components }); $i++) { my $comp = $container->get_component($i); # Skip invisible shit next unless defined($comp) && $comp->visible; my $cons = $container->get_constraint($i); # Set defaults for width unless(exists($cons->{width})) { $cons->{width} = 1; } # Set defaults for height unless(exists($cons->{height})) { $cons->{height} = 1; } # Calculate the minumum width and height this component would # consume in a row & column my $mw = $comp->minimum_width / $cons->{width}; my $mh = $comp->minimum_height / $cons->{height}; # Check the minumum height for this component against every row # in which it appears. The for uses the height to check the # inital row (0) then each (..) row (height - 1). So row 5 with # a height of 2 will check 5 and 6! THis same method is used for # columns below. for(0..$cons->{height} - 1) { unless(defined($row_maxes[$cons->{row} + $_])) { # If it hasn't been defined yet, set it $row_maxes[$cons->{row} + $_] = $mh; next; } $row_maxes[$cons->{row} + $_] = $mh if ($mh > $row_maxes[$cons->{row} + $_]); } # Check the minumum width for this component against every column # in which it appears for(0..$cons->{width} - 1) { unless(defined($col_maxes[$cons->{column} + $_])) { $col_maxes[$cons->{column} + $_] = $mw; next; } $col_maxes[$cons->{column} + $_] = $mw if ($mw > $col_maxes[$cons->{column} + $_]); } } # Find out how big of a height we need based on the heights of our rows. my $heightfromrowmax = 0; for(@row_maxes) { $heightfromrowmax += $_; } if($cheight && !scalar(@row_maxes)) { # If the height was set (and there's no rowmaxes), build a sham "max # rows" list using the height of a row my $ch = $cheight / $self->rows; @row_maxes = map({ $ch } (0..$self->rows)); } elsif($cheight && ($cheight > $heightfromrowmax)) { # If the container height is greater than the sum of the biggest rows, # add an equal amount to each row so we grow to fill it. my $diff = ($cheight - $heightfromrowmax) / $self->rows; for(my $i = 0; $i < $self->rows; $i++) { $row_maxes[$i] += $diff; } } else { my $ch = 0; foreach my $h (@row_maxes) { $ch += $h if defined($h); } # If the height wasn't set, set the container's height to the total # of all rows $cheight = $container->outside_height + $ch; $container->minimum_height($cheight); } if($cwidth) { # If the width was already set, build a sham "max cols" list using the # width of a column my $cw = $cwidth / $self->columns; @col_maxes = map({ $cw } (0..$self->columns)); } else { my $cw = 0; foreach my $w (@col_maxes) { $cw += $w; } # If the width wasn't set, set the container's width to the total of # all cols $cwidth = $container->outside_width + $cw; $container->minimum_width($cwidth); } my $ox = $bbox->origin->x; my $oy = $bbox->origin->y; for(my $i = 0; $i < scalar(@{ $container->components }); $i++) { my $comp = $container->get_component($i); next unless defined($comp) && $comp->visible; my $cons = $container->get_constraint($i); croak('Constraint must be a hashref containing row and column.') unless (ref($cons) eq 'HASH' && (exists($cons->{row}) && (exists($cons->{column})))); my $co = $comp->origin; my $row = $cons->{row}; $row = $self->rows if $row > $self->rows; my $col = $cons->{column}; $col = $self->columns if $col > $self->columns; my $width = 1; if(exists($cons->{width})) { $width = $cons->{width}; } my $height = 1; if(exists($cons->{height})) { $height = $cons->{height}; } my $x = $ox; # Find the X location for this component by adding up each column # width from 0 to the current column for(0..$col - 1) { $x += $col_maxes[$_]; } # Find the Y location for this component by adding up each row height # from 0 to the current row my $y = $oy; for(0..$row - 1) { $y += $row_maxes[$_]; } # Find the component's width by adding the widths of the all the cells # the component appears in. my $cell_width = 0; for($col..$col + $width - 1) { $cell_width += $col_maxes[$_]; } # Find the component's height by adding the heights of the all the # cells the component appears in. my $cell_height = 0; for($row..$row + $height - 1) { $cell_height += $row_maxes[$_]; } $co->x($x); $co->y($y); $comp->width($cell_width); $comp->height($cell_height); } super; return 1; }); __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Layout::Manager::Grid - Simple grid-based layout manager. =head1 DESCRIPTION Layout::Manager::Grid is a layout manager places components into evenly divided cells. When you instantiate a Grid manager, you must supply it with a count of how many rows and columns it will have. For example, a Grid with 1 column and 2 rows would look like: +--------------------------------+ | | | component 1 | | | +--------------------------------+ | | | component 2 | | | +--------------------------------+ The container is divided into as many * cells, with each taking up an equal amount of space. A grid with 3 columns and 2 rows would create 6 cells that consume 33% of the width and 50% of the height. Components are placed by specifying the cell they reside in via the row and column number. $container->add_component($comp, { row => 0, column => 3 }); $container->add_component($comp, { row => 0, column => 2, height => 2 }); Optionally, you may choose to override the default C or C of 1. Setting it to a something else will cause the component to consume that many rows or columns worth of space. Grid is similar to Java's L. =head1 SYNOPSIS $cont->add_component($comp1, { row => 0, column => 1 }); $cont->add_component($comp2, { row => 0, column => 2 }); my $lm = Layout::Manager::Grid->new(rows => 1, columns => 2); $lm->do_layout($con); =head2 DYNAMIC SIZING If the container that the Grid is manging does not have one or both of it's dimensions set, Grid will compute the appropriate sizes. The simple way for me to avoid writing a long explanation is to say it works similar to HTML tables. Rows will become as big as their biggest consituent, as will columns. It is common to add a Grid-managed component to a scene with only one of it's dimensions set. =head1 ATTRIBUTES =head2 columns The number of columns in this Grid. =head2 rows The number of rows in this Grid. =head1 METHODS =head2 do_layout Size and position the components in this layout. =head1 AUTHOR Cory Watson, C<< >> =head1 COPYRIGHT & LICENSE Copyright 2008 - 2010 Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.Layout-Manager-0.35/lib/Layout/Manager/Single.pm000644 000765 000024 00000003137 12270604305 021713 0ustar00gphatstaff000000 000000 package Layout::Manager::Single; use Moose; extends 'Layout::Manager'; override('do_layout', sub { my ($self, $container) = @_; return 0 if $container->prepared && $self->_check_container($container); my $bbox = $container->inside_bounding_box; my $cwidth = $bbox->width; my $cheight = $bbox->height; my $x = $bbox->origin->x; my $y = $bbox->origin->y; my $count = 0; foreach my $comp (@{ $container->components }) { next unless defined($comp) && $comp->visible; $comp->width($cwidth); $comp->height($cheight); $comp->origin->x($x); $comp->origin->y($y); if($comp->can('do_layout')) { $comp->do_layout($comp); } else { #$comp->prepared(1); } } $container->prepared(1); return 1; }); __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Layout::Manager::Single - One-size vertical layout manager =head1 DESCRIPTION Lays out all components in a single position. All components are set to the height and width of the container and positioned at the offsets. This basically stacks them all vertically. =head1 SYNOPSIS $cont->add_component($comp1); $cont->add_component($comp2); my $lm = Layout::Manager::Single->new(); $lm->do_layout($cont); =head1 METHODS =head2 do_layout Size and position the components in this layout. =head1 AUTHOR Cory Watson, C<< >> =head1 COPYRIGHT & LICENSE Copyright 2008 - 2010 by Cory G Watson This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.Layout-Manager-0.35/inc/Module/000755 000765 000024 00000000000 12270604667 016544 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/inc/Module/Install/000755 000765 000024 00000000000 12270604667 020152 5ustar00gphatstaff000000 000000 Layout-Manager-0.35/inc/Module/Install.pm000644 000765 000024 00000030135 12270604662 020505 0ustar00gphatstaff000000 000000 #line 1 package Module::Install; # For any maintainers: # The load order for Module::Install is a bit magic. # It goes something like this... # # IF ( host has Module::Install installed, creating author mode ) { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install # 3. The installed version of inc::Module::Install loads # 4. inc::Module::Install calls "require Module::Install" # 5. The ./inc/ version of Module::Install loads # } ELSE { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install # 3. The ./inc/ version of Module::Install loads # } use 5.005; use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or # different versions of modules. # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. $VERSION = '1.06'; # Storage for the pseudo-singleton $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; } sub import { my $class = shift; my $self = $class->new(@_); my $who = $self->_caller; #------------------------------------------------------------- # all of the following checks should be included in import(), # to allow "eval 'require Module::Install; 1' to test # installation of Module::Install. (RT #51267) #------------------------------------------------------------- # Whether or not inc::Module::Install is actually loaded, the # $INC{inc/Module/Install.pm} is what will still get set as long as # the caller loaded module this in the documented manner. # If not set, the caller may NOT have loaded the bundled version, and thus # they may not have a MI version that works with the Makefile.PL. This would # result in false errors or unexpected behaviour. And we don't want that. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; unless ( $INC{$file} ) { die <<"END_DIE" } Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; END_DIE # This reportedly fixes a rare Win32 UTC file time issue, but # as this is a non-cross-platform XS module not in the core, # we shouldn't really depend on it. See RT #24194 for detail. # (Also, this module only supports Perl 5.6 and above). eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; # If the script that is loading Module::Install is from the future, # then make will detect this and cause it to re-run over and over # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. if ( -f $0 ) { my $s = (stat($0))[9]; # If the modification time is only slightly in the future, # sleep briefly to remove the problem. my $a = $s - time; if ( $a > 0 and $a < 5 ) { sleep 5 } # Too far in the future, throw an error. my $t = time; if ( $s > $t ) { die <<"END_DIE" } Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE } # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. It was impossible to maintain duel backends, and has been deprecated. Please remove all Build.PL files and only use the Makefile.PL installer. END_DIE #------------------------------------------------------------- # To save some more typing in Module::Install installers, every... # use inc::Module::Install # ...also acts as an implicit use strict. $^H |= strict::bits(qw(refs subs vars)); #------------------------------------------------------------- unless ( -f $self->{file} ) { foreach my $key (keys %INC) { delete $INC{$key} if $key =~ /Module\/Install/; } local $^W; require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } local $^W; *{"${who}::AUTOLOAD"} = $self->autoload; $self->preload; # Unregister loader and worker packages so subdirs can use them again delete $INC{'inc/Module/Install.pm'}; delete $INC{'Module/Install.pm'}; # Save to the singleton $MAIN = $self; return 1; } sub autoload { my $self = shift; my $who = $self->_caller; my $cwd = Cwd::cwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::cwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } unless ($$sym =~ s/([^:]+)$//) { # XXX: it looks like we can't retrieve the missing function # via $$sym (usually $main::AUTOLOAD) in this case. # I'm still wondering if we should slurp Makefile.PL to # get some context or not ... my ($package, $file, $line) = caller; die <<"EOT"; Unknown function is found at $file line $line. Execution of $file aborted due to runtime errors. If you're a contributor to a project, you may need to install some Module::Install extensions from CPAN (or other repository). If you're a user of a module, please contact the author. EOT } my $method = $1; if ( uc($method) eq $method ) { # Do nothing return; } elsif ( $method =~ /^_/ and $self->can($method) ) { # Dispatch to the root M:I class return $self->$method(@_); } # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); goto &{$self->can('call')}; }; } sub preload { my $self = shift; unless ( $self->{extensions} ) { $self->load_extensions( "$self->{prefix}/$self->{path}", $self ); } my @exts = @{$self->{extensions}}; unless ( @exts ) { @exts = $self->{admin}->load_all_extensions; } my %seen; foreach my $obj ( @exts ) { while (my ($method, $glob) = each %{ref($obj) . '::'}) { next unless $obj->can($method); next if $method =~ /^_/; next if $method eq uc($method); $seen{$method}++; } } my $who = $self->_caller; foreach my $name ( sort keys %seen ) { local $^W; *{"${who}::$name"} = sub { ${"${who}::AUTOLOAD"} = "${who}::$name"; goto &{"${who}::AUTOLOAD"}; }; } } sub new { my ($class, %args) = @_; delete $INC{'FindBin.pm'}; { # to suppress the redefine warning local $SIG{__WARN__} = sub {}; require FindBin; } # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); $args{bundle} ||= 'inc/BUNDLES'; $args{base} ||= $base_path; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ( $args{path} ) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; $args{wrote} = 0; bless( \%args, $class ); } sub call { my ($self, $method) = @_; my $obj = $self->load($method) or return; splice(@_, 0, 2, $obj); goto &{$obj->can($method)}; } sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END_DIE my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } sub load_extensions { my ($self, $path, $top) = @_; my $should_reload = 0; unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; $should_reload = 1; } foreach my $rv ( $self->find_extensions($path) ) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; local $@; my $new = eval { local $^W; require $file; $pkg->can('new') }; unless ( $new ) { warn $@ if $@; next; } $self->{pathnames}{$pkg} = $should_reload ? delete $INC{$file} : $INC{$file}; push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); } $self->{extensions} ||= []; } sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find( sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; my $subpath = $1; return if lc($subpath) eq lc($self->{dispatch}); $file = "$self->{path}/$subpath.pm"; my $pkg = "$self->{name}::$subpath"; $pkg =~ s!/!::!g; # If we have a mixed-case package name, assume case has been preserved # correctly. Otherwise, root through the file to locate the case-preserved # version of the package name. if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($subpath . '.pm'); my $in_pod = 0; foreach ( split //, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text next if /^\s*#/; # and comments if ( m/^\s*package\s+($pkg)\s*;/i ) { $pkg = $1; last; } } } push @found, [ $file, $pkg ]; }, $path ) if -d $path; @found; } ##################################################################### # Common Utility Functions sub _caller { my $depth = 0; my $call = caller($depth); while ( $call eq __PACKAGE__ ) { $depth++; $call = caller($depth); } return $call; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_NEW sub _read { local *FH; open( FH, "< $_[0]" ) or die "open($_[0]): $!"; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_OLD sub _readperl { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; return $string; } sub _readpod { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; return $string if $_[0] =~ /\.pod\z/; $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; $string =~ s/^\n+//s; return $string; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_NEW sub _write { local *FH; open( FH, "> $_[0]" ) or die "open($_[0]): $!"; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_OLD # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). sub _version ($) { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { # Normalise multipart versions $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; } $s =~ s/^(\d+)\.?//; my $l = $1 || 0; my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; $l = $l . '.' . join '', @v if @v; return $l + 0; } sub _cmp ($$) { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS sub _CLASS ($) { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s ) ? $_[0] : undef; } 1; # Copyright 2008 - 2012 Adam Kennedy. Layout-Manager-0.35/inc/Module/Install/Base.pm000644 000765 000024 00000002147 12270604662 021361 0ustar00gphatstaff000000 000000 #line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.06'; } # Suspend handler for "redefined" warnings BEGIN { my $w = $SIG{__WARN__}; $SIG{__WARN__} = sub { $w }; } #line 42 sub new { my $class = shift; unless ( defined &{"${class}::call"} ) { *{"${class}::call"} = sub { shift->_top->call(@_) }; } unless ( defined &{"${class}::load"} ) { *{"${class}::load"} = sub { shift->_top->load(@_) }; } bless { @_ }, $class; } #line 61 sub AUTOLOAD { local $@; my $func = eval { shift->_top->autoload } or return; goto &$func; } #line 75 sub _top { $_[0]->{_top}; } #line 90 sub admin { $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new; } #line 106 sub is_admin { ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; use vars qw{$VERSION}; BEGIN { $VERSION = $Module::Install::Base::VERSION; } my $fake; sub new { $fake ||= bless(\@_, $_[0]); } sub AUTOLOAD {} sub DESTROY {} # Restore warning handler BEGIN { $SIG{__WARN__} = $SIG{__WARN__}->(); } 1; #line 159 Layout-Manager-0.35/inc/Module/Install/Can.pm000644 000765 000024 00000006157 12270604662 021215 0ustar00gphatstaff000000 000000 #line 1 package Module::Install::Can; use strict; use Config (); use ExtUtils::MakeMaker (); use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # check if we can load some module ### Upgrade this to not have to load the module if possible sub can_use { my ($self, $mod, $ver) = @_; $mod =~ s{::|\\}{/}g; $mod .= '.pm' unless $mod =~ /\.pm$/i; my $pkg = $mod; $pkg =~ s{/}{::}g; $pkg =~ s{\.pm$}{}i; local $@; eval { require $mod; $pkg->VERSION($ver || 0); 1 }; } # Check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { next if $dir eq ''; require File::Spec; my $abs = File::Spec->catfile($dir, $cmd); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } # Can our C compiler environment build XS files sub can_xs { my $self = shift; # Ensure we have the CBuilder module $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); # Do we have the configure_requires checker? local $@; eval "require ExtUtils::CBuilder;"; if ( $@ ) { # They don't obey configure_requires, so it is # someone old and delicate. Try to avoid hurting # them by falling back to an older simpler test. return $self->can_cc(); } # Do we have a working C compiler my $builder = ExtUtils::CBuilder->new( quiet => 1, ); unless ( $builder->have_compiler ) { # No working C compiler return 0; } # Write a C file representative of what XS becomes require File::Temp; my ( $FH, $tmpfile ) = File::Temp::tempfile( "compilexs-XXXXX", SUFFIX => '.c', ); binmode $FH; print $FH <<'END_C'; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int main(int argc, char **argv) { return 0; } int boot_sanexs() { return 1; } END_C close $FH; # Can the C compiler access the same headers XS does my @libs = (); my $object = undef; eval { local $^W = 0; $object = $builder->compile( source => $tmpfile, ); @libs = $builder->link( objects => $object, module_name => 'sanexs', ); }; my $result = $@ ? 0 : 1; # Clean up all the build files foreach ( $tmpfile, $object, @libs ) { next unless defined $_; 1 while unlink; } return $result; } # Can we locate a (the) C compiler sub can_cc { my $self = shift; my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } # Fix Cygwin bug on maybe_command(); if ( $^O eq 'cygwin' ) { require ExtUtils::MM_Cygwin; require ExtUtils::MM_Win32; if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { *ExtUtils::MM_Cygwin::maybe_command = sub { my ($self, $file) = @_; if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { ExtUtils::MM_Win32->maybe_command($file); } else { ExtUtils::MM_Unix->maybe_command($file); } } } } 1; __END__ #line 236 Layout-Manager-0.35/inc/Module/Install/Fetch.pm000644 000765 000024 00000004627 12270604662 021545 0ustar00gphatstaff000000 000000 #line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", 'anonymous@example.com'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; Layout-Manager-0.35/inc/Module/Install/Makefile.pm000644 000765 000024 00000027437 12270604662 022235 0ustar00gphatstaff000000 000000 #line 1 package Module::Install::Makefile; use strict 'vars'; use ExtUtils::MakeMaker (); use Module::Install::Base (); use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub Makefile { $_[0] } my %seen = (); sub prompt { shift; # Infinite loop protection my @c = caller(); if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; } # In automated testing or non-interactive session, always use defaults if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { local $ENV{PERL_MM_USE_DEFAULT} = 1; goto &ExtUtils::MakeMaker::prompt; } else { goto &ExtUtils::MakeMaker::prompt; } } # Store a cleaned up version of the MakeMaker version, # since we need to behave differently in a variety of # ways based on the MM version. my $makemaker = eval $ExtUtils::MakeMaker::VERSION; # If we are passed a param, do a "newer than" comparison. # Otherwise, just return the MakeMaker version. sub makemaker { ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } # Ripped from ExtUtils::MakeMaker 6.56, and slightly modified # as we only need to know here whether the attribute is an array # or a hash or something else (which may or may not be appendable). my %makemaker_argtype = ( C => 'ARRAY', CONFIG => 'ARRAY', # CONFIGURE => 'CODE', # ignore DIR => 'ARRAY', DL_FUNCS => 'HASH', DL_VARS => 'ARRAY', EXCLUDE_EXT => 'ARRAY', EXE_FILES => 'ARRAY', FUNCLIST => 'ARRAY', H => 'ARRAY', IMPORTS => 'HASH', INCLUDE_EXT => 'ARRAY', LIBS => 'ARRAY', # ignore '' MAN1PODS => 'HASH', MAN3PODS => 'HASH', META_ADD => 'HASH', META_MERGE => 'HASH', PL_FILES => 'HASH', PM => 'HASH', PMLIBDIRS => 'ARRAY', PMLIBPARENTDIRS => 'ARRAY', PREREQ_PM => 'HASH', CONFIGURE_REQUIRES => 'HASH', SKIP => 'ARRAY', TYPEMAPS => 'ARRAY', XS => 'HASH', # VERSION => ['version',''], # ignore # _KEEP_AFTER_FLUSH => '', clean => 'HASH', depend => 'HASH', dist => 'HASH', dynamic_lib=> 'HASH', linkext => 'HASH', macro => 'HASH', postamble => 'HASH', realclean => 'HASH', test => 'HASH', tool_autosplit => 'HASH', # special cases where you can use makemaker_append CCFLAGS => 'APPENDABLE', DEFINE => 'APPENDABLE', INC => 'APPENDABLE', LDDLFLAGS => 'APPENDABLE', LDFROM => 'APPENDABLE', ); sub makemaker_args { my ($self, %new_args) = @_; my $args = ( $self->{makemaker_args} ||= {} ); foreach my $key (keys %new_args) { if ($makemaker_argtype{$key}) { if ($makemaker_argtype{$key} eq 'ARRAY') { $args->{$key} = [] unless defined $args->{$key}; unless (ref $args->{$key} eq 'ARRAY') { $args->{$key} = [$args->{$key}] } push @{$args->{$key}}, ref $new_args{$key} eq 'ARRAY' ? @{$new_args{$key}} : $new_args{$key}; } elsif ($makemaker_argtype{$key} eq 'HASH') { $args->{$key} = {} unless defined $args->{$key}; foreach my $skey (keys %{ $new_args{$key} }) { $args->{$key}{$skey} = $new_args{$key}{$skey}; } } elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { $self->makemaker_append($key => $new_args{$key}); } } else { if (defined $args->{$key}) { warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; } $args->{$key} = $new_args{$key}; } } return $args; } # For mm args that take multiple space-seperated args, # append an argument to the current list. sub makemaker_append { my $self = shift; my $name = shift; my $args = $self->makemaker_args; $args->{$name} = defined $args->{$name} ? join( ' ', $args->{$name}, @_ ) : join( ' ', @_ ); } sub build_subdirs { my $self = shift; my $subdirs = $self->makemaker_args->{DIR} ||= []; for my $subdir (@_) { push @$subdirs, $subdir; } } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), ); } sub realclean_files { my $self = shift; my $realclean = $self->makemaker_args->{realclean} ||= {}; %$realclean = ( %$realclean, FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [ shift ]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub _wanted_t { } sub tests_recursive { my $self = shift; my $dir = shift || 't'; unless ( -d $dir ) { die "tests_recursive dir '$dir' does not exist"; } my %tests = map { $_ => 1 } split / /, ($self->tests || ''); require File::Find; File::Find::find( sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, $dir ); $self->tests( join ' ', sort keys %tests ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; # Check the current Perl version my $perl_version = $self->perl_version; if ( $perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; } # Make sure we have a new enough MakeMaker require ExtUtils::MakeMaker; if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { # This previous attempted to inherit the version of # ExtUtils::MakeMaker in use by the module author, but this # was found to be untenable as some authors build releases # using future dev versions of EU:MM that nobody else has. # Instead, #toolchain suggests we use 6.59 which is the most # stable version on CPAN at time of writing and is, to quote # ribasushi, "not terminally fucked, > and tested enough". # TODO: We will now need to maintain this over time to push # the version up as new versions are released. $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); } else { # Allow legacy-compatibility with 5.005 by depending on the # most recent EU:MM that supported 5.005. $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); } # Generate the MakeMaker params my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name; $args->{NAME} =~ s/-/::/g; $args->{VERSION} = $self->version or die <<'EOT'; ERROR: Can't determine distribution version. Please specify it explicitly via 'version' in Makefile.PL, or set a valid $VERSION in a module, and provide its file path via 'version_from' (or 'all_from' if you prefer) in Makefile.PL. EOT if ( $self->tests ) { my @tests = split ' ', $self->tests; my %seen; $args->{test} = { TESTS => (join ' ', grep {!$seen{$_}++} @tests), }; } elsif ( $Module::Install::ExtraTests::use_extratests ) { # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. # So, just ignore our xt tests here. } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { $args->{test} = { TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), }; } if ( $] >= 5.005 ) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = join ', ', @{$self->author || []}; } if ( $self->makemaker(6.10) ) { $args->{NO_META} = 1; #$args->{NO_MYMETA} = 1; } if ( $self->makemaker(6.17) and $self->sign ) { $args->{SIGN} = 1; } unless ( $self->is_admin ) { delete $args->{SIGN}; } if ( $self->makemaker(6.31) and $self->license ) { $args->{LICENSE} = $self->license; } my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->requires) ); # Remove any reference to perl, PREREQ_PM doesn't support it delete $args->{PREREQ_PM}->{perl}; # Merge both kinds of requires into BUILD_REQUIRES my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); %$build_prereq = ( %$build_prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->configure_requires, $self->build_requires) ); # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} || []); if ($self->bundles) { my %processed; foreach my $bundle (@{ $self->bundles }) { my ($mod_name, $dist_dir) = @$bundle; delete $prereq->{$mod_name}; $dist_dir = File::Basename::basename($dist_dir); # dir for building this module if (not exists $processed{$dist_dir}) { if (-d $dist_dir) { # List as sub-directory to be processed by make push @$subdirs, $dist_dir; } # Else do nothing: the module is already present on the system $processed{$dist_dir} = undef; } } } unless ( $self->makemaker('6.55_03') ) { %$prereq = (%$prereq,%$build_prereq); delete $args->{BUILD_REQUIRES}; } if ( my $perl_version = $self->perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; if ( $self->makemaker(6.48) ) { $args->{MIN_PERL_VERSION} = $perl_version; } } if ($self->installdirs) { warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; $args->{INSTALLDIRS} = $self->installdirs; } my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) } keys %$args; my $user_preop = delete $args{dist}->{PREOP}; if ( my $preop = $self->admin->preop($user_preop) ) { foreach my $key ( keys %$preop ) { $args{dist}->{$key} = $preop->{$key}; } } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { my $self = shift; my $makefile_name = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); local *MAKEFILE; open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; eval { flock MAKEFILE, LOCK_EX }; my $makefile = do { local $/; }; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; # Module::Install will never be used to build the Core Perl # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; # XXX - This is currently unused; not sure if it breaks other MM-users # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; seek MAKEFILE, 0, SEEK_SET; truncate MAKEFILE, 0; print MAKEFILE "$preamble$makefile$postamble" or die $!; close MAKEFILE or die $!; 1; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 544 Layout-Manager-0.35/inc/Module/Install/Metadata.pm000644 000765 000024 00000043277 12270604662 022240 0ustar00gphatstaff000000 000000 #line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } my @boolean_keys = qw{ sign }; my @scalar_keys = qw{ name module_name abstract version distribution_type tests installdirs }; my @tuple_keys = qw{ configure_requires build_requires requires recommends bundles resources }; my @resource_keys = qw{ homepage bugtracker repository }; my @array_keys = qw{ keywords author }; *authors = \&author; sub Meta { shift } sub Meta_BooleanKeys { @boolean_keys } sub Meta_ScalarKeys { @scalar_keys } sub Meta_TupleKeys { @tuple_keys } sub Meta_ResourceKeys { @resource_keys } sub Meta_ArrayKeys { @array_keys } foreach my $key ( @boolean_keys ) { *$key = sub { my $self = shift; if ( defined wantarray and not @_ ) { return $self->{values}->{$key}; } $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); return $self; }; } foreach my $key ( @scalar_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} = shift; return $self; }; } foreach my $key ( @array_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} ||= []; push @{$self->{values}->{$key}}, @_; return $self; }; } foreach my $key ( @resource_keys ) { *$key = sub { my $self = shift; unless ( @_ ) { return () unless $self->{values}->{resources}; return map { $_->[1] } grep { $_->[0] eq $key } @{ $self->{values}->{resources} }; } return $self->{values}->{resources}->{$key} unless @_; my $uri = shift or die( "Did not provide a value to $key()" ); $self->resources( $key => $uri ); return 1; }; } foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { *$key = sub { my $self = shift; return $self->{values}->{$key} unless @_; my @added; while ( @_ ) { my $module = shift or last; my $version = shift || 0; push @added, [ $module, $version ]; } push @{ $self->{values}->{$key} }, @added; return map {@$_} @added; }; } # Resource handling my %lc_resource = map { $_ => 1 } qw{ homepage license bugtracker repository }; sub resources { my $self = shift; while ( @_ ) { my $name = shift or last; my $value = shift or next; if ( $name eq lc $name and ! $lc_resource{$name} ) { die("Unsupported reserved lowercase resource '$name'"); } $self->{values}->{resources} ||= []; push @{ $self->{values}->{resources} }, [ $name, $value ]; } $self->{values}->{resources}; } # Aliases for build_requires that will have alternative # meanings in some future version of META.yml. sub test_requires { shift->build_requires(@_) } sub install_requires { shift->build_requires(@_) } # Aliases for installdirs options sub install_as_core { $_[0]->installdirs('perl') } sub install_as_cpan { $_[0]->installdirs('site') } sub install_as_site { $_[0]->installdirs('site') } sub install_as_vendor { $_[0]->installdirs('vendor') } sub dynamic_config { my $self = shift; my $value = @_ ? shift : 1; if ( $self->{values}->{dynamic_config} ) { # Once dynamic we never change to static, for safety return 0; } $self->{values}->{dynamic_config} = $value ? 1 : 0; return 1; } # Convenience command sub static_config { shift->dynamic_config(0); } sub perl_version { my $self = shift; return $self->{values}->{perl_version} unless @_; my $version = shift or die( "Did not provide a value to perl_version()" ); # Normalize the version $version = $self->_perl_version($version); # We don't support the really old versions unless ( $version >= 5.005 ) { die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; } $self->{values}->{perl_version} = $version; } sub all_from { my ( $self, $file ) = @_; unless ( defined($file) ) { my $name = $self->name or die( "all_from called with no args without setting name() first" ); $file = join('/', 'lib', split(/-/, $name)) . '.pm'; $file =~ s{.*/}{} unless -e $file; unless ( -e $file ) { die("all_from cannot find $file from $name"); } } unless ( -f $file ) { die("The path '$file' does not exist, or is not a file"); } $self->{values}{all_from} = $file; # Some methods pull from POD instead of code. # If there is a matching .pod, use that instead my $pod = $file; $pod =~ s/\.pm$/.pod/i; $pod = $file unless -e $pod; # Pull the different values $self->name_from($file) unless $self->name; $self->version_from($file) unless $self->version; $self->perl_version_from($file) unless $self->perl_version; $self->author_from($pod) unless @{$self->author || []}; $self->license_from($pod) unless $self->license; $self->abstract_from($pod) unless $self->abstract; return 1; } sub provides { my $self = shift; my $provides = ( $self->{values}->{provides} ||= {} ); %$provides = (%$provides, @_) if @_; return $provides; } sub auto_provides { my $self = shift; return $self unless $self->is_admin; unless (-e 'MANIFEST') { warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; return $self; } # Avoid spurious warnings as we are not checking manifest here. local $SIG{__WARN__} = sub {1}; require ExtUtils::Manifest; local *ExtUtils::Manifest::manicheck = sub { return }; require Module::Build; my $build = Module::Build->new( dist_name => $self->name, dist_version => $self->version, license => $self->license, ); $self->provides( %{ $build->find_dist_packages || {} } ); } sub feature { my $self = shift; my $name = shift; my $features = ( $self->{values}->{features} ||= [] ); my $mods; if ( @_ == 1 and ref( $_[0] ) ) { # The user used ->feature like ->features by passing in the second # argument as a reference. Accomodate for that. $mods = $_[0]; } else { $mods = \@_; } my $count = 0; push @$features, ( $name => [ map { ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ } @$mods ] ); return @$features; } sub features { my $self = shift; while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { $self->feature( $name, @$mods ); } return $self->{values}->{features} ? @{ $self->{values}->{features} } : (); } sub no_index { my $self = shift; my $type = shift; push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; return $self->{values}->{no_index}; } sub read { my $self = shift; $self->include_deps( 'YAML::Tiny', 0 ); require YAML::Tiny; my $data = YAML::Tiny::LoadFile('META.yml'); # Call methods explicitly in case user has already set some values. while ( my ( $key, $value ) = each %$data ) { next unless $self->can($key); if ( ref $value eq 'HASH' ) { while ( my ( $module, $version ) = each %$value ) { $self->can($key)->($self, $module => $version ); } } else { $self->can($key)->($self, $value); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; $self->admin->write_meta; return $self; } sub version_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->version( ExtUtils::MM_Unix->parse_version($file) ); # for version integrity check $self->makemaker_args( VERSION_FROM => $file ); } sub abstract_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix' )->parse_abstract($file) ); } # Add both distribution and module name sub name_from { my ($self, $file) = @_; if ( Module::Install::_read($file) =~ m/ ^ \s* package \s* ([\w:]+) \s* ; /ixms ) { my ($name, $module_name) = ($1, $1); $name =~ s{::}{-}g; $self->name($name); unless ( $self->module_name ) { $self->module_name($module_name); } } else { die("Cannot determine name from $file\n"); } } sub _extract_perl_version { if ( $_[0] =~ m/ ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /ixms ) { my $perl_version = $1; $perl_version =~ s{_}{}g; return $perl_version; } else { return; } } sub perl_version_from { my $self = shift; my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); if ($perl_version) { $self->perl_version($perl_version); } else { warn "Cannot determine perl version info from $_[0]\n"; return; } } sub author_from { my $self = shift; my $content = Module::Install::_read($_[0]); if ($content =~ m/ =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /ixms) { my $author = $1 || $2; # XXX: ugly but should work anyway... if (eval "require Pod::Escapes; 1") { # Pod::Escapes has a mapping table. # It's in core of perl >= 5.9.3, and should be installed # as one of the Pod::Simple's prereqs, which is a prereq # of Pod::Text 3.x (see also below). $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $Pod::Escapes::Name2character_number{$1} ? chr($Pod::Escapes::Name2character_number{$1}) : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { # Pod::Text < 3.0 has yet another mapping table, # though the table name of 2.x and 1.x are different. # (1.x is in core of Perl < 5.6, 2.x is in core of # Perl < 5.9.3) my $mapping = ($Pod::Text::VERSION < 2) ? \%Pod::Text::HTML_Escapes : \%Pod::Text::ESCAPES; $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $mapping->{$1} ? $mapping->{$1} : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } else { $author =~ s{E}{<}g; $author =~ s{E}{>}g; } $self->author($author); } else { warn "Cannot determine author info from $_[0]\n"; } } #Stolen from M::B my %license_urls = ( perl => 'http://dev.perl.org/licenses/', apache => 'http://apache.org/licenses/LICENSE-2.0', apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', artistic => 'http://opensource.org/licenses/artistic-license.php', artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', lgpl => 'http://opensource.org/licenses/lgpl-license.php', lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, unrestricted => undef, restrictive => undef, unknown => undef, ); sub license { my $self = shift; return $self->{values}->{license} unless @_; my $license = shift or die( 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); } return 1; } sub _extract_license { my $pod = shift; my $matched; return __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /xms ) || __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /xms ); } sub __extract_license { my $license_text = shift or return; my @phrases = ( '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, 'Artistic and GPL' => 'perl', 1, 'GNU general public license' => 'gpl', 1, 'GNU public license' => 'gpl', 1, 'GNU lesser general public license' => 'lgpl', 1, 'GNU lesser public license' => 'lgpl', 1, 'GNU library general public license' => 'lgpl', 1, 'GNU library public license' => 'lgpl', 1, 'GNU Free Documentation license' => 'unrestricted', 1, 'GNU Affero General Public License' => 'open_source', 1, '(?:Free)?BSD license' => 'bsd', 1, 'Artistic license 2\.0' => 'artistic_2', 1, 'Artistic license' => 'artistic', 1, 'Apache (?:Software )?license' => 'apache', 1, 'GPL' => 'gpl', 1, 'LGPL' => 'lgpl', 1, 'BSD' => 'bsd', 1, 'Artistic' => 'artistic', 1, 'MIT' => 'mit', 1, 'Mozilla Public License' => 'mozilla', 1, 'Q Public License' => 'open_source', 1, 'OpenSSL License' => 'unrestricted', 1, 'SSLeay License' => 'unrestricted', 1, 'zlib License' => 'open_source', 1, 'proprietary' => 'proprietary', 0, ); while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; if ( $license_text =~ /\b$pattern\b/i ) { return $license; } } return ''; } sub license_from { my $self = shift; if (my $license=_extract_license(Module::Install::_read($_[0]))) { $self->license($license); } else { warn "Cannot determine license info from $_[0]\n"; return 'unknown'; } } sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| https?\Q://github.com/\E[\w_]+/[\w_]+/issues| https?\Q://code.google.com/p/\E[\w_\-]+/issues/list )>#gx; my %links; @links{@links}=(); @links=keys %links; return @links; } sub bugtracker_from { my $self = shift; my $content = Module::Install::_read($_[0]); my @links = _extract_bugtracker($content); unless ( @links ) { warn "Cannot determine bugtracker info from $_[0]\n"; return 0; } if ( @links > 1 ) { warn "Found more than one bugtracker link in $_[0]\n"; return 0; } # Set the bugtracker bugtracker( $links[0] ); return 1; } sub requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->requires( $module => $version ); } } sub test_requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->test_requires( $module => $version ); } } # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to # numbers (eg, 5.006001 or 5.008009). # Also, convert double-part versions (eg, 5.8) sub _perl_version { my $v = $_[-1]; $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; $v =~ s/(\.\d\d\d)000$/$1/; $v =~ s/_.+$//; if ( ref($v) ) { # Numify $v = $v + 0; } return $v; } sub add_metadata { my $self = shift; my %hash = @_; for my $key (keys %hash) { warn "add_metadata: $key is not prefixed with 'x_'.\n" . "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; $self->{values}->{$key} = $hash{$key}; } } ###################################################################### # MYMETA Support sub WriteMyMeta { die "WriteMyMeta has been deprecated"; } sub write_mymeta_yaml { my $self = shift; # We need YAML::Tiny to write the MYMETA.yml file unless ( eval { require YAML::Tiny; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.yml\n"; YAML::Tiny::DumpFile('MYMETA.yml', $meta); } sub write_mymeta_json { my $self = shift; # We need JSON to write the MYMETA.json file unless ( eval { require JSON; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.json\n"; Module::Install::_write( 'MYMETA.json', JSON->new->pretty(1)->canonical->encode($meta), ); } sub _write_mymeta_data { my $self = shift; # If there's no existing META.yml there is nothing we can do return undef unless -f 'META.yml'; # We need Parse::CPAN::Meta to load the file unless ( eval { require Parse::CPAN::Meta; 1; } ) { return undef; } # Merge the perl version into the dependencies my $val = $self->Meta->{values}; my $perl = delete $val->{perl_version}; if ( $perl ) { $val->{requires} ||= []; my $requires = $val->{requires}; # Canonize to three-dot version after Perl 5.6 if ( $perl >= 5.006 ) { $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e } unshift @$requires, [ perl => $perl ]; } # Load the advisory META.yml file my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; # Overwrite the non-configure dependency hashs delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; if ( exists $val->{requires} ) { $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; } if ( exists $val->{build_requires} ) { $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; } return $meta; } 1; Layout-Manager-0.35/inc/Module/Install/Win32.pm000644 000765 000024 00000003403 12270604662 021405 0ustar00gphatstaff000000 000000 #line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $^O eq 'MSWin32' and $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and ! $self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- END_MESSAGE } 1; Layout-Manager-0.35/inc/Module/Install/WriteAll.pm000644 000765 000024 00000002376 12270604662 022236 0ustar00gphatstaff000000 000000 #line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_, ); $self->sign(1) if $args{sign}; $self->admin->WriteAll(%args) if $self->is_admin; $self->check_nmake if $args{check_nmake}; unless ( $self->makemaker_args->{PL_FILES} ) { # XXX: This still may be a bit over-defensive... unless ($self->makemaker(6.25)) { $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; } } # Until ExtUtils::MakeMaker support MYMETA.yml, make sure # we clean it up properly ourself. $self->realclean_files('MYMETA.yml'); if ( $args{inline} ) { $self->Inline->write; } else { $self->Makefile->write; } # The Makefile write process adds a couple of dependencies, # so write the META.yml files after the Makefile. if ( $args{meta} ) { $self->Meta->write; } # Experimental support for MYMETA if ( $ENV{X_MYMETA} ) { if ( $ENV{X_MYMETA} eq 'JSON' ) { $self->Meta->write_mymeta_json; } else { $self->Meta->write_mymeta_yaml; } } return 1; } 1;