ruby-fs-stack 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +0 -4
- data/VERSION +1 -1
- data/lib/ruby-fs-stack/familytree.rb +15 -5
- data/ruby-fs-stack.gemspec +4 -2
- data/spec/familytree_v2/familytree_communicator_spec.rb +24 -4
- data/spec/familytree_v2/relationships_spec.rb +73 -0
- metadata +5 -3
data/README.rdoc
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.4.
|
|
1
|
+
0.4.12
|
|
@@ -156,8 +156,6 @@ module FamilytreeV2
|
|
|
156
156
|
|
|
157
157
|
relationship_type = get_relationship_type(options)
|
|
158
158
|
with_id = options[relationship_type.to_sym]
|
|
159
|
-
|
|
160
|
-
url = "#{Base}person/#{base_id}/#{relationship_type}/#{with_id}"
|
|
161
159
|
|
|
162
160
|
# Get the existing person/relationship or create a new person
|
|
163
161
|
unless person = relationship(base_id,options.merge({:events => 'none'}))
|
|
@@ -176,6 +174,12 @@ module FamilytreeV2
|
|
|
176
174
|
familytree = Org::Familysearch::Ws::Familytree::V2::Schema::FamilyTree.new
|
|
177
175
|
familytree.persons = [person]
|
|
178
176
|
|
|
177
|
+
# Get the most current related ID for the URI
|
|
178
|
+
rels = person.relationships.get_relationships_of_type(r_options[:type])
|
|
179
|
+
rel = rels.find{|r|r.id == r_options[:with] || r.requestedId == r_options[:with]}
|
|
180
|
+
related_id = rel.id
|
|
181
|
+
url = "#{Base}person/#{base_id}/#{relationship_type}/#{related_id}"
|
|
182
|
+
|
|
179
183
|
# Post the response and return the resulting person/relationship record from response
|
|
180
184
|
response = @fs_communicator.post(url,familytree.to_json)
|
|
181
185
|
res_familytree = Org::Familysearch::Ws::Familytree::V2::Schema::FamilyTree.from_json JSON.parse(response.body)
|
|
@@ -740,8 +744,7 @@ module Org::Familysearch::Ws::Familytree::V2::Schema
|
|
|
740
744
|
# ** :event - a hash with values {:type => 'Marriage', :date => '15 Nov 2007', :place => 'Utah, United States'}
|
|
741
745
|
# ** :ordinance - a hash with values {:date => '15 Nov 2007', :temple => 'SLAKE', :place => 'Utah, United States', :type => "Sealing_to_Spouse"}
|
|
742
746
|
def add_relationship(options)
|
|
743
|
-
|
|
744
|
-
relationship = self.send(g_command.to_sym).find{|r|r.id == options[:with] || r.requestedId == options[:with]}
|
|
747
|
+
relationship = self.get_relationships_of_type(options[:type]).find{|r|r.id == options[:with] || r.requestedId == options[:with]}
|
|
745
748
|
if relationship.nil?
|
|
746
749
|
relationship = Relationship.new
|
|
747
750
|
relationship.id = options[:with]
|
|
@@ -761,6 +764,13 @@ module Org::Familysearch::Ws::Familytree::V2::Schema
|
|
|
761
764
|
self.send(s_command.to_sym,[relationship])
|
|
762
765
|
end
|
|
763
766
|
|
|
767
|
+
# ====Params
|
|
768
|
+
# * type - should be 'child', 'spouse', or 'parent'
|
|
769
|
+
def get_relationships_of_type(type)
|
|
770
|
+
g_command = get_command(type)
|
|
771
|
+
relationships = self.send(g_command.to_sym)
|
|
772
|
+
end
|
|
773
|
+
|
|
764
774
|
# Overriding the Enunciate code because of a bug (parents, spouses, and children were not pluralized)
|
|
765
775
|
# the json hash for this PersonRelationships
|
|
766
776
|
def to_jaxb_json_hash
|
|
@@ -805,7 +815,7 @@ module Org::Familysearch::Ws::Familytree::V2::Schema
|
|
|
805
815
|
|
|
806
816
|
private
|
|
807
817
|
def get_command(type)
|
|
808
|
-
(type == 'child') ? 'children' : "#{type}s"
|
|
818
|
+
(type.to_s == 'child') ? 'children' : "#{type}s"
|
|
809
819
|
end
|
|
810
820
|
|
|
811
821
|
def set_command(type)
|
data/ruby-fs-stack.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{ruby-fs-stack}
|
|
8
|
-
s.version = "0.4.
|
|
8
|
+
s.version = "0.4.12"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Jimmy Zimmerman"]
|
|
12
|
-
s.date = %q{2010-
|
|
12
|
+
s.date = %q{2010-05-01}
|
|
13
13
|
s.description = %q{A library that enables you to read and update information with the new.familysearch.org API.}
|
|
14
14
|
s.email = %q{jimmy.zimmerman@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -64,6 +64,7 @@ Gem::Specification.new do |s|
|
|
|
64
64
|
"spec/familytree_v2/note_spec.rb",
|
|
65
65
|
"spec/familytree_v2/pedigree_spec.rb",
|
|
66
66
|
"spec/familytree_v2/person_spec.rb",
|
|
67
|
+
"spec/familytree_v2/relationships_spec.rb",
|
|
67
68
|
"spec/familytree_v2/search_results_spec.rb",
|
|
68
69
|
"spec/fixtures/fakeweb_response.txt",
|
|
69
70
|
"spec/fs_utils_spec.rb",
|
|
@@ -85,6 +86,7 @@ Gem::Specification.new do |s|
|
|
|
85
86
|
"spec/familytree_v2/note_spec.rb",
|
|
86
87
|
"spec/familytree_v2/pedigree_spec.rb",
|
|
87
88
|
"spec/familytree_v2/person_spec.rb",
|
|
89
|
+
"spec/familytree_v2/relationships_spec.rb",
|
|
88
90
|
"spec/familytree_v2/search_results_spec.rb",
|
|
89
91
|
"spec/fs_utils_spec.rb",
|
|
90
92
|
"spec/identity_v1/identity_spec.rb",
|
|
@@ -303,7 +303,8 @@ describe FamilytreeV2::Communicator do
|
|
|
303
303
|
|
|
304
304
|
@person = new_person
|
|
305
305
|
@person2 = new_person
|
|
306
|
-
|
|
306
|
+
@generic_person = new_person
|
|
307
|
+
Org::Familysearch::Ws::Familytree::V2::Schema::Person.stub!(:new).and_return(@generic_person)
|
|
307
308
|
|
|
308
309
|
end
|
|
309
310
|
|
|
@@ -315,22 +316,22 @@ describe FamilytreeV2::Communicator do
|
|
|
315
316
|
it "should create a new person with a relationship since it wasn't yet found" do
|
|
316
317
|
Org::Familysearch::Ws::Familytree::V2::Schema::Person.should_receive(:new).and_return(@person)
|
|
317
318
|
@person.should_receive(:id=).with('KWQS-BBQ')
|
|
318
|
-
@person.should_receive(:create_relationship).with(:type => 'parent', :with => 'KWQS-BBR', :lineage => 'Biological')
|
|
319
319
|
@ft_v2_com.write_relationship 'KWQS-BBQ', :parent => 'KWQS-BBR', :lineage => 'Biological'
|
|
320
|
+
@person.relationships.parents.first.id.should == 'KWQS-BBR'
|
|
320
321
|
end
|
|
321
322
|
|
|
322
323
|
it "should add a marriage event if sent an event key" do
|
|
323
324
|
Org::Familysearch::Ws::Familytree::V2::Schema::Person.should_receive(:new).and_return(@person)
|
|
324
325
|
@person.should_receive(:id=).with('KWQS-BBQ')
|
|
325
|
-
@person.should_receive(:create_relationship).with(:type => 'spouse', :with => 'KWQS-BBR', :event => {:type => 'Marriage', :place => 'United States', :date => '1800'})
|
|
326
326
|
@ft_v2_com.write_relationship 'KWQS-BBQ', :spouse => 'KWQS-BBR', :event => {:type => 'Marriage', :place => 'United States', :date => '1800'}
|
|
327
|
+
@person.relationships.spouses.first.id.should == 'KWQS-BBR'
|
|
327
328
|
end
|
|
328
329
|
|
|
329
330
|
it "should add an ordinances if sent an ordinance key" do
|
|
330
331
|
Org::Familysearch::Ws::Familytree::V2::Schema::Person.should_receive(:new).and_return(@person)
|
|
331
332
|
@person.should_receive(:id=).with('KWQS-BBQ')
|
|
332
|
-
@person.should_receive(:create_relationship).with(:type => 'spouse', :with => 'KWQS-BBR', :ordinance => {:type => 'Sealing_to_Spouse', :place => 'United States', :date => '1800', :temple => 'SLAKE'})
|
|
333
333
|
@ft_v2_com.write_relationship 'KWQS-BBQ', :spouse => 'KWQS-BBR', :ordinance => {:type => 'Sealing_to_Spouse', :place => 'United States', :date => '1800', :temple => 'SLAKE'}
|
|
334
|
+
@person.relationships.spouses.first.assertions.ordinances.first.value.type.should == 'Sealing_to_Spouse'
|
|
334
335
|
end
|
|
335
336
|
|
|
336
337
|
it "should post a familytree request with the person to the correct endpoint" do
|
|
@@ -343,6 +344,25 @@ describe FamilytreeV2::Communicator do
|
|
|
343
344
|
@ft_v2_com.write_relationship 'KWQS-BBQ', :parent => 'KWQS-BBR', :lineage => 'Biological'
|
|
344
345
|
end
|
|
345
346
|
|
|
347
|
+
it "should post to the correct endpoint even if the related person ID changes" do
|
|
348
|
+
@person2.create_relationship(:type => 'parent', :with => 'KWQS-BBR', :lineage => 'Biological')
|
|
349
|
+
# Simulate a changed related ID
|
|
350
|
+
@person2.relationships.parents.first.id = 'KWQS-JIM'
|
|
351
|
+
@person2.relationships.parents.first.requestedId = 'KWQS-BBR'
|
|
352
|
+
@person2.id = 'KWQS-BBQ'
|
|
353
|
+
|
|
354
|
+
# inject this mock person into the write_relationship flow
|
|
355
|
+
Org::Familysearch::Ws::Familytree::V2::Schema::Person.should_receive(:new).and_return(@person2)
|
|
356
|
+
@person2.should_receive(:create_relationship)
|
|
357
|
+
|
|
358
|
+
familytree = Org::Familysearch::Ws::Familytree::V2::Schema::FamilyTree.new
|
|
359
|
+
familytree.persons = [@person2]
|
|
360
|
+
|
|
361
|
+
@fs_com_mock.should_receive(:post).with('/familytree/v2/person/KWQS-BBQ/parent/KWQS-JIM', familytree.to_json).and_return(@post_res)
|
|
362
|
+
@ft_v2_com.write_relationship 'KWQS-BBQ', :parent => 'KWQS-BBR', :lineage => 'Biological'
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
|
|
346
366
|
end
|
|
347
367
|
|
|
348
368
|
describe "for relationships that already exist" do
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
require 'ruby-fs-stack/familytree'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe Org::Familysearch::Ws::Familytree::V2::Schema::PersonRelationships do
|
|
6
|
+
FamTreeV2 = Org::Familysearch::Ws::Familytree::V2::Schema
|
|
7
|
+
|
|
8
|
+
describe "add_relationship" do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@relationships = FamTreeV2::PersonRelationships.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "for spousal relationships" do
|
|
14
|
+
it "should create the relationship of the right type" do
|
|
15
|
+
@relationships.add_relationship :type => 'spouse', :with => 'KWQS-BBZ', :event => {:type => 'Marriage',:place =>"Utah, United States", :date => '15 Nov 2007'}
|
|
16
|
+
@relationships.spouses.first.id.should == 'KWQS-BBZ'
|
|
17
|
+
@relationships.spouses.first.assertions.events.first.value.type.should == 'Marriage'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "for parent relationships" do
|
|
22
|
+
it "should create the relationship of the right type" do
|
|
23
|
+
@relationships.add_relationship :type => 'parent', :with => 'KWQS-BBZ', :lineage => 'Biological'
|
|
24
|
+
@relationships.parents.first.id.should == 'KWQS-BBZ'
|
|
25
|
+
@relationships.parents.first.assertions.characteristics.first.value.type.should == 'Lineage'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "for child relationships" do
|
|
30
|
+
it "should create the relationship of the right type" do
|
|
31
|
+
@relationships.add_relationship :type => 'child', :with => 'KWQS-BBZ', :lineage => 'Biological'
|
|
32
|
+
@relationships.children.first.id.should == 'KWQS-BBZ'
|
|
33
|
+
@relationships.children.first.assertions.characteristics.first.value.type.should == 'Lineage'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "get_relationships_of_type" do
|
|
40
|
+
before(:each) do
|
|
41
|
+
@relationships = FamTreeV2::PersonRelationships.new
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "for spousal relationships" do
|
|
45
|
+
it "should return the relationship of the right type" do
|
|
46
|
+
@relationships.add_relationship :type => 'spouse', :with => 'KWQS-BBZ', :event => {:type => 'Marriage',:place =>"Utah, United States", :date => '15 Nov 2007'}
|
|
47
|
+
spouses = @relationships.spouses
|
|
48
|
+
@relationships.get_relationships_of_type('spouse').should == spouses
|
|
49
|
+
@relationships.get_relationships_of_type(:spouse).should == spouses
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "for parent relationships" do
|
|
54
|
+
it "should return the relationship of the right type" do
|
|
55
|
+
@relationships.add_relationship :type => 'parent', :with => 'KWQS-BBZ', :lineage => 'Biological'
|
|
56
|
+
parents = @relationships.parents
|
|
57
|
+
@relationships.get_relationships_of_type('parent').should == parents
|
|
58
|
+
@relationships.get_relationships_of_type(:parent).should == parents
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe "for child relationships" do
|
|
63
|
+
it "should return the relationship of the right type" do
|
|
64
|
+
@relationships.add_relationship :type => 'child', :with => 'KWQS-BBZ', :lineage => 'Biological'
|
|
65
|
+
children = @relationships.children
|
|
66
|
+
@relationships.get_relationships_of_type('child').should == children
|
|
67
|
+
@relationships.get_relationships_of_type(:child).should == children
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 4
|
|
8
|
-
-
|
|
9
|
-
version: 0.4.
|
|
8
|
+
- 12
|
|
9
|
+
version: 0.4.12
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Jimmy Zimmerman
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-05-01 00:00:00 -06:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -98,6 +98,7 @@ files:
|
|
|
98
98
|
- spec/familytree_v2/note_spec.rb
|
|
99
99
|
- spec/familytree_v2/pedigree_spec.rb
|
|
100
100
|
- spec/familytree_v2/person_spec.rb
|
|
101
|
+
- spec/familytree_v2/relationships_spec.rb
|
|
101
102
|
- spec/familytree_v2/search_results_spec.rb
|
|
102
103
|
- spec/fixtures/fakeweb_response.txt
|
|
103
104
|
- spec/fs_utils_spec.rb
|
|
@@ -142,6 +143,7 @@ test_files:
|
|
|
142
143
|
- spec/familytree_v2/note_spec.rb
|
|
143
144
|
- spec/familytree_v2/pedigree_spec.rb
|
|
144
145
|
- spec/familytree_v2/person_spec.rb
|
|
146
|
+
- spec/familytree_v2/relationships_spec.rb
|
|
145
147
|
- spec/familytree_v2/search_results_spec.rb
|
|
146
148
|
- spec/fs_utils_spec.rb
|
|
147
149
|
- spec/identity_v1/identity_spec.rb
|