New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Revision.pm in branches/UKMO/dev_r5518_25hr_mean_assim_bkg/NEMOGCM/EXTERNAL/fcm/lib/Fcm/Keyword/Loader/VC – NEMO

source: branches/UKMO/dev_r5518_25hr_mean_assim_bkg/NEMOGCM/EXTERNAL/fcm/lib/Fcm/Keyword/Loader/VC/Revision.pm @ 6757

Last change on this file since 6757 was 6757, checked in by kingr, 8 years ago

Cleared SVN keywords.

File size: 2.6 KB
Line 
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# ------------------------------------------------------------------------------
6use strict;
7use warnings;
8
9package Fcm::Keyword::Loader::VC::Revision;
10
11use Fcm::Util qw{run_command};
12
13sub new {
14    my ($class, $args_ref) = @_;
15    return bless({%{$args_ref}}, $class);
16}
17
18################################################################################
19# Returns the VC location where revision keywords will be loaded from
20sub get_source {
21    my ($self) = @_;
22    return $self->{source};
23}
24
25################################################################################
26# Loads revision keywords from $self->get_source() to $entries
27sub load_to {
28    my ($self, $entries) = @_;
29    my @lines = run_command(
30        [qw{svn pg fcm:revision}, $self->get_source()],
31        DEVNULL => 1,
32        ERROR   => 'ignore',
33        METHOD  => 'qx',
34    );
35    my $load_counter = 0;
36    for my $line (@lines) {
37        chomp($line);
38        my ($key, $value) = split(qr{\s+ = \s+}xms, $line);
39        if ($key && $value) {
40            $entries->add_entry($key, $value);
41            $load_counter++;
42        }
43    }
44    return defined($load_counter);
45}
46
471;
48__END__
49
50=head1 NAME
51
52Fcm::Keyword::Loader::VC::Revision
53
54=head1 SYNOPSIS
55
56    $loader = Fcm::Keyword::Loader::VC::Revision->new({source => $source});
57    $loader->load_to($entries);
58
59=head1 DESCRIPTION
60
61Loads revision keywords from a VC location into a
62L<Fcm::Keyword::Entries|Fcm::Keyword::Entries> object containing
63L<Fcm::Keyword::Entry|Fcm::Keyword::Entry> objects.
64
65=head1 METHODS
66
67=over 4
68
69=item C<new({source =E<gt> $source})>
70
71Constructor. The argument $source is the VC location from which revision
72keywords will be loaded from.
73
74=item get_source()
75
76Returns the source VC location from which revision keywords will be loaded
77from.
78
79=item load_to($entries)
80
81Loads revision keywords from C<$self-E<gt>get_source()> to $entries.
82
83=back
84
85=head1 TO DO
86
87Abstract away the call to the VC system, which assumes the Subversion shell
88client at the moment.
89
90=head1 SEE ALSO
91
92L<Fcm::Keyword|Fcm::Keyword>,
93L<Fcm::Keyword::Entries|Fcm::Keyword::Entries>,
94L<Fcm::Keyword::Entry|Fcm::Keyword::Entry>,
95L<Fcm::Keyword::Entry::Location|Fcm::Keyword::Entry::Location>,
96L<Fcm::Keyword::Loader|Fcm::Keyword::Loader>,
97L<Fcm::Keyword::Loader::Config::Revision|Fcm::Keyword::Loader::Config::Revision>
98
99=head1 COPYRIGHT
100
101E<169> Crown copyright Met Office. All rights reserved.
102
103=cut
Note: See TracBrowser for help on using the repository browser.