| 1 | package JiftyX::Fixtures; | ||
| 2 | our $VERSION = '0.07'; | ||
| 3 | |||
| 4 | # ABSTRACT: Insert fixtures into your Jifty application database | ||
| 5 | |||
| 6 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 2 | ▶ | use UNIVERSAL::dump; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 0 | ▶ | use Jifty; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 12 | use Jifty::Everything; | ||
| 13 | use Jifty::Util; | ||
| 14 | |||
| 15 | use YAML qw(Dump LoadFile); | ||
| 16 | |||
| 17 | use JiftyX::Fixtures::Script; | ||
| 18 | |||
| 19 | sub new { | ||
| 20 | my $self = bless {}, shift; | ||
| 21 | |||
| 22 | $self->{config}->{app_root} = Jifty::Util->app_root; | ||
| 23 | $self->{config}->{framework} = Jifty->config->stash->{framework}; | ||
| 24 | |||
| 25 | my $fixtures_config = $self->{config}->{app_root} . "/etc/fixtures.yml"; | ||
| 26 | $self->{config}->{fixtures} = LoadFile($fixtures_config) if (-e $fixtures_config); | ||
| 27 | |||
| 28 | $self; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub config { | ||
| 32 | my ($self, $type, $args) = @_; | ||
| 33 | if ($args) { | ||
| 34 | $self->{config}->{$type} = $args; | ||
| 35 | $self; | ||
| 36 | } else { | ||
| 37 | $self->{config}->{$type}; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | sub run { | ||
| 42 | my ($self, $subcommand) = @_; | ||
| 43 | $subcommand ||= "load"; | ||
| 44 | unshift @ARGV, $subcommand unless defined($ARGV[0]); | ||
| 45 | JiftyX::Fixtures::Script->dispatch( config => $self->{config} ); | ||
| 46 | } | ||
| 47 | |||
| 48 | |||
| 49 | 1; | ||
| 50 | |||
| 51 | |||
| 52 | __END__ | ||