[1980] | 1 | # ------------------------------------------------------------------------------ |
---|
| 2 | # (C) Crown copyright Met Office. All rights reserved. |
---|
| 3 | # For further details please refer to the file COPYRIGHT.txt |
---|
| 4 | # which you should have received as part of this distribution. |
---|
| 5 | # ------------------------------------------------------------------------------ |
---|
| 6 | use strict; |
---|
| 7 | use warnings; |
---|
| 8 | |
---|
| 9 | package Fcm::Keyword::Loader::Config::Revision; |
---|
| 10 | |
---|
| 11 | use Fcm::Config; |
---|
| 12 | |
---|
| 13 | sub new { |
---|
| 14 | my ($class, $args_ref) = @_; |
---|
| 15 | return bless({%{$args_ref}}, $class); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | ################################################################################ |
---|
| 19 | # Returns the namespace where the revision keywords belong |
---|
| 20 | sub get_namespace { |
---|
| 21 | my ($self) = @_; |
---|
| 22 | return $self->{namespace}; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | ################################################################################ |
---|
| 26 | # Returns 'Fcm::Config' |
---|
| 27 | sub get_source { |
---|
| 28 | my ($self) = @_; |
---|
| 29 | return 'Fcm::Config'; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | ################################################################################ |
---|
| 33 | # Loads revision keywords from Fcm::Config to $entries |
---|
| 34 | sub load_to { |
---|
| 35 | my ($self, $entries) = @_; |
---|
| 36 | my $load_counter = 0; |
---|
| 37 | my $config = $self->get_source()->instance(); |
---|
| 38 | my $rev_keyword_ref = $config->setting( |
---|
| 39 | qw/URL_REVISION/, |
---|
| 40 | uc($self->get_namespace()), |
---|
| 41 | ); |
---|
| 42 | if ($rev_keyword_ref) { |
---|
| 43 | for my $key (keys(%{$rev_keyword_ref})) { |
---|
| 44 | $entries->add_entry($key, $rev_keyword_ref->{$key}); |
---|
| 45 | $load_counter++; |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | return ($config->is_initialising() ? 0 : defined($load_counter)); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | 1; |
---|
| 52 | __END__ |
---|
| 53 | |
---|
| 54 | =head1 NAME |
---|
| 55 | |
---|
| 56 | Fcm::Keyword::Loader::Config::Revision |
---|
| 57 | |
---|
| 58 | =head1 SYNOPSIS |
---|
| 59 | |
---|
| 60 | $loader = Fcm::Keyword::Loader::Config::Revision->new({namespace => $name}); |
---|
| 61 | $loader->load_to($entries); |
---|
| 62 | |
---|
| 63 | =head1 DESCRIPTION |
---|
| 64 | |
---|
| 65 | Loads revision keywords from L<Fcm::Config|Fcm::Config> into a |
---|
| 66 | L<Fcm::Keyword::Entries|Fcm::Keyword::Entries> object containing |
---|
| 67 | L<Fcm::Keyword::Entry|Fcm::Keyword::Entry> objects. |
---|
| 68 | |
---|
| 69 | =head1 METHODS |
---|
| 70 | |
---|
| 71 | =over 4 |
---|
| 72 | |
---|
| 73 | =item C<new({namespace =E<gt> $namespace})> |
---|
| 74 | |
---|
| 75 | Constructor. The argument $namespace is the namespace where the revision |
---|
| 76 | keywords belong. |
---|
| 77 | |
---|
| 78 | =item get_namespace() |
---|
| 79 | |
---|
| 80 | Returns the namespace where the revision keywords belong. |
---|
| 81 | |
---|
| 82 | =item get_source() |
---|
| 83 | |
---|
| 84 | Returns the string "L<Fcm::Config|Fcm::Config>". |
---|
| 85 | |
---|
| 86 | =item load_to($entries) |
---|
| 87 | |
---|
| 88 | Loads revision keywords in the namespace given by C<$self-E<gt>get_namespace()> |
---|
| 89 | from L<Fcm::Config|Fcm::Config> to $entries. Returns true on success. (However, |
---|
| 90 | if L<Fcm::Config|Fcm::Config> is initialising, returns false to force a reload |
---|
| 91 | next time.) |
---|
| 92 | |
---|
| 93 | =back |
---|
| 94 | |
---|
| 95 | =head1 SEE ALSO |
---|
| 96 | |
---|
| 97 | L<Fcm::Config|Fcm::Config>, |
---|
| 98 | L<Fcm::Keyword|Fcm::Keyword>, |
---|
| 99 | L<Fcm::Keyword::Entries|Fcm::Keyword::Entries>, |
---|
| 100 | L<Fcm::Keyword::Entry|Fcm::Keyword::Entry>, |
---|
| 101 | L<Fcm::Keyword::Entry::Location|Fcm::Keyword::Entry::Location>, |
---|
| 102 | L<Fcm::Keyword::Loader|Fcm::Keyword::Loader>, |
---|
| 103 | L<Fcm::Keyword::Loader::Config::Location|Fcm::Keyword::Loader::Config::Location> |
---|
| 104 | L<Fcm::Keyword::Loader::VC::Revision|Fcm::Keyword::Loader::VC::Revision> |
---|
| 105 | |
---|
| 106 | =head1 COPYRIGHT |
---|
| 107 | |
---|
| 108 | E<169> Crown copyright Met Office. All rights reserved. |
---|
| 109 | |
---|
| 110 | =cut |
---|