rbur004 / gedcom

Ruby Gedcom parser
Other
13 stars 9 forks source link

Documentation on generating GEDCOM files #5

Open mawise opened 3 years ago

mawise commented 3 years ago

Hi @rbur004 ,

This looks like an awesome library! I know it's been years since you've looked at it. The Readme states you can both parse and produce GEDCOM files, but I can't find any references in the documentation for how to produce GEDCOM files.

Thanks!

Matt

rbur004 commented 3 years ago

File.open( "../test_data/TGC551LF.out", "w:ASCII-8BIT") do |file| file.print g.transmissions[0].to_gedcom end

rbur004 commented 3 years ago

Wrote it with the intent to create a web based gedcom editor. Got side tracked by life :) I do use it to read gedcom files, to use in www.burrowes.org to load and present my Family tree. Others have extended it to be an editor too, so look at their forks.

Also good for checking gedcom files syntax and all references are consistent. ` require 'gedcom'

["burrowes.ged"].each do |source| puts "parse #{source}" g = Gedcom.file(dir + '/' + source, "r:ASCII-8BIT") #OK with LF line endings. g.transmissions[0].summary puts puts "Self check of Gedcom consistency" g.transmissions[0].self_check #validate the gedcom file just loaded, printing errors found. puts end

`

mawise commented 3 years ago

Thanks for the note!

On Sun, Sep 13, 2020 at 3:22 PM Rob Burrowes notifications@github.com wrote:

Wrote it with the intent to create a web based gedcom editor. Got side tracked by life :) I do use it to read gedcom files, to use in www.burrowes.org to load and present my Family tree. Others have extended it to be an editor too, so look at their forks.

Also good for checking gedcom files syntax and all references are consistent. ` require 'gedcom'

["burrowes.ged"].each do |source| puts "parse #{source}" g = Gedcom.file(dir + '/' + source, "r:ASCII-8BIT") #OK with LF line endings. g.transmissions[0].summary puts puts "Self check of Gedcom consistency" g.transmissions[0].self_check #validate the gedcom file just loaded, printing errors found. puts end

`

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rbur004/gedcom/issues/5#issuecomment-691720227, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2DVLSIHC7QWTS22MSLUV3SFUSW3ANCNFSM4RKXNDIA .

garz75 commented 2 years ago

Hello,

I have just discovered your gem when trying to generate a GEDCOM file from some Excel file my family created when starting to create the family tree.

From the above discussion, I could not understand if the current code is actually able to generate GEDCOM "from scratch". I tried the trial-and-error approach (see note below), but did not manage to create a simple GEDCOM with only one individual in it.

So my questions are:

thank you in advance for your help.

Fred

Note:

I tried the naive approach :

require 'gedcom'

g = Gedcom.new

transmission = Transmission.new

g.transmissions = [ transmission ]

name_record = Name_record.new(transmission)

name_record.surname = "Garzon"
name_record.given = "Frederic"

ind = Individual_record.new(transmission)

ind.name_record = [ name_record ]

transmission.individual_record = [ ind ]

puts g.transmissions[0].to_gedcom

puts g.transmissions[0].self_check

The first puts shows nothing ( g.transmissions[0].to_gedcom is nil )

The second puts raise an exception:

Traceback (most recent call last):
        8: from /Users/garz/.rvm/rubies/ruby-2.7.5/bin/irb:23:in `<main>'
        7: from /Users/garz/.rvm/rubies/ruby-2.7.5/bin/irb:23:in `load'
        6: from /Users/garz/.rvm/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        5: from (irb):22
        4: from /Users/garz/.rvm/gems/ruby-2.7.5@genealogy/gems/gedcom-0.9.4/lib/gedcom/transmission.rb:96:in `self_check'
        3: from /Users/garz/.rvm/gems/ruby-2.7.5@genealogy/gems/gedcom-0.9.4/lib/gedcom/transmission.rb:96:in `each'
        2: from /Users/garz/.rvm/gems/ruby-2.7.5@genealogy/gems/gedcom-0.9.4/lib/gedcom/transmission.rb:97:in `block in self_check'
        1: from /Users/garz/.rvm/gems/ruby-2.7.5@genealogy/gems/gedcom-0.9.4/lib/gedcom/individual_record.rb:547:in `self_check'
NoMethodError (undefined method `first' for nil:NilClass)

The nil object is the Individual_record#@individual_ref attribute. I have not looked into the entire source code yet but I guess I need an Xref for each record I create...