Author: dylan
Date: 2004-12-28 02:46:45 -0500 (Tue, 28 Dec 2004)
New Revision: 433
Added:
trunk/main/core/lib/Haver/Core.pm
Removed:
trunk/main/core/lib/Haver/Config.pm
trunk/main/core/lib/Haver/Savable.pm
trunk/main/core/lib/Haver/Util/Logger.pm
trunk/main/core/lib/Haver/Util/Misc.pm
Modified:
trunk/main/core/lib/Haver/Base.pm
trunk/main/core/lib/Haver/Formats.pm
trunk/main/core/lib/Haver/OS.pm
trunk/main/core/lib/Haver/OS/Win95.pm
trunk/main/core/lib/Haver/OS/WinNT.pm
trunk/main/core/lib/Haver/Protocol.pm
trunk/main/core/lib/Haver/Util/Reload.pm
Log:
removing old cruft. Haver::Config will return, but with a nicer design.
The Logger was badly implemented, we'll use something else in the future.
Modified: trunk/main/core/lib/Haver/Base.pm
===================================================================
--- trunk/main/core/lib/Haver/Base.pm 2004-12-28 07:10:54 UTC (rev 432)
+++ trunk/main/core/lib/Haver/Base.pm 2004-12-28 07:46:45 UTC (rev 433)
@@ -149,7 +149,7 @@
=head1 AUTHOR
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
=head1 COPYRIGHT AND LICENSE
Deleted: trunk/main/core/lib/Haver/Config.pm
===================================================================
--- trunk/main/core/lib/Haver/Config.pm 2004-12-28 07:10:54 UTC (rev 432)
+++ trunk/main/core/lib/Haver/Config.pm 2004-12-28 07:46:45 UTC (rev 433)
@@ -1,162 +0,0 @@
-# Haver::Config - Configuration Loader/Saver.
-#
-# Copyright (C) 2004 Dylan William Hardison
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Config;
-use strict;
-#use warnings;
-
-use Haver::Savable;
-use Haver::OS;
-
-use base qw(Haver::Savable);
-use YAML ();
-use Fatal qw(:void open close);
-use Haver::Util::Misc (); # merge_struct()
-
-use Haver::Preprocessor;
-
-our $VERSION = 0.04;
-our $RELOAD = 1;
-
-sub initialize {
- my ($me) = @_;
-
- $me->SUPER::initialize;
- if (exists $me->{file}) {
- $me->filename(delete $me->{file});
- }
-
- $me->{_default} = delete $me->{default};
- $me->{_merge} = delete $me->{merge};
-
- #DEBUG(paranoid): "Config file: ", $me->filename;
- if ($me->filename) {
- $me->load;
- }
-}
-
-
-sub _init_data {
- my ($me) = @_;
-
- if ($me->{_default}) {
- my $d = delete $me->{_default};
- %$me = (%$me, %$d);
- }
-}
-
-sub _load_data {
- my ($me, $data) = @_;
- #ASSERT: ref($data) eq 'HASH' or UNIVERSAL::isa($data, 'HASH');
-
- if (not $me->{_merge}) {
- %$me = (%$me, %$data);
- } else {
- %$me = %{ Haver::Util::Misc::merge_struct($data, $me) };
- }
-}
-
-sub _save_data {
- my ($me) = @_;
- my %data = ();
-
- foreach my $k (keys %$me) {
- next if $k =~ /^_/;
- $data{$k} = $me->{$k};
- }
-
- return \%data;
-}
-
-
-sub load {
- my ($me, $fn) = @_;
- $me->filename($fn) if defined $fn;
- $me->SUPER::load;
-}
-
-
-sub filename {
- my ($me, $file) = @_;
-
- if (@_ == 1) {
- return $me->{_filename};
- } elsif (@_ == 2) {
- return $me->{_filename} = $file;
- }
-
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Haver::Config - Configuration manager.
-
-
-
-=head1 SYNOPSIS
-
- use Haver::Config;
- my $config = new Haver::Config(file => 'some-file.yaml');
-
-
-=head1 DESCRIPTION
-
- WRITE ME
-
-=head1 INHERITANCE
-
-Haver::Config
-
-extends L<Haver::Savable>.
-
-overloads C<initialize> C<load>, C<_save_data>, C<_load_data>.
-
-FIXME
-
-=head1 SEE ALSO
-
-L<https://savannah.nongnu.org/projects/haver/>
-
-
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2004 by Dylan William Hardison
-
-This library is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Copied: trunk/main/core/lib/Haver/Core.pm (from rev 432,
trunk/main/core/lib/Haver.pm)
===================================================================
--- trunk/main/core/lib/Haver.pm 2004-12-28 07:10:54 UTC (rev 432)
+++ trunk/main/core/lib/Haver/Core.pm 2004-12-28 07:46:45 UTC (rev 433)
@@ -0,0 +1,75 @@
+# Haver::Core - Main module of Haver-Core
+#
+# Copyright (C) 2004 Dylan William Hardison
+#
+# This module is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This module is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this module; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+package Haver::Core;
+use strict;
+use warnings;
+
+our $VERSION = 0.08;
+
+1;
+__END__
+
+=head1 NAME
+
+Haver::Core - Common modules for Haver::Server and Haver::Client.
+
+=head1 SYNOPSIS
+
+There is none. This module contains no code.
+
+=head1 DESCRIPTION
+
+This collection of modules contains
+modules used by both the Haver server and Haver client.
+
+=head2 EXPORT
+
+None by default.
+
+=head1 SEE ALSO
+
+L<Haver::Protocol>, L<Haver::Protocol::Filter>, L<Haver::Base>.
+
+
+L<https://gna.org/projects/haver/>
+
+
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2004 by Dylan William Hardison
+
+This library is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+=cut
Modified: trunk/main/core/lib/Haver/Formats.pm
===================================================================
--- trunk/main/core/lib/Haver/Formats.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/Formats.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -17,7 +17,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package Haver::Formats;
use strict;
-#use warnings;
+use warnings;
use Haver::Preprocessor;
use POSIX qw( strftime );
Modified: trunk/main/core/lib/Haver/OS/Win95.pm
===================================================================
--- trunk/main/core/lib/Haver/OS/Win95.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/OS/Win95.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -39,8 +39,8 @@
sub config_find {
my ($this, %arg) = @_;
my $scope = $arg{scope} || 'user';
- croak "name => 'appname' required" unless exists $arg{name};
+ die "unimplemented";
}
sub user_is_root { return undef } # No such thing as root on 9x.
Modified: trunk/main/core/lib/Haver/OS/WinNT.pm
===================================================================
--- trunk/main/core/lib/Haver/OS/WinNT.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/OS/WinNT.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -57,7 +57,7 @@
} else {
croak "type => '$arg{type}' is an unknown type";
}
- } elsif ($scope eq 'global-data') {
+ } elsif ($scope eq 'data') {
if ($type eq 'file') {
$result = "$programs\\$name\\data.dat";
} elsif ($type eq 'dir') {
Modified: trunk/main/core/lib/Haver/OS.pm
===================================================================
--- trunk/main/core/lib/Haver/OS.pm 2004-12-28 07:10:54 UTC (rev 432)
+++ trunk/main/core/lib/Haver/OS.pm 2004-12-28 07:46:45 UTC (rev 433)
@@ -146,7 +146,7 @@
=item C<scope>
The scope of the config file/dir. Can be
-one of: global, user, local, or global-data.
+one of: global, user, local, or data.
On Unix and Linux, global is stored in /etc/, while on BSD it is stored
in /etc/local/. In Windows, it is stored under program files.
@@ -155,7 +155,7 @@
and that is $HOME. On Windows XPish, user config files/dirs will be part
of the user's roaming profile, while local will not be.
-global-data is /var/lib on most Unix systems, while on Windows
+data is /var/lib on most Unix systems, while on Windows
it is mostly the same as global.
=back
@@ -170,7 +170,7 @@
=head1 AUTHOR
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
=head1 COPYRIGHT AND LICENSE
Modified: trunk/main/core/lib/Haver/Protocol.pm
===================================================================
--- trunk/main/core/lib/Haver/Protocol.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/Protocol.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this module; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
package Haver::Protocol;
use strict;
use warnings;
@@ -122,8 +121,6 @@
L<https://gna.org/projects/haver/>
-
-
=head1 AUTHOR
Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
Deleted: trunk/main/core/lib/Haver/Savable.pm
===================================================================
--- trunk/main/core/lib/Haver/Savable.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/Savable.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -1,245 +0,0 @@
-# Haver::Savable - Saver/Loader
-#
-# Copyright (C) 2004 Dylan William Hardison
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Savable;
-use strict;
-use Haver::Preprocessor;
-
-use base qw( Haver::Base );
-use Fatal qw(:void open close);
-
-use File::stat (); # OO stat
-use File::Basename (); # basename()
-use File::Path (); # mkpath()
-
-
-use Carp;
-
-our $VERSION = 0.02;
-our $RELOAD = 1;
-
-sub initialize {
- my ($me) = @_;
-
- $me->{_mtime} = -1;
- $me->{_overwrite} = 0;
-}
-
-sub load {
- my ($me) = @_;
- my $filename = $me->filename;
- my $fh;
-
- #DEBUG(obj): "Loading $me";
- #ASSERT: defined $filename;
- if (-e $filename) {
- my $data = $me->read_file($filename);
- $me->_init_data;
- $me->{_mtime} = File::stat::populate(CORE::stat(_))->mtime;
- return $me->_load_data($data);
- } else {
- $me->_init_data;
- $me->{_mtime} = time;
- return undef;
- }
-
-}
-
-sub read_file {
- my ($me, $file) = @_;
- my $data = _slurp($file);
- YAML::Load($data);
-}
-
-# This slurps in the entire file.
-sub _slurp {
- my ($file) = @_;
- my $fh;
- open $fh, $file;
- local $/ = undef;
- my $data = readline $fh;
- close $fh;
-
- return $data;
-}
-
-sub _init_data { }
-
-sub save {
- my ($me) = @_;
- my $filename = $me->filename;
- my $fh;
-
- #ASSERT: defined $filename;
- my $mtime = do {
- if (-e $filename) {
- File::stat::populate(CORE::stat(_))->mtime;
- } else {
- $me->{_mtime};
- }
- };
- #ASSERT: defined $mtime;
-
- File::Path::mkpath($me->directory);
-
- if ($me->{_overwrite} or ($mtime == $me->{_mtime})) {
- my $save = $me->_save_data or return 0;
- $me->write_file($filename, $save);
- $me->{_mtime} = File::stat::stat($filename)->mtime;
- #DEBUG(obj): "Saving $me";
- return 1;
- } else {
- carp "Cowardly refusing to overwrite $filename... $mtime !=
$me->{_mtime}";
- return 0;
- }
-}
-
-sub write_file {
- my ($me, $file, $data) = @_;
- my $fh;
- open $fh, '>', $file;
- print $fh YAML::Dump($data);
- close $fh;
-}
-
-
-sub overwrite {
- my ($me, $val) = @_;
- #ASSERT: @_ == 1 or @_ == 2;
-
- if (@_ == 1) {
- return $me->{_overwrite};
- } elsif (@_ == 2) {
- return $me->{_overwrite} = $val;
- }
-}
-
-sub directory {
- my ($me) = @_;
-
- (File::Basename::fileparse($me->filename))[1];
-}
-
-sub finalize {
- my ($me) = @_;
-}
-
-
-1;
-
-__END__
-
-=head1 NAME
-
-Haver::Savable - Framework for persistent objects.
-
-=head1 SYNOPSIS
-
- # See the source code for Haver::Config.
-
-=head1 DESCRIPTION
-
-Haver::Savable is a base class for objects that need to have persistency,
-such as config files. Haver::Savable is only a base class, you need
-to inherit from it in order to use it.
-
-
-=head1 METHODS
-
-=head2 new(Z<>)
-
-the new() constructor creates and returns a new Haver::Savable.
-It takes no options.
-
-
-=head2 save(Z<>)
-
-This saves data to C<$self-E<gt>filename()>. It takes no arguments.
-The data to be saved is obtained by calling C<$self-E<gt>_save_data()>.
-=head2 load(Z<>)
-
-This loads data from C<$self-E<gt>filename()>
-and passes it to C<$self-E<gt>_load_data()>.
-
-=head2 auto_save($bool)
-
-This gets or sets the auto_save option. If auto_save is true,
-then C<$self-E<gt>save()> will be called upon object destruction.
-
-The default is false.
-
-=head2 overwrite($bool)
-
-This gets or sets the overwrite option. If overwrite
-is false, when you go to save() a savable object,
-it will cowardly refuse to overwrite C<$self-E<gt>filename>.
-
-If overwrite is true, then it will always save over
-the file, even if the file has been modified since
-the last load().
-
-The default is false.
-
-=head1 VIRTUAL METHODS
-
-These methods you must define in your subclasses (except
-for the optional one).
-
-=head2 _init_data(Z<>)
-
-This is optional. If defined, it will be called when
-C<$self-E<gt>filename()> can not be found. It should probably
-set up default values that will later be saved to C<$self-E<gt>filename()>.
-
-=head2 _load_data($data)
-
-This method should take whatever is in $data and load it into $self
-somehow. The type of $data is application-dependant; generally
-it is whatever C<$self-E<gt>_save_data()> returns (see below).
-
-=head2 _save_data(Z<>)
-
-This method should inspect $self and return whatever
-should be written (serialized) to C<$self-E<gt>filename()>.
-
-=head1 SEE ALSO
-
-L<https://gna.org/projects/haver/>
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2004 by Dylan William Hardison
-
-This library is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Deleted: trunk/main/core/lib/Haver/Util/Logger.pm
===================================================================
--- trunk/main/core/lib/Haver/Util/Logger.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/Util/Logger.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -1,185 +0,0 @@
-# Haver::Logger - Logger
-#
-# Copyright (C) 2004 Dylan William Hardison
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Util::Logger;
-use strict;
-use warnings;
-
-use POE qw( Wheel::ReadWrite Driver::SysRW Filter::Line );
-use Fatal qw( :void open close );
-
-use Haver::Preprocessor;
-
-our $VERSION = "0.01";
-my $Package = __PACKAGE__;
-
-sub create {
- my $class = shift;
- # ASSERT: (@_ == 1 and ref($_[0]) eq 'HASH') or ((@_ % 2) == 0);
- my $opts = @_ == 1 ? $_[0] : { @_ };
-
-
- create POE::Session (
- package_states => [
- $Package => {
- _start => 'on_start',
- _stop => 'on_stop',
- _default => 'on_default',
- 'shutdown' => 'on_shutdown',
- 'flush' => 'on_flush',
- },
- ],
- args => [ $opts ],
- heap => {
- alias => 'Logger' || delete $opts->{alias},
- },
- );
-}
-
-sub on_start {
- my ($kernel, $heap, $opts) = @_[KERNEL, HEAP, ARG0];
- my %wheels = ();
- my @handles = ();
- my $levels = $opts->{levels};
- my $driver = $opts->{driver} || sub { new POE::Driver::SysRW };
- my $filter = $opts->{filter} || sub { new
POE::Filter::Line(OutputLiteral => "\n") };
-
-
- foreach my $level (keys %$levels) {
- my $file = $opts->{levels}{$level};
- my $fh;
- unless (ref $file) {
- open $fh, ">$file";
- } else {
- $fh = $file;
- }
-
- $wheels{$level} = new POE::Wheel::ReadWrite (
- InputHandle => -1,
- OutputHandle => $fh,
- Driver => $driver->(),
- Filter => $filter->(),
- FlushedEvent => 'flush',
- );
- }
-
- $heap->{wheels} = \%wheels;
-
- $kernel->alias_set($heap->{alias});
- print "Logger starts.\n";
-}
-
-sub on_stop {
- print "Logger stops.\n";
-}
-
-sub on_default {
- my ($kernel, $heap, $level, $args) = @_[KERNEL, HEAP, ARG0, ARG1];
- my $msg = $args->[0];
-
- if ($level =~ /^_/) {
- return 0;
- }
-
- if (exists $heap->{wheels}{$level}) {
- $heap->{wheels}{$level}->put($msg);
- } elsif (exists $heap->{wheels}{default}) {
- $heap->{wheels}{default}->put($msg);
- } else {
- print "[$level] $msg\n";
- }
-
-}
-
-sub on_shutdown {
- my ($kernel, $heap) = @_[KERNEL, HEAP];
-
- $kernel->alias_remove($heap->{alias});
- $heap->{shutdown} = 1;
-}
-
-sub on_flush {
- my ($kernel, $heap) = @_[KERNEL, HEAP];
-
- if ($heap->{shutdown}) {
- $heap->{wheels} = {};
- }
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Haver::Logger - POE-based logging service.
-
-=head1 SYNOPSIS
-
- use Haver::Logger;
- create Haver::Logger (
- levels => {
- alert => 'alert.log',
- error => \*STDERR,
- foo => new IO::File ('bunnies.log'),
- },
- filter => sub { new POE::Filter::Line }, # optional, default
- driver => sub { new POE::Driver::SysRW }, # optional, default
- alias => 'Logger' # optional, default
- );
-
- # in some POE-state,
- $kernel->post('Logger', 'alert', 'bunnies');
- $kernel->post('Logger', 'error', 'I have been stolen by aliens');
- $kernel->post('Logger', 'foo', 'bar baz <g>');
-
- # When you're done:
- $kernel->post('Logger', 'shutdown');
-
-
-=head1 DESCRIPTION
-
-FIXME: Document this.
-
-=head1 SEE ALSO
-
-L<https://gna.org/projects/haver/>
-
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2004 by Dylan William Hardison
-
-This library is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Deleted: trunk/main/core/lib/Haver/Util/Misc.pm
===================================================================
--- trunk/main/core/lib/Haver/Util/Misc.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/Util/Misc.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -1,77 +0,0 @@
-# Haver::Util::Misc - Various routines
-#
-# Copyright (C) 2004 Dylan William Hardison, Bryan Donlan
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Util::Misc;
-use strict;
-#use warnings;
-use Haver::Preprocessor;
-use Scalar::Util qw(reftype);
-use Carp;
-
-use Exporter;
-use base 'Exporter';
-
-our @EXPORT_OK = qw( merge_struct);
-our $VERSION = 0.02;
-our $RELOAD = 1;
-
-
-# Author: bdonlan
-sub merge_struct {
- # ASSERT: @_ == 2;
- my ($left, $right) = @_;
- my $func = "merge_struct(\$left,\$right):";
-
- unless (ref $left and ref $right) {
- return $left;
- }
-
- if (reftype $left ne reftype $right) {
- croak "$func \$left and \$right are not the same!";
- }
- if (reftype $left eq 'HASH') {
- goto &merge_hash;
- } elsif (reftype $left eq 'ARRAY') {
- goto &merge_array;
- } else {
- croak "$func Can not merge a(n) ", reftype $left, " reference!";
- }
-}
-
-# Author: bdonlan
-sub merge_hash {
- # ASSERT: reftype($_[0]) eq 'HASH' and reftype($_[1]) eq 'HASH';
- my ($left, $right) = @_;
- my %merged = %$left;
- for (keys %$right) {
- if (exists $merged{$_}) {
- $merged{$_} = merge_struct($merged{$_}, $right->{$_});
- } else {
- $merged{$_} = $right->{$_};
- }
- }
- return \%merged;
-}
-
-# Author: bdonlan
-sub merge_array {
- # ASSERT: reftype($_[0]) eq 'ARRAY' and reftype($_[1]) eq 'ARRAY';
- my ($left, $right) = @_;
- return [EMAIL PROTECTED], @$right];
-}
-
-1;
Modified: trunk/main/core/lib/Haver/Util/Reload.pm
===================================================================
--- trunk/main/core/lib/Haver/Util/Reload.pm 2004-12-28 07:10:54 UTC (rev
432)
+++ trunk/main/core/lib/Haver/Util/Reload.pm 2004-12-28 07:46:45 UTC (rev
433)
@@ -19,6 +19,7 @@
use strict;
use warnings;
use File::stat;
+use Carp;
our $VERSION = '0.01';
our %Stat;
@@ -41,7 +42,9 @@
my ($this, $pat) = @_;
if (ref($pat) eq 'Regexp') {
$Pattern = $pat;
- }
+ } else {
+ croak "$this->pattern(\$pat): pattern must be a qr// regexp!";
+ }
}
sub load {
@@ -157,11 +160,11 @@
=head1 SEE ALSO
-L<https://savannah.nongnu.org/projects/haver/>
+L<Haver::Core>.
=head1 AUTHOR
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
=head1 COPYRIGHT AND LICENSE