Permalink
Browse files

support and encourage camel case plugin names everywhere

  • Loading branch information...
1 parent 8811d15 commit 84d75f3ce45aa8af11632325dac33dfb8137df47 @kraih committed Aug 17, 2011
View
@@ -92,14 +92,14 @@ sub new {
if -w $home->rel_file('log');
# Load default plugins
- $self->plugin('callback_condition');
- $self->plugin('header_condition');
- $self->plugin('default_helpers');
- $self->plugin('tag_helpers');
- $self->plugin('epl_renderer');
- $self->plugin('ep_renderer');
- $self->plugin('request_timer');
- $self->plugin('powered_by');
+ $self->plugin('CallbackCondition');
+ $self->plugin('HeaderCondition');
+ $self->plugin('DefaultHelpers');
+ $self->plugin('TagHelpers');
+ $self->plugin('EplRenderer');
+ $self->plugin('EpRenderer');
+ $self->plugin('RequestTimer');
+ $self->plugin('PoweredBy');
# Reduced log output outside of development mode
$self->log->level('info') unless $mode eq 'development';
@@ -90,7 +90,7 @@ sub startup {
my $self = shift;
# Documentation browser under "/perldoc" (this plugin requires Perl 5.10)
- $self->plugin('pod_renderer');
+ $self->plugin('PodRenderer');
# Routes
my $r = $self->routes;
@@ -29,7 +29,7 @@ __DATA__
use Mojolicious::Lite;
# Documentation browser under "/perldoc" (this plugin requires Perl 5.10)
-plugin 'pod_renderer';
+plugin 'PodRenderer';
get '/welcome' => sub {
my $self = shift;
@@ -36,7 +36,7 @@ WriteMakefile(
VERSION_FROM => 'lib/<%= $path %>',
AUTHOR => 'A Good Programmer <nospam@cpan.org>',
EXE_FILES => ['script/<%= $name %>'],
- PREREQ_PM => {'Mojolicious' => '1.78'},
+ PREREQ_PM => {'Mojolicious' => '1.79'},
test => {TESTS => 't/*.t'}
);
@@ -17,15 +17,11 @@ EOF
# So I had to hit her with this purse I found."
sub run {
my ($self, $name) = @_;
- $name ||= 'my_plugin';
-
- # Prevent bad plugins
- die qq/Your plugin name has to be snake case, like "my_plugin".\n/
- unless $name =~ /^[a-z_]+$/;
+ $name ||= 'MyPlugin';
# Class
my $class = $name;
- camelize $class;
+ camelize $class if $name =~ /^[a-z]/;
$class = "Mojolicious::Plugin::$class";
my $app = $self->class_to_path($class);
$self->render_to_rel_file('class', "$name/lib/$app", $class, $name);
@@ -120,7 +116,7 @@ WriteMakefile(
NAME => '<%= $class %>',
VERSION_FROM => 'lib/<%= $path %>',
AUTHOR => 'A Good Programmer <nospam@cpan.org>',
- PREREQ_PM => {'Mojolicious' => '1.78'},
+ PREREQ_PM => {'Mojolicious' => '1.79'},
test => {TESTS => 't/*.t'}
);
@@ -551,7 +551,7 @@ get automatically installed with the modules.
# Switch to installable "templates" directory
$self->renderer->root($self->home->rel_dir('templates'));
- $self->plugin('pod_renderer');
+ $self->plugin('PodRenderer');
my $r = $self->routes;
$r->route('/welcome')->to('example#welcome');
@@ -581,7 +581,7 @@ The C<register> method will be called when you load the plugin.
use Mojolicious::Lite;
- plugin 'debug_helper';
+ plugin 'DebugHelper';
get '/' => sub {
my $self = shift;
@@ -594,7 +594,7 @@ The C<register> method will be called when you load the plugin.
A skeleton for a full C<CPAN> compatible plugin distribution can be
automatically generated.
- $ mojo generate plugin debug_helper
+ $ mojo generate plugin DebugHelper
And if you have a C<PAUSE> account (which can be requested at
L<http://pause.perl.org>), you are only a few commands away from relasing it
@@ -713,7 +713,7 @@ plugin with a custom configuration.
use Mojolicious::Lite;
- plugin ep_renderer => {
+ plugin EpRenderer => {
name => 'mustache',
template => {
tag_start => '{{',
@@ -639,7 +639,7 @@ applications.
my $self = shift;
# Plugin
- $self->plugin('werewolf_condition');
+ $self->plugin('WerewolfCondition');
# Routes
my $r = $self->routes;
@@ -699,7 +699,7 @@ self-contained applications under a prefix.
use Mojolicious::Lite;
# Whole application mounted under "/prefix"
- plugin mount => {'/prefix' => '/home/sri/myapp.pl'};
+ plugin Mount => {'/prefix' => '/home/sri/myapp.pl'};
# Normal route
get '/' => sub { shift->render_text('Hello World!') };
@@ -743,7 +743,7 @@ Now just load the plugin and you're done.
my $self = shift;
# Plugin
- $self->plugin('my_embedded_app');
+ $self->plugin('MyEmbeddedApp');
}
1;
View
@@ -853,7 +853,7 @@ Note that this function is EXPERIMENTAL and might change without warning!
=head2 C<plugin>
- plugin 'something';
+ plugin 'SomeThing';
Alias for L<Mojolicious/"plugin">.
@@ -27,14 +27,14 @@ Mojolicious::Plugin::CallbackCondition - Callback Condition Plugin
=head1 SYNOPSIS
# Mojolicious
- $self->plugin('callback_condition');
+ $self->plugin('CallbackCondition');
$self->routes->route('/:controller/:action')->over(cb => sub {
my ($r, $c, $captures) = @_;
...
});
# Mojolicious::Lite
- plugin 'callback_condition';
+ plugin 'CallbackCondition';
get '/' => (cb => sub {
my ($r, $c, $captures) = @_;
...
@@ -38,10 +38,10 @@ Mojolicious::Plugin::Charset - Charset Plugin
=head1 SYNOPSIS
# Mojolicious
- $self->plugin(charset => {charset => 'Shift_JIS'});
+ $self->plugin(Charset => {charset => 'Shift_JIS'});
# Mojolicious::Lite
- plugin charset => {charset => 'Shift_JIS'};
+ plugin Charset => {charset => 'Shift_JIS'};
=head1 DESCRIPTION
@@ -53,7 +53,7 @@ and encoding on all layers of L<Mojolicious>.
=head2 C<charset>
# Mojolicious::Lite
- plugin charset => {charset => 'Shift_JIS'};
+ plugin Charset => {charset => 'Shift_JIS'};
Application charset.
@@ -114,16 +114,16 @@ Mojolicious::Plugin::Config - Perlish Configuration Plugin
};
# Mojolicious
- my $config = $self->plugin('config');
+ my $config = $self->plugin('Config');
# Mojolicious::Lite
- my $config = plugin 'config';
+ my $config = plugin 'Config';
# Reads myapp.conf by default and puts the parsed version into the stash
my $config = $self->stash('config');
# Everything can be customized with options
- my $config = plugin config => {
+ my $config = plugin Config => {
file => '/etc/myapp.stuff',
stash_key => 'conf'
};
@@ -140,30 +140,30 @@ ones like C<myapp.$mode.conf>.
=head2 C<default>
# Mojolicious::Lite
- plugin config => {default => {foo => 'bar'}};
+ plugin Config => {default => {foo => 'bar'}};
Default configuration.
=head2 C<ext>
# Mojolicious::Lite
- plugin config => {ext => 'stuff'};
+ plugin Config => {ext => 'stuff'};
File extension of config file, defaults to C<conf>.
=head2 C<file>
# Mojolicious::Lite
- plugin config => {file => 'myapp.conf'};
- plugin config => {file => '/etc/foo.stuff'};
+ plugin Config => {file => 'myapp.conf'};
+ plugin Config => {file => '/etc/foo.stuff'};
Configuration file, defaults to the value of the C<MOJO_CONFIG> environment
variable or C<myapp.conf> in the application home directory.
=head2 C<stash_key>
# Mojolicious::Lite
- plugin config => {stash_key => 'conf'};
+ plugin Config => {stash_key => 'conf'};
Configuration stash key.
@@ -111,10 +111,10 @@ Mojolicious::Plugin::DefaultHelpers - Default Helpers Plugin
=head1 SYNOPSIS
# Mojolicious
- $self->plugin('default_helpers');
+ $self->plugin('DefaultHelpers');
# Mojolicious::Lite
- plugin 'default_helpers';
+ plugin 'DefaultHelpers';
=head1 DESCRIPTION
@@ -88,19 +88,19 @@ __END__
=head1 NAME
-Mojolicious::Plugin::EpRenderer - EP Renderer Plugin
+Mojolicious::Plugin::EpRenderer - Embedded Perl Renderer Plugin
=head1 SYNOPSIS
# Mojolicious
- $self->plugin('ep_renderer');
- $self->plugin(ep_renderer => {name => 'foo'});
- $self->plugin(ep_renderer => {template => {line_start => '.'}});
+ $self->plugin('EpRenderer');
+ $self->plugin(EpRenderer => {name => 'foo'});
+ $self->plugin(EpRenderer => {template => {line_start => '.'}});
# Mojolicious::Lite
- plugin 'ep_renderer';
- plugin ep_renderer => {name => 'foo'};
- plugin ep_renderer => {template => {line_start => '.'}};
+ plugin 'EpRenderer';
+ plugin EpRenderer => {name => 'foo'};
+ plugin EpRenderer => {template => {line_start => '.'}};
=head1 DESCRIPTION
@@ -122,14 +122,14 @@ example for learning to build new plugins.
=head2 C<name>
# Mojolicious::Lite
- plugin ep_renderer => {name => 'foo'};
+ plugin EpRenderer => {name => 'foo'};
Handler name.
=head2 C<template>
# Mojolicious::Lite
- plugin ep_renderer => {template => {line_start => '.'}};
+ plugin EpRenderer => {template => {line_start => '.'}};
Template options.
@@ -88,15 +88,15 @@ __END__
=head1 NAME
-Mojolicious::Plugin::EplRenderer - EPL Renderer Plugin
+Mojolicious::Plugin::EplRenderer - Embedded Perl Lite Renderer Plugin
=head1 SYNOPSIS
# Mojolicious
- $self->plugin('epl_renderer');
+ $self->plugin('EplRenderer');
# Mojolicious::Lite
- plugin 'epl_renderer';
+ plugin 'EplRenderer';
=head1 DESCRIPTION
@@ -45,12 +45,12 @@ Mojolicious::Plugin::HeaderCondition - Header Condition Plugin
=head1 SYNOPSIS
# Mojolicious
- $self->plugin('header_condition');
+ $self->plugin('HeaderCondition');
$self->routes->route('/:controller/:action')
->over(headers => {Referer => qr/example\.com/});
# Mojolicious::Lite
- plugin 'header_condition';
+ plugin 'HeaderCondition';
get '/' => (headers => {Referer => qr/example\.com/}) => sub {...};
# All headers need to match
@@ -85,12 +85,12 @@ Mojolicious::Plugin::I18n - Intenationalization Plugin
=head1 SYNOPSIS
# Mojolicious
- $self->plugin('i18n');
+ $self->plugin('I18n');
% languages 'de';
<%=l 'hello' %>
# Mojolicious::Lite
- plugin 'i18n' => {namespace => 'MyApp::I18N'};
+ plugin I18n => {namespace => 'MyApp::I18N'};
<%=l 'hello' %>
# Lexicon
@@ -113,7 +113,7 @@ request header.
This plugin can save a lot of typing, since it will generate the following
code by default.
- # $self->plugin('i18n');
+ # $self->plugin('I18n');
package MyApp::I18N;
use base 'Locale::Maketext';
package MyApp::I18N::en;
@@ -130,14 +130,14 @@ The default lexicon class will only be generated if it doesn't already exist.
=head2 C<default>
# Mojolicious::Lite
- plugin i18n => {default => 'en'};
+ plugin I18n => {default => 'en'};
Default language, defaults to C<en>.
=head2 C<namespace>
# Mojolicious::Lite
- plugin i18n => {namespace => 'MyApp::I18N'};
+ plugin I18n => {namespace => 'MyApp::I18N'};
Lexicon namespace, defaults to the application class followed by C<::I18N>.
Oops, something went wrong.

0 comments on commit 84d75f3

Please sign in to comment.