Skip to content
Browse files

update code

  • Loading branch information...
1 parent 8761651 commit ab86d5c5a1254e8ab2d3943181ac2aa29d795707 @frioux committed Aug 22, 2012
Showing with 118 additions and 105 deletions.
  1. +1 −1 lib/DU/App.pm
  2. +4 −1 lib/DU/App/Command.pm
  3. +1 −1 lib/DU/App/Command/drink.pm
  4. +4 −4 lib/DU/App/Command/drink/edit.pm
  5. +5 −5 lib/DU/App/Command/drink/ls.pm
  6. +5 −5 lib/DU/App/Command/drink/new.pm
  7. +4 −4 lib/DU/App/Command/drink/rm.pm
  8. +4 −4 lib/DU/App/Command/drink/show.pm
  9. +1 −1 lib/DU/App/Command/ingredient.pm
  10. +5 −5 lib/DU/App/Command/ingredient/edit.pm
  11. +4 −4 lib/DU/App/Command/ingredient/ls.pm
  12. +5 −5 lib/DU/App/Command/ingredient/new.pm
  13. +4 −4 lib/DU/App/Command/ingredient/rm.pm
  14. +1 −1 lib/DU/App/Command/inventory.pm
  15. +7 −7 lib/DU/App/Command/inventory/add.pm
  16. +5 −5 lib/DU/App/Command/inventory/ls.pm
  17. +5 −5 lib/DU/App/Command/inventory/rm.pm
  18. +1 −1 lib/DU/App/Command/maint.pm
  19. +5 −7 lib/DU/App/Command/maint/export.pm
  20. +6 −8 lib/DU/App/Command/maint/import.pm
  21. +12 −4 lib/DU/App/Command/maint/install.pm
  22. +3 −0 lib/DU/Schema.pm
  23. +1 −1 lib/DU/Schema/Candy.pm
  24. +1 −1 lib/DU/Schema/Result.pm
  25. +1 −1 lib/DU/Schema/ResultSet/Drink.pm
  26. +1 −1 lib/DU/Schema/ResultSet/Ingredient.pm
  27. +1 −1 lib/DU/Schema/ResultSet/InventoryItem.pm
  28. +1 −1 lib/DU/Util.pm
  29. +3 −0 lib/DU/WebApp.pm
  30. +1 −1 t/editors/drink-edit-1
  31. +1 −1 t/editors/drink-new-1
  32. +1 −1 t/editors/drink-new-2
  33. +1 −1 t/editors/drink-new-based-on
  34. +1 −1 t/editors/ingredient-edit-1
  35. +1 −1 t/editors/ingredient-edit-2
  36. +1 −1 t/editors/ingredient-new-1
  37. +1 −1 t/editors/ingredient-new-2
  38. +1 −1 t/integration/app/drink.t
  39. +1 −1 t/integration/app/help.t
  40. +1 −1 t/integration/app/ingredient.t
  41. +1 −1 t/integration/app/inventory.t
  42. +1 −1 t/integration/app/maint.t
  43. +1 −1 t/lib/A.pm
  44. +1 −1 t/schema.t
  45. +1 −1 t/unit/util.t
  46. +1 −1 xt/profile.t
View
2 lib/DU/App.pm
@@ -1,6 +1,6 @@
package DU::App;
-use 5.14.1;
+use 5.16.1;
use Moo;
extends 'App::Cmd';
View
5 lib/DU/App/Command.pm
@@ -1,9 +1,12 @@
package DU::App::Command;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'App::Cmd::Command';
+sub schema { $_[0]->app->app->schema }
+sub rs { $_[0]->schema->resultset($_[1]) }
+
1;
View
2 lib/DU/App/Command/drink.pm
@@ -1,6 +1,6 @@
package DU::App::Command::drink;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'App::Cmd::Subdispatch';
View
8 lib/DU/App/Command/drink/edit.pm
@@ -1,9 +1,9 @@
package DU::App::Command::drink::edit;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util 'drink_as_markdown', 'drink_as_data';
sub abstract { 'edit drink' }
@@ -20,7 +20,7 @@ sub execute {
print drink_as_markdown($_[0]);
say 'drink (' . $_[0]->name . ') updated';
- }, 'drink', $args->[0], $self->app->app->schema->resultset('Drink'));
+ }, 'drink', $args->[0], $self->rs('Drink'));
}
1;
View
10 lib/DU/App/Command/drink/ls.pm
@@ -1,9 +1,9 @@
package DU::App::Command::drink::ls;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
sub abstract { 'list drinks' }
@@ -20,8 +20,8 @@ sub execute {
my ($self, $opt, $args) = @_;
- my $rs = $self->app->app->schema->resultset('Drink');
- my $user = $self->app->app->schema->resultset('User')->search({
+ my $rs = $self->rs('Drink');
+ my $user = $self->rs('User')->search({
name => 'frew',
})->single;
View
10 lib/DU/App/Command/drink/new.pm
@@ -1,9 +1,9 @@
package DU::App::Command::drink::new;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util qw(edit_data drink_as_data single_item drink_as_markdown);
sub abstract { 'create new drink' }
@@ -22,7 +22,7 @@ sub execute {
single_item(sub {
$create = drink_as_data($_[0]);
$create->{variant_of_drink} = $_[0]->name;
- }, 'drink', $b, $self->app->app->schema->resultset('Drink'))
+ }, 'drink', $b, $self->rs('Drink'))
} else {
$create = {
description => 'Refreshing beverage for a hot day',
@@ -48,7 +48,7 @@ sub execute {
}
}
- my $i = $self->app->app->schema->create_drink(
+ my $i = $self->schema->create_drink(
edit_data($create)
);
View
8 lib/DU/App/Command/drink/rm.pm
@@ -1,9 +1,9 @@
package DU::App::Command::drink::rm;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util;
sub abstract { 'delete drink' }
@@ -17,7 +17,7 @@ sub execute {
$_[0]->delete;
say 'drink (' . $_[0]->name . ') deleted';
- }, 'drink', $args->[0], $self->app->app->schema->resultset('Drink'));
+ }, 'drink', $args->[0], $self->rs('Drink'));
}
1;
View
8 lib/DU/App/Command/drink/show.pm
@@ -1,9 +1,9 @@
package DU::App::Command::drink::show;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util qw(single_item drink_as_markdown);
sub abstract { 'show drink' }
@@ -15,7 +15,7 @@ sub execute {
single_item(sub {
print drink_as_markdown($_[0])
- }, 'drink', $args->[0], $self->app->app->schema->resultset('Drink'));
+ }, 'drink', $args->[0], $self->rs('Drink'));
}
1;
View
2 lib/DU/App/Command/ingredient.pm
@@ -1,6 +1,6 @@
package DU::App::Command::ingredient;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'App::Cmd::Subdispatch';
View
10 lib/DU/App/Command/ingredient/edit.pm
@@ -1,9 +1,9 @@
package DU::App::Command::ingredient::edit;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util qw(single_item edit_data ingredient_as_data);
sub abstract { 'edit ingredient' }
@@ -16,15 +16,15 @@ sub execute {
single_item(sub {
my $edit = edit_data(ingredient_as_data($_[0]));
if (my $p_name = delete $edit->{isa}) {
- my $p = $self->app->app->schema->resultset('Ingredient')->find_or_create({
+ my $p = $self->rs('Ingredient')->find_or_create({
name => $p_name
});
$edit->{kind_of_id} = $p->id;
}
$_[0]->update($edit);
say 'ingredient (' . $_[0]->name . ') updated';
- }, 'ingredient', $args->[0], $self->app->app->schema->resultset('Ingredient'));
+ }, 'ingredient', $args->[0], $self->rs('Ingredient'));
}
1;
View
8 lib/DU/App/Command/ingredient/ls.pm
@@ -1,9 +1,9 @@
package DU::App::Command::ingredient::ls;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
sub abstract { 'list ingredients' }
@@ -13,7 +13,7 @@ sub execute {
my ($self, $opt, $args) = @_;
say '## Ingredients';
- say ' * ' . $_->name for $self->app->app->schema->resultset('Ingredient')->all
+ say ' * ' . $_->name for $self->rs('Ingredient')->all
}
1;
View
10 lib/DU/App/Command/ingredient/new.pm
@@ -1,9 +1,9 @@
package DU::App::Command::ingredient::new;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util;
sub abstract { 'create new ingredient' }
@@ -20,12 +20,12 @@ sub execute {
});
if (my $isa = delete $new->{isa}) {
- $new->{kind_of_id} = $self->app->app->schema->resultset('Ingredient')->find_or_create({
+ $new->{kind_of_id} = $self->rs('Ingredient')->find_or_create({
name => $isa,
})->id
}
- my $i = $self->app->app->schema->resultset('Ingredient')->create($new);
+ my $i = $self->rs('Ingredient')->create($new);
say 'ingredient (' . $i->name . ') created';
}
View
8 lib/DU/App/Command/ingredient/rm.pm
@@ -1,9 +1,9 @@
package DU::App::Command::ingredient::rm;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util;
sub abstract { 'delete ingredient' }
@@ -17,7 +17,7 @@ sub execute {
$_[0]->delete;
say 'ingredient (' . $_[0]->name . ') deleted';
- }, 'ingredient', $args->[0], $self->app->app->schema->resultset('Ingredient'));
+ }, 'ingredient', $args->[0], $self->rs('Ingredient'));
}
1;
View
2 lib/DU/App/Command/inventory.pm
@@ -1,6 +1,6 @@
package DU::App::Command::inventory;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'App::Cmd::Subdispatch';
View
14 lib/DU/App/Command/inventory/add.pm
@@ -1,9 +1,9 @@
package DU::App::Command::inventory::add;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util 'single_item';
sub abstract { 'add ingredient to inventory' }
@@ -13,8 +13,8 @@ sub usage_desc { 'du inventory add $ingredient' }
sub execute {
my ($self, $opt, $args) = @_;
- my $ii = $self->app->app->schema
- ->resultset('User')
+ my $ii = $self
+ ->rs('User')
->search({ 'me.name' => 'frew' })
->related_resultset('inventory_items');
@@ -23,8 +23,8 @@ sub execute {
->get_column('id')
->as_query;
- my $rs = $self->app->app->schema
- ->resultset('Ingredient')->search({
+ my $rs = $self
+ ->rs('Ingredient')->search({
id => { -not_in => $q }
});
View
10 lib/DU/App/Command/inventory/ls.pm
@@ -1,9 +1,9 @@
package DU::App::Command::inventory::ls;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
sub abstract { 'list inventory' }
@@ -12,8 +12,8 @@ sub usage_desc { 'du ls' }
sub execute {
my ($self, $opt, $args) = @_;
- my $rs = $self->app->app->schema
- ->resultset('User')
+ my $rs = $self
+ ->rs('User')
->search({ 'me.name' => 'frew' })
->related_resultset('inventory_items')
->related_resultset('ingredient');
View
10 lib/DU/App/Command/inventory/rm.pm
@@ -1,9 +1,9 @@
package DU::App::Command::inventory::rm;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util;
sub abstract { 'remove ingredient from inventory' }
@@ -13,8 +13,8 @@ sub usage_desc { 'du inventory rm $ingredient' }
sub execute {
my ($self, $opt, $args) = @_;
- my $rs = $self->app->app->schema
- ->resultset('User')
+ my $rs = $self
+ ->rs('User')
->search({ 'me.name' => 'frew' })
->related_resultset('inventory_items');
View
2 lib/DU/App/Command/maint.pm
@@ -1,6 +1,6 @@
package DU::App::Command::maint;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'App::Cmd::Subdispatch';
View
12 lib/DU/App/Command/maint/export.pm
@@ -1,9 +1,9 @@
package DU::App::Command::maint::export;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util qw(ingredient_as_data drink_as_data);
sub abstract { '' }
@@ -13,8 +13,6 @@ sub usage_desc { '' }
sub execute {
my ($self, $opt, $args) = @_;
- my $s = $self->app->app->schema;
-
require Archive::Tar;
require JSON;
require File::Temp;
@@ -25,13 +23,13 @@ sub execute {
$tar->add_data('export_version.txt', 1);
$tar->add_data('drinks.json',
JSON::encode_json([
- map drink_as_data($_), $s->resultset('Drink')->all
+ map drink_as_data($_), $self->rs('Drink')->all
])
);
$tar->add_data('ingredients.json',
JSON::encode_json([
- map ingredient_as_data($_), $s->resultset('Ingredient')->all
+ map ingredient_as_data($_), $self->rs('Ingredient')->all
])
);
View
14 lib/DU/App/Command/maint/import.pm
@@ -1,9 +1,9 @@
package DU::App::Command::maint::import;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util 'drink_as_data';
sub abstract { '' }
@@ -13,8 +13,6 @@ sub usage_desc { '' }
sub execute {
my ($self, $opt, $args) = @_;
- my $s = $self->app->app->schema;
-
require Archive::Tar;
require JSON;
require File::Temp;
@@ -30,8 +28,8 @@ sub execute {
my $version = $tar->get_content('export_version.txt');
- my $drink_rs = $s->resultset('Drink');
- my $ingredient_rs = $s->resultset('Ingredient');
+ my $drink_rs = $self->rs('Drink');
+ my $ingredient_rs = $self->rs('Ingredient');
my @drinks = @{JSON::decode_json($tar->get_content('drinks.json'))};
my @ingredients = @{JSON::decode_json($tar->get_content('ingredients.json'))};
@@ -49,7 +47,7 @@ sub execute {
if ($drink_rs->find_by_name($drink_data->{name})) {
die "$drink_data->{name} is already in your database"
} else {
- $s->create_drink($drink_data)
+ $self->schema->create_drink($drink_data)
}
}
View
16 lib/DU/App/Command/maint/install.pm
@@ -1,11 +1,19 @@
package DU::App::Command::maint::install;
-use 5.14.1;
-use warnings;
+use 5.16.1;
+use Moo;
-use DU::App -command;
+extends 'DU::App::Command';
use DU::Util 'single_item';
+sub _build_dh {
+ require DBIx::Class::DeploymentHandler;
+
+ DBIx::Class::DeploymentHandler->new(
+ schema => $_[0]->schema,
+ )
+}
+
sub abstract { '' }
sub usage_desc { '' }
@@ -19,7 +27,7 @@ sub execute {
use lib 't/lib';
require A;
- my $s = $self->app->app->schema;
+ my $s = $self->schema;
A->_deploy_schema($s);
A->_populate_schema($s) if $opt->seeding;
View
3 lib/DU/Schema.pm
@@ -1,5 +1,8 @@
package DU::Schema;
+use 5.16.1;
+use warnings;
+
use parent 'DBIx::Class::Schema';
our $VERSION = 1;
View
2 lib/DU/Schema/Candy.pm
@@ -3,7 +3,7 @@ package DU::Schema::Candy;
use parent 'DBIx::Class::Candy';
sub base { 'DU::Schema::Result' }
-sub perl_version { 14 }
+sub perl_version { 16 }
sub autotable { 1 }
1;
View
2 lib/DU/Schema/Result.pm
@@ -1,6 +1,6 @@
package DU::Schema::Result;
-use strict;
+use 5.16.1;
use warnings;
use parent 'DBIx::Class::Core';
View
2 lib/DU/Schema/ResultSet/Drink.pm
@@ -1,6 +1,6 @@
package DU::Schema::ResultSet::Drink;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'DU::Schema::ResultSet';
View
2 lib/DU/Schema/ResultSet/Ingredient.pm
@@ -1,6 +1,6 @@
package DU::Schema::ResultSet::Ingredient;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'DU::Schema::ResultSet';
View
2 lib/DU/Schema/ResultSet/InventoryItem.pm
@@ -1,6 +1,6 @@
package DU::Schema::ResultSet::InventoryItem;
-use 5.14.1;
+use 5.16.1;
use warnings;
use parent 'DU::Schema::ResultSet';
View
2 lib/DU/Util.pm
@@ -1,6 +1,6 @@
package DU::Util;
-use 5.14.1;
+use 5.16.1;
use warnings;
use Sub::Exporter::Progressive -setup => {
View
3 lib/DU/WebApp.pm
@@ -1,7 +1,10 @@
#!/usr/bin/env perl
package DU::WebApp;
+
+use 5.16.1;
use Web::Simple;
+
use DU::WebApp::Machine;
use Config::ZOMG;
use Path::Class::File;
View
2 t/editors/drink-edit-1
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
my $file = shift;
View
2 t/editors/drink-new-1
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
my $file = shift;
View
2 t/editors/drink-new-2
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
my $file = shift;
View
2 t/editors/drink-new-based-on
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use YAML qw(LoadFile DumpFile);
use warnings;
View
2 t/editors/ingredient-edit-1
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
my $file = shift;
View
2 t/editors/ingredient-edit-2
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
my $file = shift;
View
2 t/editors/ingredient-new-1
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
my $file = shift;
View
2 t/editors/ingredient-new-2
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
my $file = shift;
View
2 t/integration/app/drink.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;
View
2 t/integration/app/help.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;
View
2 t/integration/app/ingredient.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;
View
2 t/integration/app/inventory.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;
View
2 t/integration/app/maint.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;
View
2 t/lib/A.pm
@@ -1,6 +1,6 @@
package A;
-use 5.14.1;
+use 5.16.1;
use warnings;
use Data::Dumper::Concise;
View
2 t/schema.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;
View
2 t/unit/util.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;
View
2 xt/profile.t
@@ -1,4 +1,4 @@
-use 5.14.1;
+use 5.16.1;
use warnings;
use Test::More;

0 comments on commit ab86d5c

Please sign in to comment.
Something went wrong with that request. Please try again.