ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/ConfigArea.pm
(Generate patch)

Comparing COMP/SCRAM/src/Configuration/ConfigArea.pm (file contents):
Revision 1.4 by williamc, Fri Jan 21 11:56:38 2000 UTC vs.
Revision 1.5 by williamc, Mon Jan 24 17:22:45 2000 UTC

# Line 19 | Line 19
19   # configitem(@keys)             : return a list of fig items that match
20   #                                 the keys - all if left blank
21   # parentstore()                 : set/return the parent ObjectStore
22 + # bootstrapfromlocation([location]): bootstrap the object based on location.
23 + #                                 no location specified - cwd used
24 + # searchlocation([startdir])    : returns the location directory. search starts
25 + #                                 from cwd if not specified
26  
27   package Configuration::ConfigArea;
28   use ActiveDoc::ActiveDoc;
# Line 29 | Line 33 | use ObjectUtilities::ObjectStore;
33  
34   sub init {
35          my $self=shift;
36 +
37          $self->newparse("init");
38          $self->newparse("download");
39          $self->newparse("setup");
# Line 68 | Line 73 | sub setup {
73          # --- and parse the setup file
74          $self->parse("setup");
75          
76 +        # --- store bootstrap info
77 +        $self->store($self->location()."/.SCRAM/ConfigArea.dat");
78 +
79          # --- store self in original database
80          $self->parentconfig()->store($self,"ConfigArea",$self->name(),
81                                                          $self->version());
# Line 88 | Line 96 | sub _setupstore {
96          $self->config()->basedoc($self->parentconfig()->basedoc());
97   }
98  
99 + sub bootstrapfromlocation {
100 +        my $self=shift;
101 +        
102 +        if ( ! defined $self->location(@_) ) {
103 +          $self->error("Unable to locate the top of local configuration area");
104 +        }
105 +        $self->_setupstore();
106 +        $self->restore($self->location()."/.SCRAM/ConfigArea.dat");
107 + }
108 +
109   sub parentconfig {
110          my $self=shift;
111          @_?$self->{parentconfig}=shift
# Line 113 | Line 131 | sub restore {
131          my $fh=$self->openfile("<".$location);
132          my $varhash={};
133          $self->restorevars($fh,$varhash);
134 <        $self->location($$varhash{"location"});
134 >        if ( ! defined $self->location() ) {
135 >          $self->location($$varhash{"location"});
136 >        }
137          $self->_setupstore();
138          $self->url($$varhash{"url"});
139          $self->name($$varhash{"name"});
# Line 138 | Line 158 | sub version {
158   sub location {
159          my $self=shift;
160  
161 <        @_?$self->{location}=shift
162 <          :$self->{location};
161 >        if ( @_ ) {
162 >          $self->{location}=shift
163 >        }
164 >        elsif ( ! defined $self->{location} ) {
165 >          # try and find the release location
166 >          $self->searchlocation();
167 >        }
168 >        return  $self->{location};
169 > }
170 >
171 > sub searchlocation {
172 >        my $self=shift;
173 >        use Cwd;
174 >
175 >        #start search in current directory if not specified
176 >        my $thispath;
177 >        @_?$thispath=shift
178 >          :$thispath=cwd;
179 >
180 >        my $rv=0;
181 >
182 >        do {
183 >          if ( -e "$thispath/.SCRAM" ) {
184 >            $rv=1;
185 >          }
186 >        } while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./  );
187 >
188 >        return $rv?$thispath:undef;
189   }
190  
191   sub meta {
# Line 151 | Line 197 | sub meta {
197  
198   sub configitem {
199          my $self=shift;
154        my $location=shift;
200          
201 <        $self->config()->find("ConfigItem",@_);
201 >        return ($self->config()->find("ConfigItem",@_));
202   }
203  
204   sub addconfigitem {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines