lexorank 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lexorank/ranking.rb +9 -24
- data/lib/lexorank/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 705faccc54d5d09c0ce7e8239d777b79ebe9b8857ea2956c6b7f9378f0b027d6
|
4
|
+
data.tar.gz: b61be364fc9dfffb76947d4ad8ae6462ac8d70490a33262bdb96ac8601e1eb7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 188136b56717efec3aa8dedcdd9f977506a21677814dbe2d85488fa6f2154abe877f1412a4aaab03c1aae7b8f8badacd1982b2f77b12718893594133e10e10ef
|
7
|
+
data.tar.gz: afd223cb7e8a444cc0428cfab024e89044a9918cfe013972ea65d2c4250f4db70b6b5653d3d5ba989ad548f33f6fda34b6730f3a5053872e0f705f56187d7185
|
data/lib/lexorank/ranking.rb
CHANGED
@@ -3,13 +3,11 @@
|
|
3
3
|
class Lexorank::Ranking
|
4
4
|
include Lexorank
|
5
5
|
|
6
|
-
attr_reader :record_class, :
|
6
|
+
attr_reader :record_class, :field, :group_by, :advisory_lock_config
|
7
7
|
|
8
8
|
def initialize(record_class:, field:, group_by:, advisory_lock:)
|
9
9
|
@record_class = record_class
|
10
|
-
@
|
11
|
-
@field = process_column_name(field)
|
12
|
-
@original_group_by = group_by
|
10
|
+
@field = field
|
13
11
|
@group_by = process_group_by_column_name(group_by)
|
14
12
|
@advisory_lock_config = { enabled: record_class.respond_to?(:with_advisory_lock) }.merge(advisory_lock)
|
15
13
|
end
|
@@ -23,13 +21,11 @@ class Lexorank::Ranking
|
|
23
21
|
)
|
24
22
|
end
|
25
23
|
|
26
|
-
unless
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
if original_group_by && !group_by
|
32
|
-
warn "The supplied grouping by \"#{original_group_by}\" is neither a column nor an association of the model!"
|
24
|
+
unless field
|
25
|
+
raise(
|
26
|
+
Lexorank::InvalidConfigError,
|
27
|
+
'The supplied ":field" option cannot be "nil"!'
|
28
|
+
)
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
@@ -110,23 +106,12 @@ class Lexorank::Ranking
|
|
110
106
|
|
111
107
|
private
|
112
108
|
|
113
|
-
def process_column_name(name)
|
114
|
-
return unless name
|
115
|
-
|
116
|
-
# This requires an active connection... do we want this?
|
117
|
-
if record_class.columns.map(&:name).include?(name.to_s)
|
118
|
-
name
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
109
|
def process_group_by_column_name(name)
|
123
|
-
processed_name = process_column_name(name)
|
124
|
-
|
125
110
|
# This requires rank! to be after the specific association
|
126
|
-
if name &&
|
111
|
+
if name && (association = record_class.reflect_on_association(name))
|
127
112
|
association.foreign_key.to_sym
|
128
113
|
else
|
129
|
-
|
114
|
+
name
|
130
115
|
end
|
131
116
|
end
|
132
117
|
end
|
data/lib/lexorank/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexorank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Böhme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|