ruby-fs-stack 0.4.8 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ruby-fs-stack/familytree.rb +24 -0
- data/ruby-fs-stack.gemspec +4 -5
- data/spec/familytree_v2/person_spec.rb +102 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.9
|
@@ -396,6 +396,15 @@ module Org::Familysearch::Ws::Familytree::V2::Schema
|
|
396
396
|
end
|
397
397
|
end
|
398
398
|
|
399
|
+
def surname
|
400
|
+
if self.pieces.nil?
|
401
|
+
(self.fullText.nil?) ? nil : self.fullText.split(' ').last
|
402
|
+
else
|
403
|
+
piece = self.pieces.find{|piece|piece.type == 'Family'}
|
404
|
+
(piece.nil?) ? nil : piece.value
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
399
408
|
def buildFullText
|
400
409
|
if self.pieces.nil?
|
401
410
|
return ''
|
@@ -820,6 +829,21 @@ module Org::Familysearch::Ws::Familytree::V2::Schema
|
|
820
829
|
self.full_names.first
|
821
830
|
end
|
822
831
|
|
832
|
+
def surnames
|
833
|
+
if assertions && assertions.names
|
834
|
+
names = assertions.names.collect do |name|
|
835
|
+
name.value.forms[0].surname
|
836
|
+
end
|
837
|
+
return names.reject{|n|n.nil?}
|
838
|
+
else
|
839
|
+
[]
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
def surname
|
844
|
+
surnames.first
|
845
|
+
end
|
846
|
+
|
823
847
|
def gender
|
824
848
|
if assertions && assertions.genders && assertions.genders[0] && assertions.genders[0].value
|
825
849
|
assertions.genders[0].value.type
|
data/ruby-fs-stack.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
4
|
# -*- encoding: utf-8 -*-
|
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.9"
|
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-03-
|
12
|
+
s.date = %q{2010-03-16}
|
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 = [
|
@@ -110,4 +110,3 @@ Gem::Specification.new do |s|
|
|
110
110
|
s.add_dependency(%q<fakeweb>, [">= 0"])
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
@@ -144,6 +144,108 @@ describe Org::Familysearch::Ws::Familytree::V2::Schema::Person do
|
|
144
144
|
|
145
145
|
end
|
146
146
|
|
147
|
+
describe "surnames" do
|
148
|
+
describe "for persons with at least one name" do
|
149
|
+
before(:each) do
|
150
|
+
@person = parse_person
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should return an array of strings" do
|
154
|
+
names = @person.surnames
|
155
|
+
names.should be_a_kind_of(Array)
|
156
|
+
names[0].should be_a_kind_of(String)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return an array of names" do
|
160
|
+
names = @person.surnames
|
161
|
+
names.first.should == "Felch"
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should return a name pieced together from pieces" do
|
165
|
+
@person.add_name("Parker James /Fileh/")
|
166
|
+
names = @person.surnames
|
167
|
+
names[3].should == "Fileh"
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "surname" do
|
171
|
+
|
172
|
+
it "should return the first surname" do
|
173
|
+
@person.surname.should == "Felch"
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "for persons without names" do
|
180
|
+
|
181
|
+
def add_names_array
|
182
|
+
@person.assertions.names = []
|
183
|
+
end
|
184
|
+
|
185
|
+
def add_blank_form
|
186
|
+
nameAssertion = FamTreeV2::NameAssertion.new
|
187
|
+
nameAssertion.value = FamTreeV2::NameValue.new
|
188
|
+
nameAssertion.value.forms = [FamTreeV2::NameForm.new]
|
189
|
+
@person.assertions.names[0] = nameAssertion
|
190
|
+
end
|
191
|
+
|
192
|
+
def add_given_name_pieces
|
193
|
+
p1 = FamTreeV2::NamePiece.new
|
194
|
+
p1.type = 'Given'
|
195
|
+
p1.postdelimiters = ' '
|
196
|
+
p1.value = 'John'
|
197
|
+
p2 = FamTreeV2::NamePiece.new
|
198
|
+
p2.type = 'Given'
|
199
|
+
p2.postdelimiters = ' '
|
200
|
+
p2.value = 'Jacob'
|
201
|
+
@person.assertions.names[0].value.forms[0].pieces = [p1,p2]
|
202
|
+
end
|
203
|
+
|
204
|
+
before(:each) do
|
205
|
+
@person = parse_person('KJ86-3VD_version.js')
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should return [] if no assertions" do
|
209
|
+
@person.surnames.should == []
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should return [] if no names" do
|
213
|
+
add_assertions
|
214
|
+
@person.surnames.should == []
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should return [] if names is empty" do
|
218
|
+
add_assertions
|
219
|
+
add_names_array
|
220
|
+
@person.surnames.should == []
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should return [] if a only a blank nameform" do
|
224
|
+
add_assertions
|
225
|
+
add_names_array
|
226
|
+
add_blank_form
|
227
|
+
@person.surnames.should == []
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should return [] and nil if no Family name piece is present" do
|
231
|
+
add_assertions
|
232
|
+
add_names_array
|
233
|
+
add_blank_form
|
234
|
+
add_given_name_pieces
|
235
|
+
@person.surnames.should == []
|
236
|
+
@person.surname.should == nil
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should return the last piece of the fullText string if pieces are missing" do
|
240
|
+
@person.add_name "Parker Felch"
|
241
|
+
@person.surnames.should == ['Felch']
|
242
|
+
@person.surname.should == 'Felch'
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
147
249
|
describe "father_id" do
|
148
250
|
before(:each) do
|
149
251
|
@person = parse_person('KJ86-3VD_parents_families.js')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-fs-stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Zimmerman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-16 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|