lexorank 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 422a0db95be12bd9cffe35d7f549b1ebb71dd5de9751424a3794fd18dc2065c1
4
- data.tar.gz: 8d00dd0cb9331d2a5152bb9f68c3ba7a29ac84de4732bc03bf5bc78a946c8a58
3
+ metadata.gz: 705faccc54d5d09c0ce7e8239d777b79ebe9b8857ea2956c6b7f9378f0b027d6
4
+ data.tar.gz: b61be364fc9dfffb76947d4ad8ae6462ac8d70490a33262bdb96ac8601e1eb7f
5
5
  SHA512:
6
- metadata.gz: c49a7c38ed0853cdddc5fd1664d085ad08b8b2d91c00e8920da4a19078c6949dd29608bd92013eb31fabd2b1b46191c9ef589fb53629196f0582b53d132ca0f6
7
- data.tar.gz: 6e303a53f9185913313d20ef37a9a549b1323c174c98cda5f3533e8bf16e1188ece014fa0fbbf8545b55e040b316f671aa960b99adae3b184ab05e00c6783026
6
+ metadata.gz: 188136b56717efec3aa8dedcdd9f977506a21677814dbe2d85488fa6f2154abe877f1412a4aaab03c1aae7b8f8badacd1982b2f77b12718893594133e10e10ef
7
+ data.tar.gz: afd223cb7e8a444cc0428cfab024e89044a9918cfe013972ea65d2c4250f4db70b6b5653d3d5ba989ad548f33f6fda34b6730f3a5053872e0f705f56187d7185
@@ -3,13 +3,11 @@
3
3
  class Lexorank::Ranking
4
4
  include Lexorank
5
5
 
6
- attr_reader :record_class, :original_field, :field, :original_group_by, :group_by, :advisory_lock_config
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
- @original_field = field
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 @field
27
- # TODO: Make this raise an error. Supplying an invalid column should raise.
28
- warn "The supplied ranking column \"#{@original_field}\" is not a column of the model!"
29
- end
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 && !processed_name && (association = record_class.reflect_on_association(name))
111
+ if name && (association = record_class.reflect_on_association(name))
127
112
  association.foreign_key.to_sym
128
113
  else
129
- processed_name
114
+ name
130
115
  end
131
116
  end
132
117
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lexorank
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
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.2.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-16 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord