| 1 | ############################################################################## | ||||||||||||||||||||
| 2 | # The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. # | ||||||||||||||||||||
| 3 | # # | ||||||||||||||||||||
| 4 | # This program is free software; you can redistribute it and/or # | ||||||||||||||||||||
| 5 | # modify it under the terms of the GNU General Public License # | ||||||||||||||||||||
| 6 | # as published by the Free Software Foundation; either version 2 # | ||||||||||||||||||||
| 7 | # of the License, or (at your option) any later version. # | ||||||||||||||||||||
| 8 | # # | ||||||||||||||||||||
| 9 | # This program is distributed in the hope that it will be useful, # | ||||||||||||||||||||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||||||||||||||||||||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||||||||||||||||||||
| 12 | # GNU General Public License for more details. # | ||||||||||||||||||||
| 13 | # # | ||||||||||||||||||||
| 14 | # You should have received a copy of the GNU General Public License # | ||||||||||||||||||||
| 15 | # along with this program; if not, write to the Free Software # | ||||||||||||||||||||
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.# | ||||||||||||||||||||
| 17 | # # | ||||||||||||||||||||
| 18 | # Jon Howell can be contacted at: # | ||||||||||||||||||||
| 19 | # 6211 Sudikoff Lab, Dartmouth College # | ||||||||||||||||||||
| 20 | # Hanover, NH 03755-3510 # | ||||||||||||||||||||
| 21 | # jonh@cs.dartmouth.edu # | ||||||||||||||||||||
| 22 | # # | ||||||||||||||||||||
| 23 | # An electronic copy of the GPL is available at: # | ||||||||||||||||||||
| 24 | # http://www.gnu.org/copyleft/gpl.html # | ||||||||||||||||||||
| 25 | # # | ||||||||||||||||||||
| 26 | ############################################################################## | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | ### | ||||||||||||||||||||
| 31 | ### The Bags module provides services related to bit bags, | ||||||||||||||||||||
| 32 | ### binary files stored with and linked to by a FAQ-O-Matic. | ||||||||||||||||||||
| 33 | ### | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | package FAQ::OMatic::Bags; | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 1 | ▶ | use FAQ::OMatic; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | 1 | ▶ | use FAQ::OMatic::Item; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | sub getBagDesc { | ||||||||||||||||||
|
Subroutine
getBagDesc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 41 | # return an item containing descriptive properties about | ||||||||||||||||||||
| 42 | # a bag | ||||||||||||||||||||
| 43 | 0 | my $bagName = shift; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | my $bagDesc = new FAQ::OMatic::Item($bagName.".desc", | |||||||||||||||||||
| 46 | $FAQ::OMatic::Config::bagsDir); | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | # if it didn't exist before... | ||||||||||||||||||||
| 49 | 0 | $bagDesc->setProperty('Title', 'Bag Description'); | |||||||||||||||||||
| 50 | 0 | $bagDesc->setProperty('filename', $bagName.".desc"); | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | return $bagDesc; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | ▶ | sub getBagProperty { | ||||||||||||||||||
|
Subroutine
getBagProperty: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 56 | 0 | my $bagName = shift; | |||||||||||||||||||
| 57 | 0 | my $property = shift; | |||||||||||||||||||
| 58 | 0 | ▶ | my $default = shift || ''; | ||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | my $bagDesc = getBagDesc($bagName); | |||||||||||||||||||
| 61 | 0 | ▶ | return $bagDesc->getProperty($property) || $default; | ||||||||||||||||||
|
Condition0%0/3
$bagDesc->getProperty($property) || $default
MC/DC0%0/2
$bagDesc->getProperty($property) || $default
$bagDesc->getProperty($property)
$default
Truth table0%0/3
A || B
A= $bagDesc->getProperty($property)B= $default
| |||||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | ▶ | sub saveBagDesc { | ||||||||||||||||||
|
Subroutine
saveBagDesc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 65 | 0 | my $bagDesc = shift; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | $bagDesc->saveToFile('', | |||||||||||||||||||
| 68 | $FAQ::OMatic::Config::bagsDir); | ||||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | ▶ | sub untaintBagName { | ||||||||||||||||||
|
Subroutine
untaintBagName: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 72 | # untaint a bag name -- result is either a valid name or '' | ||||||||||||||||||||
| 73 | 0 | my $name = FAQ::OMatic::untaintFilename(shift()); | |||||||||||||||||||
| 74 | # Don't want user overwriting .desc files with binary bags -- YUK! | ||||||||||||||||||||
| 75 | 0 | ▶ | return '' if ($name =~ m/\.desc$/); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 0 | return $name; | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | ▶ | sub updateDependents { | ||||||||||||||||||
|
Subroutine
updateDependents: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 80 | 0 | my $bagName = shift; | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | my $dependent; | |||||||||||||||||||
| 83 | 0 | foreach $dependent (FAQ::OMatic::Item::getDependencies("bags.".$bagName)) { | |||||||||||||||||||
| 84 | 0 | my $dependentItem = new FAQ::OMatic::Item($dependent); | |||||||||||||||||||
| 85 | 0 | $dependentItem->writeCacheCopy(); | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 1 | 1; | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | |||||||||||||||||||||