| File: | lib/Railsish/Bootstrap.pm |
| Coverage: | 76.3% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Railsish::Bootstrap; | ||||||
| 2 | # ABSTRACT: Wuu huu huu | ||||||
| 3 | |||||||
| 4 | 2 2 2 | 17 7 19 | use strict; | ||||
| 5 | 2 2 2 | 20 5 16 | use warnings; | ||||
| 6 | 2 2 2 | 83 6 24 | use Railsish::CoreHelpers; | ||||
| 7 | 2 2 2 | 21 6 51 | use File::Spec::Functions; | ||||
| 8 | 2 2 2 | 101 7 29 | use Railsish::Router; | ||||
| 9 | |||||||
| 10 | sub import { | ||||||
| 11 | 2 6 | 10 29 | my @dir = map { catdir(app_root, "app", $_ ) } qw(controllers helpers models); | ||||
| 12 | 2 | 44 | unshift @INC, @dir; | ||||
| 13 | } | ||||||
| 14 | |||||||
| 15 | sub load_configs { | ||||||
| 16 | 1 | 0 | 9 | my $routes = app_root(config => "routes.pl"); | |||
| 17 | 1 | 506 | require $routes or die "Failed to load $routes"; | ||||
| 18 | } | ||||||
| 19 | |||||||
| 20 | 2 2 2 | 160 10 28 | use Module::Loaded; | ||||
| 21 | 2 2 2 | 154 9 24 | use Class::Implant; | ||||
| 22 | sub load_controllers { | ||||||
| 23 | 1 | 0 | 7 | my $app_root = app_root; | |||
| 24 | 1 | 17 | my @controllers = glob("\Q${app_root}\E/app/controllers/*.pm"); | ||||
| 25 | 1 | 519 | for(@controllers) { | ||||
| 26 | 3 | 250 | require $_ or die "Failed to load $_\n"; | ||||
| 27 | 3 | 40 | my $helper = $_ =~ s/Controller/Helpers/; | ||||
| 28 | 3 | 20 | if ( is_loaded($helper) ) { | ||||
| 29 | 0 | implant $helper, { into => $_ }; | |||||
| 30 | } | ||||||
| 31 | } | ||||||
| 32 | } | ||||||
| 33 | |||||||
| 34 | sub load_helpers { | ||||||
| 35 | 0 | 0 | my $app_root = app_root; | ||||
| 36 | 0 | my @helpers = glob("\Q${app_root}\E/app_root/helpers/*.pm"); | |||||
| 37 | 0 | for (@helpers) { | |||||
| 38 | 0 | require $_ or die "Failed to load $_, $!\n"; | |||||
| 39 | } | ||||||
| 40 | } | ||||||
| 41 | |||||||
| 42 | 1; | ||||||
| 43 | |||||||
| 44 - 48 | =head1 DESCRIPTION This class reads application configurations. =cut | ||||||
| 49 | |||||||