positioning 0.1.4 → 0.1.6
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 +8 -0
- data/lib/positioning/mechanisms.rb +19 -7
- data/lib/positioning/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: 2fa6907a0507b7978c58578596c4e6ca16b7e334eb98b3fa42cba47a0d0b89b5
|
4
|
+
data.tar.gz: ed8f3126f69cb0f8780244a05d48e46abd0b64468ad47838f0d5827b4fa943ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d35b26bf717252dc30d828b2fff2b5b36c82ccd5b33d5480798cc57e38bacf9434120d2a478d448998c368286272a9dc2604cb8d3ebd071da0a55c8fa4ad5ba
|
7
|
+
data.tar.gz: 3b9c21bb1a3fe42c0799ffe6e991b29f7c17fd4efec8ff3b159afa41cd8a6b8b1e975e47c8e69e22dfd673352b105f2c55d85887a07d90e528b2cd0c54b3a318
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.6] - 2024-03-05
|
4
|
+
|
5
|
+
- Allow the position to be passed as a JSON object so that we can pass in complex positions from the browser more easily.
|
6
|
+
|
7
|
+
## [0.1.5] - 2024-03-04
|
8
|
+
|
9
|
+
- Allow empty strings to represent nil for the purposes of solidifying a position
|
10
|
+
|
3
11
|
## [0.1.4] - 2024-03-04
|
4
12
|
|
5
13
|
- Fix bug relating to relative position hash coming from Rails being a Hash With Indifferent Access
|
@@ -96,16 +96,27 @@ module Positioning
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def solidify_position
|
99
|
-
position_before_type_cast = @positioned.read_attribute_before_type_cast
|
100
|
-
|
101
|
-
|
99
|
+
position_before_type_cast = @positioned.read_attribute_before_type_cast(@column)
|
100
|
+
|
101
|
+
if position_before_type_cast.is_a? String
|
102
|
+
begin
|
103
|
+
position_before_type_cast = JSON.parse(position_before_type_cast, symbolize_names: true)
|
104
|
+
rescue JSON::ParserError
|
105
|
+
end
|
106
|
+
|
107
|
+
if position_before_type_cast.is_a?(String) && position_before_type_cast.present?
|
108
|
+
position_before_type_cast = position_before_type_cast.to_sym
|
109
|
+
end
|
110
|
+
elsif position_before_type_cast.is_a? Hash
|
111
|
+
position_before_type_cast = position_before_type_cast.symbolize_keys
|
112
|
+
end
|
102
113
|
|
103
114
|
case position_before_type_cast
|
104
115
|
when Integer
|
105
116
|
self.position = position_before_type_cast.clamp(1..last_position)
|
106
|
-
when :first, {after: nil}
|
117
|
+
when :first, {after: nil}, {after: ""}
|
107
118
|
self.position = 1
|
108
|
-
when nil, :last, {before: nil}
|
119
|
+
when nil, "", :last, {before: nil}, {before: ""}
|
109
120
|
self.position = last_position
|
110
121
|
when Hash
|
111
122
|
relative_position, relative_record_or_primary_key = *position_before_type_cast.first
|
@@ -135,8 +146,9 @@ module Positioning
|
|
135
146
|
|
136
147
|
unless position.is_a? Integer
|
137
148
|
raise Error.new,
|
138
|
-
|
139
|
-
|
149
|
+
%(`#{@column}` must be an Integer, :first, :last, ) +
|
150
|
+
%{before: (#{base_class.name}, #{primary_key_column}, nil, or ""), } +
|
151
|
+
%{after: (#{base_class.name}, #{primary_key_column}, nil or ""), nil or ""}
|
140
152
|
end
|
141
153
|
end
|
142
154
|
|
data/lib/positioning/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.6
|
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-03-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|