genealogy 1.0.0 → 1.1.0
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/lib/genealogy/genealogy.rb +14 -4
- data/lib/genealogy/query_methods.rb +26 -4
- data/lib/genealogy/version.rb +1 -1
- metadata +42 -26
- checksums.yaml +0 -7
data/lib/genealogy/genealogy.rb
CHANGED
|
@@ -47,19 +47,19 @@ module Genealogy
|
|
|
47
47
|
validates_presence_of sex_column
|
|
48
48
|
validates_format_of sex_column, :with => /[#{sex_values.join}]/
|
|
49
49
|
|
|
50
|
-
## relatives associations
|
|
51
50
|
tracked_relatives.each do |key|
|
|
52
51
|
# class attribute where is stored the correspondig foreign_key column name
|
|
53
52
|
class_attribute_name = "#{key}_column"
|
|
54
53
|
foreign_key = "#{key}_id"
|
|
55
54
|
class_attribute class_attribute_name
|
|
56
55
|
self.send("#{class_attribute_name}=", options[class_attribute_name.to_sym] || foreign_key)
|
|
57
|
-
|
|
58
|
-
# self join association
|
|
56
|
+
# self join associations
|
|
59
57
|
belongs_to key, class_name: self, foreign_key: foreign_key
|
|
60
|
-
|
|
61
58
|
end
|
|
62
59
|
|
|
60
|
+
has_many :children_as_father, :class_name => self, :foreign_key => self.father_column, :dependent => :nullify, :extend => FatherAssociationExtension
|
|
61
|
+
has_many :children_as_mother, :class_name => self, :foreign_key => self.mother_column, :dependent => :nullify, :extend => MotherAssociationExtension
|
|
62
|
+
|
|
63
63
|
# Include instance methods and class methods
|
|
64
64
|
include Genealogy::QueryMethods
|
|
65
65
|
include Genealogy::AlterMethods
|
|
@@ -67,4 +67,14 @@ module Genealogy
|
|
|
67
67
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
module MotherAssociationExtension
|
|
71
|
+
def with(father_id)
|
|
72
|
+
where(father_id: father_id)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
module FatherAssociationExtension
|
|
76
|
+
def with(mother_id)
|
|
77
|
+
where(mother_id: mother_id)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
70
80
|
end
|
|
@@ -64,20 +64,42 @@ module Genealogy
|
|
|
64
64
|
case sex
|
|
65
65
|
when sex_male_value
|
|
66
66
|
if options.keys.include?(:spouse)
|
|
67
|
-
|
|
67
|
+
children_as_father.with(spouse.try(:id))
|
|
68
68
|
else
|
|
69
|
-
|
|
69
|
+
children_as_father
|
|
70
70
|
end
|
|
71
71
|
when sex_female_value
|
|
72
72
|
if options.keys.include?(:spouse)
|
|
73
|
-
|
|
73
|
+
children_as_mother.with(spouse.try(:id))
|
|
74
74
|
else
|
|
75
|
-
|
|
75
|
+
children_as_mother
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
alias_method :children, :offspring
|
|
80
80
|
|
|
81
|
+
# # offspring
|
|
82
|
+
# def offspring(options = {})
|
|
83
|
+
# if spouse = options[:spouse]
|
|
84
|
+
# raise WrongSexException, "Problems while looking for #{self}'s offspring made with spouse #{spouse} who should not be a #{spouse.sex}." if spouse.sex == sex
|
|
85
|
+
# end
|
|
86
|
+
# case sex
|
|
87
|
+
# when sex_male_value
|
|
88
|
+
# if options.keys.include?(:spouse)
|
|
89
|
+
# self.genealogy_class.where(father_id: id, mother_id: spouse.try(:id))
|
|
90
|
+
# else
|
|
91
|
+
# self.genealogy_class.where(father_id: id)
|
|
92
|
+
# end
|
|
93
|
+
# when sex_female_value
|
|
94
|
+
# if options.keys.include?(:spouse)
|
|
95
|
+
# self.genealogy_class.where(mother_id: id, father_id: spouse.try(:id))
|
|
96
|
+
# else
|
|
97
|
+
# self.genealogy_class.where(mother_id: id)
|
|
98
|
+
# end
|
|
99
|
+
# end
|
|
100
|
+
# end
|
|
101
|
+
# alias_method :children, :offspring
|
|
102
|
+
|
|
81
103
|
def eligible_offspring
|
|
82
104
|
self.genealogy_class.all - ancestors - offspring - siblings - [self]
|
|
83
105
|
end
|
data/lib/genealogy/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,111 +1,126 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: genealogy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
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:
|
|
12
|
+
date: 2014-02-11 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: '
|
|
21
|
+
version: '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: '
|
|
29
|
+
version: '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: '
|
|
37
|
+
version: '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: '
|
|
45
|
+
version: '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
|
|
47
53
|
version: '0'
|
|
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
|
|
54
61
|
version: '0'
|
|
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
|
|
61
69
|
version: '0'
|
|
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
|
|
68
77
|
version: '0'
|
|
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
|
|
75
85
|
version: '0'
|
|
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
|
|
82
93
|
version: '0'
|
|
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
|
|
89
101
|
version: '0'
|
|
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
|
|
96
109
|
version: '0'
|
|
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
|
|
103
117
|
version: '0'
|
|
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
|
|
110
125
|
version: '0'
|
|
111
126
|
description: Genealogy is a ruby gem library which extend ActiveRecord::Base class
|
|
@@ -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
|
-
rubyforge_project: '[none]'
|
|
147
|
-
rubygems_version:
|
|
162
|
+
rubyforge_project: ! '[none]'
|
|
163
|
+
rubygems_version: 1.8.23
|
|
148
164
|
signing_key:
|
|
149
|
-
specification_version:
|
|
165
|
+
specification_version: 3
|
|
150
166
|
summary: Organise ActiveRecord models into a genealogical tree structure
|
|
151
167
|
test_files: []
|
checksums.yaml
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
SHA1:
|
|
3
|
-
metadata.gz: cbde6f4104df5b3eec88c5e1b2b7a089495f91d1
|
|
4
|
-
data.tar.gz: 73479c02912fa7794b63c9e24e7a50206a8108cd
|
|
5
|
-
SHA512:
|
|
6
|
-
metadata.gz: 40686d98c83f2c96fc4a6733673613025ff636fc5256952d081ffda4293241df67f443be9f9ba34c7399049d7f12dd77c9f3a804b9955d30aa02bfd401d6b9eb
|
|
7
|
-
data.tar.gz: 3fe31cb2ac85b55de1923772a642b118fe1ab10178204d758aace27ac09a0f1eb174ce64bdd8623c224f7abf64ac5305c0d8a970b878925f3ced4045f754bd98
|