positioning 0.4.2 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf799b4590dc7a86e63c7ba46fe624bd7c6353989a6d33833942b30dd0c5bd46
4
- data.tar.gz: 773a8c4b1f0cc6d528577c8d5c8f0263e310a5e8e3f2e69beeeaf9265e063dca
3
+ metadata.gz: 0713523ffe6c61e11bf14cf8a26b4285d9679fdd795b8c90c4a3cd65ae999996
4
+ data.tar.gz: 6f84c58171c950578ec96e51ce251a3839c06b0d23a906f9bac4e1282341e5b5
5
5
  SHA512:
6
- metadata.gz: 50423eee7719178be13087622bcc14b4a9e74974bdb0685fe7281838cc7cca8f784251b81a28d92e848a2b2eb7b79e4081a3ad4043ed483200f51341c71bf82f
7
- data.tar.gz: e2ccbac3a7d0994e997a0b17907becc017893d5355fa9c06a745828b8ec90661076332e9ef1769bd9c0f6c1f8ba808e3d209e0f56b9acdf33d4e1ba6e5d9bd88
6
+ metadata.gz: ba04ca78b1c80fdd53cc0eff2aff8486a35f39c7d5c6d580a4bd5f3a79f41449e4a4b40582d83b2a683805b6d2b7f60d71cedecc6d3385c2bb602830589fc4f6
7
+ data.tar.gz: f8cba117e4cd9acac2172f3d7643e77f59006345e1ea29581dc4434d86b972998230c8532f99f4ae50c7c995f634c05394631522819706a4addf0a5af559d5a0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.4] - 2024-11-20
4
+
5
+ - Add `funding_uri` to gemspec.
6
+
7
+ ## [0.4.3] - 2024-11-18
8
+
9
+ - Add support for polymorphic `belongs_to` where we add both the `id` and the `type` to the scope.
10
+
3
11
  ## [0.4.2] - 2024-11-08
4
12
 
5
13
  NOTE: Versions 0.4.0 and 0.4.1 contain fatal flaws with the locking logic. Upgrade as soon as you can.
data/Gemfile CHANGED
@@ -6,6 +6,8 @@ gemspec
6
6
  gem "rake", "~> 13.0"
7
7
 
8
8
  gem "minitest", "~> 5.0"
9
+ gem "minitest-hooks", "~> 1.5.1"
10
+ gem "mocha", "~> 2.1.0"
9
11
 
10
12
  gem "standard", "~> 1.3"
11
13
 
@@ -13,3 +15,17 @@ if ENV["RAILS_VERSION"]
13
15
  gem "activerecord", ENV["RAILS_VERSION"]
14
16
  gem "activesupport", ENV["RAILS_VERSION"]
15
17
  end
18
+
19
+ case ENV["DB"]
20
+ when "sqlite"
21
+ if ENV["RAILS_VERSION"] &&
22
+ Gem::Version.new(ENV["RAILS_VERSION"]) >= Gem::Version.new("7.2")
23
+ gem "sqlite3", "~> 2.2.0"
24
+ else
25
+ gem "sqlite3", "~> 1.7.2"
26
+ end
27
+ when "postgresql"
28
+ gem "pg", "~> 1.5.5"
29
+ else
30
+ gem "mysql2", "~> 0.5.6"
31
+ end
data/README.md CHANGED
@@ -32,6 +32,10 @@ You should also add an index to ensure that the `position` column value is uniqu
32
32
 
33
33
  The above assumes that your items are scoped to a parent table called `lists`.
34
34
 
35
+ If you have a polymorphic `belongs_to` then you'll want to add the type column to the index also:
36
+
37
+ `add_index :items, [:listable_id, :listable_type, :position], unique: true`
38
+
35
39
  The Positioning gem uses `0` and negative integers to rearrange the lists it manages so don't add database validations to restrict the usage of these. You are also restricted from using `0` and negative integers as position values. If you try, the position value will become `1`. If you try to set an explicit position value that is greater than the next available list position, it will be rounded down to that value.
36
40
 
37
41
  ### Declaring Positioning
@@ -40,10 +44,10 @@ To declare that your model should keep track of the position of its records you
40
44
 
41
45
  ```ruby
42
46
  # The scope is global (all records will belong to the same list) and the database column
43
- # is 'positioned'
47
+ # is 'position'
44
48
  positioned
45
49
 
46
- # The scope is on the belongs_to relationship 'list' and the database column is 'positioned'
50
+ # The scope is on the belongs_to relationship 'list' and the database column is 'position'
47
51
  # We check if the scope is a belongs_to relationship and use its declared foreign_key as
48
52
  # the scope value. In this case it would be 'list_id' since we haven't overridden the
49
53
  # default foreign key.
@@ -67,9 +71,9 @@ belongs_to :list
67
71
  belongs_to :category
68
72
  positioned on: [:list, :category, :enabled]
69
73
 
70
- # If you do not want to use Advisory Lock, you can disable it entirely by passing the 'advisory_lock' flag as false
71
- belongs_to :list
72
- positioned on: :list, advisory_lock: false
74
+ # If your belongs_to is polymorphic positioning will automatically add the type to the scope
75
+ belongs_to :listable, polymorphic: true
76
+ positioned on: :listable
73
77
  ```
74
78
 
75
79
  ### Initialising a List
@@ -1,3 +1,3 @@
1
1
  module Positioning
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.4"
3
3
  end
data/lib/positioning.rb CHANGED
@@ -36,6 +36,7 @@ module Positioning
36
36
 
37
37
  if reflection&.belongs_to?
38
38
  positioning_columns[column][:scope_columns] << reflection.foreign_key
39
+ positioning_columns[column][:scope_columns] << reflection.foreign_type if reflection.polymorphic?
39
40
  positioning_columns[column][:scope_associations] << reflection.name
40
41
  else
41
42
  positioning_columns[column][:scope_columns] << scope_component
data/positioning.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
  spec.metadata["source_code_uri"] = "https://github.com/brendon/positioning"
16
16
  spec.metadata["changelog_uri"] = "https://github.com/brendon/positioning/blob/main/CHANGELOG.md"
17
+ spec.metadata["funding_uri"] = "https://github.com/sponsors/brendon"
17
18
 
18
19
  # Specify which files should be added to the gem when it is released.
19
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,11 +30,6 @@ Gem::Specification.new do |spec|
29
30
  # Uncomment to register a new dependency of your gem
30
31
  spec.add_dependency "activesupport", ">= 6.1"
31
32
  spec.add_dependency "activerecord", ">= 6.1"
32
- spec.add_development_dependency "minitest-hooks", "~> 1.5.1"
33
- spec.add_development_dependency "mocha", "~> 2.1.0"
34
- spec.add_development_dependency "mysql2", "~> 0.5.6"
35
- spec.add_development_dependency "pg", "~> 1.5.5"
36
- spec.add_development_dependency "sqlite3", "~> 1.7.2"
37
33
 
38
34
  # For more information and examples about making a new gem, check out our
39
35
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: positioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendon Muir
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-08 00:00:00.000000000 Z
11
+ date: 2024-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,76 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '6.1'
41
- - !ruby/object:Gem::Dependency
42
- name: minitest-hooks
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 1.5.1
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 1.5.1
55
- - !ruby/object:Gem::Dependency
56
- name: mocha
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 2.1.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 2.1.0
69
- - !ruby/object:Gem::Dependency
70
- name: mysql2
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.5.6
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.5.6
83
- - !ruby/object:Gem::Dependency
84
- name: pg
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 1.5.5
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 1.5.5
97
- - !ruby/object:Gem::Dependency
98
- name: sqlite3
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 1.7.2
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 1.7.2
111
41
  description:
112
42
  email:
113
43
  - brendon@spike.net.nz
@@ -134,6 +64,7 @@ metadata:
134
64
  homepage_uri: https://github.com/brendon/positioning
135
65
  source_code_uri: https://github.com/brendon/positioning
136
66
  changelog_uri: https://github.com/brendon/positioning/blob/main/CHANGELOG.md
67
+ funding_uri: https://github.com/sponsors/brendon
137
68
  post_install_message:
138
69
  rdoc_options: []
139
70
  require_paths: