Rapi-Demo-CrudModes
view release on metacpan or search on metacpan
lib/Rapi/Demo/CrudModes.pm view on Meta::CPAN
},
'Controller::SimpleCAS' => {
store_path => $self->cas_store_dir
},
'Model::RapidApp::CoreSchema' => {
sqlite_file => file( $self->coreschema_db )->absolute->stringify
}
}
}
has 'share_dir', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
$ENV{RAPI_DEMO_CRUDMODES_SHARE_DIR} || (
try{dist_dir('Rapi-Demo-CrudModes')} || (
-d "$FindBin::Bin/share" ? "$FindBin::Bin/share" : "$FindBin::Bin/../share"
)
)
};
has 'data_dir', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
# Default to the cwd
dir( cwd(), 'crudmodes_data')->stringify;
};
has 'crudmodes_db', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
file( $self->data_dir, 'crudmodes.db' )->stringify
};
has 'cas_store_dir', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
dir( $self->data_dir, 'cas_store' )->stringify
};
# Set to true to force init the local data dir on every startup,
# even if it already exists (DANGEROUS!)
has 'clear_data_dir', is => 'ro', isa => Bool, default => sub {0};
has 'coreschema_db', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
file( $self->data_dir, 'crudmodes_coreschema.db' )->stringify
};
has 'cas_store_dir', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
dir( $self->data_dir, 'cas_store' )->stringify
};
has 'local_template_dir', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
dir( $self->data_dir, 'templates' )->stringify
};
has '_template_include_paths', is => 'ro', lazy => 1, default => sub {
my $self = shift;
# overlay local, writable templates with installed,
# read-only templates installed in the share dir
return [ $self->local_template_dir, $self->_tpl_dir ];
}, isa => ArrayRef[Str];
has '_assets_dir', is => 'ro', lazy => 1, default => sub {
my $self = shift;
my $loc_assets_dir = join('/',$self->share_dir,'assets');
-d $loc_assets_dir or die join('',
"assets dir ($loc_assets_dir) not found; ",
__PACKAGE__, " may not be installed properly.\n"
);
return $loc_assets_dir;
}, isa => Str;
has '_tpl_dir', is => 'ro', lazy => 1, default => sub {
my $self = shift;
my $tpl_dir = join('/',$self->share_dir,'templates');
-d $tpl_dir or die join('',
"template dir ($tpl_dir) not found; ",
__PACKAGE__, " may not be installed properly.\n"
);
return $tpl_dir;
}, isa => Str;
has '_init_data_dir', is => 'ro', isa => Str, lazy => 1, default => sub {
my $self = shift;
dir( $self->share_dir, '_init_data_dir' )->stringify
}, init_arg => undef;
has '+inject_components', default => sub {
my $self = shift;
my $model = 'Rapi::Demo::CrudModes::Model::DB';
my $db = file( $self->crudmodes_db );
Module::Runtime::require_module($model);
$model->config->{connect_info}{dsn} = "dbi:SQLite:$db";
return [
[ $model => 'Model::DB' ]
]
};
after 'bootstrap' => sub {
my $self = shift;
my $c = $self->appname;
$c->model('DB')->_auto_deploy_schema
};
sub _init_local_data {
my ($self, $ovr) = @_;
( run in 2.616 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )