JiftyX::Fixtures - Insert fixtures into your Jifty application database


JiftyX-Fixtures documentation Contained in the JiftyX-Fixtures distribution.

Index


Code Index:

NAME

Top

JiftyX::Fixtures - Insert fixtures into your Jifty application database

VERSION

Top

version 0.07

SYNOPSIS

Top

    JiftyX::Fixtures->new->config(
      fixtures => [
        development => {
          dir => "etc/fixtures/development"
        }
      ]
    )->run;

DESCRIPTION

Top

    WARNING: This software is stil in alpha stage, any intense variation is possible.

Load pre-defined fixture from specified mode, and Insert it into you Jifty application database.

AUTHOR

Top

  shelling <shelling@cpan.org>

COPYRIGHT AND LICENSE

Top

METHODS

Top

new

Constructor, invoke without args

config

Give one arg which is selected from "app_root", "framework", "fixtures" to get the configuration detail.

Append second arg to set the configuration.

    $jf->config("fixtures"); #=> [  development => { dir => "etc/fixtures/development" }, 
                                    test => { dir => "etc/fixtures/test" } ]
    $jf->config(
      fixtures => [
        development => {
          dir => "etc/dev_fixtures"
        },
        test => {
          dir => "etc/test_fixtures"
        }
      ]
    );

run

Running subcommand, default is "load". Give one arg to specify which subcommand would be run.


JiftyX-Fixtures documentation Contained in the JiftyX-Fixtures distribution.

package JiftyX::Fixtures;
our $VERSION = '0.07';

# ABSTRACT: Insert fixtures into your Jifty application database

use strict;
use warnings;

use UNIVERSAL::dump;

use Jifty;
use Jifty::Everything;
use Jifty::Util;

use YAML qw(Dump LoadFile);

use JiftyX::Fixtures::Script;

sub new {
  my $self = bless {}, shift;

  $self->{config}->{app_root}   = Jifty::Util->app_root;
  $self->{config}->{framework}  = Jifty->config->stash->{framework};

  my $fixtures_config = $self->{config}->{app_root} . "/etc/fixtures.yml";
  $self->{config}->{fixtures}   = LoadFile($fixtures_config) if (-e $fixtures_config);

  $self;
}

sub config {
  my ($self, $type, $args) = @_;
  if ($args) {
    $self->{config}->{$type} = $args;
    $self;
  } else {
    $self->{config}->{$type};
  }
}

sub run { 
  my ($self, $subcommand) = @_;
  $subcommand ||= "load";
  unshift @ARGV, $subcommand unless defined($ARGV[0]);
  JiftyX::Fixtures::Script->dispatch( config => $self->{config} );
}
  

1;


__END__