Config-Std
view release on metacpan or search on metacpan
lib/Config/Std.pm view on Meta::CPAN
1920212223242526272829303132333435363738394041424344454647484950515253545556575859
}
no
strict
"refs"
;
*{
$caller
.
'::'
.
$opt_ref
->{read_config}} = \
&Config::Std::Hash::read_config
;
*{
$caller
.
'::'
.
$opt_ref
->{write_config}} = \
&Config::Std::Hash::write_config
;
}
package
Config::Std::Gap;
use
Class::Std;
{
sub
serialize {
return
"\n"
}
sub
update {}
sub
extend {}
sub
copy_to {}
}
package
Config::Std::Comment;
use
Class::Std;
{
my
%text_of
: ATTR( :init_arg<text> );
sub
serialize {
my
(
$self
) =
@_
;
return
$text_of
{ident
$self
};
}
sub
append_comment {
my
(
$self
,
$new_text
) =
@_
;
$text_of
{ident
$self
} .=
$new_text
;
}
sub
update {}
sub
extend {}
sub
copy_to {}
}
package
Config::Std::Keyval;
use
Class::Std;
{
my
%key_of
: ATTR( :init_arg<key> :get<key> );
my
%vals_of
: ATTR;
my
%deleted_of
: ATTR;
lib/Config/Std.pm view on Meta::CPAN
93949596979899100101102103104105106107108109110111112113
s/ (?!\Z) \n /\n
$keyspace
$sep
/gxms
for
@vals
;
$serialization
.=
$comm
||
q{}
;
$serialization
.=
join
q{}
,
map
{
"$key$sep$_\n"
}
@vals
;
}
return
$serialization
;
}
sub
update {
my
(
$self
,
$hash_ref
,
$updated_ref
) =
@_
;
my
$ident
= ident
$self
;
my
$key
=
$key_of
{
$ident
};
if
(!
exists
$hash_ref
->{
$key
}) {
$deleted_of
{
$ident
} = 1;
}
else
{
my
$val
=
$hash_ref
->{
$key
};
lib/Config/Std.pm view on Meta::CPAN
193194195196197198199200201202203204205206207208209210211212213
$self
->ensure_gap()
if
$inter_gap
&& !
$is_anon
;
for
my
$comp
( @{
$components_of
{
$ident
}} ) {
$serialization
.=
$comp
->serialize(
$def_sep
,
$name_of
{
$ident
});
}
return
$serialization
;
}
sub
update {
my
(
$self
,
$hash_ref
,
$updated_ref
) =
@_
;
my
$ident
= ident
$self
;
if
(!
defined
$hash_ref
) {
$deleted_of
{
$ident
} = 1;
return
;
}
for
my
$comp
( @{
$components_of
{
$ident
}} ) {
$comp
->update(
$hash_ref
,
$updated_ref
) or
next
;
( run in 0.226 second using v1.01-cache-2.11-cpan-eab888a1d7d )