Sha256: e288d65fcddacb89efd3ac0c8cd4daa044ad699fdc0fe0db5038de012f705ec3

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'happymapper')

file_contents = File.read(dir + '/../spec/fixtures/family_tree.xml')

module FamilySearch
  class AlternateIds
    include HappyMapper
    
    tag 'alternateIds'
    namespace 'fsapi-v1' => 'http://api.familysearch.org/v1'
    has_many :ids, String, :tag => 'id'
  end
  
  class Information
    include HappyMapper
    
    namespace 'fsapi-v1' => 'http://api.familysearch.org/v1'
    has_one :alternateIds, AlternateIds
  end
  
  class Person
    include HappyMapper
    
    namespace_url 'http://api.familysearch.org/familytree/v1'
    attribute :version, String
    attribute :modified, Time
    attribute :id, String
    has_one :information, Information
  end
  
  class Persons
    include HappyMapper
    
    namespace_url 'http://api.familysearch.org/familytree/v1'
    has_many :person, Person
  end
  
  class FamilyTree
    include HappyMapper
    
    tag 'familytree'
    namespace_url 'http://api.familysearch.org/familytree/v1'
    attribute :version, String
    attribute :status_message, String, :tag => 'statusMessage'
    attribute :status_code, String, :tag => 'statusCode'
    has_one :persons, Persons
  end
end

familytree = FamilySearch::FamilyTree.parse(file_contents)
familytree.persons.person.each do |p|
  puts p.id, p.information.alternateIds.ids, ''
end
puts familytree.to_xml

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
jimmyz-happymapper-0.3.1 examples/family_tree.rb
jimmyz-happymapper-0.3.2 examples/family_tree.rb
jimmyz-happymapper-0.3.3 examples/family_tree.rb
kdonovan-happymapper-0.3.4 examples/family_tree.rb
kdonovan-happymapper-0.3.5 examples/family_tree.rb
kdonovan-happymapper-0.3.7 examples/family_tree.rb