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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d36bdd491546880243ecc90b0d2a22680bfee8060b153019fdc6f9b064f26a1
4
- data.tar.gz: bb63791d2832294a41364c8535b2e9b19002c90eb1be08b6f016abbe7569277e
3
+ metadata.gz: 4a17a65e0a741bb249fa535cbbbee2d29de43e6af66e9809ab1a06d1adfdc8e7
4
+ data.tar.gz: 55d02c5a3aeed1014df59b423dedbe40c02b353d1e80f3e0e6b851a7bfdb44a4
5
5
  SHA512:
6
- metadata.gz: 3773b7fa6b56a3d0345491c1cca8b967335497ef461ab91d1017e4ed6bd7ea6d8ef9ba8553d87844f8cf14e2a272a450e5c1fbe721220c6890f56375b6b73b35
7
- data.tar.gz: 5df07a814a78be85e6927e2ade38bf01b35f73f26cea061b75823766847ab73bb013da837bd257cf5fa927bb391d618a10c73f79eb8813050860ad4fc692b663
6
+ metadata.gz: 5ec4ab3cbe82930d1dacdba14caff8676bff762ab1cdced215e15eb84d80bc26b165357279db58953841951d479e617aa6edfbaae348525797a6d7375d3fb999
7
+ data.tar.gz: 9cff2ca9d90b1baa624a91c7b661746edd073f7c732df5aeb40471a70c5f54b37aac6d78562ad77f6da71598e45845b073b4faca66b5653b961112efc8cb9e46
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2025-09-22
2
+ * Release 0.4.0
3
+ * Bump Gems to current versions
4
+ * Add .create_ranked! to ActiveRecord adapter
1
5
  ## 2025-06-10
2
6
  * Release 0.3.0
3
7
  * Create initial RubyGems Release
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LexoRanker
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
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.3.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.8
62
+ rubygems_version: 3.6.9
63
63
  specification_version: 4
64
64
  summary: Lexicographic ranker for Ruby
65
65
  test_files: []