Permalink
Browse files

Version 1.08

  • Loading branch information...
1 parent 890960f commit c93cbe4faaadd836801fafbc2a6fc352b5e522b3 @pjcj committed Feb 21, 2005
Showing with 261 additions and 160 deletions.
  1. +5 −0 CHANGES
  2. +49 −7 Gedcom.pm
  3. +3 −3 Gedcom/Event.pm
  4. +3 −3 Gedcom/Family.pm
  5. +51 −35 Gedcom/Grammar.pm
  6. +2 −2 Gedcom/Grammar_5_5.pm
  7. +3 −3 Gedcom/Individual.pm
  8. +29 −17 Gedcom/Item.pm
  9. +46 −28 Gedcom/LifeLines.pm
  10. +7 −5 Gedcom/Record.pm
  11. +2 −2 Makefile.PL
  12. +8 −1 README
  13. +0 −1 TODO
  14. +5 −5 ged
  15. +1 −1 gedcom.vim
  16. +9 −9 lines2perl
  17. +3 −3 parse_grammar
  18. +3 −3 t/Basic.pm
  19. +3 −3 t/Engine.pm
  20. +3 −3 t/Lines.pm
  21. +1 −1 t/basic.t
  22. +1 −1 t/bias.t
  23. +2 −2 t/birthdates.t
  24. +1 −1 t/lines.t
  25. +2 −2 t/lines/bias
  26. +6 −6 t/lines/bias.plx
  27. +2 −2 t/lines/lines.plx
  28. +2 −2 t/lines/namefreq.plx
  29. +1 −1 t/namefreq.t
  30. +1 −1 t/parse_grammar.t
  31. +1 −1 t/read_only.t
  32. +1 −1 t/resolve.t
  33. +1 −1 t/resolve_read_only.t
  34. +4 −4 tkged
View
@@ -142,3 +142,8 @@ Release 1.07 - 14th March 2000
full_value()
- Get parse_grammar working again.
- Add a test for parse_grammar.
+
+Release 1.08 - 8th May 2000
+ - Allow xrefs to match .+ instead of \w+\d+
+ - Make XML output valid.
+ - Allow extra sub-items of a grammar structure.
View
@@ -22,7 +22,7 @@ use vars qw($VERSION $Tags);
BEGIN
{
- $VERSION = "1.07";
+ $VERSION = "1.08";
$Tags =
{
@@ -158,10 +158,10 @@ BEGIN
};
}
-use Gedcom::Grammar 1.07;
-use Gedcom::Individual 1.07;
-use Gedcom::Family 1.07;
-use Gedcom::Event 1.07;
+use Gedcom::Grammar 1.08;
+use Gedcom::Individual 1.08;
+use Gedcom::Family 1.08;
+use Gedcom::Event 1.08;
sub new
{
@@ -246,6 +246,20 @@ sub write_xml
my $self = shift;
my $file = shift or die "No filename specified";
$self->{fh} = FileHandle->new($file, "w") or die "Can't open $file: $!";
+ $self->{fh}->print(<<'EOH');
+<!--
+
+This output was generated by Gedcom.pm.
+Gedcom.pm is Copyright 1999-2000, Paul Johnson (pjcj@cpan.org)
+Version 1.08 - 8th May 2000
+
+Gedcom.pm is free. It is licensed under the same terms as Perl itself.
+
+The latest version of Gedcom.pm should be available from my homepage:
+http://www.pjcj.fsnet.co.uk
+
+EOH
+ $self->{fh}->print("Generated on " . localtime() . "\n\n-->\n\n");
$self->{record}->write_xml($self->{fh});
$self->{fh}->close or die "Can't close $file: $!";
}
@@ -263,7 +277,7 @@ sub resolve_xref
my $self = shift;;
my ($x) = @_;
my $xref;
- $xref = $self->{xrefs}{$x =~ /^\@(.*)\@$/ ? $1 : $x} if defined $x;
+ $xref = $self->{xrefs}{$x =~ /^\@(.+)\@$/ ? $1 : $x} if defined $x;
$xref;
}
@@ -479,7 +493,7 @@ __END__
Gedcom - a module to manipulate Gedcom genealogy files
-Version 1.07 - 14th March 2000
+Version 1.08 - 8th May 2000
=head1 SYNOPSIS
@@ -523,6 +537,16 @@ is only usable if you can access a PC running Windows of some
description. Part of the reason I wrote this module is because I don't
do that. Well, I didn't. I can now although I prefer not to...
+Requirements:
+ Perl 5.005 or later
+ ActivePerl5 Build Number 520 or later has been reported to work
+
+Optional Modules:
+ Date::Manip.pm to work with dates
+ Text::Soundex.pm to use soundex
+ Parse::RecDescent.pm to use lines2perl
+ Roman.pm to use the LifeLines function roman from lines2perl
+
The Gedcom format is specified in a grammar file (gedcom-5.5.grammar).
Gedcom.pm parses the grammar which is then used to validate and allow
manipulation of the Gedcom file. I have only used Gedcom.pm with
@@ -714,6 +738,7 @@ See Gedcom::Record.pm for more details.
my $ged = Gedcom->new(grammar_version => 5.5,
gedcom_file => $gedcom_file,
+ read_only => 1,
callback => $cb);
my $ged = Gedcom->new(grammar_file => "gedcom-5.5.grammar",
@@ -730,6 +755,23 @@ grammar file as grammar_file. Usually, you will do neither of these,
and in this case the grammar version will default to the latest
available version, currently 5.5.
+The read_only parameter indicates that the Gedcom data structure will be
+used primarily for read_only operations. In this mode the gedcom file
+is read lazily, such that whenever possible the Gedcom records are not
+read until they are needed. This can save on both memory and CPU usage,
+provided that not too much of the gedcom file is needed. If the whole
+of the gedcom file needs to be read, for example to validate it, or to
+write it out in a different format, then this option should not be used.
+
+With or without the read_only option, the gedcom file is accessed in the
+same fashion and the data structures can be changed. In this respect,
+the name read_only is not very accurate, but since changing the Gedcom
+data will generally mean that the data will be written which means that
+the data will first be read, the read_only option is generally useful
+when the data will not be written and when not all the data will be
+read. You may find it useful to experiment with this option and check
+the amount of CPU time and memroy that your application uses.
+
callback is an optional reference to a subroutine which will be called
at various times while the gedcom file (and the grammar file, ir
applicable) is being read. It's purpose is to provide feedback during
View
@@ -13,10 +13,10 @@ require 5.005;
package Gedcom::Event;
-use Gedcom::Record 1.07;
+use Gedcom::Record 1.08;
use vars qw($VERSION @ISA);
-$VERSION = "1.07";
+$VERSION = "1.08";
@ISA = qw( Gedcom::Record );
# sub type
@@ -45,7 +45,7 @@ __END__
Gedcom::Event - a module to manipulate Gedcom events
-Version 1.07 - 14th March 2000
+Version 1.08 - 8th May 2000
=head1 SYNOPSIS
View
@@ -13,10 +13,10 @@ require 5.005;
package Gedcom::Family;
-use Gedcom::Record 1.07;
+use Gedcom::Record 1.08;
use vars qw($VERSION @ISA);
-$VERSION = "1.07";
+$VERSION = "1.08";
@ISA = qw( Gedcom::Record );
sub husband
@@ -82,7 +82,7 @@ __END__
Gedcom::Family - a module to manipulate Gedcom families
-Version 1.07 - 14th March 2000
+Version 1.08 - 8th May 2000
=head1 SYNOPSIS
View
@@ -15,10 +15,10 @@ package Gedcom::Grammar;
use Data::Dumper;
-use Gedcom::Item 1.07;
+use Gedcom::Item 1.08;
use vars qw($VERSION @ISA);
-$VERSION = "1.07";
+$VERSION = "1.08";
@ISA = qw( Gedcom::Item );
sub structure
@@ -61,51 +61,67 @@ sub items
keys %{$self->valid_items}
}
-sub valid_items
+sub _valid_items
{
my $self = shift;
- unless (exists $self->{_valid_items})
+ my %valid_items;
+ for my $item (@{$self->{items}})
{
- my %valid_items;
- for my $item (@{$self->{items}})
+ my $min = $item->min;
+ my $max = $item->max;
+ if ($item->{tag})
{
- my $min = $item->min;
- my $max = $item->max;
- if ($item->{tag})
+ $valid_items{$item->{tag}} =
{
- $valid_items{$item->{tag}} =
+ grammar => $item,
+ min => $min,
+ max => $max
+ };
+ }
+ else
+ {
+ die "What's a " . Data::Dumper->new([$item], ["grammar"])
+ unless my ($value) = $item->{value} =~ /<<(.*)>>/;
+ die "Can't find $value in gedcom structures"
+ unless my $structure = $self->structure($value);
+ $item->{structure} = $structure;
+ while (my($tag, $g) = each %{$structure->valid_items})
+ {
+ $valid_items{$tag} =
{
- grammar => $item,
- min => $min,
- max => $max
+ grammar => $g->{grammar},
+ # min and max can be calculated by multiplication because
+ # the grammar always permits multiple selection records, and
+ # selection records never have compulsory records. This may
+ # change in future grammars, but I would not expect it to -
+ # such a grammar would seem to have little practical use.
+ min => $g->{min} * $min,
+ max => $g->{max} * $max
};
}
- else
+ if (exists $item->{items} && @{$item->{items}})
{
- die "What's a " . Data::Dumper->new([$item], ["grammar"])
- unless my ($value) = $item->{value} =~ /<<(.*)>>/;
- die "Can't find $value in gedcom structures"
- unless my $structure = $self->structure($value);
- $item->{structure} = $structure;
- while (my($tag, $g) = each %{$structure->valid_items})
+ my $extra_items = $item->_valid_items;
+ while (my ($sub_item, $sub_grammar) = each %valid_items)
{
- $valid_items{$tag} =
+ $sub_grammar->{grammar}->valid_items;
+ while (my ($i, $g) = each %$extra_items)
{
- grammar => $g->{grammar},
- # min and max can be calculated by multiplication because
- # the grammar always permits multiple selection records, and
- # selection records never have compulsory records. This may
- # change in future grammars, but I would not expect it to -
- # such a grammar would seem to have little practical use.
- min => $g->{min} * $min,
- max => $g->{max} * $max
- };
+ # print "adding $i to $sub_item\n";
+ $sub_grammar->{grammar}{_valid_items}{$i} = $g;
+ }
+ # print "giving @{[keys %{$sub_grammar->{grammar}->valid_items}]}\n";
}
}
}
- $self->{_valid_items} = \%valid_items;
}
- $self->{_valid_items}
+ \%valid_items
+}
+
+sub valid_items
+{
+ my $self = shift;
+ $self->{_valid_items} ||= $self->_valid_items
}
1;
@@ -116,13 +132,13 @@ __END__
Gedcom::Grammar - a module to manipulate Gedcom grammars
-Version 1.07 - 14th March 2000
+Version 1.08 - 8th May 2000
=head1 SYNOPSIS
use Gedcom::Grammar;
- my $st = $grammar->structures("GEDCOM");
+ my $st = $grammar->structure("GEDCOM");
my $sgr = $grammar->item("DATE");
my @items = $grammar->valid_items;
my $min = $grammar->min;
@@ -152,7 +168,7 @@ objects.
=head2 structures
- my $st = $grammar->structures("GEDCOM");
+ my $st = $grammar->structure("GEDCOM");
Return the grammar item of the specified structure, if it exists, or undef.
View
@@ -14,7 +14,7 @@
# Edit parse_grammar or Makefile.PL to increase the legibility of this file.
# (Removal of the leading spaces nearly halves the size of the file.)
-# Version 1.07 - 14th March 2000
+# Version 1.08 - 8th May 2000
use strict;
@@ -23,7 +23,7 @@ require 5.005;
package Gedcom::Grammar_5_5;
use vars qw($VERSION $grammar);
-$VERSION = "1.07";
+$VERSION = "1.08";
$grammar = bless( {
level => -1,
View
@@ -13,10 +13,10 @@ require 5.005;
package Gedcom::Individual;
-use Gedcom::Record 1.07;
+use Gedcom::Record 1.08;
use vars qw($VERSION @ISA);
-$VERSION = "1.07";
+$VERSION = "1.08";
@ISA = qw( Gedcom::Record );
sub name
@@ -293,7 +293,7 @@ __END__
Gedcom::Individual - a module to manipulate Gedcom individuals
-Version 1.07 - 14th March 2000
+Version 1.08 - 8th May 2000
=head1 SYNOPSIS
Oops, something went wrong.

0 comments on commit c93cbe4

Please sign in to comment.