summaryrefslogtreecommitdiff
path: root/lib/CIL/Base.pm
diff options
context:
space:
mode:
authorFrancois Marier <francois@debian.org>2010-08-05 20:52:16 -0400
committerFrancois Marier <francois@debian.org>2010-08-05 20:52:16 -0400
commit9fcb3bc29dfd429f521c4e40452197dc364310c3 (patch)
treed343c4aeb67a1cc4b00dfebf873937aa9cccf12a /lib/CIL/Base.pm
parent1515145646c5aa80eb4c298607ea33da731ab586 (diff)
Imported Upstream version 0.07.00upstream/0.07.00
Diffstat (limited to 'lib/CIL/Base.pm')
-rw-r--r--lib/CIL/Base.pm19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/CIL/Base.pm b/lib/CIL/Base.pm
index f9b932f..34fba60 100644
--- a/lib/CIL/Base.pm
+++ b/lib/CIL/Base.pm
@@ -38,11 +38,11 @@ sub new_from_name {
croak 'provide a name'
unless defined $name;
- my $filename = $class->create_filename($cil, $name);
+ my $filename = $class->filename($cil, $name);
croak "filename '$filename' does no exist"
- unless -f $filename;
+ unless $cil->file_exists($filename);
- my $data = CIL::Utils->parse_cil_file($filename, $class->last_field);
+ my $data = $cil->parse_cil_file($filename, $class->last_field);
my $issue = $class->new_from_data( $name, $data );
return $issue;
}
@@ -74,6 +74,7 @@ sub new_from_data {
$self->set_no_update($field, $data->{$field});
}
$self->set_no_update('Changed', 0);
+ $self->set_no_update('Updated', $data->{Updated});
return $self;
}
@@ -115,10 +116,11 @@ sub set_data {
sub save {
my ($self, $cil) = @_;
- my $filename = $self->create_filename($cil, $self->name);
+ my $filename = $self->filename($cil, $self->name);
my $fields = $self->fields();
- CIL::Utils->write_cil_file( $filename, $self->{data}, @$fields );
+
+ $cil->save( $filename, $self->{data}, @$fields );
}
sub as_output {
@@ -127,7 +129,7 @@ sub as_output {
return CIL::Utils->format_data_as_output( $self->{data}, @$fields );
}
-sub create_filename {
+sub filename {
my ($class, $cil, $name) = @_;
# create the filename from it's parts
@@ -170,10 +172,7 @@ sub set {
# so that we can update fields without 'Updated' being changed
sub set_no_update {
my ($self, $field, $value) = @_;
-
- my $saved_update_time = $self->Updated;
- $self->set( $field, $value );
- $self->Updated( $saved_update_time );
+ $self->{data}{$field} = $value;
}
sub set_inserted_now {