| 1 | package Wrangler::Config; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Cwd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use JSON::XS (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use File::HomeDir; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Data::Dumper (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Digest::MD5 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # Wx::PlatformInfo; # check for unicode build | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | our %default_settings = ( | |||||||||||||||||||||||||||
| 16 | 'ui.main.width' => 1000, | ||||||||||||||||||||||||||||
| 17 | 'ui.main.height' => 800, | ||||||||||||||||||||||||||||
| 18 | 'ui.main.maximized' => 0, | ||||||||||||||||||||||||||||
| 19 | 'ui.main.centered' => 1, | ||||||||||||||||||||||||||||
| 20 | 'ui.language' => 'en', | ||||||||||||||||||||||||||||
| 21 | 'ui.foreground_colour' => [30, 30, 30], # font-colour, def, if-undefined = use-system/wx-default | ||||||||||||||||||||||||||||
| 22 | 'ui.layout.menubar' => 1, | ||||||||||||||||||||||||||||
| 23 | 'ui.layout.navbar' => 1, | ||||||||||||||||||||||||||||
| 24 | 'ui.layout.sidebar' => 1, | ||||||||||||||||||||||||||||
| 25 | 'ui.layout.statusbar' => 1, | ||||||||||||||||||||||||||||
| 26 | 'ui.sidebar.width' => 180, | ||||||||||||||||||||||||||||
| 27 | 'ui.filebrowser.include_updir' => 1, # def:1 | ||||||||||||||||||||||||||||
| 28 | 'ui.filebrowser.include_hidden' => 0, # def:0 | ||||||||||||||||||||||||||||
| 29 | 'ui.filebrowser.zebra_striping' => 1, # def:1 | ||||||||||||||||||||||||||||
| 30 | 'ui.filebrowser.highlight_media' => 1, # def 1 | ||||||||||||||||||||||||||||
| 31 | 'ui.filebrowser.highlight_colour.audio' => [220, 220, 240], # def | ||||||||||||||||||||||||||||
| 32 | 'ui.filebrowser.highlight_colour.image' => [220, 240, 220], # def | ||||||||||||||||||||||||||||
| 33 | 'ui.filebrowser.highlight_colour.video' => [240, 220, 220], # def | ||||||||||||||||||||||||||||
| 34 | 'ui.filebrowser.font_size' => 9, # def 9 | ||||||||||||||||||||||||||||
| 35 | 'ui.filebrowser.offer.delete' => 1, | ||||||||||||||||||||||||||||
| 36 | 'ui.filebrowser.confirm.delete' => 1, | ||||||||||||||||||||||||||||
| 37 | 'ui.filebrowser.columns' => [ | ||||||||||||||||||||||||||||
| 38 | { label => 'Name', value_from => 'Filesystem::Filename', text_align => 'left', width => 120 }, | ||||||||||||||||||||||||||||
| 39 | { label => 'Type-Description', value_from => 'MIME::Description', text_align => 'right', width => 100 }, | ||||||||||||||||||||||||||||
| 40 | { label => 'Modified', value_from => 'Filesystem::Modified', text_align => 'left', width => 140 }, | ||||||||||||||||||||||||||||
| 41 | { label => 'Size', value_from => 'Filesystem::Size', text_align => 'right', width => 70 }, | ||||||||||||||||||||||||||||
| 42 | ], | ||||||||||||||||||||||||||||
| 43 | 'metadata.extractionTimeout' => 1500, # in ms | ||||||||||||||||||||||||||||
| 44 | 'ui.formeditor.selected' => "Photo 'tagging'", | ||||||||||||||||||||||||||||
| 45 | 'ui.formeditor' => { | ||||||||||||||||||||||||||||
| 46 | "Photo 'tagging'" => [ | ||||||||||||||||||||||||||||
| 47 | "Filesystem::Filename", | ||||||||||||||||||||||||||||
| 48 | "Extended Attributes::orientation", | ||||||||||||||||||||||||||||
| 49 | "Extended Attributes::title", | ||||||||||||||||||||||||||||
| 50 | "Extended Attributes::description", | ||||||||||||||||||||||||||||
| 51 | "Extended Attributes::tags", | ||||||||||||||||||||||||||||
| 52 | ] | ||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||
| 54 | 'openwith' => { | ||||||||||||||||||||||||||||
| 55 | 'image/*' => '/usr/bin/eog', | ||||||||||||||||||||||||||||
| 56 | 'audio/*' => '/usr/bin/avplay', | ||||||||||||||||||||||||||||
| 57 | 'video/*' => '/usr/bin/avplay', | ||||||||||||||||||||||||||||
| 58 | 'text/*' => '/usr/bin/gedit', | ||||||||||||||||||||||||||||
| 59 | }, | ||||||||||||||||||||||||||||
| 60 | 'valueshortcuts' => { | ||||||||||||||||||||||||||||
| 61 | '1-49' => { | ||||||||||||||||||||||||||||
| 62 | name => "ALT+1", | ||||||||||||||||||||||||||||
| 63 | key => "Extended Attributes::orientation", | ||||||||||||||||||||||||||||
| 64 | value => "Rotate 270 CW", | ||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||
| 66 | '1-50' => { | ||||||||||||||||||||||||||||
| 67 | name => "ALT+2", | ||||||||||||||||||||||||||||
| 68 | key => "Extended Attributes::orientation", | ||||||||||||||||||||||||||||
| 69 | value => "Rotate 90 CW", | ||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||
| 71 | }, | ||||||||||||||||||||||||||||
| 72 | 'plugins' => { | ||||||||||||||||||||||||||||
| 73 | 'ColourLabels' => 1, | ||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | 1 | our %settings; | |||||||||||||||||||||||||||
| 77 | 1 | our $digest; | |||||||||||||||||||||||||||
| 78 | 1 | our %env; | |||||||||||||||||||||||||||
| 79 | 1 | ▶ | if($^O =~ /Win/i){ | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 80 | 0 | $env{HostOS} = 'Windows'; | |||||||||||||||||||||||||||
| 81 | 0 | $env{PathSeparator} = '\\'; | |||||||||||||||||||||||||||
| 82 | 0 | $env{CRLF} = "\n"; | |||||||||||||||||||||||||||
| 83 | 0 | $env{HelperFfmpeg} = Cwd::getcwd()."/helpers/ffmpeg-shared/ffmpeg.exe"; | |||||||||||||||||||||||||||
| 84 | 0 | $env{HelperMPlayer} = Cwd::getcwd()."/helpers/mplayer/mplayer.exe"; | |||||||||||||||||||||||||||
| 85 | 0 | $env{UserConfigDir} = $ENV{APPDATA} . $env{PathSeparator} . 'wrangler'; | |||||||||||||||||||||||||||
| 86 | }elsif($^O =~ /nix$|ux$/i){ | ||||||||||||||||||||||||||||
| 87 | 1 | $env{HostOS} = 'Linux'; | |||||||||||||||||||||||||||
| 88 | 1 | $env{PathSeparator} = '/'; | |||||||||||||||||||||||||||
| 89 | 1 | $env{CRLF} = "\n"; | |||||||||||||||||||||||||||
| 90 | 1 | ▶ | if(-e '/usr/bin/firefox'){ | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 91 | 0 | $env{BrowserStartCommand} = 'firefox'; | |||||||||||||||||||||||||||
| 92 | }elsif(-e '/usr/bin/chromium-browser'){ | ||||||||||||||||||||||||||||
| 93 | 0 | $env{BrowserStartCommand} = 'chromium-browser'; | |||||||||||||||||||||||||||
| 94 | }elsif(-e '/usr/bin/mozilla'){ | ||||||||||||||||||||||||||||
| 95 | 0 | $env{BrowserStartCommand} = 'mozilla'; | |||||||||||||||||||||||||||
| 96 | }elsif(-e '/usr/bin/konqueror'){ | ||||||||||||||||||||||||||||
| 97 | 0 | $env{BrowserStartCommand} = 'konqueror'; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | 1 | $env{HelperFfmpeg} = "avconv"; | |||||||||||||||||||||||||||
| 100 | 1 | $env{HelperMPlayer} = "mplayer"; | |||||||||||||||||||||||||||
| 101 | 1 | ▶ | if( $ENV{XDG_CONFIG_HOME} ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | ($env{UserConfigDir}) = $ENV{XDG_CONFIG_HOME} =~ /:/ ? split(':', $ENV{XDG_CONFIG_HOME}, 2) : ($ENV{XDG_CONFIG_HOME}); # may hold multiple paths | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | $env{UserConfigDir} .= $env{PathSeparator} . 'wrangler'; | |||||||||||||||||||||||||||
| 104 | # Wrangler::debug("Wrangler::Config::read: XDG_CONFIG_HOME:$ENV{XDG_CONFIG_HOME})"); | ||||||||||||||||||||||||||||
| 105 | }else{ | ||||||||||||||||||||||||||||
| 106 | 1 | $env{UserConfigDir} = File::HomeDir->my_home() . $env{PathSeparator} . ".config" . $env{PathSeparator} . 'wrangler'; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | }elsif($^O =~ /Mac/i){ | ||||||||||||||||||||||||||||
| 109 | 0 | $env{HostOS} = 'Mac'; | |||||||||||||||||||||||||||
| 110 | 0 | $env{PathSeparator} = ':'; | |||||||||||||||||||||||||||
| 111 | 0 | $env{CRLF} = "\r"; | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | if(-e '/usr/bin/firefox'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | $env{BrowserStartCommand} = 'firefox'; | |||||||||||||||||||||||||||
| 114 | }else{ | ||||||||||||||||||||||||||||
| 115 | 0 | $env{BrowserStartCommand} = 'safari'; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | 0 | $env{HelperFfmpeg} = "ffmpeg"; | |||||||||||||||||||||||||||
| 118 | 0 | $env{HelperMPlayer} = "mplayer"; | |||||||||||||||||||||||||||
| 119 | 0 | $env{UserConfigDir} = undef; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | %env = ( | ||||||||||||||||||||||||||||
| 122 | 1 | %env, | |||||||||||||||||||||||||||
| 123 | 'config.file.location' => 'home-dir', | ||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||
|
Subroutine
read: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | 0 | my $path; | |||||||||||||||||||||||||||
| 128 | 0 | ▶ | if(-e Cwd::cwd . $env{PathSeparator} . '.wrangler.json' ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | Wrangler::debug('Wrangler::Config::read: Planning to read settings file from working-dir: .wrangler.yaml'); | |||||||||||||||||||||||||||
| 130 | 0 | $path = Cwd::cwd . $env{PathSeparator} . '.wrangler.json'; | |||||||||||||||||||||||||||
| 131 | 0 | $env{'config.file.location'} = 'working-dir'; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | unless($path){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 0 | $path = $env{UserConfigDir}; | |||||||||||||||||||||||||||
| 136 | 0 | ▶ | $path .= $env{PathSeparator} . '.wrangler.json' if $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if($path){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | $env{'config.file.location'} = 'home-dir'; | |||||||||||||||||||||||||||
| 139 | 0 | Wrangler::debug('Wrangler::Config::read: Planning to read settings file from home-dir: '.$path); | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | unless($path){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | # OS specific system config-file locations | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if( $env{HostOS} eq 'Linux' ){ | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 146 | 0 | $path = File::HomeDir->my_home() . $env{PathSeparator} . ".config" . $env{PathSeparator} . 'wrangler'; | |||||||||||||||||||||||||||
| 147 | 0 | $path = '/etc/wrangler/.wrangler.json'; | |||||||||||||||||||||||||||
| 148 | }elsif( $env{HostOS} eq 'Windows'){ | ||||||||||||||||||||||||||||
| 149 | 0 | $path = undef; | |||||||||||||||||||||||||||
| 150 | }elsif( $env{HostOS} eq 'Mac'){ | ||||||||||||||||||||||||||||
| 151 | # todo | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if($path){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 0 | $env{'config.file.location'} = 'system-dir'; | |||||||||||||||||||||||||||
| 156 | 0 | Wrangler::debug('Wrangler::Config::read: Planning to read settings file from system-dir: '.$path); | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if($path && -f $path){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$path and -f $path
MC/DC0%0/2
$path and -f $path
$path
-f $path
Truth table0%0/3
A and B
A= $pathB= -f $path
| |||||||||||||||||||||||||||||
| 161 | 0 | Wrangler::debug('Wrangler::Config::read: reading settings file:'. $path); | |||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $json = path($path)->slurp_utf8 or Wrangler::debug("Wrangler::Config::read: error reading config file: $!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | my $ref = eval { JSON::XS::decode_json( $json ) }; | |||||||||||||||||||||||||||
| 164 | 0 | ▶ | Wrangler::debug("Wrangler::Config::read: error decoding config file: $@") if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 0 | %settings = %$ref; | |||||||||||||||||||||||||||
| 166 | }else{ | ||||||||||||||||||||||||||||
| 167 | 0 | %settings = %default_settings; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | Wrangler::debug('Wrangler::Config::read: no config-file found; using default settings; on change, write config to '. $env{'config.file.location'} .': .wrangler.json'); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | $digest = Digest::MD5::md5( Data::Dumper::Dumper(\%settings) ); | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | ## is the config file valid? check if show-stopping values are set | ||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $settings{'ui.main.width'} = $default_settings{'ui.main.width'} unless $settings{'ui.main.width'} && $settings{'ui.main.width'} > 30; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Wrangler::Config::settings{"ui.main.width"} and $Wrangler::Config::settings{"ui.main.width"} > 30
MC/DC0%0/2
$Wrangler::Config::settings{"ui.main.width"} and $Wrangler::Config::settings{"ui.main.width"} > 30
$Wrangler::Config::settings{"ui.main.width"}
$Wrangler::Config::settings{"ui.main.width"} > 30
Truth table0%0/3
A and B
A= $Wrangler::Config::settings{"ui.main.width"}B= $Wrangler::Config::settings{"ui.main.width"} > 30
| |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $settings{'ui.main.height'} = $default_settings{'ui.main.height'} unless $settings{'ui.main.height'} && $settings{'ui.main.height'} > 30; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Wrangler::Config::settings{"ui.main.height"} and $Wrangler::Config::settings{"ui.main.height"} > 30
MC/DC0%0/2
$Wrangler::Config::settings{"ui.main.height"} and $Wrangler::Config::settings{"ui.main.height"} > 30
$Wrangler::Config::settings{"ui.main.height"}
$Wrangler::Config::settings{"ui.main.height"} > 30
Truth table0%0/3
A and B
A= $Wrangler::Config::settings{"ui.main.height"}B= $Wrangler::Config::settings{"ui.main.height"} > 30
| |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | $settings{'ui.filebrowser.columns'} = $default_settings{'ui.filebrowser.columns'} unless $settings{'ui.filebrowser.columns'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub config { | ||||||||||||||||||||||||||
|
Subroutine
config: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if($_[1]){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | ▶ | unless( defined($settings{ $_[1] }) ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | Wrangler::debug("Wrangler::Config::config: key:$_[1] not defined!"); | |||||||||||||||||||||||||||
| 184 | 0 | ▶ | return unless $_[2]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | 0 | ▶ | return $settings{ $_[1] } unless $_[2]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 0 | Wrangler::debug("Wrangler::Config::config: $_[1] => $_[2]"); | |||||||||||||||||||||||||||
| 188 | 0 | $settings{ $_[1] } = $_[2]; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 0 | return \%settings; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub write { | ||||||||||||||||||||||||||
|
Subroutine
write: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | unless($digest){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | Wrangler::debug("Wrangler::Config::write: stopped (over-) writing an empty config file. Check your config file for syntax errors"); | |||||||||||||||||||||||||||
| 196 | 0 | return; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if( Digest::MD5::md5( Data::Dumper::Dumper(\%settings) ) eq $digest ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 0 | Wrangler::debug("Wrangler::Config::write: settings not changed, write skipped"); | |||||||||||||||||||||||||||
| 201 | }else{ | ||||||||||||||||||||||||||||
| 202 | 0 | my $path; | |||||||||||||||||||||||||||
| 203 | 0 | ▶ | if( $env{'config.file.location'} eq 'working-dir' ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 0 | $path = Cwd::cwd . $env{PathSeparator} . '.wrangler.json'; | |||||||||||||||||||||||||||
| 205 | }else{ # the default | ||||||||||||||||||||||||||||
| 206 | 0 | $path = File::HomeDir->my_home() . $env{PathSeparator} . ".config"; | |||||||||||||||||||||||||||
| 207 | 0 | ▶ | unless(-d $path){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | mkdir($path) or Wrangler::debug("Wrangler::Config::write: error creating directory $path"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | 0 | $path .= $env{PathSeparator} . 'wrangler'; | |||||||||||||||||||||||||||
| 211 | 0 | ▶ | unless(-d $path){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 0 | ▶ | mkdir($path) or Wrangler::debug("Wrangler::Config::write: error creating directory $path"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | 0 | $path .= $env{PathSeparator} . '.wrangler.json'; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | Wrangler::debug("Wrangler::Config::write: settings from ".$env{'config.file.location'}." changed, write to: ".$path); | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 0 | my $json = eval { JSON::XS->new->utf8->pretty->encode( \%settings ) }; | |||||||||||||||||||||||||||
| 220 | 0 | ▶ | Wrangler::debug("Wrangler::Config::write: error encoding config file: $@") if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | path($path)->spew_utf8($json) or Wrangler::debug("Wrangler::Config::write: error writing config file: $path: $!") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 1 | 1; | |||||||||||||||||||||||||||