lexoranker 0.3.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/lexoranker/rankable_methods/adapters/active_record.rb +20 -7
- data/lib/lexoranker/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: 4a17a65e0a741bb249fa535cbbbee2d29de43e6af66e9809ab1a06d1adfdc8e7
|
4
|
+
data.tar.gz: 55d02c5a3aeed1014df59b423dedbe40c02b353d1e80f3e0e6b851a7bfdb44a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ec4ab3cbe82930d1dacdba14caff8676bff762ab1cdced215e15eb84d80bc26b165357279db58953841951d479e617aa6edfbaae348525797a6d7375d3fb999
|
7
|
+
data.tar.gz: 9cff2ca9d90b1baa624a91c7b661746edd073f7c732df5aeb40471a70c5f54b37aac6d78562ad77f6da71598e45845b073b4faca66b5653b961112efc8cb9e46
|
data/CHANGELOG.md
CHANGED
@@ -22,6 +22,26 @@ module LexoRanker
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_ranked(attributes, position: nil, &block)
|
25
|
+
instance = instance_ranked(attributes, position:, &block)
|
26
|
+
instance.save
|
27
|
+
instance
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_ranked!(attributes, position: nil, &block)
|
31
|
+
instance = instance_ranked(attributes, position:, &block)
|
32
|
+
instance.save!
|
33
|
+
instance
|
34
|
+
end
|
35
|
+
|
36
|
+
def ranks_around_position(id, position, scope_value: nil)
|
37
|
+
scope = ranked.where.not(id: id)
|
38
|
+
scope = scope.where("#{rankable_scope}": scope_value) unless scope_value.nil?
|
39
|
+
scope.offset(position - 1).limit(2).pluck(:"#{rankable_column}")
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def instance_ranked(attributes, position: nil, &block)
|
25
45
|
position = case position
|
26
46
|
when :top, :bottom
|
27
47
|
[:"move_to_#{position}"]
|
@@ -32,15 +52,8 @@ module LexoRanker
|
|
32
52
|
end
|
33
53
|
instance = new(attributes, &block)
|
34
54
|
instance.send(*position)
|
35
|
-
instance.save
|
36
55
|
instance
|
37
56
|
end
|
38
|
-
|
39
|
-
def ranks_around_position(id, position, scope_value: nil)
|
40
|
-
scope = ranked.where.not(id: id)
|
41
|
-
scope = scope.where("#{rankable_scope}": scope_value) unless scope_value.nil?
|
42
|
-
scope.offset(position - 1).limit(2).pluck(:"#{rankable_column}")
|
43
|
-
end
|
44
57
|
end
|
45
58
|
|
46
59
|
def ranked_collection
|
data/lib/lexoranker/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexoranker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PJ Davis
|
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
|
-
rubygems_version: 3.6.
|
62
|
+
rubygems_version: 3.6.9
|
63
63
|
specification_version: 4
|
64
64
|
summary: Lexicographic ranker for Ruby
|
65
65
|
test_files: []
|