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.
Project.pm in vendors/fcm/current/examples/lib/FCM/Admin – NEMO

source: vendors/fcm/current/examples/lib/FCM/Admin/Project.pm @ 1977

Last change on this file since 1977 was 1977, checked in by flavoni, 14 years ago

importing fcm vendor

File size: 6.5 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# ------------------------------------------------------------------------------
6
7use strict;
8use warnings;
9
10package FCM::Admin::Project;
11
12use overload q{""} => \&get_name;
13use FCM::Admin::Config;
14use File::Spec;
15
16my $ARCHIVE_EXTENSION = q{.tgz};
17
18# ------------------------------------------------------------------------------
19# Creates a new instance of this class.
20sub new {
21    my ($class, $args_ref) = @_;
22    return bless({%{$args_ref}}, $class);
23}
24
25# ------------------------------------------------------------------------------
26# Returns the name of the project.
27sub get_name {
28    my ($self) = @_;
29    return $self->{name};
30}
31
32# ------------------------------------------------------------------------------
33# Returns the base name of the backup archive of the project's SVN repository.
34sub get_svn_archive_base_name {
35    my ($self) = @_;
36    return $self->get_svn_base_name() . $ARCHIVE_EXTENSION;
37}
38
39# ------------------------------------------------------------------------------
40# Returns the path of the backup archive of the project's SVN repository.
41sub get_svn_backup_path {
42    my ($self) = @_;
43    return File::Spec->catfile(
44        FCM::Admin::Config->instance()->get_svn_backup_dir(),
45        $self->get_svn_archive_base_name(),
46    );
47}
48
49# ------------------------------------------------------------------------------
50# Returns the base name of the project's Subversion repository.
51sub get_svn_base_name {
52    my ($self) = @_;
53    return
54        $self->get_name()
55        . FCM::Admin::Config->instance()->get_svn_project_suffix();
56}
57
58# ------------------------------------------------------------------------------
59# Returns the path to the revision dumps of the project's SVN repository.
60sub get_svn_dump_path {
61    my ($self) = @_;
62    return File::Spec->catfile(
63        FCM::Admin::Config->instance()->get_svn_dump_dir(),
64        $self->get_svn_base_name(),
65    );
66}
67
68# ------------------------------------------------------------------------------
69# Returns the path to the project's SVN live repository's hooks directory.
70sub get_svn_live_hook_path {
71    my ($self) = @_;
72    return File::Spec->catfile($self->get_svn_live_path(), q{hooks});
73}
74
75# ------------------------------------------------------------------------------
76# Returns the path to the project's SVN live repository.
77sub get_svn_live_path {
78    my ($self) = @_;
79    return File::Spec->catfile(
80        FCM::Admin::Config->instance()->get_svn_live_dir(),
81        $self->get_svn_base_name(),
82    );
83}
84
85# ------------------------------------------------------------------------------
86# Returns the file:// URI to the project's SVN live repository.
87sub get_svn_file_uri {
88    my ($self) = @_;
89    return q{file://} . $self->get_svn_live_path();
90    # Note: can use URI::file in theory, but it returns file:/path (instead of
91    #       file:///path) which Subversion does not like.
92}
93
94# ------------------------------------------------------------------------------
95# Returns the base name of the project's Trac environment backup archive.
96sub get_trac_archive_base_name {
97    my ($self) = @_;
98    return $self->get_name() . $ARCHIVE_EXTENSION;
99}
100
101# ------------------------------------------------------------------------------
102# Returns the path to the project's Trac backup archive.
103sub get_trac_backup_path {
104    my ($self) = @_;
105    return File::Spec->catfile(
106        FCM::Admin::Config->instance()->get_trac_backup_dir(),
107        $self->get_trac_archive_base_name(),
108    );
109}
110
111# ------------------------------------------------------------------------------
112# Returns the path to the project's Trac live environment's database.
113sub get_trac_live_db_path {
114    my ($self) = @_;
115    return File::Spec->catfile($self->get_trac_live_path(), qw{db trac.db});
116}
117
118# ------------------------------------------------------------------------------
119# Returns the path to the project's Trac live environment's INI file.
120sub get_trac_live_ini_path {
121    my ($self) = @_;
122    return File::Spec->catfile($self->get_trac_live_path(), qw{conf trac.ini});
123}
124
125# ------------------------------------------------------------------------------
126# Returns the path to the project's Trac live environment.
127sub get_trac_live_path {
128    my ($self) = @_;
129    return File::Spec->catfile(
130        FCM::Admin::Config->instance()->get_trac_live_dir(),
131        $self->get_name(),
132    );
133}
134
1351;
136__END__
137
138=head1 NAME
139
140FCM::Admin::Project
141
142=head1 SYNOPSIS
143
144    use FCM::Admin::Project;
145    $project = FCM::Admin::Project->new({name => 'foo'});
146    $path = $project->get_svn_live_path();
147
148=head1 DESCRIPTION
149
150An object of this class represents a project hosted/managed by FCM. The methods
151of this class relies on L<FCM::Admin::Config|FCM::Admin::Config> for many of the
152configurations.
153
154=head1 METHODS
155
156=over 4
157
158=item FCM::Admin::Project->new({name => $name})
159
160Returns a new instance. A name of the project must be specified.
161
162=item $project->get_name()
163
164Returns the name of the project.
165
166=item $project->get_svn_archive_base_name()
167
168Returns the base name of the backup archive of the project's Subversion
169repository.
170
171=item $project->get_svn_backup_path()
172
173Returns the path to the backup archive of the project's Subversion repository.
174
175=item $project->get_svn_base_name()
176
177Returns the base name of the project's Subversion repository.
178
179=item $project->get_svn_dump_path()
180
181Returns the path to the revision dumps of the project's Subversion repository.
182
183=item $project->get_svn_live_hook_path()
184
185Returns the path to the project's SVN live repository's hooks directory.
186
187=item $project->get_svn_live_path()
188
189Returns the path to the project's SVN live repository.
190
191=item $project->get_svn_file_uri()
192
193Returns the file:// URI to the project's SVN live repository.
194
195=item $project->get_trac_archive_base_name()
196
197Returns the base name of the project's Trac environment backup archive.
198
199=item $project->get_trac_backup_path()
200
201Returns the path to the project's Trac backup archive.
202
203=item $project->get_trac_live_db_path()
204
205Returns the path to the project's Trac live environment's database.
206
207=item $project->get_trac_live_ini_path()
208
209Returns the path to the project's Trac live environment's INI file.
210
211=item $project->get_trac_live_path()
212
213Returns the path to the project's Trac live environment.
214
215=back
216
217=head1 SEE ALSO
218
219L<FCM::Admin::Config|FCM::Admin::Config>
220
221=head1 COPYRIGHT
222
223E<169> Crown copyright Met Office. All rights reserved.
224
225=cut
Note: See TracBrowser for help on using the repository browser.