| 1 | package Treex::Core::Config; | ||||||||||||||||||||||||||||
| 2 | 75 | $Treex::Core::Config::VERSION = '2.20210102'; | |||||||||||||||||||||||||||
| 3 | 75 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 75 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 75 | ▶ | use 5.010; # operator // | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 75 | ▶ | use File::HomeDir 0.97; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 75 | ▶ | use File::ShareDir; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 75 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 75 | ▶ | use File::Slurp 9999; # prior versions had different interface | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 75 | ▶ | use Cwd qw(realpath); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 75 | ▶ | use Treex::Core::Log; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 75 | ▶ | use Treex::Core::Loader 'load_module'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 75 | ▶ | use YAML 0.72 qw(LoadFile DumpFile); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # this should be somehow systematized, since there will be probably many switches like this one | ||||||||||||||||||||||||||||
| 17 | 75 | our $debug_run_jobs_locally; ## no critic (ProhibitPackageVars) | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # 0: Treex::Core::Common::pos_validated_list() called if params needed, skipped otherwise | ||||||||||||||||||||||||||||
| 20 | # 1: Treex::Core::Common::pos_validated_list() called always | ||||||||||||||||||||||||||||
| 21 | # 2: MooseX::Params::Validate::pos_validated_list called always | ||||||||||||||||||||||||||||
| 22 | 75 | our $params_validate = 0; ## no critic (ProhibitPackageVars) | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 75 | my $config = __PACKAGE__->_load_config(); | |||||||||||||||||||||||||||
| 25 | 75 | my $dirty = 0; #indicates that configuration has changed. N/A yet, no method changes config to something else than default | |||||||||||||||||||||||||||
| 26 | 75 | my $running_in_tred; ## no critic (ProhibitUnusedVariables) | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 75 | ▶ | sub _load_config { | ||||||||||||||||||||||||||
|
Subroutine
_load_config: called CC=4 SCAR=19.4
| |||||||||||||||||||||||||||||
| 29 | 75 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | 75 | my %args = @_; | |||||||||||||||||||||||||||
| 31 | 75 | ▶ | my $from = $args{from} // $self->config_file(); #/ | ||||||||||||||||||||||||||
|
Condition33%1/3
$args{"from"} // $self->config_file
MC/DC0%0/2
$args{"from"} // $self->config_file
$args{"from"}
$self->config_file
Truth table33%1/3
A // B
A= $args{"from"}B= $self->config_file
| |||||||||||||||||||||||||||||
| 32 | 75 | ▶ | return {} if !-e $from; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | my $yaml = read_file( $from, { err_mode => 'quiet' } ); | |||||||||||||||||||||||||||
| 34 | 0 | my $toReturn = YAML::Load($yaml); | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | return $toReturn // {}; #rather than undef return empty hashref | ||||||||||||||||||||||||||
|
Condition0%0/2
$toReturn // {}
MC/DC0%0/1
$toReturn // {}
$toReturn
Truth table0%0/2
A
A= $toReturn
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 75 | ▶ | sub _save_config { | ||||||||||||||||||||||||||
|
Subroutine
_save_config: called CC=6 SCAR=24.7
| |||||||||||||||||||||||||||||
| 39 | 75 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 75 | my %args = @_; | |||||||||||||||||||||||||||
| 41 | 75 | ▶ | my $to = $args{to} // $self->config_file(); #/ | ||||||||||||||||||||||||||
|
Condition33%1/3
$args{"to"} // $self->config_file
MC/DC0%0/2
$args{"to"} // $self->config_file
$args{"to"}
$self->config_file
Truth table33%1/3
A // B
A= $args{"to"}B= $self->config_file
| |||||||||||||||||||||||||||||
| 42 | 75 | ▶ | return if ( -e $to && !$dirty ); #skip when config file already exists and no changes made from this run of treex so we won't overwrite existing configuration | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e $to and not $dirty
MC/DC0%0/2
-e $to and not $dirty
-e $to
not $dirty
Truth table33%1/3
A and not(B)
A= -e $toB= not $dirty
| |||||||||||||||||||||||||||||
| 43 | 75 | ▶ | return if ( !scalar %{$config} ); #skip when config is empty | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | eval { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | DumpFile( $to, $config ); | |||||||||||||||||||||||||||
| 46 | 0 | 1; | |||||||||||||||||||||||||||
| 47 | } or log_warn(qq(Couldn't save config file $to)); | ||||||||||||||||||||||||||||
| 48 | 0 | return; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 74 | ▶ | END { | ||||||||||||||||||||||||||
|
Subroutine
END: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | 74 | __PACKAGE__->_save_config(); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 150 | ▶ | sub config_dir { | ||||||||||||||||||||||||||
|
Subroutine
config_dir: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 150 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | 150 | ▶ | my $dirname = $ENV{TREEX_CONFIG} // File::Spec->catdir( File::HomeDir->my_home(), '.treex' ); #/ # if evironment variable not set defaults to ~/.treex | ||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{"TREEX_CONFIG"} // "File::Spec"->catdir("File::HomeDir"->my_home, ".treex")
MC/DC0%0/2
$ENV{"TREEX_CONFIG"} // "File::Spec"->catdir("File::HomeDir"->my_home, ".treex")
$ENV{"TREEX_CONFIG"}
"File::Spec"->catdir("File::HomeDir"->my_home, ".treex")
Truth table33%1/3
A // B
A= $ENV{"TREEX_CONFIG"}B= "File::Spec"->catdir("File::HomeDir"->my_home, ".treex")
| |||||||||||||||||||||||||||||
| 58 | 150 | ▶ | if ( !-e $dirname ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 1 | mkdir $dirname; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 150 | ▶ | if ( -d $dirname ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 150 | return $dirname; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||
| 65 | 0 | return File::HomeDir->my_dist_config( 'Treex-Core', { create => 1 } ); #last fallback, hidden somewhere under ~/.local directory | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 150 | ▶ | sub config_file { | ||||||||||||||||||||||||||
|
Subroutine
config_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 70 | 150 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | 150 | return File::Spec->catfile( $self->config_dir(), 'config.yaml' ); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub _default_resource_path { | ||||||||||||||||||||||||||
|
Subroutine
_default_resource_path: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 76 | 0 | my @path; | |||||||||||||||||||||||||||
| 77 | 0 | push @path, File::Spec->catdir( $self->config_dir(), 'share' ); | |||||||||||||||||||||||||||
| 78 | 0 | push @path, File::HomeDir->my_dist_data( 'Treex-Core', { create => 0 } ); | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ( defined $ENV{TMT_ROOT} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | push @path, File::Spec->catdir( $ENV{TMT_ROOT}, 'share' ); | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return @path if wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | return \@path; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub resource_path { | ||||||||||||||||||||||||||
|
Subroutine
resource_path: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 87 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 88 | 0 | my @path; | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( defined $config->{resource_path} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | @path = @{ $config->{resource_path} }; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||
| 93 | 0 | @path = $self->_default_resource_path(); | |||||||||||||||||||||||||||
| 94 | 0 | $config->{resource_path} = \@path; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | 0 | ▶ | return @path if wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | return \@path; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 66 | ▶ | sub _devel_version { | ||||||||||||||||||||||||||
|
Subroutine
_devel_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | 66 | my $self = shift; | |||||||||||||||||||||||||||
| 102 | 66 | return -d $self->lib_core_dir() . "/share/"; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # to je otazka, jak to co nejelegantneji poznat, ze jde o work.copy. a ne nainstalovanou distribuci | ||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub share_dir { | ||||||||||||||||||||||||||
|
Subroutine
share_dir: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 108 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( defined $config->{share_dir} && defined realpath( $config->{share_dir} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $config->{"share_dir"} and defined realpath($config->{"share_dir"})
MC/DC0%0/2
defined $config->{"share_dir"} and defined realpath($config->{"share_dir"})
defined $config->{"share_dir"}
defined realpath($config->{"share_dir"})
Truth table0%0/3
A and B
A= defined $config->{"share_dir"}B= defined realpath($config->{"share_dir"})
| |||||||||||||||||||||||||||||
| 110 | 0 | return $config->{share_dir}; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||
| 113 | 0 | delete $config->{share_dir}; | |||||||||||||||||||||||||||
| 114 | 0 | my $share_dir; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | # return File::HomeDir->my_home."/.treex/share"; # future solution, probably symlink | ||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ( $self->_devel_version() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 0 | $share_dir = realpath( $self->lib_core_dir() . "/../../../../share/" ); # default on UFAL machines | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||
| 121 | 0 | $share_dir = File::Spec->catdir( $self->config_dir(), 'share' ); # by default take ~/.treex/share | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | #$config->{share_dir} = $share_dir; | ||||||||||||||||||||||||||||
| 125 | 0 | return $share_dir; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub share_url { | ||||||||||||||||||||||||||
|
Subroutine
share_url: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 131 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ( !defined $config->{share_url} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 0 | $config->{share_url} = 'http://ufallab.ms.mff.cuni.cz/tectomt/share'; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | 0 | return $config->{share_url}; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub tred_dir { | ||||||||||||||||||||||||||
|
Subroutine
tred_dir: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 139 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ( !defined $config->{tred_dir} || !defined realpath( $config->{tred_dir} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $config->{"tred_dir"} and defined realpath($config->{"tred_dir"})
MC/DC0%0/2
defined $config->{"tred_dir"} and defined realpath($config->{"tred_dir"})
defined $config->{"tred_dir"}
defined realpath($config->{"tred_dir"})
Truth table0%0/3
A and B
A= defined $config->{"tred_dir"}B= defined realpath($config->{"tred_dir"})
| |||||||||||||||||||||||||||||
| 141 | 0 | delete $config->{tred_dir}; | |||||||||||||||||||||||||||
| 142 | 0 | return realpath( File::Spec->catdir( $self->share_dir(), 'tred' ) ); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | return $config->{tred_dir}; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 66 | ▶ | sub pml_schema_dir { | ||||||||||||||||||||||||||
|
Subroutine
pml_schema_dir: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 66 | my $self = shift; | |||||||||||||||||||||||||||
| 149 | 66 | ▶ | if ( !defined $config->{pml_schema_dir} || !defined realpath( $config->{pml_schema_dir} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $config->{"pml_schema_dir"} and defined realpath($config->{"pml_schema_dir"})
MC/DC0%0/2
defined $config->{"pml_schema_dir"} and defined realpath($config->{"pml_schema_dir"})
defined $config->{"pml_schema_dir"}
defined realpath($config->{"pml_schema_dir"})
Truth table33%1/3
A and B
A= defined $config->{"pml_schema_dir"}B= defined realpath($config->{"pml_schema_dir"})
| |||||||||||||||||||||||||||||
| 150 | 66 | delete $config->{pml_schema_dir}; | |||||||||||||||||||||||||||
| 151 | 66 | ▶ | if ( $self->_devel_version() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | #$config->{pml_schema_dir} = realpath( $self->lib_core_dir() . "/share/tred_extension/treex/resources/" ); | ||||||||||||||||||||||||||||
| 154 | 0 | return realpath( $self->lib_core_dir() . "/share/tred_extension/treex/resources/" ); | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | else { | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | #$config->{pml_schema_dir} = realpath( File::ShareDir::dist_dir('Treex-Core') . "/tred_extension/treex/resources/" ); #that's different share than former TMT_SHARE | ||||||||||||||||||||||||||||
| 159 | 66 | return realpath( File::Spec->catdir( File::ShareDir::dist_dir('Treex-Core'), qw(tred_extension treex resources) ) ); #that's different share than former TMT_SHARE | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | 0 | return $config->{pml_schema_dir}; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub tred_extension_dir { | ||||||||||||||||||||||||||
|
Subroutine
tred_extension_dir: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ( !defined $config->{tred_extension_dir} || !defined realpath( $config->{tred_extension_dir} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $config->{"tred_extension_dir"} and defined realpath($config->{"tred_extension_dir"})
MC/DC0%0/2
defined $config->{"tred_extension_dir"} and defined realpath($config->{"tred_extension_dir"})
defined $config->{"tred_extension_dir"}
defined realpath($config->{"tred_extension_dir"})
Truth table0%0/3
A and B
A= defined $config->{"tred_extension_dir"}B= defined realpath($config->{"tred_extension_dir"})
| |||||||||||||||||||||||||||||
| 168 | 0 | delete $config->{tred_extension_dir}; | |||||||||||||||||||||||||||
| 169 | 0 | return realpath( File::Spec->catdir( $self->pml_schema_dir(), q(..), q(..) ) ); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | 0 | return $config->{tred_extension_dir}; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 66 | ▶ | sub lib_core_dir { | ||||||||||||||||||||||||||
|
Subroutine
lib_core_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 175 | 66 | my $self = shift; | |||||||||||||||||||||||||||
| 176 | 66 | return realpath( $self->_caller_dir() ); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 1 | ▶ | sub tmp_dir { | ||||||||||||||||||||||||||
|
Subroutine
tmp_dir: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||
| 180 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 181 | 1 | ▶ | if ( !defined $config->{tmp_dir} || !defined realpath( $config->{tmp_dir} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $config->{"tmp_dir"} and defined realpath($config->{"tmp_dir"})
MC/DC0%0/2
defined $config->{"tmp_dir"} and defined realpath($config->{"tmp_dir"})
defined $config->{"tmp_dir"}
defined realpath($config->{"tmp_dir"})
Truth table33%1/3
A and B
A= defined $config->{"tmp_dir"}B= defined realpath($config->{"tmp_dir"})
| |||||||||||||||||||||||||||||
| 182 | 1 | delete $config->{tmp_dir}; | |||||||||||||||||||||||||||
| 183 | 1 | return $self->_default_tmp_dir(); | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | 0 | return $config->{tmp_dir}; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub treex_server_url { | ||||||||||||||||||||||||||
|
Subroutine
treex_server_url: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 189 | return exists $ENV{TREEX_SERVER_URL} ? | ||||||||||||||||||||||||||||
| 190 | 0 | ▶ | $ENV{TREEX_SERVER_URL} : $config->{treex_server_url} || 'tcp://127.0.0.1:7338'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$config->{"treex_server_url"} or "tcp://127.0.0.1:7338"
MC/DC0%0/1
$config->{"treex_server_url"} or "tcp://127.0.0.1:7338"
$config->{"treex_server_url"}
Truth table0%0/2
A
A= $config->{"treex_server_url"}
| |||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub use_services { | ||||||||||||||||||||||||||
|
Subroutine
use_services: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | return $ENV{USE_SERVICES} if defined $ENV{USE_SERVICES}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ($config->{use_services}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $config->{use_services} = 0 unless load_module('Treex::Service::Role'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return $config->{use_services} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$config->{'use_services'} || 0
MC/DC0%0/1
$config->{'use_services'} || 0
$config->{'use_services'}
Truth table0%0/2
A
A= $config->{'use_services'}
| |||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 1 | ▶ | sub _default_tmp_dir { | ||||||||||||||||||||||||||
|
Subroutine
_default_tmp_dir: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||
| 204 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 205 | 1 | my $dot_treex = File::HomeDir->my_dist_data( 'Treex-Core', { create => 1 } ); | |||||||||||||||||||||||||||
| 206 | 1 | my $suffix = 'tmp'; | |||||||||||||||||||||||||||
| 207 | 1 | my $tmp_dir = File::Spec->catdir( $dot_treex, $suffix ); | |||||||||||||||||||||||||||
| 208 | 1 | ▶ | if ( !-e $tmp_dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 1 | ▶ | mkdir $tmp_dir or log_fatal("Cannot create temporary directory"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | 1 | return $tmp_dir; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 66 | ▶ | sub _caller_dir { | ||||||||||||||||||||||||||
|
Subroutine
_caller_dir: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 215 | 66 | my $self = shift; | |||||||||||||||||||||||||||
| 216 | 66 | my %call_info; | |||||||||||||||||||||||||||
| 217 | @call_info{ | ||||||||||||||||||||||||||||
| 218 | 66 | qw(pack file line sub has_args wantarray evaltext is_require) | |||||||||||||||||||||||||||
| 219 | } = caller(0); | ||||||||||||||||||||||||||||
| 220 | 66 | $call_info{file} =~ s/[^\/]+$//; | |||||||||||||||||||||||||||
| 221 | 66 | return $call_info{file}; | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 75 | 1; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | __END__ | ||||||||||||||||||||||||||||