Padre-Plugin-Moose-0.21/0000755000175000017500000000000011730337050014672 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/META.yml0000644000175000017500000000146211730337037016153 0ustar azawawiazawawi--- abstract: 'Moose, Mouse and MooseX::Declare support for Padre' author: - 'Ahmad M. Zawawi ' build_requires: ExtUtils::MakeMaker: 6.59 Locale::Msgfmt: 0.15 Test::More: 0.88 configure_requires: ExtUtils::MakeMaker: 6.59 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: Padre-Plugin-Moose no_index: directory: - inc - share - t requires: Moose: 2.0402 Padre: 0.94 perl: 5.8.0 resources: bugtracker: http://padre.perlide.org/ homepage: http://padre.perlide.org/trac/wiki/PadrePluginMoose license: http://dev.perl.org/licenses/ repository: http://svn.perlide.org/padre/trunk/Padre-Plugin-Moose version: 0.21 Padre-Plugin-Moose-0.21/README0000644000175000017500000000207211730337034015555 0ustar azawawiazawawiPadre-Plugin-Moose This plugin enables Padre to syntax highlight Moose, Mouse and MooseX::Declare keywords. It also features a user-friendly assistant dialog to generate code for classes, roles and their members. The dialog contains also Moose online references. 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 Padre::Plugin::Moose You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Padre-Plugin-Moose AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Padre-Plugin-Moose CPAN Ratings http://cpanratings.perl.org/d/Padre-Plugin-Moose Search CPAN http://search.cpan.org/dist/Padre-Plugin-Moose COPYRIGHT AND LICENCE Copyright (C) 2012 Ahmad M. Zawawi This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Padre-Plugin-Moose-0.21/MYMETA.yml0000644000175000017500000000112511730337037016415 0ustar azawawiazawawi--- abstract: 'Moose, Mouse and MooseX::Declare support for Padre' author: - 'Ahmad M. Zawawi ' build_requires: ExtUtils::MakeMaker: 6.59 Locale::Msgfmt: 0.15 Test::More: 0.88 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Padre-Plugin-Moose no_index: directory: - t - inc requires: Moose: 2.0402 Padre: 0.94 perl: 5.008 version: 0.21 Padre-Plugin-Moose-0.21/lib/0000755000175000017500000000000011730337050015440 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/lib/Padre/0000755000175000017500000000000011730337050016473 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/lib/Padre/Plugin/0000755000175000017500000000000011730337050017731 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/0000755000175000017500000000000011730337050021013 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Destructor.pm0000644000175000017500000000507111730324234023512 0ustar azawawiazawawipackage Padre::Plugin::Moose::Destructor; use Moose; our $VERSION = '0.21'; extends 'Padre::Plugin::Moose::ClassMember'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; with 'Padre::Plugin::Moose::Role::CanHandleInspector'; has 'modifier' => ( is => 'rw', isa => 'Str' ); sub generate_moose_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $code; my $name = $self->name; my $modifier = $self->modifier; if ( defined $modifier && $modifier eq 'around' ) { $code = "around '$name' => sub {\n"; $code .= "\tmy \$orig = shift;\n"; $code .= "\tmy \$self = shift;\n"; $code .= "\n"; $code .= "\t# before calling $name\n" if $comments; $code .= "\t\$self->\$orig(\@_)\n"; $code .= "\t# after calling $name\n" if $comments; $code .= "};\n"; } elsif ( defined $modifier && $modifier =~ /^(before|after)$/ ) { $code = $self->modifier . " '$name' => sub {\n\tmy \$self = shift;\n};\n"; } else { $code = "sub $name {\n\tmy \$self = shift;\n}\n"; } return $code; } # Generate Mouse code! sub generate_mouse_code { return $_[0]->generate_moose_code(@_); } sub generate_moosex_declare_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $code; my $name = $self->name; my $modifier = $self->modifier; if ( defined $modifier && $modifier eq 'around' ) { $code = "around $name {\n"; $code .= "\n"; $code .= "\t# before calling $name\n" if $comments; $code .= "\t\$self->\$orig(\@_)\n"; $code .= "\t# after calling $name\n" if $comments; $code .= "};\n"; } elsif ( defined $modifier && $modifier =~ /^(before|after)$/ ) { $code = $self->modifier . " '$name' => sub {\n\tmy \$self = shift;\n};\n"; } else { $code = "method $name {\n" . ( $comments ? "\t# \$self is predeclared by MooseX::Declare" : q{} ) . "\n}\n"; } return $code; } sub provide_help { require Wx; return Wx::gettext('A special type of subroutine called at the destruction of an object'); } sub read_from_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name modifier)) { $self->$field( $grid->GetCellValue( $row++, 1 ) ); } } sub write_to_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name modifier)) { $grid->SetCellValue( $row++, 1, $self->$field ); } } sub get_grid_data { require Wx; return [ { name => Wx::gettext('Name:') }, { name => Wx::gettext('Modifier:'), choices => [qw(around after before)] }, ]; } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/FBP/0000755000175000017500000000000011730337050021422 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/FBP/Assistant.pm0000644000175000017500000003212311730324234023732 0ustar azawawiazawawipackage Padre::Plugin::Moose::FBP::Assistant; ## no critic # This module was generated by Padre::Plugin::FormBuilder::Perl. # To change this module edit the original .fbp file and regenerate. # DO NOT MODIFY THIS FILE BY HAND! use 5.008005; use utf8; use strict; use warnings; use Padre::Wx 'Grid'; use Padre::Wx::Role::Main (); use Padre::Wx::Editor (); our $VERSION = '0.21'; our @ISA = qw{ Padre::Wx::Role::Main Wx::Dialog }; sub new { my $class = shift; my $parent = shift; my $self = $class->SUPER::new( $parent, -1, Wx::gettext("Moose Assistant"), Wx::DefaultPosition, [ 750, 480 ], Wx::DEFAULT_DIALOG_STYLE | Wx::RESIZE_BORDER, ); $self->SetSizeHints( [ 750, 480 ], Wx::DefaultSize ); $self->SetMinSize( [ 750, 480 ] ); my $m_staticText2 = Wx::StaticText->new( $self, -1, Wx::gettext("Object Tree"), ); $m_staticText2->SetFont( Wx::Font->new( Wx::NORMAL_FONT->GetPointSize, 70, 90, 92, 0, "" ) ); $self->{tree} = Wx::TreeCtrl->new( $self, -1, Wx::DefaultPosition, Wx::DefaultSize, Wx::TR_DEFAULT_STYLE | Wx::SIMPLE_BORDER, ); Wx::Event::EVT_KEY_UP( $self->{tree}, sub { $self->on_tree_key_up( $_[1] ); }, ); Wx::Event::EVT_TREE_ITEM_MENU( $self, $self->{tree}, sub { shift->on_tree_item_menu(@_); }, ); Wx::Event::EVT_TREE_SEL_CHANGED( $self, $self->{tree}, sub { shift->on_tree_selection_change(@_); }, ); my $m_staticText3 = Wx::StaticText->new( $self, -1, Wx::gettext("Properties"), ); $m_staticText3->SetFont( Wx::Font->new( Wx::NORMAL_FONT->GetPointSize, 70, 90, 92, 0, "" ) ); $self->{inspector} = Wx::Grid->new( $self, -1, Wx::DefaultPosition, [ -1, 150 ], Wx::SIMPLE_BORDER, ); $self->{inspector}->CreateGrid( 20, 2 ); $self->{inspector}->EnableEditing(1); $self->{inspector}->EnableGridLines(1); $self->{inspector}->EnableDragGridSize(0); $self->{inspector}->SetMargins( 0, 0 ); $self->{inspector}->SetColSize( 0, 140 ); $self->{inspector}->SetColSize( 1, 140 ); $self->{inspector}->EnableDragColMove(0); $self->{inspector}->EnableDragColSize(1); $self->{inspector}->SetColLabelSize(0); $self->{inspector}->SetColLabelAlignment( Wx::ALIGN_CENTRE, Wx::ALIGN_CENTRE ); $self->{inspector}->EnableDragRowSize(1); $self->{inspector}->SetRowLabelAlignment( Wx::ALIGN_CENTRE, Wx::ALIGN_CENTRE ); $self->{inspector}->SetDefaultCellAlignment( Wx::ALIGN_LEFT, Wx::ALIGN_TOP ); $self->{inspector}->SetMinSize( [ -1, 150 ] ); Wx::Event::EVT_GRID_CELL_CHANGE( $self->{inspector}, sub { $self->on_grid_cell_change( $_[1] ); }, ); $self->{help} = Wx::TextCtrl->new( $self, -1, "", Wx::DefaultPosition, Wx::DefaultSize, Wx::TE_MULTILINE | Wx::TE_NO_VSCROLL | Wx::TE_READONLY | Wx::NO_BORDER, ); $self->{help}->SetMinSize( [ -1, 100 ] ); $self->{help}->SetForegroundColour( Wx::SystemSettings::GetColour(Wx::SYS_COLOUR_INFOBK) ); $self->{help}->SetBackgroundColour( Wx::SystemSettings::GetColour(Wx::SYS_COLOUR_INFOBK) ); my $m_staticText4 = Wx::StaticText->new( $self, -1, Wx::gettext("Palette"), ); $m_staticText4->SetFont( Wx::Font->new( Wx::NORMAL_FONT->GetPointSize, 70, 90, 92, 0, "" ) ); $self->{palette} = Wx::Notebook->new( $self, -1, Wx::DefaultPosition, Wx::DefaultSize, ); $self->{containers} = Wx::Panel->new( $self->{palette}, -1, Wx::DefaultPosition, Wx::DefaultSize, Wx::TAB_TRAVERSAL, ); $self->{add_class_button} = Wx::Button->new( $self->{containers}, -1, Wx::gettext("&Class"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{add_class_button}, sub { shift->on_add_class_button(@_); }, ); $self->{add_role_button} = Wx::Button->new( $self->{containers}, -1, Wx::gettext("&Role"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{add_role_button}, sub { shift->on_add_role_button(@_); }, ); $self->{members} = Wx::Panel->new( $self->{palette}, -1, Wx::DefaultPosition, Wx::DefaultSize, Wx::TAB_TRAVERSAL, ); $self->{add_attribute_button} = Wx::Button->new( $self->{members}, -1, Wx::gettext("&Attribute"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{add_attribute_button}, sub { shift->on_add_attribute_button(@_); }, ); $self->{add_method_button} = Wx::Button->new( $self->{members}, -1, Wx::gettext("&Method"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{add_method_button}, sub { shift->on_add_method_button(@_); }, ); $self->{add_subtype_button} = Wx::Button->new( $self->{members}, -1, Wx::gettext("&Subtype"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{add_subtype_button}, sub { shift->on_add_subtype_button(@_); }, ); $self->{add_constructor_button} = Wx::Button->new( $self->{members}, -1, Wx::gettext("&Constructor"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{add_constructor_button}, sub { shift->on_add_constructor_button(@_); }, ); $self->{add_destructor_button} = Wx::Button->new( $self->{members}, -1, Wx::gettext("&Destructor"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{add_destructor_button}, sub { shift->on_add_destructor_button(@_); }, ); $self->{online_refs} = Wx::Panel->new( $self->{palette}, -1, Wx::DefaultPosition, Wx::DefaultSize, Wx::TAB_TRAVERSAL, ); $self->{moose_manual_hyperlink} = Wx::HyperlinkCtrl->new( $self->{online_refs}, -1, Wx::gettext("Moose Manual"), "https://metacpan.org/module/Moose::Manual", Wx::DefaultPosition, Wx::DefaultSize, Wx::HL_DEFAULT_STYLE, ); $self->{moose_cookbook_hyperlink} = Wx::HyperlinkCtrl->new( $self->{online_refs}, -1, Wx::gettext("How to Cook a Moose?"), "https://metacpan.org/module/Moose::Cookbook", Wx::DefaultPosition, Wx::DefaultSize, Wx::HL_DEFAULT_STYLE, ); $self->{moose_website_hyperlink} = Wx::HyperlinkCtrl->new( $self->{online_refs}, -1, Wx::gettext("Moose Website"), "http://moose.iinteractive.com/", Wx::DefaultPosition, Wx::DefaultSize, Wx::HL_DEFAULT_STYLE, ); my $m_staticText5 = Wx::StaticText->new( $self, -1, Wx::gettext("Preview"), ); $m_staticText5->SetFont( Wx::Font->new( Wx::NORMAL_FONT->GetPointSize, 70, 90, 92, 0, "" ) ); $self->{preview} = Padre::Wx::Editor->new( $self, -1, ); my $m_staticline2 = Wx::StaticLine->new( $self, -1, Wx::DefaultPosition, Wx::DefaultSize, Wx::LI_HORIZONTAL, ); $self->{generate_code_button} = Wx::Button->new( $self, -1, Wx::gettext("&Generate"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{generate_code_button}, sub { shift->on_generate_code_button_clicked(@_); }, ); $self->{reset_button} = Wx::Button->new( $self, -1, Wx::gettext("Rese&t"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{reset_button}, sub { shift->on_reset_button_clicked(@_); }, ); $self->{preferences_button} = Wx::Button->new( $self, -1, Wx::gettext("&Preferences"), Wx::DefaultPosition, Wx::DefaultSize, ); Wx::Event::EVT_BUTTON( $self, $self->{preferences_button}, sub { shift->on_preferences_button_clicked(@_); }, ); $self->{close_button} = Wx::Button->new( $self, Wx::ID_CANCEL, Wx::gettext("Cl&ose"), Wx::DefaultPosition, Wx::DefaultSize, ); my $left_sizer = Wx::BoxSizer->new(Wx::VERTICAL); $left_sizer->Add( $m_staticText2, 0, Wx::EXPAND | Wx::LEFT | Wx::RIGHT | Wx::TOP, 5 ); $left_sizer->Add( $self->{tree}, 1, Wx::ALL | Wx::EXPAND, 5 ); $left_sizer->Add( $m_staticText3, 0, Wx::EXPAND | Wx::LEFT | Wx::RIGHT | Wx::TOP, 5 ); $left_sizer->Add( $self->{inspector}, 0, Wx::ALL | Wx::EXPAND, 5 ); $left_sizer->Add( $self->{help}, 0, Wx::BOTTOM | Wx::EXPAND | Wx::LEFT | Wx::RIGHT, 5 ); my $container_sizer = Wx::BoxSizer->new(Wx::HORIZONTAL); $container_sizer->Add( $self->{add_class_button}, 0, Wx::ALIGN_CENTER_HORIZONTAL | Wx::ALL, 2 ); $container_sizer->Add( $self->{add_role_button}, 0, Wx::ALL, 2 ); $self->{containers}->SetSizerAndFit($container_sizer); $self->{containers}->Layout; my $members_sizer = Wx::BoxSizer->new(Wx::HORIZONTAL); $members_sizer->Add( $self->{add_attribute_button}, 0, Wx::ALL, 2 ); $members_sizer->Add( $self->{add_method_button}, 0, Wx::ALL, 2 ); $members_sizer->Add( $self->{add_subtype_button}, 0, Wx::ALL, 2 ); $members_sizer->Add( $self->{add_constructor_button}, 0, Wx::ALL, 2 ); $members_sizer->Add( $self->{add_destructor_button}, 0, Wx::ALL, 2 ); $self->{members}->SetSizerAndFit($members_sizer); $self->{members}->Layout; my $online_refs_sizer = Wx::BoxSizer->new(Wx::HORIZONTAL); $online_refs_sizer->Add( $self->{moose_manual_hyperlink}, 0, Wx::ALIGN_CENTER_VERTICAL | Wx::ALL, 5 ); $online_refs_sizer->Add( $self->{moose_cookbook_hyperlink}, 0, Wx::ALIGN_CENTER_VERTICAL | Wx::ALL, 5 ); $online_refs_sizer->Add( $self->{moose_website_hyperlink}, 0, Wx::ALIGN_CENTER_VERTICAL | Wx::ALL, 5 ); $self->{online_refs}->SetSizerAndFit($online_refs_sizer); $self->{online_refs}->Layout; $self->{palette}->AddPage( $self->{containers}, Wx::gettext("Containers"), 1 ); $self->{palette}->AddPage( $self->{members}, Wx::gettext("Members"), 0 ); $self->{palette}->AddPage( $self->{online_refs}, Wx::gettext("Online References"), 0 ); my $button_sizer = Wx::BoxSizer->new(Wx::HORIZONTAL); $button_sizer->Add( $self->{generate_code_button}, 0, Wx::ALIGN_BOTTOM | Wx::ALL, 5 ); $button_sizer->Add( $self->{reset_button}, 0, Wx::ALIGN_BOTTOM | Wx::BOTTOM | Wx::RIGHT | Wx::TOP, 5 ); $button_sizer->Add( $self->{preferences_button}, 0, Wx::ALL, 5 ); $button_sizer->Add( 0, 0, 1, Wx::EXPAND, 5 ); $button_sizer->Add( $self->{close_button}, 0, Wx::ALIGN_BOTTOM | Wx::ALL, 5 ); my $right_sizer = Wx::BoxSizer->new(Wx::VERTICAL); $right_sizer->Add( $m_staticText4, 0, Wx::EXPAND | Wx::LEFT | Wx::RIGHT | Wx::TOP, 5 ); $right_sizer->Add( $self->{palette}, 0, Wx::EXPAND | Wx::ALL, 5 ); $right_sizer->Add( $m_staticText5, 0, Wx::EXPAND | Wx::LEFT | Wx::RIGHT | Wx::TOP, 5 ); $right_sizer->Add( $self->{preview}, 1, Wx::ALL | Wx::EXPAND, 5 ); $right_sizer->Add( $m_staticline2, 0, Wx::EXPAND | Wx::LEFT | Wx::RIGHT, 5 ); $right_sizer->Add( $button_sizer, 0, Wx::EXPAND, 5 ); my $top_sizer = Wx::BoxSizer->new(Wx::HORIZONTAL); $top_sizer->Add( $left_sizer, 0, Wx::EXPAND, 5 ); $top_sizer->Add( $right_sizer, 1, Wx::EXPAND, 5 ); my $main_sizer = Wx::BoxSizer->new(Wx::VERTICAL); $main_sizer->Add( $top_sizer, 1, Wx::EXPAND, 5 ); $self->SetSizer($main_sizer); $self->Layout; return $self; } sub on_tree_key_up { $_[0]->main->error('Handler method on_tree_key_up for event tree.OnKeyUp not implemented'); } sub on_tree_item_menu { $_[0]->main->error('Handler method on_tree_item_menu for event tree.OnTreeItemMenu not implemented'); } sub on_tree_selection_change { $_[0]->main->error('Handler method on_tree_selection_change for event tree.OnTreeSelChanged not implemented'); } sub on_grid_cell_change { $_[0]->main->error('Handler method on_grid_cell_change for event inspector.OnGridCellChange not implemented'); } sub on_add_class_button { $_[0]->main->error('Handler method on_add_class_button for event add_class_button.OnButtonClick not implemented'); } sub on_add_role_button { $_[0]->main->error('Handler method on_add_role_button for event add_role_button.OnButtonClick not implemented'); } sub on_add_attribute_button { $_[0]->main->error( 'Handler method on_add_attribute_button for event add_attribute_button.OnButtonClick not implemented'); } sub on_add_method_button { $_[0]->main->error('Handler method on_add_method_button for event add_method_button.OnButtonClick not implemented'); } sub on_add_subtype_button { $_[0]->main->error( 'Handler method on_add_subtype_button for event add_subtype_button.OnButtonClick not implemented'); } sub on_add_constructor_button { $_[0]->main->error( 'Handler method on_add_constructor_button for event add_constructor_button.OnButtonClick not implemented'); } sub on_add_destructor_button { $_[0]->main->error( 'Handler method on_add_destructor_button for event add_destructor_button.OnButtonClick not implemented'); } sub on_generate_code_button_clicked { $_[0]->main->error( 'Handler method on_generate_code_button_clicked for event generate_code_button.OnButtonClick not implemented'); } sub on_reset_button_clicked { $_[0]->main->error('Handler method on_reset_button_clicked for event reset_button.OnButtonClick not implemented'); } sub on_preferences_button_clicked { $_[0]->main->error( 'Handler method on_preferences_button_clicked for event preferences_button.OnButtonClick not implemented'); } 1; # Copyright 2008-2012 The Padre development team as listed in Padre.pm. # LICENSE # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl 5 itself. Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/FBP/Preferences.pm0000644000175000017500000000673611730324234024235 0ustar azawawiazawawipackage Padre::Plugin::Moose::FBP::Preferences; ## no critic # This module was generated by Padre::Plugin::FormBuilder::Perl. # To change this module edit the original .fbp file and regenerate. # DO NOT MODIFY THIS FILE BY HAND! use 5.008005; use utf8; use strict; use warnings; use Padre::Wx (); use Padre::Wx::Role::Main (); our $VERSION = '0.21'; our @ISA = qw{ Padre::Wx::Role::Main Wx::Dialog }; sub new { my $class = shift; my $parent = shift; my $self = $class->SUPER::new( $parent, -1, Wx::gettext("Preferences"), Wx::DefaultPosition, [ 247, 204 ], Wx::DEFAULT_DIALOG_STYLE, ); my $options_labels = Wx::StaticText->new( $self, -1, Wx::gettext("Code Generation Options:"), ); $options_labels->SetFont( Wx::Font->new( Wx::NORMAL_FONT->GetPointSize, 70, 90, 92, 0, "" ) ); $self->{generated_code_label} = Wx::StaticText->new( $self, -1, Wx::gettext("Type:"), ); $self->{generated_code_combo} = Wx::ComboBox->new( $self, -1, "Moose", Wx::DefaultPosition, Wx::DefaultSize, [ "Moose", "Mouse", "MooseX::Declare", ], Wx::CB_READONLY, ); $self->{namespace_autoclean_checkbox} = Wx::CheckBox->new( $self, -1, Wx::gettext("Use namespace::autoclean?"), Wx::DefaultPosition, Wx::DefaultSize, ); $self->{comments_checkbox} = Wx::CheckBox->new( $self, -1, Wx::gettext("Generate Comments?"), Wx::DefaultPosition, Wx::DefaultSize, ); $self->{sample_code_checkbox} = Wx::CheckBox->new( $self, -1, Wx::gettext("Generate Sample code?"), Wx::DefaultPosition, Wx::DefaultSize, ); $self->{static_line} = Wx::StaticLine->new( $self, -1, Wx::DefaultPosition, Wx::DefaultSize, Wx::LI_HORIZONTAL, ); $self->{ok_button} = Wx::Button->new( $self, Wx::ID_OK, Wx::gettext("&OK"), Wx::DefaultPosition, Wx::DefaultSize, ); $self->{cancel_button} = Wx::Button->new( $self, Wx::ID_CANCEL, Wx::gettext("&Cancel"), Wx::DefaultPosition, Wx::DefaultSize, ); my $generated_code_sizer = Wx::BoxSizer->new(Wx::HORIZONTAL); $generated_code_sizer->Add( $self->{generated_code_label}, 0, Wx::ALIGN_CENTER_VERTICAL | Wx::ALL, 5 ); $generated_code_sizer->Add( $self->{generated_code_combo}, 0, Wx::ALL, 5 ); my $button_sizer = Wx::BoxSizer->new(Wx::HORIZONTAL); $button_sizer->Add( 0, 0, 1, Wx::EXPAND, 5 ); $button_sizer->Add( $self->{ok_button}, 0, Wx::ALL, 5 ); $button_sizer->Add( $self->{cancel_button}, 0, Wx::ALL, 5 ); my $sizer = Wx::BoxSizer->new(Wx::VERTICAL); $sizer->Add( $options_labels, 0, Wx::EXPAND | Wx::LEFT | Wx::RIGHT | Wx::TOP, 5 ); $sizer->Add( $generated_code_sizer, 0, Wx::EXPAND, 5 ); $sizer->Add( $self->{namespace_autoclean_checkbox}, 0, Wx::ALL, 5 ); $sizer->Add( $self->{comments_checkbox}, 0, Wx::ALIGN_CENTER_VERTICAL | Wx::ALL | Wx::EXPAND, 5 ); $sizer->Add( $self->{sample_code_checkbox}, 0, Wx::ALIGN_CENTER_VERTICAL | Wx::ALL | Wx::EXPAND, 5 ); $sizer->Add( $self->{static_line}, 0, Wx::EXPAND | Wx::ALL, 5 ); $sizer->Add( $button_sizer, 0, Wx::EXPAND, 5 ); $self->SetSizer($sizer); $self->Layout; return $self; } 1; # Copyright 2008-2012 The Padre development team as listed in Padre.pm. # LICENSE # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl 5 itself. Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Attribute.pm0000644000175000017500000001000611730324234023311 0ustar azawawiazawawipackage Padre::Plugin::Moose::Attribute; use Moose; our $VERSION = '0.21'; extends 'Padre::Plugin::Moose::ClassMember'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; with 'Padre::Plugin::Moose::Role::CanHandleInspector'; has 'access_type' => ( is => 'rw', isa => 'Str' ); has 'type' => ( is => 'rw', isa => 'Str' ); has 'trigger' => ( is => 'rw', isa => 'Str' ); has 'required' => ( is => 'rw', isa => 'Bool' ); has 'class_has' => ( is => 'rw', isa => 'Bool' ); has 'coerce' => ( is => 'rw', isa => 'Bool' ); has 'does' => ( is => 'rw', isa => 'Str' ); has 'weak_ref' => ( is => 'rw', isa => 'Bool' ); has 'lazy' => ( is => 'rw', isa => 'Bool' ); has 'builder' => ( is => 'rw', isa => 'Str' ); has 'default' => ( is => 'rw', isa => 'Str' ); has 'clearer' => ( is => 'rw', isa => 'Str' ); has 'predicate' => ( is => 'rw', isa => 'Str' ); has 'documentation' => ( is => 'rw', isa => 'Str' ); my @FIELDS = qw( name access_type type class_has required trigger coerce does weak_ref lazy builder default clearer predicate documentation); sub generate_moose_code { my $self = shift; my $options = shift; my $comment = $options->{comments}; my $has_code = ''; $has_code .= ( "\tis => '" . $self->access_type . "',\n" ) if defined $self->access_type && $self->access_type ne ''; $has_code .= ( "\tisa => '" . $self->type . "',\n" ) if defined $self->type && $self->type ne ''; $has_code .= ("\trequired => 1,\n") if $self->required; $has_code .= ( "\ttrigger => " . $self->trigger . ",\n" ) if defined $self->trigger && $self->trigger ne ''; my $has = ( $self->class_has ) ? 'class_has' : 'has'; return "$has '" . $self->name . "'" . ( $has_code ne '' ? qq{ => (\n$has_code)} : q{} ) . ";\n"; } # Generate Mouse code! sub generate_mouse_code { my $self = shift; my $options = shift; my $comment = $options->{comments}; my $has_code = ''; $has_code .= ( "\tis => '" . $self->access_type . "',\n" ) if defined $self->access_type && $self->access_type ne ''; $has_code .= ( "\tisa => '" . $self->type . "',\n" ) if defined $self->type && $self->type ne ''; $has_code .= ("\trequired => 1,\n") if $self->required; $has_code .= ( "\ttrigger => " . $self->trigger . ",\n" ) if defined $self->trigger && $self->trigger ne ''; return "has '" . $self->name . "'" . ( $has_code ne '' ? qq{ => (\n$has_code)} : q{} ) . ";\n"; } sub generate_moosex_declare_code { return $_[0]->generate_moose_code(@_); } sub provide_help { require Wx; return Wx::gettext('An attribute is a property that every member of a class has.'); } sub read_from_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (@FIELDS) { $self->$field( $grid->GetCellValue( $row++, 1 ) ); } } sub write_to_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (@FIELDS) { $grid->SetCellValue( $row++, 1, $self->$field ); } } sub get_grid_data { require Wx; return [ { name => Wx::gettext('Name:') }, { name => Wx::gettext('Access type:'), choices => [qw(rw ro bare)] }, { name => Wx::gettext('Type:'), choices => [ qw(Any Item Bool Maybe[] Undef Defined Value Str Num Int ClassName RoleName Ref ScalarRef[] ArrayRef[] HashRef[] CodeRef RegexpRef GlobRef FileHandle Object) ] }, { name => Wx::gettext('Class Attribute?'), is_bool => 1 }, { name => Wx::gettext('Required?'), is_bool => 1 }, { name => Wx::gettext('Trigger:') }, { name => Wx::gettext('Coerce?'), is_bool => 1 }, { name => Wx::gettext('Does role:') }, { name => Wx::gettext('Weak Ref?'), is_bool => 1 }, { name => Wx::gettext('lazy?'), is_bool => 1 }, { name => Wx::gettext('Builder:') }, { name => Wx::gettext('Default:') }, { name => Wx::gettext('Clearer:') }, { name => Wx::gettext('Predicate:') }, { name => Wx::gettext('Documentation:') }, ]; } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Role/0000755000175000017500000000000011730337050021714 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Role/CanGenerateCode.pm0000644000175000017500000000127711730324234025230 0ustar azawawiazawawipackage Padre::Plugin::Moose::Role::CanGenerateCode; use Moose::Role; our $VERSION = '0.21'; sub generate_code { my $self = shift; my $options = shift; my $type = $options->{type}; return $self->generate_moose_code($options) if $type eq 'Moose'; return $self->generate_mouse_code($options) if $type eq 'Mouse'; return $self->generate_moosex_declare_code($options) if $type eq 'MooseX::Declare'; } requires 'generate_moose_code'; requires 'generate_mouse_code'; requires 'generate_moosex_declare_code'; no Moose::Role; 1; __END__ =pod =head1 NAME Padre::Plugin::Moose::Role::CanGenerateCode - Something that can generate Moose, Mouse or MooseX::Declare code =cut Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Role/NeedsPluginEvent.pm0000644000175000017500000000114711727342643025506 0ustar azawawiazawawipackage Padre::Plugin::Moose::Role::NeedsPluginEvent; use Moose::Role; requires 'on_save_as'; requires 'new_document_from_string'; sub fire_plugin_event { my $orig = shift; my $self = shift; # Save the return value my $result = $self->$orig(@_); # Fire event that Padre does not implement at the moment $self->{ide}->plugin_manager->plugin_event('editor_changed'); # And return the original result return $result; } # Hook up to new_document_from_string around 'new_document_from_string' => \&fire_plugin_event; # Hook up to on_save_as around 'on_save_as' => \&fire_plugin_event; no Moose::Role; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Role/CanProvideHelp.pm0000644000175000017500000000041111730324234025111 0ustar azawawiazawawipackage Padre::Plugin::Moose::Role::CanProvideHelp; use Moose::Role; our $VERSION = '0.21'; requires 'provide_help'; no Moose::Role; 1; __END__ =pod =head1 NAME Padre::Plugin::Moose::Role::CanProvideHelp - Something that can provide help about itself =cut Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Role/CanHandleInspector.pm0000644000175000017500000000054311730324234025760 0ustar azawawiazawawipackage Padre::Plugin::Moose::Role::CanHandleInspector; use Moose::Role; our $VERSION = '0.21'; requires 'read_from_inspector'; requires 'write_to_inspector'; requires 'get_grid_data'; no Moose::Role; 1; __END__ =pod =head1 NAME Padre::Plugin::Moose::Role::CanHandleInspector - Something that can read from and write to the object inspector =cut Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Role/HasClassMembers.pm0000644000175000017500000000207211730324234025267 0ustar azawawiazawawipackage Padre::Plugin::Moose::Role::HasClassMembers; use Moose::Role; our $VERSION = '0.21'; has 'attributes' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); has 'subtypes' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); has 'methods' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); sub to_class_members_code { my $self = shift; my $options = shift; my $code = ''; # Generate attributes $code .= "\n" if scalar @{ $self->attributes }; for my $attribute ( @{ $self->attributes } ) { $code .= $attribute->generate_code($options); } # Generate subtypes $code .= "\n" if scalar @{ $self->subtypes }; for my $subtype ( @{ $self->subtypes } ) { $code .= $subtype->generate_code($options); } # Generate methods $code .= "\n" if scalar @{ $self->methods }; for my $method ( @{ $self->methods } ) { $code .= $method->generate_code($options); } return $code; } no Moose::Role; 1; __END__ =pod =head1 NAME Padre::Plugin::Moose::Role::HasClassMembers - Something that has attributes, subtypes and methods =cut Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Assistant.pm0000644000175000017500000003536111730324234023332 0ustar azawawiazawawipackage Padre::Plugin::Moose::Assistant; use 5.008; use Moose; use Padre::Wx::Role::Dialog (); use Padre::Plugin::Moose::FBP::Assistant (); our $VERSION = '0.21'; our @ISA = qw{ Padre::Wx::Role::Dialog Padre::Plugin::Moose::FBP::Assistant }; sub new { my $class = shift; my $plugin = shift; my $self = $class->SUPER::new( $plugin->main ); # Store the plugin object for future usage $self->{plugin} = $plugin; # Center & title $self->CenterOnParent; $self->SetTitle( sprintf( Wx::gettext('Moose Assistant %s - Written for fun by Ahmad M. Zawawi (azawawi)'), $VERSION ) ); # Restore defaults $self->restore_defaults; # TODO Bug Alias to fix the wxFormBuilder bug regarding this one $self->{inspector}->SetRowLabelSize(0); # Hide the inspector as needed $self->show_inspector(undef); # Setup preview editor my $preview = $self->{preview}; require Padre::Document; $preview->{Document} = Padre::Document->new( mimetype => 'application/x-perl', ); $preview->{Document}->set_editor($preview); $preview->SetLexer('application/x-perl'); # Syntax highlight Moose keywords require Padre::Plugin::Moose::Util; Padre::Plugin::Moose::Util::add_moose_keywords_highlighting( $plugin->{config}->{type}, $preview->{Document}, $preview ); $preview->Show(1); $self->show_code_in_preview(1); return $self; } # This is called to start and show the dialog sub run { my $self = shift; # Apply the current theme to the preview editor my $style = $self->main->config->editor_style; my $theme = Padre::Wx::Theme->find($style)->clone; $theme->apply( $self->{preview} ); $self->ShowModal; } # Set up the events sub on_grid_cell_change { my $self = shift; my $element = $self->{current_element} or return; if ( $element->does('Padre::Plugin::Moose::Role::CanHandleInspector') ) { $element->read_from_inspector( $self->{inspector} ); } $self->show_code_in_preview(0); return; } sub on_tree_selection_change { my $self = shift; my $event = shift; my $tree = $self->{tree}; my $item = $event->GetItem or return; my $element = $tree->GetPlData($item) or return; my $is_parent = $element->does('Padre::Plugin::Moose::Role::HasClassMembers'); my $is_program = $element->isa('Padre::Plugin::Moose::Program'); # Show/Hide the inspector as needed $self->show_inspector( $is_program ? undef : $element ); # Display help about the current element $self->{help}->SetValue( $element->provide_help ); $self->{current_element} = $element; # Find parent element if ( $element->does('Padre::Plugin::Moose::Role::ClassMember') ) { $self->{current_parent} = $tree->GetPlData( $tree->GetItemParent($item) ); } else { $self->{current_parent} = $element if $is_parent; } $self->Layout; # TODO improve the crude workaround to positioning unless ($is_program) { my $preview = $self->{preview}; my $line_num = 0; for my $line ( split /\n/, $preview->GetText ) { my $name = quotemeta $element->name; if ( $line =~ /$name/ ) { my $position = $preview->PositionFromLine($line_num); $preview->SetCurrentPos($position); $preview->SetAnchor($position); $preview->ScrollToLine($line_num); last; } $line_num++; } } return; } sub show_code_in_preview { my $self = shift; my $should_select_item = shift; eval { # Generate code my $config = $self->{plugin}->{config}; my $code = $self->{program}->generate_code( { type => $config->{type}, comments => $config->{comments}, sample_code => $config->{sample_code}, namespace_autoclean => $config->{namespace_autoclean}, } ); # And show it in preview editor my $preview = $self->{preview}; $preview->SetReadOnly(0); $preview->SetText($code); $preview->SetReadOnly(1); # Update tree $self->update_tree($should_select_item); }; if ($@) { $self->error( sprintf( Wx::gettext('Error:%s'), $@ ) ); } return; } sub update_tree { my $self = shift; my $should_select_item = shift; my $tree = $self->{tree}; my $lock = $self->lock_update($tree); $tree->DeleteAllItems; my $selected_item; my $program = $self->{program}; my $program_node = $tree->AddRoot( Wx::gettext('Program'), -1, -1, Wx::TreeItemData->new($program) ); if ( $program eq $self->{current_element} ) { $selected_item = $program_node; } for my $class ( @{ $program->roles }, @{ $program->classes } ) { my $class_node = $tree->AppendItem( $program_node, $class->name, -1, -1, Wx::TreeItemData->new($class) ); for my $class_item ( @{ $class->attributes }, @{ $class->subtypes }, @{ $class->methods } ) { my $class_item_node = $tree->AppendItem( $class_node, $class_item->name, -1, -1, Wx::TreeItemData->new($class_item) ); if ( $class_item == $self->{current_element} ) { $selected_item = $class_item_node; } } if ( $class == $self->{current_element} ) { $selected_item = $class_node; } $tree->Expand($class_node); } $tree->ExpandAll; # Select the tree node outside this event to # prevent deep recurision if ( $should_select_item and defined $selected_item ) { Wx::Event::EVT_IDLE( $self, sub { $tree->SelectItem($selected_item); Wx::Event::EVT_IDLE( $self, undef ); } ); } return; } sub show_inspector { my $self = shift; my $element = shift; my $inspector = $self->{inspector}; my $lock = $self->lock_update($inspector); $inspector->DeleteRows( 0, $inspector->GetNumberRows ); unless ( defined $element ) { return; } my $type = blessed($element); unless ( defined $type and $type =~ /(Class|Role|Attribute|Subtype|Method|Constructor|Destructor)$/ ) { $self->error("type: $element is not Class, Role, Attribute, Subtype or Method\n"); return; } my $data = $element->get_grid_data; $inspector->InsertRows( 0, scalar @$data ); $inspector->SetGridCursor( 0, 1 ); foreach my $i ( 0 .. $#$data ) { my $row = $data->[$i]; $inspector->SetCellValue( $i, 0, $row->{name} ); $inspector->SetReadOnly( $i, 0 ); if ( defined $row->{is_bool} ) { $inspector->SetCellEditor( $i, 1, Wx::GridCellBoolEditor->new ); $inspector->SetCellValue( $i, 1, 1 ); } elsif ( defined $row->{choices} ) { $inspector->SetCellEditor( $i, 1, Wx::GridCellChoiceEditor->new( $row->{choices}, 1 ) ); } } if ( $element->does('Padre::Plugin::Moose::Role::CanHandleInspector') ) { $element->write_to_inspector($inspector); } return; } sub on_add_class_button { my $self = shift; # Add a new class object to program require Padre::Plugin::Moose::Class; my $class = Padre::Plugin::Moose::Class->new; $class->name( "Class" . $self->{class_count}++ ); $class->immutable(1); push @{ $self->{program}->classes }, $class; $self->{current_element} = $class; $self->show_inspector($class); $self->show_code_in_preview(1); return; } sub on_add_role_button { my $self = shift; # Add a new role object to program require Padre::Plugin::Moose::Role; my $role = Padre::Plugin::Moose::Role->new; $role->name( "Role" . $self->{role_count}++ ); push @{ $self->{program}->roles }, $role; $self->{current_element} = $role; $self->show_inspector($role); $self->show_code_in_preview(1); return; } sub on_add_attribute_button { my $self = shift; # Only allowed within a class/role element unless ( defined $self->{current_element} && defined $self->{current_parent} && $self->{current_parent}->does('Padre::Plugin::Moose::Role::HasClassMembers') ) { $self->error( Wx::gettext('You can only add an attribute to a class or role') ); $self->{palette}->SetSelection(0); return; } # Add a new attribute object to class require Padre::Plugin::Moose::Attribute; my $attribute = Padre::Plugin::Moose::Attribute->new; $attribute->name( 'attribute' . $self->{attribute_count}++ ); push @{ $self->{current_parent}->attributes }, $attribute; $self->{current_element} = $attribute; $self->show_inspector($attribute); $self->show_code_in_preview(1); return; } sub on_add_subtype_button { my $self = shift; # Only allowed within a class/role element unless ( defined $self->{current_element} && defined $self->{current_parent} && $self->{current_parent}->does('Padre::Plugin::Moose::Role::HasClassMembers') ) { $self->error( Wx::gettext('You can only add a subtype to a class or role') ); $self->{palette}->SetSelection(0); return; } # Add a new subtype object to class require Padre::Plugin::Moose::Subtype; my $subtype = Padre::Plugin::Moose::Subtype->new; $subtype->name( 'Subtype' . $self->{subtype_count}++ ); push @{ $self->{current_parent}->subtypes }, $subtype; $self->{current_element} = $subtype; $self->show_inspector($subtype); $self->show_code_in_preview(1); return; } sub on_add_method_button { my $self = shift; # Only allowed within a class/role element unless ( defined $self->{current_element} && defined $self->{current_parent} && $self->{current_parent}->does('Padre::Plugin::Moose::Role::HasClassMembers') ) { $self->error( Wx::gettext('You can only add a method to a class or role') ); $self->{palette}->SetSelection(0); return; } # Add a new method object to class require Padre::Plugin::Moose::Method; my $method = Padre::Plugin::Moose::Method->new; $method->name( 'method_' . $self->{method_count}++ ); push @{ $self->{current_parent}->methods }, $method; $self->{current_element} = $method; $self->show_inspector($method); $self->show_code_in_preview(1); return; } sub on_add_constructor_button { my $self = shift; # Only allowed within a class/role element unless ( defined $self->{current_element} && defined $self->{current_parent} && $self->{current_parent}->does('Padre::Plugin::Moose::Role::HasClassMembers') ) { $self->error( Wx::gettext('You can only add a constructor to a class or role') ); $self->{palette}->SetSelection(0); return; } # Add a new constructor object to class/role require Padre::Plugin::Moose::Constructor; my $constructor = Padre::Plugin::Moose::Constructor->new; $constructor->name('BUILD'); push @{ $self->{current_parent}->methods }, $constructor; $self->{current_element} = $constructor; $self->show_inspector($constructor); $self->show_code_in_preview(1); return; } sub on_add_destructor_button { my $self = shift; # Only allowed within a class/role element unless ( defined $self->{current_element} && defined $self->{current_parent} && $self->{current_parent}->does('Padre::Plugin::Moose::Role::HasClassMembers') ) { $self->error( Wx::gettext('You can only add a destructor to a class or role') ); $self->{palette}->SetSelection(0); return; } # Add a new destructor object to class/role require Padre::Plugin::Moose::Destructor; my $destructor = Padre::Plugin::Moose::Destructor->new; $destructor->name('DEMOLISH'); push @{ $self->{current_parent}->methods }, $destructor; $self->{current_element} = $destructor; $self->show_inspector($destructor); $self->show_code_in_preview(1); return; } sub on_reset_button_clicked { my $self = shift; if ( $self->yes_no( Wx::gettext('Do you really want to reset?') ) ) { $self->restore_defaults; $self->show_code_in_preview(1); } return; } sub on_generate_code_button_clicked { my $self = shift; Wx::Event::EVT_IDLE( $self, sub { $self->main->new_document_from_string( $self->{preview}->GetText => 'application/x-perl', ); Wx::Event::EVT_IDLE( $self, undef ); } ); $self->EndModal(Wx::ID_OK); return; } sub restore_defaults { my $self = shift; $self->{class_count} = 1; $self->{role_count} = 1; $self->{attribute_count} = 1; $self->{subtype_count} = 1; $self->{method_count} = 1; require Padre::Plugin::Moose::Program; $self->{program} = Padre::Plugin::Moose::Program->new; $self->{current_element} = $self->{program}; $self->{current_parent} = $self->{program}; return; } # Called when a item context menu is requested. sub on_tree_item_menu { my $self = shift; my $event = shift; my $item = $event->GetItem; my $tree = $self->{tree}; my $element = $tree->GetPlData($item) or return; return if $element->isa('Padre::Plugin::Moose::Program'); # Generate the context menu for this element my $menu = Wx::Menu->new; Wx::Event::EVT_MENU( $self, $menu->Append( -1, Wx::gettext('Delete') ), sub { $self->delete_element($element); } ); # Pops up the context menu $tree->PopupMenu( $menu, $event->GetPoint->x, $event->GetPoint->y, ); return; } sub on_tree_key_up { my $self = shift; my $event = shift; my $mod = $event->GetModifiers || 0; # see Padre::Wx::Main::key_up $mod = $mod & ( Wx::MOD_ALT + Wx::MOD_CMD + Wx::MOD_SHIFT ); my $tree = $self->{tree}; my $item_id = $tree->GetSelection; my $element = $tree->GetPlData($item_id) or return; if ( $event->GetKeyCode == Wx::K_DELETE ) { $self->delete_element($element); } $event->Skip; return; } sub delete_element { my $self = shift; my $element = shift or return; if ( $self->yes_no( sprintf( Wx::gettext('Do you want to delete %s?'), $element->name ) ) ) { #TODO do the actual item deletion } return; } sub on_preferences_button_clicked { my $self = shift; # Create a new preferences dialog require Padre::Plugin::Moose::Preferences; my $prefs = Padre::Plugin::Moose::Preferences->new($self); # Update plugin variables from plugin's configuration hash my $plugin = $self->{plugin}; my $config = $plugin->{config}; $prefs->{generated_code_combo}->SetValue( $config->{type} ); $prefs->{comments_checkbox}->SetValue( $config->{comments} ); $prefs->{sample_code_checkbox}->SetValue( $config->{sample_code} ); $prefs->{namespace_autoclean_checkbox}->SetValue( $config->{namespace_autoclean} ); # Preferences: go modal! if ( $prefs->ShowModal == Wx::wxID_OK ) { # Update configuration when the user hits the OK button my $type = $prefs->{generated_code_combo}->GetValue; $config->{type} = $type; $config->{comments} = $prefs->{comments_checkbox}->IsChecked; $config->{sample_code} = $prefs->{sample_code_checkbox}->IsChecked; $config->{namespace_autoclean} = $prefs->{namespace_autoclean_checkbox}->IsChecked; $plugin->config_write($config); # Update tree and preview editor $self->show_code_in_preview(1); # Add moose et all keywords highlight to preview editor require Padre::Plugin::Moose::Util; Padre::Plugin::Moose::Util::add_moose_keywords_highlighting( $self->{preview}->{Document}, $type ); # Add moose et all keywords highlight to current editor my $doc = $self->current->document or return; if ( $doc->isa('Padre::Plugin::Moose::Document') ) { Padre::Plugin::Moose::Util::add_moose_keywords_highlighting( $doc, $type ); } } return; } 1; # Copyright 2008-2012 The Padre development team as listed in Padre.pm. # LICENSE # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl 5 itself. Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Preferences.pm0000644000175000017500000000101711730324234023611 0ustar azawawiazawawipackage Padre::Plugin::Moose::Preferences; use 5.008; use Padre::Plugin::Moose::FBP::Preferences (); our $VERSION = '0.21'; our @ISA = qw{ Padre::Plugin::Moose::FBP::Preferences }; sub new { my $class = shift; my $parent = shift; my $self = $class->SUPER::new($parent); $self->CenterOnParent; return $self; } 1; # Copyright 2008-2012 The Padre development team as listed in Padre.pm. # LICENSE # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl 5 itself. Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Method.pm0000644000175000017500000000503311730324234022572 0ustar azawawiazawawipackage Padre::Plugin::Moose::Method; use Moose; our $VERSION = '0.21'; extends 'Padre::Plugin::Moose::ClassMember'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; with 'Padre::Plugin::Moose::Role::CanHandleInspector'; has 'modifier' => ( is => 'rw', isa => 'Str' ); sub generate_moose_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $code; my $name = $self->name; my $modifier = $self->modifier; if ( defined $modifier && $modifier eq 'around' ) { $code = "around '$name' => sub {\n"; $code .= "\tmy \$orig = shift;\n"; $code .= "\tmy \$self = shift;\n"; $code .= "\n"; $code .= "\t# before calling $name\n" if $comments; $code .= "\t\$self->\$orig(\@_)\n"; $code .= "\t# after calling $name\n" if $comments; $code .= "};\n"; } elsif ( defined $modifier && $modifier =~ /^(before|after)$/ ) { $code = $self->modifier . " '$name' => sub {\n\tmy \$self = shift;\n};\n"; } else { $code = "sub $name {\n\tmy \$self = shift;\n}\n"; } return $code; } # Generate Mouse code! sub generate_mouse_code { return $_[0]->generate_moose_code(@_); } sub generate_moosex_declare_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $code; my $name = $self->name; my $modifier = $self->modifier; if ( defined $modifier && $modifier eq 'around' ) { $code = "around $name {\n"; $code .= "\n"; $code .= "\t# before calling $name\n" if $comments; $code .= "\t\$self->\$orig(\@_)\n"; $code .= "\t# after calling $name\n" if $comments; $code .= "};\n"; } elsif ( defined $modifier && $modifier =~ /^(before|after)$/ ) { $code = $self->modifier . " $name {\n};\n"; } else { $code = "method $name {\n" . ( $comments ? "\t# \$self is predeclared by MooseX::Declare" : q{} ) . "\n}\n"; } return $code; } sub provide_help { require Wx; return Wx::gettext('A method is a subroutine within a class that defines behavior at runtime'); } sub read_from_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name modifier)) { $self->$field( $grid->GetCellValue( $row++, 1 ) ); } } sub write_to_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name modifier)) { $grid->SetCellValue( $row++, 1, $self->$field ); } } sub get_grid_data { require Wx; return [ { name => Wx::gettext('Name:') }, { name => Wx::gettext('Modifier:'), choices => [qw(around after before)] }, ]; } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Constructor.pm0000644000175000017500000000506711730324234023706 0ustar azawawiazawawipackage Padre::Plugin::Moose::Constructor; use Moose; our $VERSION = '0.21'; extends 'Padre::Plugin::Moose::ClassMember'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; with 'Padre::Plugin::Moose::Role::CanHandleInspector'; has 'modifier' => ( is => 'rw', isa => 'Str' ); sub generate_moose_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $code; my $name = $self->name; my $modifier = $self->modifier; if ( defined $modifier && $modifier eq 'around' ) { $code = "around '$name' => sub {\n"; $code .= "\tmy \$orig = shift;\n"; $code .= "\tmy \$self = shift;\n"; $code .= "\n"; $code .= "\t# before calling $name\n" if $comments; $code .= "\t\$self->\$orig(\@_)\n"; $code .= "\t# after calling $name\n" if $comments; $code .= "};\n"; } elsif ( defined $modifier && $modifier =~ /^(before|after)$/ ) { $code = $self->modifier . " '$name' => sub {\n\tmy \$self = shift;\n};\n"; } else { $code = "sub $name {\n\tmy \$self = shift;\n}\n"; } return $code; } # Generate Mouse code! sub generate_mouse_code { return $_[0]->generate_moose_code(@_); } sub generate_moosex_declare_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $code; my $name = $self->name; my $modifier = $self->modifier; if ( defined $modifier && $modifier eq 'around' ) { $code = "around $name {\n"; $code .= "\n"; $code .= "\t# before calling $name\n" if $comments; $code .= "\t\$self->\$orig(\@_)\n"; $code .= "\t# after calling $name\n" if $comments; $code .= "};\n"; } elsif ( defined $modifier && $modifier =~ /^(before|after)$/ ) { $code = $self->modifier . " '$name' => sub {\n\tmy \$self = shift;\n};\n"; } else { $code = "method $name {\n" . ( $comments ? "\t# \$self is predeclared by MooseX::Declare" : q{} ) . "\n}\n"; } return $code; } sub provide_help { require Wx; return Wx::gettext('A special type of subroutine called at the creation of an object'); } sub read_from_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name modifier)) { $self->$field( $grid->GetCellValue( $row++, 1 ) ); } } sub write_to_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name modifier)) { $grid->SetCellValue( $row++, 1, $self->$field ); } } sub get_grid_data { require Wx; return [ { name => Wx::gettext('Name:') }, { name => Wx::gettext('Modifier:'), choices => [qw(around after before)] }, ]; } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Role.pm0000644000175000017500000001033311730324234022252 0ustar azawawiazawawipackage Padre::Plugin::Moose::Role; use Moose; our $VERSION = '0.21'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::HasClassMembers'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; with 'Padre::Plugin::Moose::Role::CanHandleInspector'; has 'name' => ( is => 'rw', isa => 'Str' ); has 'requires_list' => ( is => 'rw', isa => 'Str', default => '' ); sub generate_moose_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $namespace_autoclean = $options->{namespace_autoclean}; my $role = $self->name; my $requires = $self->requires_list; $role =~ s/^\s+|\s+$//g; $requires =~ s/^\s+|\s+$//g; my @requires = split /,/, $requires; my $code = "package $role;\n"; $code .= "\nuse Moose::Role;\n"; if ($namespace_autoclean) { $code .= "use namespace::clean;"; $code .= $comments ? " # Keep imports out of your namespace\n" : "\n"; } # If there is at least one subtype, we need to add this import if ( scalar @{ $self->subtypes } ) { $code .= "use Moose::Util::TypeConstraints;\n"; } $code .= "\n" if scalar @requires; for my $require (@requires) { $code .= "requires '$require';\n"; } # Generate class members $code .= $self->to_class_members_code($options); if ( scalar @{ $self->subtypes } ) { $code .= "\nno Moose::Util::TypeConstraints;\n"; } if ($namespace_autoclean) { $code .= "\n1;\n\n"; } else { if ( scalar @{ $self->subtypes } ) { $code .= "\nno Moose::Util::TypeConstraints;\n"; } $code .= "\nno Moose::Role;\n1;\n\n"; } return $code; } # Generate Mouse code! sub generate_mouse_code { my $self = shift; my $options = shift; my $namespace_autoclean = $options->{namespace_autoclean}; my $role = $self->name; my $requires = $self->requires_list; $role =~ s/^\s+|\s+$//g; $requires =~ s/^\s+|\s+$//g; my @requires = split /,/, $requires; my $code = "package $role;\n"; $code .= "\nuse Mouse::Role;\n"; if ($namespace_autoclean) { $code .= "use namespace::clean;\n"; } # If there is at least one subtype, we need to add this import if ( scalar @{ $self->subtypes } ) { $code .= "use Mouse::Util::TypeConstraints;\n"; } $code .= "\n" if scalar @requires; for my $require (@requires) { $code .= "requires '$require';\n"; } # Generate class members $code .= $self->to_class_members_code($options); if ($namespace_autoclean) { $code .= "\n1;\n\n"; } else { if ( scalar @{ $self->subtypes } ) { $code .= "\nno Moose::Util::TypeConstraints;\n"; } $code .= "\nno Mouse::Role;\n1;\n\n"; } return $code; } sub generate_moosex_declare_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $role = $self->name; my $requires = $self->requires_list; $role =~ s/^\s+|\s+$//g; $requires =~ s/^\s+|\s+$//g; my @requires = split /,/, $requires; my $role_body = ''; # If there is at least one subtype, we need to add this import if ( scalar @{ $self->subtypes } ) { $role_body .= "use Mouse::Util::TypeConstraints;\n"; } $role_body .= "\n" if scalar @requires; for my $require (@requires) { $role_body .= "requires '$require';\n"; } # Generate class members $role_body .= $self->to_class_members_code($options); my @lines = split /\n/, $role_body; for my $line (@lines) { $line = "\t$line" if $line ne ''; } $role_body = join "\n", @lines; # namespace::autoclean is implicit in { } return "use MooseX::Declare;\nrole $role {\n$role_body\n}\n\n"; } sub provide_help { require Wx; return Wx::gettext('A role provides some piece of behavior or state that can be shared between classes.'); } sub read_from_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name requires_list)) { $self->$field( $grid->GetCellValue( $row++, 1 ) ); } } sub write_to_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name requires_list)) { $grid->SetCellValue( $row++, 1, $self->$field ); } } sub get_grid_data { require Wx; return [ { name => Wx::gettext('Name:') }, { name => Wx::gettext('Requires:') }, ]; } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Class.pm0000644000175000017500000001427211730324234022424 0ustar azawawiazawawipackage Padre::Plugin::Moose::Class; use Moose; our $VERSION = '0.21'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::HasClassMembers'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; with 'Padre::Plugin::Moose::Role::CanHandleInspector'; has 'name' => ( is => 'rw', isa => 'Str', default => '' ); has 'superclasses' => ( is => 'rw', isa => 'Str', default => '' ); has 'roles' => ( is => 'rw', isa => 'Str', default => '' ); has 'immutable' => ( is => 'rw', isa => 'Bool' ); has 'namespace_autoclean' => ( is => 'rw', isa => 'Bool' ); has 'singleton' => ( is => 'rw', isa => 'Bool' ); sub generate_moose_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $namespace_autoclean = $options->{namespace_autoclean}; my $class = $self->name; my $superclasses = $self->superclasses; my $roles = $self->roles; my $make_immutable = $self->immutable; $class =~ s/^\s+|\s+$//g; $superclasses =~ s/^\s+|\s+$//g; $roles =~ s/^\s+|\s+$//g; my @roles = split /,/, $roles; my $code = "package $class;\n"; $code .= "\nuse Moose;"; $code .= $comments ? " # automatically turns on strict and warnings\n" : "\n"; if ($namespace_autoclean) { $code .= "use namespace::clean;"; $code .= $comments ? " # Keep imports out of your namespace\n" : "\n"; } # If there is at least one subtype, we need to add this import if ( scalar @{ $self->subtypes } ) { $code .= "use Moose::Util::TypeConstraints;\n"; } # Singleton via MooseX::Singleton $code .= "use MooseX::Singleton;\n" if $self->singleton; # Class attributes via MooseX::ClassAttribute for my $attribute ( @{ $self->attributes } ) { if ( $attribute->class_has ) { $code .= "use MooseX::ClassAttribute;\n" if $attribute->class_has; last; } } $code .= "\nextends '$superclasses';\n" if $superclasses ne ''; $code .= "\n" if scalar @roles; for my $role (@roles) { $code .= "with '$role';\n"; } # Generate class members $code .= $self->to_class_members_code($options); if ($make_immutable) { $code .= "\n__PACKAGE__->meta->make_immutable;"; $code .= $comments ? " # Makes it faster at the cost of startup time\n" : "\n"; } if ($namespace_autoclean) { $code .= "\n1;\n\n"; } else { if ( scalar @{ $self->subtypes } ) { $code .= "\nno Moose::Util::TypeConstraints;\n"; } $code .= "\nno Moose;\n1;\n\n"; } return $code; } # Generate Mouse code! sub generate_mouse_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $namespace_autoclean = $options->{namespace_autoclean}; my $class = $self->name; my $superclasses = $self->superclasses; my $roles = $self->roles; my $make_immutable = $self->immutable; $class =~ s/^\s+|\s+$//g; $superclasses =~ s/^\s+|\s+$//g; $roles =~ s/^\s+|\s+$//g; my @roles = split /,/, $roles; my $code = "package $class;\n"; $code .= "\nuse Mouse;"; $code .= $comments ? " # automatically turns on strict and warnings\n" : "\n"; if ($namespace_autoclean) { $code .= "use namespace::clean;"; $code .= $comments ? " # Keep imports out of your namespace\n" : "\n"; } # If there is at least one subtype, we need to add this import if ( scalar @{ $self->subtypes } ) { $code .= "use Mouse::Util::TypeConstraints;\n"; } $code .= "\nextends '$superclasses';\n" if $superclasses ne ''; $code .= "\n" if scalar @roles; for my $role (@roles) { $code .= "with '$role';\n"; } # Generate class members $code .= $self->to_class_members_code($options); if ($make_immutable) { $code .= "\n__PACKAGE__->meta->make_immutable;"; $code .= $comments ? " # Makes it faster at the cost of startup time\n" : "\n"; } if ($namespace_autoclean) { $code .= "\n1;\n\n"; } else { if ( scalar @{ $self->subtypes } ) { $code .= "\nno Mouse::Util::TypeConstraints;\n"; } $code .= "\nno Mouse;\n1;\n\n"; } return $code; } sub generate_moosex_declare_code { my $self = shift; my $options = shift; my $comments = $options->{comments}; my $class = $self->name; my $superclasses = $self->superclasses; my $roles = $self->roles; my $make_immutable = $self->immutable; $class =~ s/^\s+|\s+$//g; $superclasses =~ s/^\s+|\s+$//g; $roles =~ s/^\s+|\s+$//g; my @roles = split /,/, $roles; my $class_body = ''; # If there is at least one subtype, we need to add this import if ( scalar @{ $self->subtypes } ) { $class_body .= "use Moose::Util::TypeConstraints;\n"; } # Generate class members $class_body .= $self->to_class_members_code($options); my @lines = split /\n/, $class_body; for my $line (@lines) { $line = "\t$line" if $line ne ''; } $class_body = join "\n", @lines; my $extends = ( $superclasses ne '' ) ? "extends ($superclasses) " : q{}; my $with = ( scalar @roles ) ? "with ($roles) " : q{}; my $mutable = $make_immutable ? q{} : "is mutable "; # namespace::autoclean is implicit in { } return "use MooseX::Declare;\nclass $class $extends$with$mutable\{\n$class_body\n}\n"; } sub provide_help { require Wx; return Wx::gettext( ' A class is a blueprint of how to create objects of itself. A class can contain attributes, subtypes and methods which enable objects to have state and behavior.' ); } sub read_from_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name superclasses roles immutable singleton)) { $self->$field( $grid->GetCellValue( $row++, 1 ) ); } } sub write_to_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name superclasses roles immutable singleton)) { $grid->SetCellValue( $row++, 1, $self->$field ); } } sub get_grid_data { require Wx; return [ { name => Wx::gettext('Name:') }, { name => Wx::gettext('Superclasses:') }, { name => Wx::gettext('Roles:') }, { name => Wx::gettext('Make immutable?'), is_bool => 1 }, { name => Wx::gettext('Singleton?'), is_bool => 1 }, ]; } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Util.pm0000644000175000017500000000150711730324234022271 0ustar azawawiazawawipackage Padre::Plugin::Moose::Util; use 5.008; use strict; use warnings; our $VERSION = '0.21'; sub add_moose_keywords_highlighting { my $type = shift or return; my $document = shift or return; my $editor = shift or return; my $keywords = Padre::Wx::Scintilla->keywords($document); if ( Params::Util::_ARRAY($keywords) ) { foreach my $i ( 0 .. $#$keywords ) { my $keyword_list = $keywords->[$i]; if ( $i == 0 ) { $keyword_list .= ' has with extends before around after' . ' override super augment inner type subtype' . ' enum class_type as where coerce via from' . ' requires excludes'; if ( $type eq 'MooseX::Declare' ) { $keyword_list .= ' class role method dirty clean mutable'; } } $editor->Wx::Scintilla::TextCtrl::SetKeyWords( $i, $keyword_list ); } } return; } Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Subtype.pm0000644000175000017500000000420511730324234023005 0ustar azawawiazawawipackage Padre::Plugin::Moose::Subtype; use Moose; our $VERSION = '0.21'; extends 'Padre::Plugin::Moose::ClassMember'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; with 'Padre::Plugin::Moose::Role::CanHandleInspector'; has 'base_type' => ( is => 'rw', isa => 'Str', default => '' ); has 'constraint' => ( is => 'rw', isa => 'Str', default => '' ); has 'error_message' => ( is => 'rw', isa => 'Str', default => '' ); sub generate_moose_code { my $self = shift; my $code = "subtype '" . $self->name . "'"; $code .= ",\n\tas '" . $self->base_type . "'" if defined $self->base_type && $self->base_type ne ''; $code .= ",\n\twhere { " . $self->constraint . " }" if ( defined $self->constraint && $self->constraint ne '' ) and $self->constraint ne ''; $code .= ",\n\tmessage { \"" . $self->error_message . "\" }" if ( defined $self->error_message ) and $self->error_message ne ''; $code .= ";\n"; return $code; } # Generate Mouse code! sub generate_mouse_code { return $_[0]->generate_moose_code(@_); } sub generate_moosex_declare_code { return $_[0]->generate_moose_code(@_); } sub provide_help { require Wx; return Wx::gettext( 'A subtype provides the ability to create custom type constraints to be used in attribute definition.'); } sub read_from_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name base_type constraint error_message)) { $self->$field( $grid->GetCellValue( $row++, 1 ) ); } } sub write_to_inspector { my $self = shift; my $grid = shift; my $row = 0; for my $field (qw(name base_type constraint error_message)) { $grid->SetCellValue( $row++, 1, $self->$field ); } } sub get_grid_data { require Wx; return [ { name => Wx::gettext('Name:') }, { name => Wx::gettext('Base Type:'), choices => [ qw(Any Item Bool Maybe[] Undef Defined Value Str Num Int ClassName RoleName Ref ScalarRef[] ArrayRef[] HashRef[] CodeRef RegexpRef GlobRef FileHandle Object) ] }, { name => Wx::gettext('Constraint:') }, { name => Wx::gettext('Error message:') }, ]; } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/ClassMember.pm0000644000175000017500000000025711730324234023552 0ustar azawawiazawawipackage Padre::Plugin::Moose::ClassMember; use Moose; our $VERSION = '0.21'; has 'name' => ( is => 'rw', isa => 'Str' ); __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose/Program.pm0000644000175000017500000000446011730324234022764 0ustar azawawiazawawipackage Padre::Plugin::Moose::Program; use Moose; our $VERSION = '0.21'; with 'Padre::Plugin::Moose::Role::CanGenerateCode'; with 'Padre::Plugin::Moose::Role::CanProvideHelp'; has 'roles' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); has 'classes' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); sub generate_moose_code { my $self = shift; my $options = shift; my $code = ''; # Generate roles for my $role ( @{ $self->roles } ) { $code .= $role->generate_moose_code($options); } # Generate classes for my $class ( @{ $self->classes } ) { $code .= $class->generate_moose_code($options); } # Generate sample usage code if ( $options->{sample_code} ) { $code .= "\npackage main;\n"; my $count = 1; for my $class ( @{ $self->classes } ) { if ( $class->singleton ) { $code .= "my \$o$count = " . $class->name . "->instance;\n"; } else { $code .= "my \$o$count = " . $class->name . "->new;\n"; } $count++; } } return $code; } # Generate Mouse code! sub generate_mouse_code { my $self = shift; my $options = shift; my $code = ''; # Generate roles for my $role ( @{ $self->roles } ) { $code .= $role->generate_mouse_code($options); } # Generate classes for my $class ( @{ $self->classes } ) { $code .= $class->generate_mouse_code($options); } # Generate sample usage code if ( $options->{sample_code} ) { $code .= "\npackage main;\n"; my $count = 1; for my $class ( @{ $self->classes } ) { $code .= "my \$o$count = " . $class->name . "->new;\n"; $count++; } } return $code; } sub generate_moosex_declare_code { my $self = shift; my $options = shift; my $code = ''; # Generate roles for my $role ( @{ $self->roles } ) { $code .= $role->generate_moosex_declare_code($options); } # Generate classes for my $class ( @{ $self->classes } ) { $code .= $class->generate_moosex_declare_code($options); } # Generate sample usage code if ( $options->{sample_code} ) { $code .= "\npackage main;\n"; my $count = 1; for my $class ( @{ $self->classes } ) { $code .= "my \$o$count = " . $class->name . "->new;\n"; $count++; } } return $code; } sub provide_help { require Wx; return Wx::gettext('A program can contain multiple class, role definitions'); } __PACKAGE__->meta->make_immutable; no Moose; 1; Padre-Plugin-Moose-0.21/lib/Padre/Plugin/Moose.pm0000644000175000017500000001474211730324234021361 0ustar azawawiazawawipackage Padre::Plugin::Moose; use 5.008; use strict; use warnings; use Padre::Plugin (); our $VERSION = '0.21'; our @ISA = 'Padre::Plugin'; # Child modules we need to unload when disabled use constant CHILDREN => qw{ Padre::Plugin::Moose Padre::Plugin::Moose::Role::CanGenerateCode Padre::Plugin::Moose::Role::CanHandleInspector Padre::Plugin::Moose::Role::CanProvideHelp Padre::Plugin::Moose::Role::HasClassMembers Padre::Plugin::Moose::Role::NeedsPluginEvent Padre::Plugin::Moose::Attribute Padre::Plugin::Moose::Class Padre::Plugin::Moose::ClassMember Padre::Plugin::Moose::Constructor Padre::Plugin::Moose::Destructor Padre::Plugin::Moose::Method Padre::Plugin::Moose::Program Padre::Plugin::Moose::Role Padre::Plugin::Moose::Subtype Padre::Plugin::Moose::Util Padre::Plugin::Moose::Assistant Padre::Plugin::Moose::Preferences Padre::Plugin::Moose::FBP::Assistant Padre::Plugin::Moose::FBP::Preferences }; # Called when Padre wants to check what package versions this # plugin needs sub padre_interfaces { 'Padre::Plugin' => 0.94, 'Padre::Document' => 0.94, 'Padre::Wx::Main' => 0.94, 'Padre::Wx::Theme' => 0.94, 'Padre::Wx::Editor' => 0.94, 'Padre::Wx::Role::Main' => 0.94, 'Padre::Wx::Role::Dialog' => 0.94, ; } # Called when Padre wants a name for the plugin sub plugin_name { Wx::gettext('Moose'); } # Called when the plugin is enabled by Padre sub plugin_enable { my $self = shift; # Read the plugin configuration, and my $config = $self->config_read; unless ( defined $config ) { # No configuration, let us create it $config = {}; } # Make sure defaults are respected if they are undefined. unless ( defined $config->{type} ) { $config->{type} = 'Moose'; } unless ( defined $config->{namespace_autoclean} ) { $config->{namespace_autoclean} = 0; } unless ( defined $config->{comments} ) { $config->{comments} = 1; } unless ( defined $config->{sample_code} ) { $config->{sample_code} = 1; } # Write the plugin's configuration $self->config_write($config); # Update configuration attribute $self->{config} = $config; # Generate missing Padre's events # TODO remove once Padre 0.96 is released require Padre::Plugin::Moose::Role::NeedsPluginEvent; Padre::Plugin::Moose::Role::NeedsPluginEvent->meta->apply( $self->main ); # Highlight the current editor. This is needed when a plugin is enabled # for the first time $self->editor_changed; return 1; } # Called when the plugin is disabled by Padre sub plugin_disable { my $self = shift; # Destroy resident dialog if ( defined $self->{assistant} ) { $self->{assistant}->Destroy; $self->{assistant} = undef; } # TODO: Switch to Padre::Unload once Padre 0.96 is released for my $package (CHILDREN) { require Padre::Unload; Padre::Unload->unload($package); } } # Called when Padre wants to display plugin menu items sub menu_plugins { my $self = shift; my $main = $self->main; my $menu_item = Wx::MenuItem->new( undef, -1, Wx::gettext('Moose Assistant') . "...\tF8", ); Wx::Event::EVT_MENU( $main, $menu_item, sub { $self->show_assistant; }, ); return $menu_item; } # Shows the Moose assistant dialog. Creates it only once if needed sub show_assistant { my $self = shift; eval { unless ( defined $self->{assistant} ) { require Padre::Plugin::Moose::Assistant; $self->{assistant} = Padre::Plugin::Moose::Assistant->new($self); } }; if ($@) { $self->main->error( sprintf( Wx::gettext('Error: %s'), $@ ) ); } else { $self->{assistant}->run; } return; } # Called when an editor is opened sub editor_enable { my $self = shift; my $editor = shift; my $document = shift; # Only on Perl documents return unless $document->isa('Padre::Document::Perl'); require Padre::Plugin::Moose::Util; Padre::Plugin::Moose::Util::add_moose_keywords_highlighting( $self->{config}->{type}, $document, $editor ); } # Called when an editor is changed sub editor_changed { my $self = shift; my $current = $self->current or return; my $document = $current->document or return; my $editor = $current->editor or return; # Only on Perl documents return unless $document->isa('Padre::Document::Perl'); require Padre::Plugin::Moose::Util; Padre::Plugin::Moose::Util::add_moose_keywords_highlighting( $self->{config}->{type}, $document, $editor ); } 1; __END__ =pod =head1 NAME Padre::Plugin::Moose - Moose, Mouse and MooseX::Declare support for Padre =head1 SYNOPSIS cpan Padre::Plugin::Moose Then use it via L, The Perl IDE. Press F8. =head1 DESCRIPTION Once you enable this Plugin under Padre, you'll get a brand new menu with the following options: =head2 Moose Assistant Opens up a user-friendly dialog where you can add classes, roles and their members. The dialog contains a tree view of created class and role elements and a preview of the generated Perl code. It also contains links to Moose online references. =head2 Moose Preferences Provides the ability to change the operation type (Moose, Mouse or MooseX::Declare) and toggle the usage of namespace::clean, comments and sample usage code generation. =head2 Keyword Syntax Highlighting Moose/Mouse and MooseX::Declare keywords are highlighted automatically in any Perl document. The operation type determines what to highlight. =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. 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 Padre::Plugin::Moose You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 SEE ALSO L, L =head1 AUTHORS Ahmad M. Zawawi =head1 CONTRIBUTORS Adam Kennedy Kevin Dawson Ebowtie@cpan.orgE =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Ahmad M. Zawawi This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Padre-Plugin-Moose-0.21/Makefile.PL0000644000175000017500000000075211730337034016652 0ustar azawawiazawawiuse strict; use warnings; use inc::Module::Install; name 'Padre-Plugin-Moose'; all_from 'lib/Padre/Plugin/Moose.pm'; requires 'Padre' => '0.94'; requires 'Moose' => '2.0402'; test_requires 'Test::More' => '0.88'; no_index 'directory' => qw{ t share inc}; homepage 'http://padre.perlide.org/trac/wiki/PadrePluginMoose'; bugtracker 'http://padre.perlide.org/'; repository 'http://svn.perlide.org/padre/trunk/Padre-Plugin-Moose'; install_share_with_mofiles; WriteAll; Padre-Plugin-Moose-0.21/t/0000755000175000017500000000000011730337050015135 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/t/01-eol.t0000644000175000017500000000175511725664345016345 0ustar azawawiazawawiuse strict; use warnings; use Test::More; BEGIN { # Don't run tests for installs unless ( $ENV{AUTOMATED_TESTING} or $ENV{RELEASE_TESTING} ) { plan( skip_all => "Author tests not required for installation" ); } unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) { plan skip_all => 'Needs DISPLAY'; exit 0; } } # Checks for UNIX end of lines (aka newlines) use File::Find::Rule; use Padre::Util (); my @files = File::Find::Rule->file->name( '*.pm', '*.pod', '*.pl', '*.p6', '*.t', '*.yml', '*.txt' )->in( 'lib', 't', 'share' ); @files = ( @files, 'Makefile.PL', 'Changes', 'padre.yml' ); plan( tests => scalar @files ); foreach my $file (@files) { my $eol = Padre::Util::newline_type( slurp($file) ); ok( ( $eol eq 'UNIX' ) || ( $eol eq 'None' ), "$file has UNIX-EOLs or none" ); } ###################################################################### # Support Functions sub slurp { my $file = shift; open my $fh, '<', $file or die $!; binmode $fh; local $/ = undef; return <$fh>; } Padre-Plugin-Moose-0.21/t/00-compile.t0000644000175000017500000000207211722637376017207 0ustar azawawiazawawi#!perl use strict; use warnings; use Test::More; BEGIN { if ( not $ENV{DISPLAY} and not $^O eq 'MSWin32' ) { plan skip_all => 'Needs DISPLAY'; exit 0; } } use File::Find; use File::Temp qw{ tempdir }; my @modules; find( sub { return if $File::Find::name !~ /\.pm\z/; my $found = $File::Find::name; $found =~ s{^lib/}{}; $found =~ s{[/\\]}{::}g; $found =~ s/\.pm$//; # nothing to skip push @modules, $found; }, 'lib', ); my @scripts = glob "bin/*"; my $plan = scalar(@modules) + scalar(@scripts); $plan ? ( plan tests => $plan ) : ( plan skip_all => "no tests to run" ); { # fake home for cpan-testers # no fake requested ## local $ENV{HOME} = tempdir( CLEANUP => 1 ); like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" ) for sort @modules; SKIP: { eval "use Test::Script 1.05; 1;"; skip "Test::Script needed to test script compilation", scalar(@scripts) if $@; foreach my $file (@scripts) { my $script = $file; $script =~ s!.*/!!; script_compiles( $file, "$script script compiles" ); } } } Padre-Plugin-Moose-0.21/Padre-Plugin-Moose.fbp0000644000175000017500000056417511730337034020756 0ustar azawawiazawawi C++ 1 source_name 0 UTF-8 connect 1000 none 1 Padre::Plugin::Moose . 1 1 0 0 1 1 impl_virtual 0 wxID_ANY 750,480 Padre::Plugin::Moose::FBP::Assistant 750,480 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Moose Assistant wxFILTER_NONE wxDefaultValidator main_sizer wxVERTICAL none 5 wxEXPAND 1 top_sizer wxHORIZONTAL none 5 wxEXPAND 0 left_sizer wxVERTICAL none 5 wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 1 1 ,90,92,-1,70,0 0 wxID_ANY Object Tree m_staticText2 none wxFILTER_NONE wxDefaultValidator -1 5 wxALL|wxEXPAND 1 1 1 0 wxID_ANY tree protected wxTR_DEFAULT_STYLE wxFILTER_NONE wxDefaultValidator wxSIMPLE_BORDER on_tree_key_up on_tree_item_menu on_tree_selection_change 5 wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 1 1 ,90,92,-1,70,0 0 wxID_ANY Properties m_staticText3 none wxFILTER_NONE wxDefaultValidator -1 5 wxALL|wxEXPAND 0 0 0 wxALIGN_LEFT wxALIGN_TOP wxALIGN_CENTRE 0 wxALIGN_CENTRE 2 140,140 1 0 1 0 1 1 1 1 0 wxID_ANY 0 0 -1,-1 -1,150 inspector protected wxALIGN_CENTRE 0 wxALIGN_CENTRE 20 -1,150 wxFILTER_NONE wxDefaultValidator wxSIMPLE_BORDER on_grid_cell_change 5 wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 0 wxSYS_COLOUR_INFOBK 1 1 wxSYS_COLOUR_INFOBK 0 wxID_ANY 0 -1,100 help protected wxTE_MULTILINE|wxTE_NO_VSCROLL|wxTE_READONLY wxFILTER_NONE wxDefaultValidator wxNO_BORDER 5 wxEXPAND 1 right_sizer wxVERTICAL none 5 wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 1 1 ,90,92,-1,70,0 0 wxID_ANY Palette m_staticText4 none wxFILTER_NONE wxDefaultValidator -1 5 wxEXPAND | wxALL 0 1 1 0 wxID_ANY palette protected wxFILTER_NONE wxDefaultValidator Containers 1 1 1 0 wxID_ANY containers protected wxFILTER_NONE wxDefaultValidator wxTAB_TRAVERSAL container_sizer wxHORIZONTAL none 2 wxALIGN_CENTER_HORIZONTAL|wxALL 0 1 0 1 0 wxID_ANY &Class -1,-1 add_class_button protected wxFILTER_NONE wxDefaultValidator on_add_class_button 2 wxALL 0 1 0 1 0 wxID_ANY &Role -1,-1 add_role_button protected wxFILTER_NONE wxDefaultValidator on_add_role_button Members 0 1 1 0 wxID_ANY members protected wxFILTER_NONE wxDefaultValidator wxTAB_TRAVERSAL members_sizer wxHORIZONTAL none 2 wxALL 0 1 0 1 0 wxID_ANY &Attribute -1,-1 add_attribute_button protected wxFILTER_NONE wxDefaultValidator on_add_attribute_button 2 wxALL 0 1 0 1 0 wxID_ANY &Method -1,-1 add_method_button protected wxFILTER_NONE wxDefaultValidator on_add_method_button 2 wxALL 0 1 0 1 0 wxID_ANY &Subtype -1,-1 add_subtype_button protected wxFILTER_NONE wxDefaultValidator on_add_subtype_button 2 wxALL 0 1 0 1 0 wxID_ANY &Constructor -1,-1 add_constructor_button protected wxFILTER_NONE wxDefaultValidator on_add_constructor_button 2 wxALL 0 1 0 1 0 wxID_ANY &Destructor -1,-1 add_destructor_button protected wxFILTER_NONE wxDefaultValidator on_add_destructor_button Online References 0 1 1 0 wxID_ANY online_refs protected wxFILTER_NONE wxDefaultValidator wxTAB_TRAVERSAL online_refs_sizer wxHORIZONTAL none 5 wxALIGN_CENTER_VERTICAL|wxALL 0 1 1 0 wxID_ANY Moose Manual moose_manual_hyperlink protected wxHL_DEFAULT_STYLE https://metacpan.org/module/Moose::Manual wxFILTER_NONE wxDefaultValidator 5 wxALIGN_CENTER_VERTICAL|wxALL 0 1 1 0 wxID_ANY How to Cook a Moose? moose_cookbook_hyperlink protected wxHL_DEFAULT_STYLE https://metacpan.org/module/Moose::Cookbook wxFILTER_NONE wxDefaultValidator 5 wxALIGN_CENTER_VERTICAL|wxALL 0 1 1 0 wxID_ANY Moose Website moose_website_hyperlink protected wxHL_DEFAULT_STYLE http://moose.iinteractive.com/ wxFILTER_NONE wxDefaultValidator 5 wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 1 1 ,90,92,-1,70,0 0 wxID_ANY Preview m_staticText5 none wxFILTER_NONE wxDefaultValidator -1 5 wxALL|wxEXPAND 1 Padre::Wx::Editor 1 1 0 wxID_ANY Padre::Wx::Editor preview protected wxFILTER_NONE wxDefaultValidator wxSIMPLE_BORDER 5 wxEXPAND|wxLEFT|wxRIGHT 0 1 1 0 wxID_ANY m_staticline2 none wxLI_HORIZONTAL wxFILTER_NONE wxDefaultValidator 5 wxEXPAND 0 button_sizer wxHORIZONTAL none 5 wxALIGN_BOTTOM|wxALL 0 1 0 1 0 wxID_ANY &Generate generate_code_button protected wxFILTER_NONE wxDefaultValidator on_generate_code_button_clicked 5 wxALIGN_BOTTOM|wxBOTTOM|wxRIGHT|wxTOP 0 1 0 1 0 wxID_ANY Rese&t reset_button protected wxFILTER_NONE wxDefaultValidator on_reset_button_clicked 5 wxALL 0 1 0 1 0 wxID_ANY &Preferences preferences_button protected wxFILTER_NONE wxDefaultValidator on_preferences_button_clicked 5 wxEXPAND 1 0 protected 0 5 wxALIGN_BOTTOM|wxALL 0 1 0 1 0 wxID_CANCEL Cl&ose close_button protected wxFILTER_NONE wxDefaultValidator wxBOTH 1 1 impl_virtual 0 wxID_ANY Padre::Plugin::Moose::FBP::Preferences 247,204 wxDEFAULT_DIALOG_STYLE Preferences wxFILTER_NONE wxDefaultValidator sizer wxVERTICAL none 5 wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 1 1 ,90,92,-1,70,0 0 wxID_ANY Code Generation Options: options_labels none wxFILTER_NONE wxDefaultValidator -1 5 wxEXPAND 0 generated_code_sizer wxHORIZONTAL none 5 wxALIGN_CENTER_VERTICAL|wxALL 0 1 1 0 wxID_ANY Type: generated_code_label protected wxFILTER_NONE wxDefaultValidator -1 5 wxALL 0 "Moose" "Mouse" "MooseX::Declare" 1 1 0 wxID_ANY generated_code_combo protected wxCB_READONLY wxFILTER_NONE wxDefaultValidator Moose 5 wxALL 0 0 1 1 0 wxID_ANY Use namespace::autoclean? namespace_autoclean_checkbox protected wxFILTER_NONE wxDefaultValidator 5 wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND 0 1 1 1 0 wxID_ANY Generate Comments? comments_checkbox protected wxFILTER_NONE wxDefaultValidator 5 wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND 0 1 1 1 0 wxID_ANY Generate Sample code? sample_code_checkbox protected wxFILTER_NONE wxDefaultValidator 5 wxEXPAND | wxALL 0 1 1 0 wxID_ANY static_line protected wxLI_HORIZONTAL wxFILTER_NONE wxDefaultValidator 5 wxEXPAND 0 button_sizer wxHORIZONTAL none 5 wxEXPAND 1 0 protected 0 5 wxALL 0 1 0 1 0 wxID_OK &OK ok_button protected wxFILTER_NONE wxDefaultValidator 5 wxALL 0 1 0 1 0 wxID_CANCEL &Cancel cancel_button protected wxFILTER_NONE wxDefaultValidator Padre-Plugin-Moose-0.21/share/0000755000175000017500000000000011730337050015774 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/share/locale/0000755000175000017500000000000011730337050017233 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/share/locale/Padre__Plugin__Moose-it-it.po0000644000175000017500000002157311730324327024643 0ustar azawawiazawawimsgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-03-07 16:32+0200\n" "PO-Revision-Date: \n" "Last-Translator: Simone Blandino \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: Italian\n" "X-Poedit-Country: ITALY\n" #: lib/Padre/Plugin/Moose/Class.pm:194 msgid " A class is a blueprint of how to create objects of itself. A class can contain attributes, subtypes and methods which enable objects to have state and behavior." msgstr "Una classe è un progetto che indica come costruire oggetti da se stessa. Una classe può contenere attributi, sottotipi e metodi che consentono agli oggetti di possedere uno stato e un comportamento" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:190 msgid "&Attribute" msgstr "&Attributo" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:150 msgid "&Class" msgstr "&Classe" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:238 msgid "&Constructor" msgstr "&Costruttore" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:254 msgid "&Destructor" msgstr "&Distruttore" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:328 msgid "&Generate" msgstr "&Genera" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:206 msgid "&Method" msgstr "&Metodo" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:360 msgid "&Preferences" msgstr "&Preferenze" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:166 msgid "&Role" msgstr "&Ruolo" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:222 msgid "&Subtype" msgstr "&Sottotipo" #: lib/Padre/Plugin/Moose/Method.pm:75 msgid "A method is a subroutine within a class that defines behavior at runtime" msgstr "Un metodo è una subroutine interna a una classe che definisce un comportamento in fase di esecuzione" #: lib/Padre/Plugin/Moose/Program.pm:108 msgid "A program can contain multiple class, role definitions" msgstr "Un programma può contenere molteplici classi e definizioni di ruoli" #: lib/Padre/Plugin/Moose/Role.pm:119 msgid "A role provides some piece of behavior or state that can be shared between classes." msgstr "Un ruolo fornisce un elemento di comportamento o di stato che possono essere condivisi tra classi." #: lib/Padre/Plugin/Moose/Constructor.pm:75 msgid "A special type of subroutine called at the creation of an object" msgstr "Un tipo particolare di subroutine richiamata al momento della creazione di un oggetto" #: lib/Padre/Plugin/Moose/Destructor.pm:75 msgid "A special type of subroutine called at the destruction of an object" msgstr "Un tipo particolare di subroutine richiamata al momento della distruzione di un oggetto" #: lib/Padre/Plugin/Moose/Subtype.pm:46 msgid "A subtype provides the ability to create custom type constraints to be used in attribute definition." msgstr "Un sottotipo rende possibile creare vincoli di tipo personalizzati da usare nella definizione degli attributi." #: lib/Padre/Plugin/Moose/Attribute.pm:98 msgid "Access type:" msgstr "Tipo di accesso:" #: lib/Padre/Plugin/Moose/Attribute.pm:71 msgid "An attribute is a property that every member of a class has." msgstr "Un attributo è una proprietà che hanno tutti i membri di una classe." #: lib/Padre/Plugin/Moose/Subtype.pm:73 msgid "Base Type:" msgstr "Tipo base:" #: lib/Padre/Plugin/Moose/Attribute.pm:111 msgid "Builder:" msgstr "Builder:" #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:102 msgid "Cancel" msgstr "Annulla" #: lib/Padre/Plugin/Moose/Attribute.pm:104 msgid "Class Attribute?" msgstr "Attributo di classe?" #: lib/Padre/Plugin/Moose/Class.pm:225 msgid "Clean namespace?" msgstr "Ripulire spazio dei nomi?" #: lib/Padre/Plugin/Moose/Attribute.pm:113 msgid "Clearer:" msgstr "Clearer:" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:376 msgid "Close" msgstr "Chiudi" #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:38 msgid "Code Generation Options:" msgstr "Opzioni generazione codice:" #: lib/Padre/Plugin/Moose/Attribute.pm:107 msgid "Coerce?" msgstr "Forzare?" #: lib/Padre/Plugin/Moose/Subtype.pm:78 msgid "Constraint:" msgstr "Vincoli:" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:413 msgid "Containers" msgstr "Contenitori" #: lib/Padre/Plugin/Moose/Attribute.pm:112 msgid "Default:" msgstr "Predefinito:" #: lib/Padre/Plugin/Moose/Assistant.pm:485 msgid "Delete" msgstr "Elimina" #: lib/Padre/Plugin/Moose/Assistant.pm:428 msgid "Do you really want to reset?" msgstr "Desiderate davvero eseguire un reset?" #: lib/Padre/Plugin/Moose/Attribute.pm:115 msgid "Documentation:" msgstr "Documentazione:" #: lib/Padre/Plugin/Moose/Attribute.pm:108 msgid "Does role:" msgstr "Svolge il ruolo:" #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:86 msgid "Enable Snippets?" msgstr "Abilitare frammenti?" #: lib/Padre/Plugin/Moose/Subtype.pm:79 msgid "Error message:" msgstr "Messaggio di errore" #: lib/Padre/Plugin/Moose.pm:146 #, perl-format msgid "Error: %s" msgstr "Errore: %s" #: lib/Padre/Plugin/Moose/Assistant.pm:156 #, perl-format msgid "Error:%s" msgstr "Errore:%s" #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:62 msgid "Generate Comments?" msgstr "Generare commenti?" #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:70 msgid "Generate Sample code?" msgstr "Generare codice d'esempio?" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:288 msgid "How to Cook a Moose?" msgstr "Come cucinare un Alce?" #: lib/Padre/Plugin/Moose/Class.pm:224 msgid "Make immutable?" msgstr "Rendere costante?" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:414 msgid "Members" msgstr "Membri" #: lib/Padre/Plugin/Moose/Destructor.pm:102 #: lib/Padre/Plugin/Moose/Method.pm:102 #: lib/Padre/Plugin/Moose/Constructor.pm:102 msgid "Modifier:" msgstr "Modificatori:" #: lib/Padre/Plugin/Moose.pm:57 msgid "Moose" msgstr "Moose" #: lib/Padre/Plugin/Moose.pm:121 #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:30 msgid "Moose Assistant" msgstr "Assistente Moose" #: lib/Padre/Plugin/Moose/Assistant.pm:27 #, perl-format msgid "Moose Assistant %s - Written for fun by Ahmad M. Zawawi (azawawi)" msgstr "Assistente Moose %s - Scritto per gioco da Ahmad M. Zawawi (azawawi)" #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:29 msgid "Moose Assistant Preferences" msgstr "Preferenze assistente Moose" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:278 msgid "Moose Manual" msgstr "Manuale Moose?" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:298 msgid "Moose Website" msgstr "Sito web Moose" #: lib/Padre/Plugin/Moose/Destructor.pm:101 #: lib/Padre/Plugin/Moose/Attribute.pm:97 #: lib/Padre/Plugin/Moose/Method.pm:101 #: lib/Padre/Plugin/Moose/Constructor.pm:101 #: lib/Padre/Plugin/Moose/Role.pm:145 #: lib/Padre/Plugin/Moose/Class.pm:221 #: lib/Padre/Plugin/Moose/Subtype.pm:72 msgid "Name:" msgstr "Nome:" #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:94 msgid "OK" msgstr "OK" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:41 msgid "Object Tree" msgstr "Albero oggetti" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:415 msgid "Online References" msgstr "Riferimento online" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:128 msgid "Palette" msgstr "Palette" #: lib/Padre/Plugin/Moose/Attribute.pm:114 msgid "Predicate:" msgstr "Predicato:" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:308 msgid "Preview" msgstr "Anteprima" #: lib/Padre/Plugin/Moose/Assistant.pm:174 msgid "Program" msgstr "Programma" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:79 msgid "Properties" msgstr "Proprietà" #: lib/Padre/Plugin/Moose/Attribute.pm:105 msgid "Required?" msgstr "Richiesto?" #: lib/Padre/Plugin/Moose/Role.pm:146 msgid "Requires:" msgstr "Richiede:" #: lib/Padre/Plugin/Moose/FBP/Assistant.pm:344 msgid "Reset" msgstr "Reset" #: lib/Padre/Plugin/Moose/Class.pm:223 msgid "Roles:" msgstr "Ruoli:" #: lib/Padre/Plugin/Moose/Class.pm:226 msgid "Singleton?" msgstr "Istanza singola?" #: lib/Padre/Plugin/Moose/Class.pm:222 msgid "Superclasses:" msgstr "Superclassi" #: lib/Padre/Plugin/Moose/Attribute.pm:106 msgid "Trigger:" msgstr "Trigger:" #: lib/Padre/Plugin/Moose/Attribute.pm:99 #: lib/Padre/Plugin/Moose/FBP/Preferences.pm:45 msgid "Type:" msgstr "Tipo:" #: lib/Padre/Plugin/Moose/Attribute.pm:109 msgid "Weak Ref?" msgstr "Riferimento debole?" #: lib/Padre/Plugin/Moose/Assistant.pm:383 msgid "You can only add a constructor to a class or role" msgstr "Potete aggiungere un costruttore solo a una classe o a un ruolo" #: lib/Padre/Plugin/Moose/Assistant.pm:408 msgid "You can only add a destructor to a class or role" msgstr "Potete aggiungere un distruttore solo a una classe o a un ruolo" #: lib/Padre/Plugin/Moose/Assistant.pm:358 msgid "You can only add a method to a class or role" msgstr "Potete aggiungere un metodo solo a una classe o a un ruolo" #: lib/Padre/Plugin/Moose/Assistant.pm:333 msgid "You can only add a subtype to a class or role" msgstr "Potete aggiungere un sottotipo solo a una classe o a un ruolo" #: lib/Padre/Plugin/Moose/Assistant.pm:308 msgid "You can only add an attribute to a class or role" msgstr "Potete aggiungere un attributo solo a una classe o a un ruolo" #: lib/Padre/Plugin/Moose/Attribute.pm:110 msgid "lazy?" msgstr "Pigro?" Padre-Plugin-Moose-0.21/share/locale/Padre__Plugin__Moose-ar.po0000644000175000017500000000644711730324327024222 0ustar azawawiazawawimsgid "" msgstr "" "Project-Id-Version: Padre-Plugin-Mojolicious\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-11-02 12:26+0200\n" "PO-Revision-Date: 2010-11-02 12:27+0200\n" "Last-Translator: Ahmad M. Zawawi \n" "Language-Team: Arabic\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: lib/Padre/Plugin/Mojolicious.pm:25 msgid "Mojolicious" msgstr "بريمج Mojolicious" #: lib/Padre/Plugin/Mojolicious.pm:39 #: lib/Padre/Plugin/Mojolicious/NewApp.pm:47 msgid "New Mojolicious Application" msgstr "تطبيق Mojolicious جديد" #: lib/Padre/Plugin/Mojolicious.pm:47 msgid "Start Web Server" msgstr "تشغيل خادم الويب" #: lib/Padre/Plugin/Mojolicious.pm:51 msgid "Stop Web Server" msgstr "ايقاف خادم الويب" #: lib/Padre/Plugin/Mojolicious.pm:57 msgid "Mojolicious Online References" msgstr "مراجع Mojolicious على الانترنت" #: lib/Padre/Plugin/Mojolicious.pm:58 msgid "Mojolicious Manual" msgstr "دليل Mojolicious" #: lib/Padre/Plugin/Mojolicious.pm:61 msgid "Mojolicious Website" msgstr "موقع ويب Mojolicious" #: lib/Padre/Plugin/Mojolicious.pm:64 msgid "Mojolicious Community Live Support" msgstr "دعم مجتمع Mojolicious المباشر" #: lib/Padre/Plugin/Mojolicious.pm:72 msgid "About" msgstr "عن" #: lib/Padre/Plugin/Mojolicious.pm:91 #, perl-format msgid "" "Mojolicious application script not found at\n" "%s\n" "\n" "Please make sure the active document is from your Mojolicious project." msgstr "" "فشل العثور على سكريبت تطبيق Mojolicious\n" "%s\n" "\n" "الرجاء التأكد من الوثيقة الحالية في مشروع Mojolicious الخاص بك." #: lib/Padre/Plugin/Mojolicious.pm:94 msgid "Server not found" msgstr "الخادم غير موجود" #: lib/Padre/Plugin/Mojolicious.pm:120 msgid "Web server appears to be running. Launch web browser now?" msgstr "ببدو أن خادم الويب شغال. هل تريد تشغيل متصفح الويب الآن؟" #: lib/Padre/Plugin/Mojolicious.pm:121 msgid "Start Web Browser?" msgstr "تشغيل متصفح الويب؟" #: lib/Padre/Plugin/Mojolicious.pm:147 msgid "" "\n" "Web server stopped successfully.\n" msgstr "" "\n" "تم ايقاف خادم الويب بنجاح.\n" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:26 msgid "Application Name:" msgstr "اسم التطبيق:" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:30 msgid "Parent Directory:" msgstr "الدليل الأصل:" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:31 msgid "Pick parent directory" msgstr "اختر الدليل الأصل:" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:84 msgid "Invalid Application name" msgstr "اسم التطبيق خاطئ" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:84 #: lib/Padre/Plugin/Mojolicious/NewApp.pm:87 msgid "missing field" msgstr "حقل مفقود" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:87 msgid "You need to select a base directory" msgstr "يجب ان تختار دليل البدايه" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:121 #, perl-format msgid "%s apparently created. Do you want to open it now?" msgstr "يبدو أن الملف %s موجود. هل تريد فتح الملف؟" #: lib/Padre/Plugin/Mojolicious/NewApp.pm:122 msgid "Done" msgstr "تم" Padre-Plugin-Moose-0.21/MYMETA.json0000644000175000017500000000202711730337037016567 0ustar azawawiazawawi{ "abstract" : "Moose, Mouse and MooseX::Declare support for Padre", "author" : [ "Ahmad M. Zawawi " ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Padre-Plugin-Moose", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "6.59", "Locale::Msgfmt" : "0.15", "Test::More" : "0.88" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "runtime" : { "requires" : { "Moose" : "2.0402", "Padre" : "0.94", "perl" : "5.008" } } }, "release_status" : "stable", "version" : "0.21" } Padre-Plugin-Moose-0.21/padre.yml0000644000175000017500000000022611730337034016512 0ustar azawawiazawawi--- editor_indent_tab: 1 editor_indent_tab_width: 8 editor_indent_width: 8 config_perltidy: ../tools/perltidyrc config_perlcritic: xt/critic-util.ini Padre-Plugin-Moose-0.21/Changes0000644000175000017500000001752611730337034016202 0ustar azawawiazawawiChanges for Padre-Plugin-Moose 0.21 2012.3.15 - Fix segfault when new files are open without any open files (AZAWAWI, Reported by El_Che) - Updated Padre Italian translation (SBLANDIN) - Unload P:P:Moose when the plugin is disabled (BOWTIE) - Focus on the class and role tab after showing the error message: You can only add X to a class or role (AZAWAWI) - Less code in Makefile.PL (AZAWAWI) 0.20 2012.3.10 (AZAWAWI) - Added missing README - Highlight the current editor. This is needed when a plugin is enabled for the first time - Added more button accelerator + Perl tidy - Rename NeedsSaveAsEvent to NeedsPluginEvent 0.19 2012.3.10 (AZAWAWI) - Moved TextMate-style TAB-completion feature into Padre::Plugin::Snippet. - No need to provide a Perl document subclass to Padre therefore no problems with other Perl document subclassing plugins. - In MooseX::Declare, around modifier has $self and $orig predefined - Documentation updates. - No more "Enable Snippets" in preferences dialog. - One can choose between the namespace::clean or the purist approach to using Moose and Mouse. 0.18 2012.3.7 (AZAWAWI) - Perfected TextMate-style TAB-completion feature. Thanks for BOWTIE++ for throughly testing it. - Added perl snippets that are on by default regardless of current code generator type 0.17 2012.3.3 - Perl tidy and fix missing updated Changes. Must have been sleeping when I released 0.16 (AZAWAWI) 0.16 2012.3.3 - Removing the static box sizers from the design for a cleaner look (ADAMK) - Added missing $VERSION to ClassMember (ADAMK) - Completed plugin dependencies (ADAMK) - Added modal preferences dialog (AZAWAWI) - Renamed the dialog to "Moose Assistant" (AZAWAWI) - Added MooseX::Declare keyword syntax highlighting (AZAWAWI) - Added MooseX::Declare and Mouse snippets (AZAWAWI) - Added more documentation (AZAWAWI) - Switch from YAML::Tiny to YAML for stopping the leading whitespace loss (AZAWAWI) - Added t/eol.t author test (AZAWAWI) - Snippets YAML files is divided by type: Moose, Mouse and MooseX::Declare (AZAWAWI) - Added snippets checkbox to toggle functionality (AZAWAWI) 0.15 2012.2.29 (AZAWAWI) - Add Moose keywords highlighting - Add YAML-based TextMate-style Moose keyword snippet completion (Thanks for El_Che and perigrin) - Added basic constructor/destructor support - Switch order of members tab to be most used first: attributes, methods, subtypes, constructor and then destructor. - Inspector is now bigger since it is a scrolled window. - Fix q{editable inspector in Program node at startup} TODO - Dialog is no longer cramped (width is 750 instead of 640 pixels) 0.14 2012.2.27 (AZAWAWI) - Added MooseX::Declare code generation - Code generation options UI - Minimum dialog size is 640x480 and it is now resizable (bowtie++) - Ability to change generation code target (Moose, Mouse or MooseX::Declare) via a combo box - Fixed immutable/namespace::clean order (GabrielVieira++ for the bug report) - Perl tidy + Makefile.PL now includes plugin homepage as wiki page (bowtie++) 0.13 2012.2.27 (AZAWAWI) - Add Mouse support - Added method modifiers list completion - Added support for class attributes via MooseX::ClassAttribute - Added support for singletons via MooseX::Singleton - Inspector is now a scrolled window - Added to attributes the following options: coerce, does, weak_ref, lazy, builder, default, clearer, predicate, documentation. 0.12 2012.2.26 (AZAWAWI) - Delete key and right-click (context menu) now work on the delete option. No actual deletion is done at the moment - Add the UI/event hooks for constructor/destructor buttons. No code generation at the moment - Choice combo list is now in inspector. (bowtie++ for the idea) 0.11 2012.2.24 (AZAWAWI) - New polished dialog UI :) - Added method modifiers (around, before, after) - Removed About button and moved its information to the dialog title 0.10 2012.2.24 (AZAWAWI) - Fixed future timestamp for recently released 0.09. Stupid old dev VM image :) 0.09 2012.2.24 (AZAWAWI) - Escape regular expression while positioning the preview editor - Current editor theme is always applied. - No need to hide controls. Let us do the right way and validate each action (bowtie++). - Use Moose sugar 'blessed' instead of Scalar::Util::blessed - which is the same but cooler :) - Fixed ellipsis in plugin manager (bowtie++) - Stop doing that grid focus automatically. It screws up navigation - Various POD updates regarding methods. - Clicking on a tree element scrolls to the first line of its generated code instead of the Padre-default centerize - About dialog is reusing ->message() and is modal friendly - ::Main now does('Padre::Wx::Role::Dialog'). Alias++ - ::Role::CanHandleInspector now requires 'get_grid_data'. No global %INSPECTOR in ::Main - has 'attribute'; # is now supported, no default values. Just the basics :) Better attribute/subtype code generation - Each tree element knows how to handle the inspector via ::Role::CanHandleInspector - Various name refactoring and more roles in ::Role namespace 0.08 2012.2.23 (AZAWAWI) - Refactored the dialog to be modal and improved its UI - The dialog is resident until the plugin is disabled. - Generate closes the dialog but does not destroy your work. Added "reset" button - Class members can be added now when inside a class/role. There is no need to click on the parent again as before. - Disable adding class members when you're over Program node - Added q{ my $self = shift } to generated method body. - Subtype has now a base type and is usable now. 0.07 2012.2.22 - Show the generated code that is related the currently selected element (AZAWAWI) - Added keyboard button accelerators and "Insert code" is now "Generate" (BOWTIE, AZAWAWI) - Added a simple inspector help text field that explains the current element (AZAWAWI) - The code generator is now called at startup (AZAWAWI) - The buttons are shown/hidden instead of enabled/disabled (AZAWAWI) - Inside Program elements, you can create class/role (AZAWAWI) - Inside Class/Role elements, you can create attribute, subtype or method (AZAWAWI) 0.06 2012.2.22 (HOTFIX to 0.05) - Tree item selection is now done in EVT_IDLE lifecycle to prevent deep recursion when editing (AZAWAWI) 0.05 2012.2.22 - Added Inspector edit mode (AZAWAWI) - Fixed Recommended order for namespace::clean (AZAWAWI) - Install share directory with MO files (AZAWAWI) - Add q{use Moose::Util::TypeConstraint} when needed (AZAWAWI) - q{Add Method} implemented (AZAWAWI) - Added Padre::Plugin::Moose::CodeGen role. Less POD cruft. Lazy loading. (AZAWAWI) 0.04 2012.2.21 - Added namespace::clean as a dependency (AZAWAWI) - Fixed a role code generation bug (AZAWAWI) - Added Program Inspector (AZAWAWI) - Added Program Outline (AZAWAWI) - Basic Attribute/Subtype code generation (AZAWAWI) 0.03 2012.2.21 - Fixed dialog not properly closing on non-win32 platforms (BOWTIE, AZAWAWI) - Refactor variable names (AZAWAWI) - Sample code is now correct (AZAWAWI) - q{Moose} is now q{Moose...} :) (BOWTIE, AZAWAWI) 0.02 2012.2.20 The following feature list is here: (AZAWAWI) - Added Moose website/manual/cookbook hyperlinks - Added "Add class/role/attribute/subtype" tabs - Added code generation readonly preview editor - Added comments/main code generation checkboxes - Added insert code 0.01 2012.2.15 - Initial release to CPAN (AZAWAWI) Padre-Plugin-Moose-0.21/MANIFEST0000644000175000017500000000237411730337047016037 0ustar azawawiazawawiChanges 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/Msgfmt.pm inc/Module/Install/Share.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Padre/Plugin/Moose.pm lib/Padre/Plugin/Moose/Assistant.pm lib/Padre/Plugin/Moose/Attribute.pm lib/Padre/Plugin/Moose/Class.pm lib/Padre/Plugin/Moose/ClassMember.pm lib/Padre/Plugin/Moose/Constructor.pm lib/Padre/Plugin/Moose/Destructor.pm lib/Padre/Plugin/Moose/FBP/Assistant.pm lib/Padre/Plugin/Moose/FBP/Preferences.pm lib/Padre/Plugin/Moose/Method.pm lib/Padre/Plugin/Moose/Preferences.pm lib/Padre/Plugin/Moose/Program.pm lib/Padre/Plugin/Moose/Role.pm lib/Padre/Plugin/Moose/Role/CanGenerateCode.pm lib/Padre/Plugin/Moose/Role/CanHandleInspector.pm lib/Padre/Plugin/Moose/Role/CanProvideHelp.pm lib/Padre/Plugin/Moose/Role/HasClassMembers.pm lib/Padre/Plugin/Moose/Role/NeedsPluginEvent.pm lib/Padre/Plugin/Moose/Subtype.pm lib/Padre/Plugin/Moose/Util.pm Makefile.PL MANIFEST This list of files META.yml MYMETA.json MYMETA.yml Padre-Plugin-Moose.fbp padre.yml README share/locale/Padre__Plugin__Moose-ar.po share/locale/Padre__Plugin__Moose-it-it.po t/00-compile.t t/01-eol.t Padre-Plugin-Moose-0.21/inc/0000755000175000017500000000000011730337050015443 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/inc/Module/0000755000175000017500000000000011730337050016670 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/inc/Module/Install.pm0000644000175000017500000003013511730337036020642 0ustar azawawiazawawi#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. Padre-Plugin-Moose-0.21/inc/Module/Install/0000755000175000017500000000000011730337050020276 5ustar azawawiazawawiPadre-Plugin-Moose-0.21/inc/Module/Install/Makefile.pm0000644000175000017500000002743711730337036022372 0ustar azawawiazawawi#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 Padre-Plugin-Moose-0.21/inc/Module/Install/WriteAll.pm0000644000175000017500000000237611730337036022373 0ustar azawawiazawawi#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; Padre-Plugin-Moose-0.21/inc/Module/Install/Metadata.pm0000644000175000017500000004327711730337036022375 0ustar azawawiazawawi#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; Padre-Plugin-Moose-0.21/inc/Module/Install/Fetch.pm0000644000175000017500000000462711730337036021702 0ustar azawawiazawawi#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; Padre-Plugin-Moose-0.21/inc/Module/Install/Win32.pm0000644000175000017500000000340311730337036021542 0ustar azawawiazawawi#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; Padre-Plugin-Moose-0.21/inc/Module/Install/Can.pm0000644000175000017500000000615711730337036021352 0ustar azawawiazawawi#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 Padre-Plugin-Moose-0.21/inc/Module/Install/Msgfmt.pm0000644000175000017500000000175311730337036022103 0ustar azawawiazawawi#line 1 package Module::Install::Msgfmt; use 5.008005; use strict; use warnings; use File::Spec (); use Module::Install::Base (); our $VERSION = '0.15'; our @ISA = 'Module::Install::Base'; sub install_share_with_mofiles { my $self = shift; my @orig = (@_); my $class = ref($self); my $prefix = $self->_top->{prefix}; my $name = $self->_top->{name}; my $dir = @_ ? pop : 'share'; my $type = @_ ? shift : 'dist'; my $module = @_ ? shift : ''; $self->build_requires( 'Locale::Msgfmt' => '0.15' ); $self->install_share(@orig); my $distname = ""; if ( $type eq 'dist' ) { $distname = $self->name; } else { $distname = Module::Install::_CLASS($module); $distname =~ s/::/-/g; } my $path = File::Spec->catfile( 'auto', 'share', $type, $distname ); $self->postamble(<<"END_MAKEFILE"); config :: \t\$(NOECHO) \$(PERL) "-MLocale::Msgfmt" -e "Locale::Msgfmt::do_msgfmt_for_module_install(q(\$(INST_LIB)), q($path))" END_MAKEFILE } 1; Padre-Plugin-Moose-0.21/inc/Module/Install/Base.pm0000644000175000017500000000214711730337036021516 0ustar azawawiazawawi#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 Padre-Plugin-Moose-0.21/inc/Module/Install/Share.pm0000644000175000017500000000464311730337036021711 0ustar azawawiazawawi#line 1 package Module::Install::Share; use strict; use Module::Install::Base (); use File::Find (); use ExtUtils::Manifest (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub install_share { my $self = shift; my $dir = @_ ? pop : 'share'; my $type = @_ ? shift : 'dist'; unless ( defined $type and $type eq 'module' or $type eq 'dist' ) { die "Illegal or invalid share dir type '$type'"; } unless ( defined $dir and -d $dir ) { require Carp; Carp::croak("Illegal or missing directory install_share param: '$dir'"); } # Split by type my $S = ($^O eq 'MSWin32') ? "\\" : "\/"; my $root; if ( $type eq 'dist' ) { die "Too many parameters to install_share" if @_; # Set up the install $root = "\$(INST_LIB)${S}auto${S}share${S}dist${S}\$(DISTNAME)"; } else { my $module = Module::Install::_CLASS($_[0]); unless ( defined $module ) { die "Missing or invalid module name '$_[0]'"; } $module =~ s/::/-/g; $root = "\$(INST_LIB)${S}auto${S}share${S}module${S}$module"; } my $manifest = -r 'MANIFEST' ? ExtUtils::Manifest::maniread() : undef; my $skip_checker = $ExtUtils::Manifest::VERSION >= 1.54 ? ExtUtils::Manifest::maniskip() : ExtUtils::Manifest::_maniskip(); my $postamble = ''; my $perm_dir = eval($ExtUtils::MakeMaker::VERSION) >= 6.52 ? '$(PERM_DIR)' : 755; File::Find::find({ no_chdir => 1, wanted => sub { my $path = File::Spec->abs2rel($_, $dir); if (-d $_) { return if $skip_checker->($File::Find::name); $postamble .=<<"END"; \t\$(NOECHO) \$(MKPATH) "$root${S}$path" \t\$(NOECHO) \$(CHMOD) $perm_dir "$root${S}$path" END } else { return if ref $manifest && !exists $manifest->{$File::Find::name}; return if $skip_checker->($File::Find::name); $postamble .=<<"END"; \t\$(NOECHO) \$(CP) "$dir${S}$path" "$root${S}$path" END } }, }, $dir); # Set up the install $self->postamble(<<"END_MAKEFILE"); config :: $postamble END_MAKEFILE # The above appears to behave incorrectly when used with old versions # of ExtUtils::Install (known-bad on RHEL 3, with 5.8.0) # So when we need to install a share directory, make sure we add a # dependency on a moderately new version of ExtUtils::MakeMaker. $self->build_requires( 'ExtUtils::MakeMaker' => '6.11' ); # 99% of the time we don't want to index a shared dir $self->no_index( directory => $dir ); } 1; __END__ #line 154