From: hakim Date: Sat, 20 Nov 2010 17:14:24 +0000 (+0000) Subject: Client side: dzil Oyster plugins X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4aedd3bbc6229c5bcbc927ced6470fea743c520a;p=p5sagit%2FOyster.git Client side: dzil Oyster plugins --- diff --git a/dist.ini b/dist.ini index b032c02..b773a52 100644 --- a/dist.ini +++ b/dist.ini @@ -4,6 +4,7 @@ author = osfameron license = Perl_5 copyright_holder = osfameron copyright_year = 2010 +copyright_holder = The Contributors version = 0.001 diff --git a/lib/Dist/Zilla/App/Command/provision.pm b/lib/Dist/Zilla/App/Command/provision.pm new file mode 100644 index 0000000..1b355a6 --- /dev/null +++ b/lib/Dist/Zilla/App/Command/provision.pm @@ -0,0 +1,76 @@ +use strict; +use warnings; +package Dist::Zilla::App::Command::provision; +BEGIN { + $Dist::Zilla::App::Command::provision::VERSION = '0.1'; +} +# ABSTRACT: release your dist to the CPAN +use Dist::Zilla::App -command; +use Moose; +use Config::Any; + +sub abstract { 'provision a new Oyster VM' } + +sub opt_spec { + [ 'name|s' => 'the name of the VM to create' ], +} + +sub execute { + my ($self, $opt, $arg) = @_; + + my $zilla = $self->zilla; + + my $name = $opt->name + or die "No name provided!"; + my @config_files = ( './oyster.conf' ); # TODO make configurable + + my $cfg = Config::Any->load_files({ files => \@config_files }); + ($cfg) = values %{ $cfg->[0] }; # FIX with ::JFDI or similar + + my $Provision = $cfg->{Provision} or die "No section"; + my $target = $Provision->{$name} or die "No section for <$name>"; + + my $type = $target->{type} || 'EC2'; + + use Oyster::Provision; + my $server = Oyster::Provision->new( + name => $name, + size => '256', + image => 'Meerkat', + pub_ssh => "$ENV{HOME}/.ssh/id_rsa.pub", + provision_backend => $type, + ); + $server->create; + print "Instance $name created! ($server)\n"; +} + +1; + +__END__ +=pod + +=head1 NAME + +Dist::Zilla::App::Command::provision - provision a new Oyster VM + +=head1 VERSION + +version 0.1 + +=head1 SYNOPSIS + + TODO + +=head1 AUTHOR + +CONTRIBUTORS + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2010 by CONTRIBUTORS + +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 + diff --git a/lib/Dist/Zilla/Plugin/Oyster.pm b/lib/Dist/Zilla/Plugin/Oyster.pm new file mode 100644 index 0000000..07e388f --- /dev/null +++ b/lib/Dist/Zilla/Plugin/Oyster.pm @@ -0,0 +1,58 @@ +use strict; +use warnings; +package Dist::Zilla::Plugin::Oyster; +BEGIN { + our $VERSION = 0.07;# VERSION +} +1; +# ABSTRACT: set of plugins for working with Oyster + + +__END__ +=pod + +=head1 NAME + +Dist::Zilla::Plugin::Oyster - set of plugins for working with Oyster + +=head1 VERSION + +version 0.07 + +=head1 DESCRIPTION + +The following is a list of plugins in this distribution to help you integrate +L and L + +=over + +=item * L Create a new Oyster Project + +=back + +=head1 PATCHES + +Please read the SubmittingPatches file included with this Distribution. Patches +that are of sufficient quality, within the goals of the project and pass the +checklist will probably be accepted. + +=head1 AUTHORS + +=over 4 + +=item * + +see README (TODO) + +=back + +=head1 COPYRIGHT AND LICENSE + +This software is Copyright (c) 2010 by Caleb Cushing. + +This is free software, licensed under: + + The Artistic License 2.0 + +=cut + diff --git a/lib/Dist/Zilla/Plugin/Oyster/Helper.pm b/lib/Dist/Zilla/Plugin/Oyster/Helper.pm new file mode 100644 index 0000000..9733556 --- /dev/null +++ b/lib/Dist/Zilla/Plugin/Oyster/Helper.pm @@ -0,0 +1,89 @@ +use strict; +use warnings; +package Dist::Zilla::Plugin::Oyster::Helper; +BEGIN { + our $VERSION = 0.01;# VERSION +} +use Moose; +use Dist::Zilla::File::InMemory; + +extends 'Catalyst::Helper'; + +has _zilla_gatherer => ( + is => 'ro', + required => 1, + handles => { + _zilla_add_file => 'add_file', + }, +); + +# we don't want these to do anything +sub _mk_changes {}; +sub _mk_makefile {}; +sub _mk_readme {}; +sub _mk_apptest {}; +sub _mk_podtest {}; +sub _mk_podcoveragetest {}; + +sub mk_file { + my ( $self, $file_obj , $output ) = @_; + + # unfortunately the stringified $file_obj includes a prepended + # {dist_repo} name which dzil already creates if we don't regex it out we + # end up with {dist_repo}/{dist_repo}/{files} instead of just + # {dist_repo}/{files} + my $name = "$file_obj"; + $name =~ s{[\w-]+/}{}; + + my $file + = Dist::Zilla::File::InMemory->new({ + name => $name, + content => $output, + }); + + $file->mode( oct(755) ) if $file->name =~ /script/; + + $self->_zilla_add_file($file); +} +__PACKAGE__->meta->make_immutable; +no Moose; +1; +# ABSTRACT: a subclass of Catalyst::Helper + + +__END__ +=pod + +=head1 NAME + +Dist::Zilla::Plugin::Oyster::Helper - a subclass of Catalyst::Helper + +=head1 VERSION + +version 0.07 + +=head1 DESCRIPTION + +this is used to override methods in L so that it works +better with dzil. + +=head1 AUTHORS + +=over 4 + +=item * + +CONTRIBUTORS TODO (note, based on xenoterracide & t0m's work) + +=back + +=head1 COPYRIGHT AND LICENSE + +TODO + +This is free software, licensed under: + + The Artistic License 2.0 + +=cut + diff --git a/lib/Dist/Zilla/Plugin/Oyster/New.pm b/lib/Dist/Zilla/Plugin/Oyster/New.pm new file mode 100644 index 0000000..5ab89e6 --- /dev/null +++ b/lib/Dist/Zilla/Plugin/Oyster/New.pm @@ -0,0 +1,126 @@ +use strict; +use warnings; +package Dist::Zilla::Plugin::Oyster::New; +BEGIN { + our $VERSION = 0.01;# VERSION +} +use Moose; +use Dist::Zilla::Plugin::Oyster::Helper; +with qw( Dist::Zilla::Role::ModuleMaker ); + +use Dist::Zilla::File::FromCode; + +sub make_module { + my ( $self ) = @_; + + if ( $Catalyst::Helper::VERSION <= 1.28 ) { + $self->log('getting authors from ENV variable AUTHOR not dzil'); + } + + # format $name to what C::Helper wants + my $name = $self->zilla->name; + $name =~ s/-/::/g; + + # turn authors into a scalar it's what C::Helper wants + my $authors = join( ',', @{$self->zilla->authors} ); + + my $helper + = Dist::Zilla::Plugin::Oyster::Helper->new({ + name => $name, + author => $authors, + _zilla_gatherer => $self, + }); + + # $name here is for backcompat in older versions of C::Devel + $helper->mk_app( $name ); +} +__PACKAGE__->meta->make_immutable; +no Moose; +1; +# ABSTRACT: create a new catalyst project with dzil new + + +__END__ +=pod + +=head1 NAME + +Dist::Zilla::Plugin::Oyster::New - create a new Oyster project with dzil new + +=head1 VERSION + +version 0.07 + +=head1 SYNOPSIS + +in C<{home}/.dzil/profiles/oyster/profile.ini> + + [Oyster::New / :DefaultModuleMaker] + [@Oyster] + +=head1 DESCRIPTION + +this plugin is used to generate the same files L does when +C is run. + +=head1 EXAMPLE + +You probably want more than just the bare minimum profile.ini, here's a more +functional one. I suggest putting it in +C<{home}/.dzil/profiles/oyster/profile.ini> + + [Oyster::New / :DefaultModuleMaker] + [@Oyster] + +Now you can run the following command to create a skeleton catalyst app. + + dzil new -p oyster MyApp + +Obviously C is arbitrary and can be named whatever you like. + +=head1 METHODS + +=over + +=item * make_module + +required see L + +=back + +=head1 BUGS + +or features depending on your opinion and the nature of the issue. The +following are known "issue's". + +=over + +=item * Doesn't create all the files catalyst.pl does + +Some files like README, Makefile.PL and some of the tests, etc, are better +generated by C. Use existing dzil plugins to generate these. + +=back + +For all other problems use the bug tracker + +=head1 AUTHORS + +=over 4 + +=item * + +TODO, see CONTRIBUTORS + +=back + +=head1 COPYRIGHT AND LICENSE + +This software is Copyright (c) 2010 by Caleb Cushing. + +This is free software, licensed under: + + The Artistic License 2.0 + +=cut + diff --git a/lib/Dist/Zilla/PluginBundle/Oyster.pm b/lib/Dist/Zilla/PluginBundle/Oyster.pm new file mode 100644 index 0000000..df44b07 --- /dev/null +++ b/lib/Dist/Zilla/PluginBundle/Oyster.pm @@ -0,0 +1,127 @@ +package Dist::Zilla::PluginBundle::Oyster; +BEGIN { + $Dist::Zilla::PluginBundle::Basic::VERSION = '0.1'; +} +# ABSTRACT: the basic plugins to maintain and release CPAN dists +use Moose; +with 'Dist::Zilla::Role::PluginBundle::Easy'; + +sub configure { + my ($self) = @_; + + $self->add_plugins(qw( + GatherDir + PruneCruft + ManifestSkip + MetaYAML + License + Readme + ExtraTests + ExecDir + ShareDir + + MakeMaker + Manifest + + TestRelease + ConfirmRelease + )); +} + +__PACKAGE__->meta->make_immutable; +no Moose; +1; + + +=pod + +=head1 NAME + +Dist::Zilla::PluginBundle::Oyster - the basic plugins to maintain and release to Oyster + +=head1 VERSION + +version 4.102344 + +=head1 DESCRIPTION + +This plugin is meant to be a basic "first step" bundle for using Dist::Zilla. +It won't munge any of your code, but will generate a F and allows +easy, reliable releasing of distributions. + +It includes the following plugins with their default configuration: + +=over 4 + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +L + +=item * + +=back + +=head1 AUTHOR + +Ricardo SIGNES ++ nwe.pm + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2010 by Ricardo SIGNES. + +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 + + +__END__ diff --git a/oyster.conf b/oyster.conf new file mode 100644 index 0000000..98f1bc7 --- /dev/null +++ b/oyster.conf @@ -0,0 +1,7 @@ + + + type Rackspace + username foo + password baz + +