genealogy 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/genealogy/query_methods.rb +71 -4
- data/lib/genealogy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWNhZWM3Y2ZkOTg2ZTYwNzNjOTAyODQ5ODk3NTA1ZTk3NWU4Y2JlMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTljMTlmNDMzN2ZlNWFhNThmN2MzMmRiZWRlZGNmMGNlNGNiZWQ5YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjRmZjYwMjI2MTAxMzY4ODc3YjY2ZWZiZjRlNWYxMTdiMDJhMGVlNzlkYjY1
|
10
|
+
Y2I2YjE3NjU3OGEwMGI2YzU5ODBlZmYxNGI1Mjc4YjQxZjU5NjIzZjAwNjRl
|
11
|
+
YmM0NjlhZmQ3NzM0Y2E3MTNjZmI0Mzk4MWNlNWMyMGRmYmNlMTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGEyMzdmM2U0ODIzNzJlMzYyM2I1NjY4YjdhZGIxMjM4MjNhZjU4YjEwZTM3
|
14
|
+
YzRmZjM1MTFkZWI2YWQyZjM5NDBlZDdhNGI5MzU4ZWFkZDI2ZTU4MzJkNDEw
|
15
|
+
YzZlMzUwNTU5OGU2YzlmMjgyMGNlNTI1OWZhY2M1MjhlNTAyYjk=
|
@@ -56,6 +56,10 @@ module Genealogy
|
|
56
56
|
result
|
57
57
|
end
|
58
58
|
|
59
|
+
def great_grandparents
|
60
|
+
parents.compact.inject([]){|memo, parent| memo |= parent.grandparents}
|
61
|
+
end
|
62
|
+
|
59
63
|
# offspring
|
60
64
|
def offspring(options = {})
|
61
65
|
if spouse = options[:spouse]
|
@@ -167,12 +171,75 @@ module Genealogy
|
|
167
171
|
offspring.inject([]){|memo,child| memo |= child.offspring}
|
168
172
|
end
|
169
173
|
|
170
|
-
def
|
171
|
-
|
174
|
+
def great_grandchildren
|
175
|
+
grandchildren.compact.inject([]){|memo,grandchild| memo |= grandchild.offspring}
|
176
|
+
end
|
177
|
+
|
178
|
+
def uncles_and_aunts(options={})
|
179
|
+
relation = case options[:lineage]
|
180
|
+
when :paternal
|
181
|
+
[father]
|
182
|
+
when :maternal
|
183
|
+
[mother]
|
184
|
+
else
|
185
|
+
parents
|
186
|
+
end
|
187
|
+
|
188
|
+
case options[:sex]
|
189
|
+
when :male
|
190
|
+
relation.compact.inject([]){|memo,parent| memo |= parent.siblings(half: options[:half]).select(&:is_male?)}
|
191
|
+
when :female
|
192
|
+
relation.compact.inject([]){|memo,parent| memo |= parent.siblings(half: options[:half]).select(&:is_female?)}
|
193
|
+
else
|
194
|
+
relation.compact.inject([]){|memo,parent| memo |= parent.siblings(half: options[:half])}
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def uncles(options = {})
|
199
|
+
uncles_and_aunts(sex: :male, lineage: options[:lineage], half: options[:half])
|
200
|
+
end
|
201
|
+
|
202
|
+
def aunts(options={})
|
203
|
+
uncles_and_aunts(sex: :female, lineage: options[:lineage], half: options[:half])
|
204
|
+
end
|
205
|
+
|
206
|
+
def paternal_uncles(options = {})
|
207
|
+
uncles(sex: :male, lineage: :paternal, half: options[:half])
|
208
|
+
end
|
209
|
+
|
210
|
+
def maternal_uncles(options = {})
|
211
|
+
uncles(sex: :male, lineage: :maternal, half: options[:half])
|
212
|
+
end
|
213
|
+
|
214
|
+
def paternal_aunts(options = {})
|
215
|
+
aunts(lineage: :paternal, half: options[:half])
|
216
|
+
end
|
217
|
+
|
218
|
+
def maternal_aunts(options = {})
|
219
|
+
aunts(sex: :female, lineage: :maternal, half: options[:half])
|
220
|
+
end
|
221
|
+
|
222
|
+
def cousins(options = {}, uncle_aunt_options = {})
|
223
|
+
uncles_and_aunts(uncle_aunt_options).compact.inject([]){|memo,parent_sibling| memo |= parent_sibling.offspring}
|
224
|
+
end
|
225
|
+
|
226
|
+
def nieces_and_nephews(options = {}, sibling_options = {})
|
227
|
+
case options[:sex]
|
228
|
+
when :male
|
229
|
+
siblings(sibling_options).inject([]){|memo,sib| memo |= sib.offspring}.select(&:is_male?)
|
230
|
+
when :female
|
231
|
+
siblings(sibling_options).inject([]){|memo,sib| memo |= sib.offspring}.select(&:is_female?)
|
232
|
+
else
|
233
|
+
siblings(sibling_options).inject([]){|memo,sib| memo |= sib.offspring}
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def nephews(options = {}, sibling_options = {})
|
238
|
+
nieces_and_nephews(options.merge({sex: :male}), sibling_options)
|
172
239
|
end
|
173
240
|
|
174
|
-
def
|
175
|
-
|
241
|
+
def nieces(options = {}, sibling_options = {})
|
242
|
+
nieces_and_nephews(options.merge({sex: :female}), sibling_options)
|
176
243
|
end
|
177
244
|
|
178
245
|
def family(options = {})
|
data/lib/genealogy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genealogy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masciugo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project: ! '[none]'
|
147
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.3.0
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Organise ActiveRecord models into a genealogical tree structure
|