[interchange-cvs] interchange - heins modified lib/Vend/Config.pm

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Sun Aug 11 12:00:01 2002


User:      heins
Date:      2002-08-11 15:59:29 GMT
Modified:  lib/Vend Config.pm
Log:
* Add automated tag groups corresponding to the directory under the
  TagDir (or TagDirs).

* Only has one level of directory, so similarly-named directories in differ=
ent
  bases will be in the same group.

* This allows you to do:

	TagInclude   :SystemTag :UserTag

  This would include all tags found in code/SystemTag and code/UserTag,
  but exclude tags found in code/UI_Tag.

* Groups are created at the time get_system_code() is first run.

Revision  Changes    Path
2.64      +49 -22    interchange/lib/Vend/Config.pm


rev 2.64, prev_rev 2.63
Index: Config.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.63
retrieving revision 2.64
diff -u -r2.63 -r2.64
--- Config.pm	11 Aug 2002 15:48:43 -0000	2.63
+++ Config.pm	11 Aug 2002 15:59:29 -0000	2.64
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.63 2002/08/11 15:48:43 mheins Exp $
+# $Id: Config.pm,v 2.64 2002/08/11 15:59:29 mheins Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -37,14 +37,14 @@
 			@Locale_directives_ary @Locale_directives_scalar
 			@Locale_directives_code
 			@Locale_directives_currency @Locale_keys_currency
-			$GlobalRead  $SystemCodeDone $CodeDest
+			$GlobalRead  $SystemCodeDone $SystemGroupsDone $CodeDest
 			);
 use Safe;
 use Fcntl;
 use Vend::Parse;
 use Vend::Util;
=20
-$VERSION =3D substr(q$Revision: 2.63 $, 10);
+$VERSION =3D substr(q$Revision: 2.64 $, 10);
=20
 my %CDname;
=20
@@ -283,8 +283,8 @@
 	['HitCount',		 'yesno',            'No'],
 	['IpHead',			 'yesno',            'No'],
 	['IpQuad',			 'integer',          '1'],
-	['TemplateDir',      'root_dir_array', 	 ''],
 	['TagDir',      	 'root_dir_array', 	 'code'],
+	['TemplateDir',      'root_dir_array', 	 ''],
 	['DomainTail',		 'yesno',            'Yes'],
 	['AcrossLocks',		 'yesno',            'No'],
 	['TolerateGet',		 'yesno',            'No'],
@@ -969,6 +969,47 @@
 }
=20
 use File::Find;
+
+my %extmap =3D qw/
+	ia	ItemAction
+	fa	FormAction
+	am	ActionMap
+	oc	OrderCheck
+	ut	UserTag
+	fi	Filter
+	fw	Widget
+	lc	LocaleChange
+	tag	UserTag
+	ct	CoreTag
+/;
+
+for( values %extmap ) {
+	$extmap{lc $_} =3D $_;
+}
+
+sub get_system_groups {
+
+	my @files;
+	my $wanted =3D sub {
+		return if (m{^\.} || ! -f $_);
+		$File::Find::name =3D~ m{/([^/]+)/([^/.]+)\.(\w+)$}
+			or return;
+		my $group =3D $1;
+		my $tname =3D $2;
+		my $ext =3D $extmap{lc $3} or return;
+		$ext =3D~ /Tag$/ or return;
+		push @files, [ $group, $tname ];
+	};
+	File::Find::find($wanted, @$Global::TagDir);
+
+	$Global::TagGroup ||=3D {};
+	for(@files) {
+		my $g =3D $Global::TagGroup->{":$_->[0]"} ||=3D [];
+		push @$g, $_->[1];
+	}
+	return;
+}
+
 sub get_system_code {
=20
 	return if $CodeDest;
@@ -976,29 +1017,12 @@
=20=09
 	# defined means don't go here anymore
 	$SystemCodeDone =3D '';
-	my %extmap =3D qw/
-		ia	ItemAction
-		fa	FormAction
-		am	ActionMap
-		oc	OrderCheck
-		ut	UserTag
-		fi	Filter
-		fw	Widget
-		lc	LocaleChange
-		tag	UserTag
-		ct	CoreTag
-	/;
-
-	for( values %extmap ) {
-		$extmap{lc $_} =3D $_;
-	}
-
 	my @files;
 	my $wanted =3D sub {
 		return if (m{^\.} || ! -f $_);
 		return unless m{^[^.]+\.(\w+)$};
 		my $ext =3D $extmap{lc $1} or return;
-		push @files, [ $File::Find::name, $ext ];
+		push @files, [ $File::Find::name, $ext];
 	};
 	File::Find::find($wanted, @$Global::TagDir);
=20
@@ -1494,6 +1518,7 @@
=20
 	my $c;
 	my $g;
+
 	my $mapper =3D $incmap{$var} || 'TagGroup';
 	if(defined $C) {
 		$c =3D $C->{$var} || {};
@@ -1515,6 +1540,8 @@
 	}
=20
 	delete $c->{ALL};
+
+	get_system_groups() unless $SystemGroupsDone;
=20
 	my @incs =3D Text::ParseWords::shellwords($setting);
=20