Changeset 3302
- Timestamp:
- 03/12/09 09:45:10 (3 years ago)
- File:
-
- 1 edited
-
trunk/Padre/lib/Padre/Config.pm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Config.pm
r3301 r3302 14 14 use warnings; 15 15 16 use Carp (); 17 use File::Spec (); 18 use File::Copy (); 19 use File::Path (); 20 use Params::Util qw{ _POSINT _INSTANCE }; 21 use Padre::Config::Setting (); 22 use Padre::Config::Human (); 23 use Padre::Config::Project (); 24 use Padre::Config::Host (); 25 16 use Carp qw{ croak }; 17 use Params::Util qw{ _POSINT _INSTANCE }; 26 18 use Padre::Config::Constants qw{ :stores :types $PADRE_CONFIG_DIR }; 19 use Padre::Config::Setting (); 20 use Padre::Config::Human (); 21 use Padre::Config::Project (); 22 use Padre::Config::Host (); 23 27 24 28 25 our $VERSION = '0.28'; … … 179 176 my $human = shift; 180 177 unless ( _INSTANCE($host, 'Padre::Config::Host') ) { 181 Carp::croak("Did not provide a host config to Padre::Config->new");178 croak("Did not provide a host config to Padre::Config->new"); 182 179 } 183 180 unless ( _INSTANCE($human, 'Padre::Config::Human') ) { 184 Carp::croak("Did not provide a user config to Padre::Config->new");181 croak("Did not provide a user config to Padre::Config->new"); 185 182 } 186 183 … … 192 189 my $project = shift; 193 190 unless ( _INSTANCE($project, 'Padre::Config::Project') ) { 194 Carp::croak("Did not provide a project config to Padre::Config->new");191 croak("Did not provide a project config to Padre::Config->new"); 195 192 } 196 193 $self->[$PROJECT] = $project; … … 207 204 # Does the setting exist? 208 205 my $setting = $SETTING{$name} or 209 Carp::croak("The configuration setting '$name' does not exist");206 croak("The configuration setting '$name' does not exist"); 210 207 211 208 # All types are $ASCII-like 212 209 unless ( defined $value and not ref $value ) { 213 Carp::croak("Missing or non-scalar value for setting '$name'");210 croak("Missing or non-scalar value for setting '$name'"); 214 211 } 215 212 … … 217 214 my $type = $setting->type; 218 215 if ( $type == $BOOLEAN and $value ne '1' and $value ne '0' ) { 219 Carp::croak("Tried to change setting '$name' to non-boolean '$value'");216 croak("Tried to change setting '$name' to non-boolean '$value'"); 220 217 } 221 218 if ( $type == $POSINT and not _POSINT($value) ) { 222 Carp::croak("Tried to change setting '$name' to non-posint '$value'");219 croak("Tried to change setting '$name' to non-posint '$value'"); 223 220 } 224 221 if ( $type == $INTEGER and not _INTEGER($value) ) { 225 Carp::croak("Tried to change setting '$name' to non-integer '$value'");222 croak("Tried to change setting '$name' to non-integer '$value'"); 226 223 } 227 224 if ( $type == $PATH and not -e $value ) { 228 Carp::croak("Tried to change setting '$name' to non-existant path '$value'");225 croak("Tried to change setting '$name' to non-existant path '$value'"); 229 226 } 230 227 … … 243 240 # Does the setting exist? 244 241 my $setting = $SETTING{$name} or 245 Carp::croak("The configuration setting '$name' does not exist");242 croak("The configuration setting '$name' does not exist"); 246 243 247 244 return $DEFAULT{$name}; … … 293 290 my $object = Padre::Config::Setting->new(@_); 294 291 if ( $SETTING{$object->{name}} ) { 295 Carp::croak("The $object->{name} setting is already defined");292 croak("The $object->{name} setting is already defined"); 296 293 } 297 294 … … 312 309 eval $code; ## no critic 313 310 if ( $@ ) { 314 Carp::croak("Failed to compile setting $object->{name}");311 croak("Failed to compile setting $object->{name}"); 315 312 } 316 313
Note: See TracChangeset
for help on using the changeset viewer.
