familysearch-gedcomx 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,386 @@
1
+ {
2
+ "persons" : [ {
3
+ "id" : "L7PD-KY3",
4
+ "links" : {
5
+ "ancestry" : {
6
+ "href" : "https://familysearch.org/platform/tree/ancestry?person=L7PD-KY3",
7
+ "title" : "Ancestry"
8
+ },
9
+ "fs-child-relationships" : {
10
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/fs-child-relationships",
11
+ "title" : "FamilySearch Person Relationships"
12
+ },
13
+ "person" : {
14
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3",
15
+ "title" : "Person"
16
+ },
17
+ "descendancy" : {
18
+ "href" : "https://familysearch.org/platform/tree/descendancy?person=L7PD-KY3",
19
+ "title" : "Descendancy"
20
+ },
21
+ "discussion-references" : {
22
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/discussion-references",
23
+ "title" : "Discussion References"
24
+ },
25
+ "person-with-relationships" : {
26
+ "href" : "https://familysearch.org/platform/tree/persons-with-relationships?person=L7PD-KY3",
27
+ "title" : "Person With Relationships"
28
+ },
29
+ "change-history" : {
30
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/changes",
31
+ "title" : "Change History"
32
+ },
33
+ "fs-parent-relationships" : {
34
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/fs-parent-relationships",
35
+ "title" : "FamilySearch Person Relationships"
36
+ },
37
+ "spouse-relationships" : {
38
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/spouse-relationships",
39
+ "title" : "Person Relationships"
40
+ },
41
+ "child-relationships" : {
42
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/child-relationships",
43
+ "title" : "Person Relationships"
44
+ },
45
+ "parent-relationships" : {
46
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/parent-relationships",
47
+ "title" : "Person Relationships"
48
+ },
49
+ "source-references" : {
50
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/source-references",
51
+ "title" : "Source References"
52
+ },
53
+ "notes" : {
54
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/notes",
55
+ "title" : "Notes"
56
+ },
57
+ "person-matches" : {
58
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/matches",
59
+ "title" : "Person Matches"
60
+ }
61
+ },
62
+ "living" : false,
63
+ "gender" : {
64
+ "id" : "V.777-777N",
65
+ "links" : {
66
+ "conclusion" : {
67
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/V.777-777N",
68
+ "title" : "Conclusion"
69
+ }
70
+ },
71
+ "confidence" : "http://gedcomx.org/Low",
72
+ "attribution" : {
73
+ "contributor" : {
74
+ "resource" : "https://familysearch.org/platform/users/agents/MMN3-1QG",
75
+ "resourceId" : "MMN3-1QG"
76
+ },
77
+ "modified" : 1337659403627
78
+ },
79
+ "type" : "http://gedcomx.org/Male"
80
+ },
81
+ "names" : [ {
82
+ "id" : "V.777-7771",
83
+ "links" : {
84
+ "conclusion" : {
85
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/V.777-7771",
86
+ "title" : "Conclusion"
87
+ }
88
+ },
89
+ "attribution" : {
90
+ "contributor" : {
91
+ "resource" : "https://familysearch.org/platform/users/agents/MMN3-1QG",
92
+ "resourceId" : "MMN3-1QG"
93
+ },
94
+ "modified" : 1348777068968
95
+ },
96
+ "type" : "http://gedcomx.org/BirthName",
97
+ "nameForms" : [ {
98
+ "lang" : "i-default",
99
+ "fullText" : "Marshall P Felch",
100
+ "parts" : [ {
101
+ "type" : "http://gedcomx.org/Given",
102
+ "value" : "Marshall P"
103
+ }, {
104
+ "type" : "http://gedcomx.org/Surname",
105
+ "value" : "Felch"
106
+ } ]
107
+ } ],
108
+ "preferred" : true
109
+ }, {
110
+ "id" : "N.777-777H",
111
+ "links" : {
112
+ "conclusion" : {
113
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/N.777-777H",
114
+ "title" : "Conclusion"
115
+ }
116
+ },
117
+ "confidence" : "http://gedcomx.org/Low",
118
+ "attribution" : {
119
+ "contributor" : {
120
+ "resource" : "https://familysearch.org/platform/users/agents/MMWG-V3Y",
121
+ "resourceId" : "MMWG-V3Y"
122
+ },
123
+ "modified" : 1337704958316
124
+ },
125
+ "type" : "http://gedcomx.org/BirthName",
126
+ "nameForms" : [ {
127
+ "lang" : "i-default",
128
+ "fullText" : "Marshall P. Felch",
129
+ "parts" : [ {
130
+ "type" : "http://gedcomx.org/Given",
131
+ "value" : "Marshall P."
132
+ }, {
133
+ "type" : "http://gedcomx.org/Surname",
134
+ "value" : "Felch"
135
+ } ]
136
+ } ],
137
+ "preferred" : false
138
+ }, {
139
+ "id" : "N.777-777L",
140
+ "links" : {
141
+ "conclusion" : {
142
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/N.777-777L",
143
+ "title" : "Conclusion"
144
+ }
145
+ },
146
+ "confidence" : "http://gedcomx.org/Low",
147
+ "attribution" : {
148
+ "contributor" : {
149
+ "resource" : "https://familysearch.org/platform/users/agents/MMMM-MM8",
150
+ "resourceId" : "MMMM-MM8"
151
+ },
152
+ "modified" : 1337704958316
153
+ },
154
+ "type" : "http://gedcomx.org/BirthName",
155
+ "nameForms" : [ {
156
+ "lang" : "i-default",
157
+ "fullText" : "Marshall B. Felch",
158
+ "parts" : [ {
159
+ "type" : "http://gedcomx.org/Given",
160
+ "value" : "Marshall B."
161
+ }, {
162
+ "type" : "http://gedcomx.org/Surname",
163
+ "value" : "Felch"
164
+ } ]
165
+ } ],
166
+ "preferred" : false
167
+ }, {
168
+ "id" : "N.777-777Z",
169
+ "links" : {
170
+ "conclusion" : {
171
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/N.777-777Z",
172
+ "title" : "Conclusion"
173
+ }
174
+ },
175
+ "confidence" : "http://gedcomx.org/Low",
176
+ "attribution" : {
177
+ "contributor" : {
178
+ "resource" : "https://familysearch.org/platform/users/agents/MMN3-1QG",
179
+ "resourceId" : "MMN3-1QG"
180
+ },
181
+ "modified" : 1337704958316
182
+ },
183
+ "type" : "http://gedcomx.org/BirthName",
184
+ "nameForms" : [ {
185
+ "lang" : "i-default",
186
+ "fullText" : "Marshall Parker Felch",
187
+ "parts" : [ {
188
+ "type" : "http://gedcomx.org/Given",
189
+ "value" : "Marshall Parker"
190
+ }, {
191
+ "type" : "http://gedcomx.org/Surname",
192
+ "value" : "Felch"
193
+ } ]
194
+ } ],
195
+ "preferred" : false
196
+ }, {
197
+ "id" : "N.777-7779",
198
+ "links" : {
199
+ "conclusion" : {
200
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/N.777-7779",
201
+ "title" : "Conclusion"
202
+ }
203
+ },
204
+ "confidence" : "http://gedcomx.org/Low",
205
+ "attribution" : {
206
+ "contributor" : {
207
+ "resource" : "https://familysearch.org/platform/users/agents/MMWG-V3Y",
208
+ "resourceId" : "MMWG-V3Y"
209
+ },
210
+ "modified" : 1337704958316
211
+ },
212
+ "type" : "http://gedcomx.org/BirthName",
213
+ "nameForms" : [ {
214
+ "lang" : "i-default",
215
+ "fullText" : "Marshall P.",
216
+ "parts" : [ {
217
+ "type" : "http://gedcomx.org/Given",
218
+ "value" : "Marshall P."
219
+ } ]
220
+ } ],
221
+ "preferred" : false
222
+ }, {
223
+ "id" : "N.777-777V",
224
+ "links" : {
225
+ "conclusion" : {
226
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/N.777-777V",
227
+ "title" : "Conclusion"
228
+ }
229
+ },
230
+ "confidence" : "http://gedcomx.org/Low",
231
+ "attribution" : {
232
+ "contributor" : {
233
+ "resource" : "https://familysearch.org/platform/users/agents/MMMM-MM8",
234
+ "resourceId" : "MMMM-MM8"
235
+ },
236
+ "modified" : 1337704958316
237
+ },
238
+ "type" : "http://gedcomx.org/BirthName",
239
+ "nameForms" : [ {
240
+ "lang" : "i-default",
241
+ "fullText" : "Marshal Parker Felch",
242
+ "parts" : [ {
243
+ "type" : "http://gedcomx.org/Given",
244
+ "value" : "Marshal Parker"
245
+ }, {
246
+ "type" : "http://gedcomx.org/Surname",
247
+ "value" : "Felch"
248
+ } ]
249
+ } ],
250
+ "preferred" : false
251
+ } ],
252
+ "facts" : [ {
253
+ "id" : "V.777-777P",
254
+ "links" : {
255
+ "conclusion" : {
256
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/V.777-777P",
257
+ "title" : "Conclusion"
258
+ }
259
+ },
260
+ "confidence" : "http://gedcomx.org/Low",
261
+ "attribution" : {
262
+ "contributor" : {
263
+ "resource" : "https://familysearch.org/platform/users/agents/MMN3-1QG",
264
+ "resourceId" : "MMN3-1QG"
265
+ },
266
+ "modified" : 1256701431214
267
+ },
268
+ "type" : "http://gedcomx.org/Birth",
269
+ "date" : {
270
+ "original" : "Jun 1834",
271
+ "formal" : "+1834-06",
272
+ "normalized" : [ {
273
+ "value" : "June 1834"
274
+ } ]
275
+ },
276
+ "place" : {
277
+ "original" : "Middlesex County, Massachusetts, United States",
278
+ "description" : "#-1680125262"
279
+ }
280
+ }, {
281
+ "id" : "V.777-777P",
282
+ "links" : {
283
+ "conclusion" : {
284
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/V.777-777P",
285
+ "title" : "Conclusion"
286
+ }
287
+ },
288
+ "confidence" : "http://gedcomx.org/Low",
289
+ "attribution" : {
290
+ "contributor" : {
291
+ "resource" : "https://familysearch.org/platform/users/agents/MMN3-1QG",
292
+ "resourceId" : "MMN3-1QG"
293
+ },
294
+ "modified" : 1256701431214
295
+ },
296
+ "type" : "http://gedcomx.org/Christening",
297
+ "date" : {
298
+ "original" : "Jun 1834",
299
+ "formal" : "+1834-06",
300
+ "normalized" : [ {
301
+ "value" : "June 1834"
302
+ } ]
303
+ },
304
+ "place" : {
305
+ "original" : "Middlesex County, Massachusetts, United States",
306
+ "description" : "#-1680125262"
307
+ }
308
+ }, {
309
+ "id" : "V.777-7774",
310
+ "links" : {
311
+ "conclusion" : {
312
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/V.777-7774",
313
+ "title" : "Conclusion"
314
+ }
315
+ },
316
+ "confidence" : "http://gedcomx.org/Low",
317
+ "attribution" : {
318
+ "contributor" : {
319
+ "resource" : "https://familysearch.org/platform/users/agents/MM3T-K8D",
320
+ "resourceId" : "MM3T-K8D"
321
+ },
322
+ "modified" : 1337659403627
323
+ },
324
+ "type" : "http://gedcomx.org/Death",
325
+ "date" : {
326
+ "original" : "9 Feb 1902",
327
+ "formal" : "+1902-02-09",
328
+ "normalized" : [ {
329
+ "value" : "9 February 1902"
330
+ } ]
331
+ },
332
+ "place" : {
333
+ "original" : "Fremont, Colorado, United States",
334
+ "description" : "#-1759301427"
335
+ }
336
+ }, {
337
+ "id" : "V.777-7774",
338
+ "links" : {
339
+ "conclusion" : {
340
+ "href" : "https://familysearch.org/platform/tree/persons/L7PD-KY3/conclusions/V.777-7774",
341
+ "title" : "Conclusion"
342
+ }
343
+ },
344
+ "confidence" : "http://gedcomx.org/Low",
345
+ "attribution" : {
346
+ "contributor" : {
347
+ "resource" : "https://familysearch.org/platform/users/agents/MM3T-K8D",
348
+ "resourceId" : "MM3T-K8D"
349
+ },
350
+ "modified" : 1337659403627
351
+ },
352
+ "type" : "http://gedcomx.org/Burial",
353
+ "date" : {
354
+ "original" : "9 Feb 1902",
355
+ "formal" : "+1902-02-09",
356
+ "normalized" : [ {
357
+ "value" : "9 February 1902"
358
+ } ]
359
+ },
360
+ "place" : {
361
+ "original" : "Fremont, Colorado, United States",
362
+ "description" : "#-1759301427"
363
+ }
364
+ } ],
365
+ "display" : {
366
+ "name" : "Marshall P Felch",
367
+ "gender" : "Male",
368
+ "lifespan" : "1834-1902",
369
+ "birthDate" : "June 1834",
370
+ "birthPlace" : "Middlesex County, Massachusetts, United States",
371
+ "deathDate" : "9 February 1902",
372
+ "deathPlace" : "Fremont, Colorado, United States"
373
+ }
374
+ } ],
375
+ "places" : [ {
376
+ "id" : "-1680125262",
377
+ "names" : [ {
378
+ "value" : "Middlesex, Massachusetts, United States"
379
+ } ]
380
+ }, {
381
+ "id" : "-1759301427",
382
+ "names" : [ {
383
+ "value" : "Fremont, Colorado, United States"
384
+ } ]
385
+ } ]
386
+ }
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe FamilySearch::Gedcomx::GraphPerson do
5
+ before(:each) do
6
+ @child = FamilySearch::Gedcomx::FamilySearch.new(JSON.parse(File.read('spec/familysearch/gedcomx/fixtures/person-with-relationships.json')))
7
+ @father = FamilySearch::Gedcomx::FamilySearch.new(JSON.parse(File.read('spec/familysearch/gedcomx/fixtures/person-with-relationships-father.json')))
8
+ @mother = FamilySearch::Gedcomx::FamilySearch.new(JSON.parse(File.read('spec/familysearch/gedcomx/fixtures/person-with-relationships-mother.json')))
9
+ @graph = FamilySearch::Gedcomx::Graph.new
10
+ @graph << @child
11
+ @graph << @father
12
+ @graph << @mother
13
+ @root = @graph.root
14
+ end
15
+
16
+ it "should be setup correctly" do
17
+ @child.should be_instance_of(FamilySearch::Gedcomx::FamilySearch)
18
+ @graph.should be_instance_of(FamilySearch::Gedcomx::Graph)
19
+ @graph.persons.size.should == 3
20
+ @root.id.should == @child.persons[0].id
21
+ end
22
+
23
+ describe "#father_id" do
24
+ it "should return the id of the father from the first childAndParentsRelationships" do
25
+ @root.father_id.should == 'L78M-RLN'
26
+ end
27
+
28
+ it "should return nil if any of the values are nil" do
29
+ # Create the relationship to where the father is missing
30
+ cpr = @graph.childAndParentsRelationships.find{|cpr|cpr.child.resourceId == @root.id}
31
+ cpr.father = nil
32
+ @root.father_id.should be_nil
33
+
34
+ @graph.childAndParentsRelationships = []
35
+ @root.father_id.should be_nil
36
+ end
37
+ end
38
+
39
+ describe "#mother_id" do
40
+ it "should return the id of the mother from the first childAndParentsRelationships" do
41
+ @root.mother_id.should == 'L78M-TD6'
42
+ end
43
+
44
+ it "should return nil if any of the values are nil" do
45
+ # Create the relationship to where the father is missing
46
+ cpr = @graph.childAndParentsRelationships.find{|cpr|cpr.child.resourceId == @root.id}
47
+ cpr.mother = nil
48
+ @root.mother_id.should be_nil
49
+
50
+ @graph.childAndParentsRelationships = []
51
+ @root.mother_id.should be_nil
52
+ end
53
+ end
54
+
55
+ describe "#father" do
56
+ it "should return a GraphPerson" do
57
+ @root.father.should be_instance_of(FamilySearch::Gedcomx::GraphPerson)
58
+ end
59
+
60
+ it "should return the father's person" do
61
+ @root.father.id.should == 'L78M-RLN'
62
+ end
63
+
64
+ it "should return nil if the person hasn't been loaded yet" do
65
+ @root.father.father_id.should_not be_nil
66
+ @root.father.father.should be_nil
67
+ end
68
+
69
+ it "should return nil if the father_id is nil" do
70
+ @root.stub!(:father_id).and_return(nil)
71
+ @root.father.should be_nil
72
+ end
73
+
74
+ end
75
+
76
+ describe "#mother" do
77
+ it "should return a GraphPerson" do
78
+ @root.mother.should be_instance_of(FamilySearch::Gedcomx::GraphPerson)
79
+ end
80
+
81
+ it "should return the mother's person" do
82
+ @root.mother.id.should == 'L78M-TD6'
83
+ end
84
+
85
+ it "should return nil if the person hasn't been loaded yet" do
86
+ @root.mother.mother_id.should_not be_nil
87
+ @root.mother.mother.should be_nil
88
+ end
89
+
90
+ it "should return nil if the father_id is nil" do
91
+ @root.stub!(:mother_id).and_return(nil)
92
+ @root.mother.should be_nil
93
+ end
94
+
95
+ end
96
+
97
+ describe "#all_parents" do
98
+ it "should return an array of GraphParents objects" do
99
+ @root.all_parents[0].class.should == FamilySearch::Gedcomx::GraphParents
100
+ end
101
+
102
+ it "should allow me to get to the father, mother, and child of the relationship" do
103
+ @root.all_parents[0].father.class.should == FamilySearch::Gedcomx::GraphPerson
104
+ @root.all_parents[0].mother.class.should == FamilySearch::Gedcomx::GraphPerson
105
+ @root.all_parents[0].child.class.should == FamilySearch::Gedcomx::GraphPerson
106
+ end
107
+
108
+ it "should return the right person" do
109
+ @root.all_parents[0].father.should == @root.father
110
+ @root.all_parents[0].mother.should == @root.mother
111
+ @root.all_parents[0].child.should == @root
112
+ end
113
+ end
114
+
115
+ end