genealogy 0.3.9 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,7 +59,7 @@ module Genealogy
59
59
  # offspring
60
60
  def offspring(options = {})
61
61
  if spouse = options[:spouse]
62
- raise WrongSexException, "Something wrong with spouse #{spouse} gender." if spouse.sex == sex
62
+ raise WrongSexException, "Problems while looking for #{self}'s offspring made with spouse #{spouse} who should not be a #{spouse.sex}." if spouse.sex == sex
63
63
  end
64
64
  case sex
65
65
  when sex_male_value
@@ -174,6 +174,7 @@ module Genealogy
174
174
 
175
175
  def family(options = {})
176
176
  res = [self] | siblings | parents | offspring
177
+ res |= [current_spouse] if self.class.current_spouse_enabled
177
178
  res |= case options[:half]
178
179
  when nil
179
180
  []
@@ -186,11 +187,16 @@ module Genealogy
186
187
  else
187
188
  raise WrongOptionValueException, "Admitted values for :half options are: :father, :mother, :include, nil"
188
189
  end
189
- offspring.inject(res){|memo,child| memo |= child.parents}.compact
190
+ res = offspring.inject(res){|memo,child| memo |= child.parents} #add spouses
191
+
192
+ res += [grandparents + grandchildren + uncles_and_aunts + nieces_and_nephews].flatten if options[:extended]
193
+
194
+ res.compact
190
195
  end
191
196
 
192
197
  def family_hash(options = {})
193
198
  roles = [:father, :mother, :children, :siblings]
199
+ roles += [:current_spouse] if self.class.current_spouse_enabled
194
200
  roles += case options[:half]
195
201
  when nil
196
202
  []
@@ -203,19 +209,18 @@ module Genealogy
203
209
  else
204
210
  raise WrongOptionValueException, "Admitted values for :half options are: :father, :mother, :include, nil"
205
211
  end
212
+ roles += [:paternal_grandfather, :paternal_grandmother, :maternal_grandfather, :maternal_grandmother, :grandchildren, :uncles_and_aunts, :nieces_and_nephews] if options[:extended]
206
213
  h = {}
207
214
  roles.each{|role| h[role] = self.send(role)}
208
215
  h
209
216
  end
210
217
 
211
218
  def extended_family(options = {})
212
- (family(options) + grandparents + grandchildren + uncles_and_aunts + nieces_and_nephews).compact
219
+ family(options.merge(:extended => true))
213
220
  end
214
221
 
215
222
  def extended_family_hash(options = {})
216
- h = family_hash(options)
217
- [:paternal_grandfather, :paternal_grandmother, :maternal_grandfather, :maternal_grandmother, :grandchildren, :uncles_and_aunts, :nieces_and_nephews].each{|role| h[role] = self.send(role)}
218
- h
223
+ family_hash(options.merge(:extended => true))
219
224
  end
220
225
 
221
226
  def sex_to_s
@@ -1,3 +1,3 @@
1
1
  module Genealogy
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.12"
3
3
  end
metadata CHANGED
@@ -1,46 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genealogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.12
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - masciugo
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-12-02 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activerecord
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ! '>='
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: '0'
21
+ version: '3.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ! '>='
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: '3.0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: activesupport
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ! '>='
35
+ - - ~>
32
36
  - !ruby/object:Gem::Version
33
- version: '0'
37
+ version: '3.0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ! '>='
43
+ - - ~>
39
44
  - !ruby/object:Gem::Version
40
- version: '0'
45
+ version: '3.0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: sqlite3
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rspec
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ! '>='
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ! '>='
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: debugger
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ! '>='
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ! '>='
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: gem-release
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ! '>='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ! '>='
109
124
  - !ruby/object:Gem::Version
@@ -127,25 +142,26 @@ files:
127
142
  homepage: https://github.com/masciugo/genealogy
128
143
  licenses:
129
144
  - MIT
130
- metadata: {}
131
145
  post_install_message:
132
146
  rdoc_options: []
133
147
  require_paths:
134
148
  - lib
135
149
  required_ruby_version: !ruby/object:Gem::Requirement
150
+ none: false
136
151
  requirements:
137
152
  - - ! '>='
138
153
  - !ruby/object:Gem::Version
139
154
  version: '0'
140
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
141
157
  requirements:
142
158
  - - ! '>='
143
159
  - !ruby/object:Gem::Version
144
160
  version: '0'
145
161
  requirements: []
146
162
  rubyforge_project: ! '[none]'
147
- rubygems_version: 2.0.3
163
+ rubygems_version: 1.8.23
148
164
  signing_key:
149
- specification_version: 4
165
+ specification_version: 3
150
166
  summary: Organise ActiveRecord models into a genealogical tree structure
151
167
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzJjYzM4NzU0NWU4OWI3N2I1OWUzZWU5OGI3M2VlOTc3NTU5MGU1Yg==
5
- data.tar.gz: !binary |-
6
- ZWRhODI1YjMxMjA1NDA3MTQ3ZGNhN2NhNDgyOTEyMDQ2ZGY5MmIyZA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZmNiN2MwOTJkN2E2NmExNmMyY2MzYWI5ZWJkMTkwNjE2YTJkNzJlMzM4MDll
10
- MTE3MTM0YmI1NWM0N2U3YzA0NDAxYzg1ZDMxNTllMzZkYzJmMTMzMTc1NTc3
11
- MTgyNTMyM2FkZTlkMGY1MGFhZDllM2Q2OWU0MzNlNTc1ZjJhMDQ=
12
- data.tar.gz: !binary |-
13
- MmY0Yzc1M2FjY2ZjYjJhZWFlZTcyMDMwYmFjOWIxNmQwYzAyMjAxM2E1N2Nl
14
- ZTFiYjQzYzBmMzRlNzBkMmI4NWQxY2JkMDg2OGYzZjg4MTdmOWY4ZDBkZTRm
15
- N2QyNDM5OWY2Y2RhYWNlNjdkZjBjNTljNWEyMDJhMjdkMzExNzU=