| XML-Toolkit documentation | Contained in the XML-Toolkit distribution. |
XML::Toolkit::Cmd::Command::generate - generate clases from XML
xmltk generate
The XML::Toolkit::Cmd::Command::generate class implements ...
Insert description of method here...
Insert description of method here...
Moose
namespace::autoclean
XML::Toolkit::Builder
Moose::Util::TypeConstraints
Devel::PackagePath
Moose
MooseX::AttributeHelpers
XML::Toolkit
None known currently, please email the author if you find any.
Chris Prather (chris@prather.org)
Copyright 2009 by Chris Prather.
This software is free. It is licensed under the same terms as Perl itself.
| XML-Toolkit documentation | Contained in the XML-Toolkit distribution. |
package XML::Toolkit::Cmd::Command::generate; use Moose; use namespace::autoclean; extends qw(MooseX::App::Cmd::Command XML::Toolkit::App); use XML::Toolkit::Config::Container; use MooseX::Types::Path::Class qw(File); use Moose::Util::TypeConstraints; with qw( MooseX::Getopt::Dashes XML::Toolkit::Cmd::ClassTemplate ); has input => ( isa => File, is => 'ro', coerce => 1, required => 1, ); around _build_template => sub { my ( $next, $self ) = ( shift, shift ); my $template = <<'END_TEMPLATE'; [% PERL %] use Devel::PackagePath; my $p = Devel::PackagePath->new( package => "[% meta.name %]"); my $file = (split '::', "[% meta.name %]")[-1]; $p->create; $stash->set(filename => "${\$p->path}/$file.pm"); [% END %] [%- FILTER redirect("${filename}") -%] END_TEMPLATE $template .= $self->$next(@_) . "__END__\n[% END %]"; return $template; }; sub run { my ($self) = @_; my $builder = XML::Toolkit::Config::Container->new( namespace => $self->namespace, xmlns => $self->xmlns, template => $self->template, )->builder; $builder->parse_file( $self->input->stringify ); print $builder->render; } __PACKAGE__->meta->make_immutable; 1; __END__