| 1 | package ODS::Translator; | ||
| 2 | |||
| 3 | use YAOO; | ||
| 4 | |||
| 5 | auto_build; | ||
| 6 | |||
| 7 | use ODS::Utils qw/load/; | ||
| 8 | |||
| 9 | has [translation, into_translation, file] => isa(string); | ||
| 10 | |||
| 11 | has stub => isa(string('ODS::Storage')); | ||
| 12 | |||
| 13 | sub translate { | ||
| 14 | my ($self) = @_; | ||
| 15 | |||
| 16 | my $stub = 'ODS::Storage'; | ||
| 17 | |||
| 18 | my $original = load( sprintf "%s::%s", $self->stub, $self->translation ); | ||
| 19 | |||
| 20 | my $into = load(sprintf "%s::%s", $self->stub, $self->into_translation); | ||
| 21 | |||
| 22 | if ($self->translation =~ m/^File/ && $self->into_translation =~ m/^File/) { | ||
| 23 | $original = $original->new( | ||
| 24 | file => $self->file | ||
| 25 | ); | ||
| 26 | $into = $into->new( | ||
| 27 | file => $self->file | ||
| 28 | ); | ||
| 29 | |||
| 30 | my $data = $original->parse_data_format($original->read_file()); | ||
| 31 | |||
| 32 | $into->write_file($into->stringify_data_format($data)); | ||
| 33 | } | ||
| 34 | |||
| 35 | return 1; | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; |