Permalink
Browse files

0.06

  • Loading branch information...
1 parent 0a86dd5 commit 491cacf5f573a2755175a4d7ed9bb92399ef2daa @kberov committed Aug 5, 2012
Showing with 39 additions and 31 deletions.
  1. +4 −0 Changes
  2. +0 −1 Makefile.PL
  3. +21 −20 README
  4. +14 −10 lib/Mojolicious/Plugin/DSC.pm
View
@@ -1,5 +1,9 @@
Revision history for Mojolicious::Plugin::DSC
+0.06 2012-08-05 23:49 EEST
+ - README is a text file now
+ - enhanced documentation
+
0.05 2012-08-04 14:50 EEST
- Added tests and example classes.
- Added missing licence in Makefile.PL.
View
@@ -13,5 +13,4 @@ WriteMakefile(
test => {TESTS => 't/*.t'},
dist => {COMPRESS => 'gzip -9f', SUFFIX => 'gz',},
clean => {FILES => 'Mojolicious-Plugin-DSC-*'},
-
);
View
41 README
@@ -1,10 +1,7 @@
-=encoding utf8
-
-=head1 NAME
Mojolicious::Plugin::DSC - use DBIx::Simple::Class in your application.
-=head1 SYNOPSIS
+SYNOPSIS
#load
# Mojolicious
@@ -14,51 +11,55 @@ Mojolicious::Plugin::DSC - use DBIx::Simple::Class in your application.
plugin 'DSC', $config;
#use
- my $user = $app->dbix->query('SELECT * FROM users WHERE user=?','ivan');
+ my $user = $app->dbix->query('
+ SELECT * FROM users WHERE user=?','ivan');
#...and if you added My::User to 'load_classes' (see below)
- my $user = My::User->query('SELECT * FROM users WHERE user=?','ivan');
+ my $user = My::User->query(
+ 'SELECT * FROM users WHERE user=?','ivan');
-=head1 DESCRIPTION
+DESCRIPTION
Mojolicious::Plugin::DSC is a L<Mojolicious> plugin that helps you
use L<DBIx::Simple::Class> in your application.
It also adds a helper (C<$app-E<gt>dbix> by default) which is a DBIx::Simple instance.
-=head1 CONFIGURATION
+CONFIGURATION
You can add all classes from your schema to the configuration
-and they will be loaded when the plugin is registered.
+and they will be loaded so you do not have to C<use My::Table>.
The configuration is pretty flexible:
# in Mojolicious startup()
$self->plugin('DSC', {
- driver => 'SQLite',
- database =>':memory:',
+ dsn => 'dbi:SQLite:database=:memory:;host=localhost'
});
#or
$self->plugin('DSC', {
- driver => 'mysql',
+ driver => 'mysqlPP',
database => 'mydbname',
host => '127.0.0.1',
user => 'myself',
password => 'secret',
- onconnect_do => ['SET NAMES UTF8','SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"'],
- dbh_attributes => {RaiseError=>0, AutoCommit=>0},
+ onconnect_do => [
+ 'SET NAMES UTF8',
+ 'SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"'
+ ],
+ dbh_attributes => {AutoCommit=>0},
namespace => 'My',
+
#will load My::User, My::Content, My::Pages
- load_classes =>['User', 'Content', 'Pages'],
+ load_classes =>['User', 'Content', 'My::Pages'],
+
#now you can use $app->DBIX instead of $app->dbix
dbix_helper => 'DBIX'
});
-=head1 LICENSE AND COPYRIGHT
+LICENSE AND COPYRIGHT
Copyright 2012 Красимир Беров (Krasimir Berov).
-This program is free software, you can redistribute it and/or modify it under
-the terms of the Artistic License version 2.0.
+This program is free software, you can redistribute it and/or modify
+it under the terms of the Artistic License version 2.0.
See http://dev.perl.org/licenses/ for more information.
-
-=cut
@@ -3,7 +3,7 @@ use Mojo::Base 'Mojolicious::Plugin';
use DBIx::Simple::Class;
-our $VERSION = '0.05';
+our $VERSION = '0.06';
#some known good defaults
my %COMMON_ATTRIBUTES = (
@@ -146,26 +146,30 @@ It also adds a helper (C<$app-E<gt>dbix> by default) which is a DBIx::Simple ins
=head1 CONFIGURATION
You can add all classes from your schema to the configuration
-and they will be loaded when the plugin is registered.
+and they will be loaded so you do not have to C<use My::Table>.
The configuration is pretty flexible:
# in Mojolicious startup()
$self->plugin('DSC', {
- driver => 'SQLite',
- database =>':memory:',
+ dsn => 'dbi:SQLite:database=:memory:;host=localhost'
});
#or
$self->plugin('DSC', {
- driver => 'mysql',
+ driver => 'mysqlPP',
database => 'mydbname',
host => '127.0.0.1',
user => 'myself',
password => 'secret',
- onconnect_do => ['SET NAMES UTF8','SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"'],
- dbh_attributes => {RaiseError=>0, AutoCommit=>0},
+ onconnect_do => [
+ 'SET NAMES UTF8',
+ 'SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"'
+ ],
+ dbh_attributes => {AutoCommit=>0},
namespace => 'My',
+
#will load My::User, My::Content, My::Pages
- load_classes =>['User', 'Content', 'Pages'],
+ load_classes =>['User', 'Content', 'My::Pages'],
+
#now you can use $app->DBIX instead of $app->dbix
dbix_helper => 'DBIX'
});
@@ -196,8 +200,8 @@ L<DBIx::Simple::Class>, L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolic
Copyright 2012 Красимир Беров (Krasimir Berov).
-This program is free software, you can redistribute it and/or modify it under
-the terms of the Artistic License version 2.0.
+This program is free software, you can redistribute it and/or
+modify it under the terms of the Artistic License version 2.0.
See http://dev.perl.org/licenses/ for more information.

0 comments on commit 491cacf

Please sign in to comment.