| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Farly; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 11 |  |  | 11 |  | 132994 | use 5.008008; | 
|  | 11 |  |  |  |  | 38 |  | 
|  | 11 |  |  |  |  | 6400 |  | 
| 4 | 11 |  |  | 11 |  | 58 | use strict; | 
|  | 11 |  |  |  |  | 18 |  | 
|  | 11 |  |  |  |  | 322 |  | 
| 5 | 11 |  |  | 11 |  | 55 | use warnings; | 
|  | 11 |  |  |  |  | 19 |  | 
|  | 11 |  |  |  |  | 1439 |  | 
| 6 | 11 |  |  | 11 |  | 53 | use Carp; | 
|  | 11 |  |  |  |  | 22 |  | 
|  | 11 |  |  |  |  | 1083 |  | 
| 7 | 11 |  |  | 11 |  | 9685 | use IO::File; | 
|  | 11 |  |  |  |  | 126266 |  | 
|  | 11 |  |  |  |  | 1474 |  | 
| 8 | 11 |  |  | 11 |  | 98 | use File::Spec; | 
|  | 11 |  |  |  |  | 22 |  | 
|  | 11 |  |  |  |  | 283 |  | 
| 9 | 11 |  |  | 11 |  | 10863 | use Log::Any qw($log); | 
|  | 11 |  |  |  |  | 25674 |  | 
|  | 11 |  |  |  |  | 52 |  | 
| 10 | 11 |  |  | 11 |  | 6658 | use Farly::Director; | 
|  | 11 |  |  |  |  | 38 |  | 
|  | 11 |  |  |  |  | 343 |  | 
| 11 | 11 |  |  | 11 |  | 6419 | use Farly::Object; | 
|  | 11 |  |  |  |  | 38 |  | 
|  | 11 |  |  |  |  | 4815 |  | 
| 12 |  |  |  |  |  |  | require Time::HiRes; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | our $VERSION = '0.26'; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub new { | 
| 17 | 5 |  |  | 5 | 1 | 522 | my ( $class, $container ) = @_; | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 5 |  |  |  |  | 50 | my $self = { DIRECTOR => Farly::Director->new(), }; | 
| 20 | 5 |  |  |  |  | 20 | bless $self, $class; | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 5 |  |  |  |  | 42 | $log->info("$self NEW"); | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 5 |  |  |  |  | 21 | return $self; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | sub director { | 
| 28 | 15 |  |  | 15 | 0 | 98 | return $_[0]->{DIRECTOR}; | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub process { | 
| 32 | 5 |  |  | 5 | 1 | 40 | my ( $self, $type, $file_name ) = @_; | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 5 | 50 |  |  |  | 215 | croak "$file_name is not a file" unless ( -f $file_name ); | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 5 |  |  |  |  | 20 | my $location      = "Farly/$type/Builder.pm"; | 
| 37 | 5 |  |  |  |  | 26 | my $builder_class = 'Farly::'.$type.'::Builder'; | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 5 |  |  |  |  | 3602 | require $location; | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 5 |  |  |  |  | 41 | my $builder = $builder_class->new(); | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 5 |  |  |  |  | 43 | my $file = IO::File->new($file_name); | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 5 |  |  |  |  | 533 | $self->director()->set_file($file); | 
| 46 | 5 |  |  |  |  | 25 | $self->director()->set_builder($builder); | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 5 |  |  |  |  | 73 | my $start = [ Time::HiRes::gettimeofday() ]; | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 5 |  |  |  |  | 13 | my $container; | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 5 |  |  |  |  | 9 | eval { $container = $self->director()->run(); }; | 
|  | 5 |  |  |  |  | 16 |  | 
| 53 | 5 | 50 |  |  |  | 35 | if ($@) { | 
| 54 | 0 |  |  |  |  | 0 | die "Import of $file_name failed\n", $@, "\n"; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 5 |  |  |  |  | 41 | my $elapsed = Time::HiRes::tv_interval($start); | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 5 |  |  |  |  | 218 | $log->info("parse time: $elapsed seconds"); | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 5 |  |  |  |  | 52 | $log->info( "imported " . $container->size() . " objects" ); | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 5 |  |  |  |  | 48 | return $container; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | 1; | 
| 67 |  |  |  |  |  |  | __END__ |