esse-kaminari 0.1.0 → 0.1.1

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: 687b463fe9326db75c88bf64acab19dfda495ed463b84c4ca3450a39cd75e129
4
- data.tar.gz: eebe2e2b042dc73f21f06f7a3476e917d0e48c16141719ecd8f1fc4454800745
3
+ metadata.gz: 4bb521b48ea334e1f66c75e3eab8d2fc2f0cbf9bd010cff13a73f3c7bbad8b91
4
+ data.tar.gz: 8f4eb94f2ba55bd53bd480973b2095f657ee23ee1c6889fc30a2027a857c154b
5
5
  SHA512:
6
- metadata.gz: ec7c5abf2ce720343c82c2b9df29a97391991737b153172b372d051ab1d813d37a22446e7b3fe23dc97807f8d9b5b02686cb2458228e25c41b2e02a5eb08f59e
7
- data.tar.gz: eb0d9ddef0786b305ce9a5d89dcba05e0daea2c5bf049aaa345499c6000004849359471f8c9bb795333c58b878b09057d12ea8c10e0c8b36425f7065e46bd226
6
+ metadata.gz: b6d0cee89d357188638eb5ba320c312dea09d4e75d9a5e1310927cae74cbeff59f81f780560cb52763d5e788b623cf8f6ea092f1039e7bae2e50f4c5722286ea
7
+ data.tar.gz: d9aae101f6a7fbb471f30630cabb100706093a2a3f8c6810192e5dc1faee965d659f4cc794d7f3349c304215e7bbad04ac09b17a799ef2b3e9eb45eb6f31f045
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## 0.1.1 - 2023-03-01
8
+ * Correct bug related to the `page` method when the `per` is already set
9
+
10
+ ## 0.1.0 - 2022-07-05
11
+ The first release of the esse-kaminari plugin. This release includes the following features:
12
+ * DSL for kaminari pagination for the ESSE framework
data/Gemfile.lock CHANGED
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: .
12
12
  specs:
13
- esse-kaminari (0.1.0)
13
+ esse-kaminari (0.1.1)
14
14
  esse
15
15
  kaminari
16
16
 
@@ -65,6 +65,8 @@ GEM
65
65
  multi_json (1.15.0)
66
66
  nokogiri (1.13.6-x86_64-darwin)
67
67
  racc (~> 1.4)
68
+ nokogiri (1.13.6-x86_64-linux)
69
+ racc (~> 1.4)
68
70
  parallel (1.22.1)
69
71
  parser (3.1.2.0)
70
72
  ast (~> 2.4.1)
@@ -122,6 +124,7 @@ GEM
122
124
 
123
125
  PLATFORMS
124
126
  x86_64-darwin-19
127
+ x86_64-linux
125
128
 
126
129
  DEPENDENCIES
127
130
  awesome_print
@@ -138,4 +141,4 @@ DEPENDENCIES
138
141
  standard (~> 1.3)
139
142
 
140
143
  BUNDLED WITH
141
- 2.3.13
144
+ 2.3.18
@@ -17,9 +17,12 @@ module Esse
17
17
  def #{::Kaminari.config.page_method_name}(num=nil)
18
18
  reset!
19
19
 
20
+ @page = [num.to_i, 1].max
21
+ @per_page ||= limit_value
22
+
20
23
  definition.update(
21
- size: limit_value,
22
- from: (limit_value * ([num.to_i, 1].max - 1))
24
+ size: @per_page,
25
+ from: @per_page * (@page - 1),
23
26
  )
24
27
 
25
28
  self
@@ -36,7 +39,7 @@ module Esse
36
39
  end
37
40
 
38
41
  def total_count
39
- response.total
42
+ response.total
40
43
  end
41
44
 
42
45
  def paginated_results
@@ -44,12 +47,20 @@ module Esse
44
47
  end
45
48
 
46
49
  def limit(value)
47
- definition.update(size: value)
50
+ return self if value.to_i <= 0
51
+ reset!
52
+ @per_page = value.to_i
53
+
54
+ definition.update(size: @per_page)
55
+ definition.update(from: @per_page * (@page - 1)) if @page
48
56
  self
49
57
  end
50
58
 
51
59
  def offset(value)
52
- definition.update(from: value)
60
+ return self if value.to_i < 0
61
+ reset!
62
+ @page = nil
63
+ definition.update(from: value.to_i)
53
64
  self
54
65
  end
55
66
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Esse
4
4
  module Kaminari
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esse-kaminari
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos G. Zimmermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-14 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: esse
@@ -178,6 +178,7 @@ extensions: []
178
178
  extra_rdoc_files: []
179
179
  files:
180
180
  - ".rubocop.yml"
181
+ - CHANGELOG.md
181
182
  - Gemfile
182
183
  - Gemfile.lock
183
184
  - LICENSE.txt