Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
forge001
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
forge001
Commits
2ef76f71
Commit
2ef76f71
authored
11 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
first shot
parent
975a466a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
textarchive/lib/TA/ObjReg.pm
+70
-0
70 additions, 0 deletions
textarchive/lib/TA/ObjReg.pm
textarchive/lib/TA/Util.pm
+44
-0
44 additions, 0 deletions
textarchive/lib/TA/Util.pm
with
114 additions
and
0 deletions
textarchive/lib/TA/ObjReg.pm
0 → 100644
+
70
−
0
View file @
2ef76f71
package
TA::
ObjReg
;
use
strict
;
use
JSON
;
use
TA::
Util
;
sub
new
{
my
$class
=
shift
;
my
%par
=
@_
;
# check the presence of all required parameters
my
$stopit
=
0
;
foreach
my
$k
(
qw(project subproject)
)
{
unless
(
exists
(
$par
{
$k
}))
{
print
STDERR
"
missing parameter '
$k
'
\n
";
$stopit
=
1
;
}
}
return
undef
if
(
$stopit
);
my
$obj
=
{};
bless
$obj
,
$class
;
foreach
my
$par
(
keys
%par
)
{
$obj
->
{
$par
}
=
$par
{
$par
};
}
$par
;
}
sub
get_project
{
my
$obj
=
shift
;
my
$proj_name
=
$obj
->
{'
project
'};
my
$proj_cfg_fnm
=
join
('
/
',
$ENV
{'
TABASE
'},
'
projects
',
$proj_name
,
'
config.json
');
my
$proj_cfg
;
unless
(
$proj_cfg
=
TA::Util::
slurp_file
(
$proj_cfg_fnm
,
'
json
'))
{
print
STDERR
"
project '
$proj_name
' at 'proj_cfg_fnm'
\n
";
return
undef
;
}
}
sub
add
{
}
# =head1 INTERNAL FUNCTIONS
1
;
__END__
=head1 ENVIRONMENT
=head1 TODOs
* this is a stub for storage in a local filesystem
** connect to centralized connection service
This diff is collapsed.
Click to expand it.
textarchive/lib/TA/Util.pm
0 → 100644
+
44
−
0
View file @
2ef76f71
package
TA::
Util
;
use
strict
;
=head2 _file_slurp ($filename, $format)
read contents of that file and
=cut
sub
slurp_file
{
my
$fnm
=
shift
;
my
$format
=
shift
||
'
lines
';
open
(
FI
,
$fnm
)
or
return
undef
;
my
@lines
=
<
FI
>
;
close
(
FI
);
if
(
$format
eq
'
array
')
{
return
@lines
;
}
elsif
(
$format
eq
'
arrayref
')
{
return
\
@lines
;
}
elsif
(
$format
eq
'
string
')
{
return
join
('',
@lines
);
}
elsif
(
$format
eq
'
json
')
{
my
$str
=
join
('',
@lines
);
return
decode_json
(
$str
);
}
print
STDERR
"
unknown slurp format '
$format
'
\n
";
return
undef
;
}
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment