]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/commitdiff
Make LT::Set::Path the base role, remove ::Op, and rename the old ::Path to ::Union
authorVincent Pit <vince@profvince.com>
Thu, 27 Jan 2011 14:01:07 +0000 (15:01 +0100)
committerVincent Pit <vince@profvince.com>
Thu, 27 Jan 2011 14:01:07 +0000 (15:01 +0100)
20 files changed:
MANIFEST
lib/LaTeX/TikZ.pm
lib/LaTeX/TikZ/Formatter.pm
lib/LaTeX/TikZ/Interface.pm
lib/LaTeX/TikZ/Mod/Clip.pm
lib/LaTeX/TikZ/Set/Circle.pm
lib/LaTeX/TikZ/Set/Line.pm
lib/LaTeX/TikZ/Set/Op.pm [deleted file]
lib/LaTeX/TikZ/Set/Path.pm
lib/LaTeX/TikZ/Set/Point.pm
lib/LaTeX/TikZ/Set/Polyline.pm
lib/LaTeX/TikZ/Set/Raw.pm
lib/LaTeX/TikZ/Set/Rectangle.pm
lib/LaTeX/TikZ/Set/Sequence.pm
lib/LaTeX/TikZ/Set/Union.pm [new file with mode: 0644]
t/00-load.t
t/01-api.t
t/10-set.t
t/30-functor.t
t/92-pod-coverage.t

index a7179929cdb842df2142d9acaabf9aac627ffdcc..01e994a857d8cb87732d42a71056d3460dfbaa3e 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -29,13 +29,13 @@ lib/LaTeX/TikZ/Set/Arrow.pm
 lib/LaTeX/TikZ/Set/Circle.pm
 lib/LaTeX/TikZ/Set/Line.pm
 lib/LaTeX/TikZ/Set/Mutable.pm
 lib/LaTeX/TikZ/Set/Circle.pm
 lib/LaTeX/TikZ/Set/Line.pm
 lib/LaTeX/TikZ/Set/Mutable.pm
-lib/LaTeX/TikZ/Set/Op.pm
 lib/LaTeX/TikZ/Set/Path.pm
 lib/LaTeX/TikZ/Set/Point.pm
 lib/LaTeX/TikZ/Set/Polyline.pm
 lib/LaTeX/TikZ/Set/Raw.pm
 lib/LaTeX/TikZ/Set/Rectangle.pm
 lib/LaTeX/TikZ/Set/Sequence.pm
 lib/LaTeX/TikZ/Set/Path.pm
 lib/LaTeX/TikZ/Set/Point.pm
 lib/LaTeX/TikZ/Set/Polyline.pm
 lib/LaTeX/TikZ/Set/Raw.pm
 lib/LaTeX/TikZ/Set/Rectangle.pm
 lib/LaTeX/TikZ/Set/Sequence.pm
+lib/LaTeX/TikZ/Set/Union.pm
 lib/LaTeX/TikZ/Tools.pm
 samples/synopsis.pl
 t/00-load.t
 lib/LaTeX/TikZ/Tools.pm
 samples/synopsis.pl
 t/00-load.t
index 61dd5749b80dc0c2319d9766b313edc35ca736d6..362d136ecc20c6b7fa619ae96e3ea1e4bc33019b 100644 (file)
@@ -53,20 +53,20 @@ It allows you to build structures representing geometrical figures, apply a wide
 
 =head1 CONCEPTS
 
 
 =head1 CONCEPTS
 
-Traditionally, in TikZ, there are two ways of grouping elements, or I<ops>, together :
+Traditionally, in TikZ, there are two ways of grouping paths together :
 
 =over 4
 
 =item *
 
 
 =over 4
 
 =item *
 
-either as a I<sequence>, where each element is drawn in its own line :
+either as a I<sequence>, where each path is drawn in its own line :
 
     \draw (0cm,0cm) -- (0cm,1cm) ;
     \draw (0cm,0cm) -- (1cm,0cm) ;
 
 =item *
 
 
     \draw (0cm,0cm) -- (0cm,1cm) ;
     \draw (0cm,0cm) -- (1cm,0cm) ;
 
 =item *
 
-or as a I<path>, where elements are all drawn as one line :
+or as an I<union>, where paths are all drawn as one line :
 
     \draw (0cm,0cm) -- (0cm,1cm) (0cm,0cm) -- (1cm,0cm) ;
 
 
     \draw (0cm,0cm) -- (0cm,1cm) (0cm,0cm) -- (1cm,0cm) ;
 
@@ -74,7 +74,7 @@ or as a I<path>, where elements are all drawn as one line :
 
 This distinction is important because there are some primitives that only apply to paths but not to sequences, and vice versa.
 
 
 This distinction is important because there are some primitives that only apply to paths but not to sequences, and vice versa.
 
-Figures are made of ops, path or sequence I<sets> assembled together in a tree.
+Figures are made of path or sequence I<sets> assembled together in a tree.
 
 I<Modifiers> can be applied onto any set to alter the way in which it is generated.
 The two TikZ concepts of I<clips> and I<layers> have been unified with the modifiers.
 
 I<Modifiers> can be applied onto any set to alter the way in which it is generated.
 The two TikZ concepts of I<clips> and I<layers> have been unified with the modifiers.
@@ -83,9 +83,9 @@ The two TikZ concepts of I<clips> and I<layers> have been unified with the modif
 
 =head2 Containers
 
 
 =head2 Containers
 
-=head3 C<< Tikz->path(@ops) >>
+=head3 C<< Tikz->union(@seq) >>
 
 
-Creates a L<LaTeX::TikZ::Set::Path> object out of the ops C<@ops>.
+Creates a L<LaTeX::TikZ::Set::Union> object out of the paths C<@kids>.
 
     # A path made of two circles
     Tikz->path(
 
     # A path made of two circles
     Tikz->path(
@@ -99,7 +99,7 @@ Creates a L<LaTeX::TikZ::Set::Path> object out of the ops C<@ops>.
 
 =head3 C<< Tikz->seq(@kids) >>
 
 
 =head3 C<< Tikz->seq(@kids) >>
 
-Creates a L<LaTeX::TikZ::Set::Sequence> object out of the sequences, paths or ops C<@kids>.
+Creates a L<LaTeX::TikZ::Set::Sequence> object out of the sequences or paths C<@kids>.
 
     my $bag = Tikz->seq($sequence, $path, $circle, $raw, $point);
 
 
     my $bag = Tikz->seq($sequence, $path, $circle, $raw, $point);
 
index 77f3b53b1b609763635fe266e03aeaea596fc281..a5bda82f88ffa32c445c7f0f5157ac4389ed4e11 100644 (file)
@@ -212,10 +212,9 @@ my $find_mods = do {
     }
    }
 
     }
    }
 
-   my @subsets = $set->isa('LaTeX::TikZ::Set::Sequence')
-                 ? $set->kids
-                 : $set->isa('LaTeX::TikZ::Set::Path')
-                   ? $set->ops
+   my @subsets = ($set->isa('LaTeX::TikZ::Set::Sequence')
+                  || $set->isa('LaTeX::TikZ::Set::Union'))
+                   ? $set->kids
                    : ();
 
    $find_mods_rec->($_, $layers, $others) for @subsets;
                    : ();
 
    $find_mods_rec->($_, $layers, $others) for @subsets;
index e92888e7e05d37e6c17ef84e96098a2cb7fa84a7..356a42e02e6e780e689446465c11ac531e54d1de 100644 (file)
@@ -69,7 +69,7 @@ sub load {
 
  require LaTeX::TikZ::Set::Raw;       # raw
 
 
  require LaTeX::TikZ::Set::Raw;       # raw
 
- require LaTeX::TikZ::Set::Path;      # path
+ require LaTeX::TikZ::Set::Union;     # union
  require LaTeX::TikZ::Set::Sequence;  # seq
 
  require LaTeX::TikZ::Set::Point;     # point
  require LaTeX::TikZ::Set::Sequence;  # seq
 
  require LaTeX::TikZ::Set::Point;     # point
index 59cb2c4f380d65d75d1f980e6cf51cdf954c350c..1b61b4db0f996ddf3bc2caff61a0a598920713c9 100644 (file)
@@ -45,7 +45,7 @@ The path that specifies the clipped area.
 
 has clip => (
  is       => 'ro',
 
 has clip => (
  is       => 'ro',
- does     => 'LaTeX::TikZ::Set::Op',
+ does     => 'LaTeX::TikZ::Set::Path',
  required => 1,
 );
 
  required => 1,
 );
 
index d1f7317bb69ba6f70d232ced9b359831ee92455a..54c1540a5db5d5b9fee7e743be41879758707609 100644 (file)
@@ -27,11 +27,11 @@ use Any::Moose 'Util::TypeConstraints';
 
 =head1 RELATIONSHIPS
 
 
 =head1 RELATIONSHIPS
 
-This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
 
 =cut
 
 
 =cut
 
-with 'LaTeX::TikZ::Set::Op';
+with 'LaTeX::TikZ::Set::Path';
 
 =head1 ATTRIBUTES
 
 
 =head1 ATTRIBUTES
 
@@ -95,7 +95,7 @@ __PACKAGE__->meta->make_immutable;
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set>, L<LaTeX::TikZ::Set::Op>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set>, L<LaTeX::TikZ::Set::Path>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
index 3ee969493a0f764a292c4cdca1ea424dd3c219f0..4054bfd1d282eb380dad5f5758402b5bbe9665e8 100644 (file)
@@ -24,11 +24,11 @@ use Any::Moose;
 
 =head1 RELATIONSHIPS
 
 
 =head1 RELATIONSHIPS
 
-This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
 
 =cut
 
 
 =cut
 
-with 'LaTeX::TikZ::Set::Op';
+with 'LaTeX::TikZ::Set::Path';
 
 =head1 ATTRIBUTES
 
 
 =head1 ATTRIBUTES
 
@@ -89,7 +89,7 @@ __PACKAGE__->meta->make_immutable;
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
diff --git a/lib/LaTeX/TikZ/Set/Op.pm b/lib/LaTeX/TikZ/Set/Op.pm
deleted file mode 100644 (file)
index 69d8a63..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package LaTeX::TikZ::Set::Op;
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-LaTeX::TikZ::Set::Op - A role for set objects that can be part of a path.
-
-=head1 VERSION
-
-Version 0.02
-
-=cut
-
-our $VERSION = '0.02';
-
-=head1 DESCRIPTION
-
-Ops are the components of a path.
-They can be built together to form a path.
-Thus, they are all the elements against which we can call the C<path> method.
-
-=cut
-
-use Any::Moose 'Role';
-
-=head1 RELATIONSHIPS
-
-This role consumes the L<LaTeX::TikZ::Set> role, and as such implements the L</draw> method.
-
-=cut
-
-with 'LaTeX::TikZ::Set';
-
-=head1 METHODS
-
-This method is required by the interface :
-
-=over 4
-
-=item *
-
-C<path $formatter>
-
-Returns the TikZ code that builds a path out of the current set object as a string formatted by the L<LaTeX::TikZ::Formatter> object C<$formatter>.
-
-=back
-
-=cut
-
-requires qw<
- path
->;
-
-=head2 C<draw>
-
-=cut
-
-sub draw {
- my $set = shift;
-
- [ "\\draw " . $set->path(@_) . ' ;' ];
-}
-
-=head1 SEE ALSO
-
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set>.
-
-=head1 AUTHOR
-
-Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
-
-You can contact me by mail or on C<irc.perl.org> (vincent).
-
-=head1 BUGS
-
-Please report any bugs or feature requests to C<bug-latex-tikz at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-TikZ>.
-I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
-
-=head1 SUPPORT
-
-You can find documentation for this module with the perldoc command.
-
-    perldoc LaTeX::TikZ
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2010 Vincent Pit, all rights reserved.
-
-This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
-
-=cut
-
-1; # End of LaTeX::TikZ::Set::Op;
index a19d8c0ff436c879911fa2f70a236d63f92be8f0..f7a5fb21b684deb1afca328d216f41597d42db27 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 =head1 NAME
 
 
 =head1 NAME
 
-LaTeX::TikZ::Set::Path - A set object representing a path.
+LaTeX::TikZ::Set::Path - A role for set objects that can be part of a path.
 
 =head1 VERSION
 
 
 =head1 VERSION
 
@@ -15,89 +15,55 @@ Version 0.02
 
 our $VERSION = '0.02';
 
 
 our $VERSION = '0.02';
 
-use LaTeX::TikZ::Interface;
-use LaTeX::TikZ::Functor;
+=head1 DESCRIPTION
 
 
-use LaTeX::TikZ::Tools;
-
-use Any::Moose;
-
-=head1 RELATIONSHIPS
-
-This class consumes the L<LaTeX::TikZ::Set::Op> and L<LaTeX::TikZ::Set::Mutable> roles, and as such implements the L</path> and L</add> methods.
+Paths are all the elements against which we can call the C<path> method.
 
 =cut
 
 
 =cut
 
-with qw<
- LaTeX::TikZ::Set::Op
- LaTeX::TikZ::Set::Mutable
->;
+use Any::Moose 'Role';
 
 
-=head1 ATTRIBUTES
-
-=head2 C<ops>
+=head1 RELATIONSHIPS
 
 
-The L<LaTeX::TikZ::Set::Op> objects that from the path.
+This role consumes the L<LaTeX::TikZ::Set> role, and as such implements the L</draw> method.
 
 =cut
 
 
 =cut
 
-has '_ops' => (
- is       => 'ro',
- isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Op]]',
- init_arg => 'ops',
- default  => sub { [ ] },
-);
-
-sub ops { @{$_[0]->_ops} }
+with 'LaTeX::TikZ::Set';
 
 =head1 METHODS
 
 
 =head1 METHODS
 
-=head2 C<add>
+This method is required by the interface :
 
 
-=cut
+=over 4
 
 
-my $ltso_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Set::Op');
+=item *
 
 
-sub add {
- my $set = shift;
+C<path $formatter>
 
 
- $ltso_tc->assert_valid($_) for @_;
+Returns the TikZ code that builds a path out of the current set object as a string formatted by the L<LaTeX::TikZ::Formatter> object C<$formatter>.
 
 
- push @{$set->_ops}, @_;
+=back
 
 
- $set;
-}
+=cut
+
+requires qw<
+ path
+>;
 
 
-=head2 C<path>
+=head2 C<draw>
 
 =cut
 
 
 =cut
 
-sub path {
+sub draw {
  my $set = shift;
 
  my $set = shift;
 
join ' ', map $_->path(@_), $set->ops;
[ "\\draw " . $set->path(@_) . ' ;' ];
 }
 
 }
 
-LaTeX::TikZ::Interface->register(
- path => sub {
-  shift;
-
-  __PACKAGE__->new(ops => \@_);
- },
-);
-
-LaTeX::TikZ::Functor->default_rule(
- (__PACKAGE__) => sub {
-  my ($functor, $set, @args) = @_;
-  $set->new(ops => [ map $_->$functor(@args), $set->ops ])
- }
-);
-
-__PACKAGE__->meta->make_immutable;
-
 =head1 SEE ALSO
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>, L<LaTeX::TikZ::Set::Mutable>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
@@ -124,4 +90,4 @@ This program is free software; you can redistribute it and/or modify it under th
 
 =cut
 
 
 =cut
 
-1; # End of LaTeX::TikZ::Set::Path
+1; # End of LaTeX::TikZ::Set::Path;
index 2309db3910c228eea5059d96d54126c2c76c9824..d5761d17614c4186e66535b14c3e995af15bcdf1 100644 (file)
@@ -25,11 +25,11 @@ use Any::Moose 'Util::TypeConstraints';
 
 =head1 RELATIONSHIPS
 
 
 =head1 RELATIONSHIPS
 
-This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
 
 =cut
 
 
 =cut
 
-with 'LaTeX::TikZ::Set::Op';
+with 'LaTeX::TikZ::Set::Path';
 
 =head1 ATTRIBUTES
 
 
 =head1 ATTRIBUTES
 
@@ -146,7 +146,7 @@ __PACKAGE__->meta->make_immutable;
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
index dbd9b0ab8c95a9d0697a21625fe4d0b638a74f8c..a1992a5d11790e0bd677745bb28e6ee38bfeeaa8 100644 (file)
@@ -25,11 +25,11 @@ use Any::Moose 'Util::TypeConstraints';
 
 =head1 RELATIONSHIPS
 
 
 =head1 RELATIONSHIPS
 
-This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
 
 =cut
 
 
 =cut
 
-with 'LaTeX::TikZ::Set::Op';
+with 'LaTeX::TikZ::Set::Path';
 
 subtype 'LaTeX::TikZ::Set::Polyline::Vertices'
      => as 'ArrayRef[LaTeX::TikZ::Set::Point]'
 
 subtype 'LaTeX::TikZ::Set::Polyline::Vertices'
      => as 'ArrayRef[LaTeX::TikZ::Set::Point]'
@@ -110,7 +110,7 @@ __PACKAGE__->meta->make_immutable;
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
index 159492d0f87cddb7378f2f34ad72267abe3d8a5d..68f40254acc29ab0283583acba496b99a52f8e64 100644 (file)
@@ -22,11 +22,11 @@ use Any::Moose;
 
 =head1 RELATIONSHIPS
 
 
 =head1 RELATIONSHIPS
 
-This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
 
 =cut
 
 
 =cut
 
-with 'LaTeX::TikZ::Set::Op';
+with 'LaTeX::TikZ::Set::Path';
 
 =head1 ATTRIBUTES
 
 
 =head1 ATTRIBUTES
 
@@ -69,7 +69,7 @@ __PACKAGE__->meta->make_immutable;
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
index c6729397418184822e013397211031cb42bf3895..2e290db8be8b013b6f42c2595d328580d0a1c8ef 100644 (file)
@@ -24,11 +24,11 @@ use Any::Moose;
 
 =head1 RELATIONSHIPS
 
 
 =head1 RELATIONSHIPS
 
-This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
 
 =cut
 
 
 =cut
 
-with 'LaTeX::TikZ::Set::Op';
+with 'LaTeX::TikZ::Set::Path';
 
 =head1 ATTRIBUTES
 
 
 =head1 ATTRIBUTES
 
@@ -154,7 +154,7 @@ __PACKAGE__->meta->make_immutable;
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
index 446721e015b35ce2198a0f10ac7b15be88f05b7d..c4531218aec1c135e8143ec47ebed45cfdf84aa0 100644 (file)
@@ -40,7 +40,7 @@ with qw<
 subtype 'LaTeX::TikZ::Set::Sequence::Elements'
      => as 'Object'
      => where {
 subtype 'LaTeX::TikZ::Set::Sequence::Elements'
      => as 'Object'
      => where {
-             $_->does('LaTeX::TikZ::Set::Op')
+             $_->does('LaTeX::TikZ::Set::Path')
           or $_->isa('LaTeX::TikZ::Set::Sequence')
      };
 
           or $_->isa('LaTeX::TikZ::Set::Sequence')
      };
 
@@ -48,7 +48,7 @@ subtype 'LaTeX::TikZ::Set::Sequence::Elements'
 
 =head2 C<kids>
 
 
 =head2 C<kids>
 
-The L<LaTeX::TikZ::Set::Op> or L<LaTeX::TikZ::Set::Sequence> objects that from the sequence.
+The L<LaTeX::TikZ::Set::Path> or L<LaTeX::TikZ::Set::Sequence> objects that from the sequence.
 
 =cut
 
 
 =cut
 
@@ -113,7 +113,7 @@ __PACKAGE__->meta->make_immutable;
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>, L<LaTeX::TikZ::Set::Mutable>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>, L<LaTeX::TikZ::Set::Mutable>.
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
diff --git a/lib/LaTeX/TikZ/Set/Union.pm b/lib/LaTeX/TikZ/Set/Union.pm
new file mode 100644 (file)
index 0000000..2648d3d
--- /dev/null
@@ -0,0 +1,127 @@
+package LaTeX::TikZ::Set::Union;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+LaTeX::TikZ::Set::Union - A set object representing a path formed by the reunion of several subpaths.
+
+=head1 VERSION
+
+Version 0.02
+
+=cut
+
+our $VERSION = '0.02';
+
+use LaTeX::TikZ::Interface;
+use LaTeX::TikZ::Functor;
+
+use LaTeX::TikZ::Tools;
+
+use Any::Moose;
+
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Path> and L<LaTeX::TikZ::Set::Mutable> roles, and as such implements the L</path> and L</add> methods.
+
+=cut
+
+with qw<
+ LaTeX::TikZ::Set::Path
+ LaTeX::TikZ::Set::Mutable
+>;
+
+=head1 ATTRIBUTES
+
+=head2 C<kids>
+
+The L<LaTeX::TikZ::Set::Path> objects that form the path.
+
+=cut
+
+has '_kids' => (
+ is       => 'ro',
+ isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Path]]',
+ init_arg => 'kids',
+ default  => sub { [ ] },
+);
+
+sub kids { @{$_[0]->_kids} }
+
+=head1 METHODS
+
+=head2 C<add>
+
+=cut
+
+my $ltsp_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Set::Path');
+
+sub add {
+ my $set = shift;
+
+ $ltsp_tc->assert_valid($_) for @_;
+
+ push @{$set->_kids}, @_;
+
+ $set;
+}
+
+=head2 C<path>
+
+=cut
+
+sub path {
+ my $set = shift;
+
+ join ' ', map $_->path(@_), $set->kids;
+}
+
+LaTeX::TikZ::Interface->register(
+ union => sub {
+  shift;
+
+  __PACKAGE__->new(kids => \@_);
+ },
+);
+
+LaTeX::TikZ::Functor->default_rule(
+ (__PACKAGE__) => sub {
+  my ($functor, $set, @args) = @_;
+  $set->new(kids => [ map $_->$functor(@args), $set->kids ])
+ }
+);
+
+__PACKAGE__->meta->make_immutable;
+
+=head1 SEE ALSO
+
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>, L<LaTeX::TikZ::Set::Mutable>.
+
+=head1 AUTHOR
+
+Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
+
+You can contact me by mail or on C<irc.perl.org> (vincent).
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-latex-tikz at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-TikZ>.
+I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc LaTeX::TikZ
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2010 Vincent Pit, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
+1; # End of LaTeX::TikZ::Set::Union
index a0af7c676913b2a02dfbd92ae02887794ac66591..a82117458062da21ec293555232905c2719a64ff 100644 (file)
@@ -32,13 +32,13 @@ BEGIN {
  use_ok( 'LaTeX::TikZ::Set::Circle' );
  use_ok( 'LaTeX::TikZ::Set::Line' );
  use_ok( 'LaTeX::TikZ::Set::Mutable' );
  use_ok( 'LaTeX::TikZ::Set::Circle' );
  use_ok( 'LaTeX::TikZ::Set::Line' );
  use_ok( 'LaTeX::TikZ::Set::Mutable' );
- use_ok( 'LaTeX::TikZ::Set::Op' );
  use_ok( 'LaTeX::TikZ::Set::Path' );
  use_ok( 'LaTeX::TikZ::Set::Point' );
  use_ok( 'LaTeX::TikZ::Set::Polyline' );
  use_ok( 'LaTeX::TikZ::Set::Raw' );
  use_ok( 'LaTeX::TikZ::Set::Rectangle' );
  use_ok( 'LaTeX::TikZ::Set::Sequence' );
  use_ok( 'LaTeX::TikZ::Set::Path' );
  use_ok( 'LaTeX::TikZ::Set::Point' );
  use_ok( 'LaTeX::TikZ::Set::Polyline' );
  use_ok( 'LaTeX::TikZ::Set::Raw' );
  use_ok( 'LaTeX::TikZ::Set::Rectangle' );
  use_ok( 'LaTeX::TikZ::Set::Sequence' );
+ use_ok( 'LaTeX::TikZ::Set::Union' );
  use_ok( 'LaTeX::TikZ::Tools' );
 }
 
  use_ok( 'LaTeX::TikZ::Tools' );
 }
 
index dd098d96fa2d490a128d78cf64645016517a2a69..b0d7b20498c0ae204fd375d664f38e344918fcd1 100644 (file)
@@ -31,7 +31,7 @@ is(prototype('Tikz'), '', 'main::Tikz is actually a constant');
 my @methods = qw<
  formatter functor
  raw
 my @methods = qw<
  formatter functor
  raw
path seq
union seq
  point line polyline closed_polyline rectangle circle arc arrow
  raw_mod
  clip layer
  point line polyline closed_polyline rectangle circle arc arrow
  raw_mod
  clip layer
index 5ec0e33d26420ee5c323e148f39db65dbd25778a..9d20422f25d0da150350051c5b6cd0ab7e9787ce 100644 (file)
@@ -157,15 +157,15 @@ sub failed_valid {
 }
 
 eval {
 }
 
 eval {
- Tikz->path($foo, $seq2);
+ Tikz->union($foo, $seq2);
 };
 };
-like $@, failed_valid('Maybe[ArrayRef[LaTeX::TikZ::Set::Op]]'),
-         'creating a path that contains a sequence croaks';
+like $@, failed_valid('Maybe[ArrayRef[LaTeX::TikZ::Set::Path]]'),
+         'creating an union that contains a sequence croaks';
 
 my $path = eval {
 
 my $path = eval {
- Tikz->path($foo, $bar, $baz);
+ Tikz->union($foo, $bar, $baz);
 };
 };
-is $@, '', 'creating a path set doesn\'t croak';
+is $@, '', 'creating an union set doesn\'t croak';
 
 check $path, 'one path set', <<'RES';
 \draw foo bar baz ;
 
 check $path, 'one path set', <<'RES';
 \draw foo bar baz ;
@@ -184,5 +184,5 @@ RES
 eval {
  $path->add($seq2);
 };
 eval {
  $path->add($seq2);
 };
-like $@, failed_valid('LaTeX::TikZ::Set::Op'),
+like $@, failed_valid('LaTeX::TikZ::Set::Path'),
          'adding a sequence to a path croaks';
          'adding a sequence to a path croaks';
index 64d7d4b6023e61c398fdd5fb09864dda41b6652c..a5952efe26f1f09053a3e17d00aa50586a68ab59 100644 (file)
@@ -122,7 +122,7 @@ $special = eval {
   '+LaTeX::TikZ::Mod'       => sub { die "mod\n" },
   '+LaTeX::TikZ::Set'       => sub { die "set\n" },
   'LaTeX::TikZ::Set::Point' => sub { Tikz->point(7) },
   '+LaTeX::TikZ::Mod'       => sub { die "mod\n" },
   '+LaTeX::TikZ::Set'       => sub { die "set\n" },
   'LaTeX::TikZ::Set::Point' => sub { Tikz->point(7) },
-  'LaTeX::TikZ::Set::Op'    => sub { Tikz->raw('moo') },
+  'LaTeX::TikZ::Set::Path'  => sub { Tikz->raw('moo') },
  );
 };
 is $@, '', 'creating a special functor with + and normal rules doesn\'t croak';
  );
 };
 is $@, '', 'creating a special functor with + and normal rules doesn\'t croak';
index bf0ee707878244193fc59b460b4f7d17ab67f827..f6cc91bc22d00272c44d3c131adbb3f145a0f85a 100644 (file)
@@ -47,11 +47,11 @@ pod_coverage_ok( 'LaTeX::TikZ::Set::Arrow' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Circle' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Line' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Mutable' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Circle' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Line' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Mutable' );
-pod_coverage_ok( 'LaTeX::TikZ::Set::Op' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Path' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Point' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Polyline' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Raw' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Rectangle' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Sequence' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Path' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Point' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Polyline' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Raw' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Rectangle' );
 pod_coverage_ok( 'LaTeX::TikZ::Set::Sequence' );
+pod_coverage_ok( 'LaTeX::TikZ::Set::Union' );
 pod_coverage_ok( 'LaTeX::TikZ::Tools' );
 pod_coverage_ok( 'LaTeX::TikZ::Tools' );