esse-pagy 0.0.1 → 0.43.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.
@@ -0,0 +1,138 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ esse-pagy (0.43.0)
5
+ esse (>= 0.2.4)
6
+ pagy (>= 5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (8.0.3)
12
+ base64
13
+ benchmark (>= 0.3)
14
+ bigdecimal
15
+ concurrent-ruby (~> 1.0, >= 1.3.1)
16
+ connection_pool (>= 2.2.5)
17
+ drb
18
+ i18n (>= 1.6, < 2)
19
+ logger (>= 1.4.2)
20
+ minitest (>= 5.1)
21
+ securerandom (>= 0.3)
22
+ tzinfo (~> 2.0, >= 2.0.5)
23
+ uri (>= 0.13.1)
24
+ ast (2.4.3)
25
+ base64 (0.3.0)
26
+ benchmark (0.4.1)
27
+ bigdecimal (3.2.3)
28
+ coderay (1.1.3)
29
+ concurrent-ruby (1.3.5)
30
+ connection_pool (2.5.4)
31
+ diff-lcs (1.6.2)
32
+ drb (2.2.3)
33
+ esse (0.2.6)
34
+ multi_json
35
+ thor (>= 0.19)
36
+ esse-rspec (0.0.6)
37
+ esse (>= 0.2.4)
38
+ rspec (>= 3)
39
+ i18n (1.14.7)
40
+ concurrent-ruby (~> 1.0)
41
+ json (2.15.0)
42
+ language_server-protocol (3.17.0.5)
43
+ lint_roller (1.1.0)
44
+ logger (1.7.0)
45
+ method_source (1.1.0)
46
+ minitest (5.25.5)
47
+ multi_json (1.17.0)
48
+ pagy (9.4.0)
49
+ parallel (1.27.0)
50
+ parser (3.3.9.0)
51
+ ast (~> 2.4.1)
52
+ racc
53
+ prism (1.5.1)
54
+ pry (0.15.2)
55
+ coderay (~> 1.1)
56
+ method_source (~> 1.0)
57
+ racc (1.8.1)
58
+ rack (3.2.1)
59
+ rainbow (3.1.1)
60
+ rake-manifest (0.2.3)
61
+ regexp_parser (2.11.3)
62
+ rspec (3.13.1)
63
+ rspec-core (~> 3.13.0)
64
+ rspec-expectations (~> 3.13.0)
65
+ rspec-mocks (~> 3.13.0)
66
+ rspec-core (3.13.5)
67
+ rspec-support (~> 3.13.0)
68
+ rspec-expectations (3.13.5)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.13.0)
71
+ rspec-mocks (3.13.5)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.13.0)
74
+ rspec-support (3.13.6)
75
+ rubocop (1.81.0)
76
+ json (~> 2.3)
77
+ language_server-protocol (~> 3.17.0.2)
78
+ lint_roller (~> 1.1.0)
79
+ parallel (~> 1.10)
80
+ parser (>= 3.3.0.2)
81
+ rainbow (>= 2.2.2, < 4.0)
82
+ regexp_parser (>= 2.9.3, < 3.0)
83
+ rubocop-ast (>= 1.47.1, < 2.0)
84
+ ruby-progressbar (~> 1.7)
85
+ unicode-display_width (>= 2.4.0, < 4.0)
86
+ rubocop-ast (1.47.1)
87
+ parser (>= 3.3.7.2)
88
+ prism (~> 1.4)
89
+ rubocop-performance (1.25.0)
90
+ lint_roller (~> 1.1)
91
+ rubocop (>= 1.75.0, < 2.0)
92
+ rubocop-ast (>= 1.38.0, < 2.0)
93
+ rubocop-rspec (3.7.0)
94
+ lint_roller (~> 1.1)
95
+ rubocop (~> 1.72, >= 1.72.1)
96
+ ruby-progressbar (1.13.0)
97
+ securerandom (0.4.1)
98
+ standard (1.35.0.1)
99
+ language_server-protocol (~> 3.17.0.2)
100
+ lint_roller (~> 1.0)
101
+ rubocop (~> 1.62)
102
+ standard-custom (~> 1.0.0)
103
+ standard-performance (~> 1.3)
104
+ standard-custom (1.0.2)
105
+ lint_roller (~> 1.0)
106
+ rubocop (~> 1.50)
107
+ standard-performance (1.8.0)
108
+ lint_roller (~> 1.1)
109
+ rubocop-performance (~> 1.25.0)
110
+ thor (1.4.0)
111
+ tzinfo (2.0.6)
112
+ concurrent-ruby (~> 1.0)
113
+ unicode-display_width (3.2.0)
114
+ unicode-emoji (~> 4.1)
115
+ unicode-emoji (4.1.0)
116
+ uri (1.0.3)
117
+
118
+ PLATFORMS
119
+ ruby
120
+ x86_64-linux
121
+
122
+ DEPENDENCIES
123
+ activesupport
124
+ esse (~> 0.2.4)
125
+ esse-pagy!
126
+ esse-rspec (~> 0.0.1)
127
+ pagy (~> 9.0)
128
+ pry
129
+ rack
130
+ rake-manifest
131
+ rspec
132
+ rubocop
133
+ rubocop-performance
134
+ rubocop-rspec
135
+ standard
136
+
137
+ BUNDLED WITH
138
+ 2.5.23
data/lib/esse/pagy.rb CHANGED
@@ -3,8 +3,14 @@
3
3
  require "esse"
4
4
  require "pagy"
5
5
 
6
- ::Pagy::DEFAULT[:esse_search] ||= :search
7
- ::Pagy::DEFAULT[:esse_pagy_search] ||= :pagy_search
6
+ # Pagy < 43 ships a mutable DEFAULT and a Backend mixin used by the
7
+ # `pagy_esse`/`pagy_search` controller helpers. Pagy 43 froze DEFAULT, removed
8
+ # the Backend mixin, and split paginators into Pagy::Offset/Keyset/Search.
9
+ # Only register the controller-helper defaults where they apply.
10
+ unless ::Pagy::DEFAULT.frozen?
11
+ ::Pagy::DEFAULT[:esse_search] ||= :search
12
+ ::Pagy::DEFAULT[:esse_pagy_search] ||= :pagy_search
13
+ end
8
14
 
9
15
  # I'll try to move this to the `pagy` gem. But we need to wait for the `pagy` author to accept the PR.
10
16
  # @see https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/elasticsearch_rails.rb
@@ -18,7 +24,7 @@ module Esse
18
24
  args.define_singleton_method(:method_missing) { |*a| args += a }
19
25
  end
20
26
  end
21
- alias_method ::Pagy::DEFAULT[:esse_pagy_search], :pagy_esse
27
+ alias_method :pagy_search, :pagy_esse
22
28
  end
23
29
 
24
30
  module ClusterSearch
@@ -27,19 +33,30 @@ module Esse
27
33
  args.define_singleton_method(:method_missing) { |*a| args += a }
28
34
  end
29
35
  end
30
- alias_method ::Pagy::DEFAULT[:esse_pagy_search], :pagy_esse
36
+ alias_method :pagy_search, :pagy_esse
31
37
  end
32
38
 
33
39
  module ClassMethods
34
40
  def new_from_esse(query, vars = {})
35
41
  vars[:count] = query.response.total
36
42
  vars[:page] = (query.offset_value / query.limit_value.to_f).ceil + 1
37
- vars[:items] = query.limit_value
38
- ::Pagy.new(vars)
43
+ vars[:limit] = query.limit_value
44
+
45
+ if defined?(::Pagy::Offset)
46
+ # Pagy 43+: bare Pagy is abstract; offset pagination is Pagy::Offset.
47
+ ::Pagy::Offset.new(**vars)
48
+ elsif ::Pagy::VERSION.to_i < 9
49
+ # Convert :limit back to :items for older Pagy versions
50
+ vars[:items] = vars.delete(:limit)
51
+ ::Pagy.new(vars)
52
+ else
53
+ ::Pagy.new(**vars)
54
+ end
39
55
  end
40
56
  end
41
57
 
42
- # Add specialized backend methods to paginate Esse::Search::Query
58
+ # Add specialized backend methods to paginate Esse::Search::Query.
59
+ # Only relevant on Pagy versions that still ship Pagy::Backend (< 43).
43
60
  module Backend
44
61
  private
45
62
 
@@ -47,12 +64,20 @@ module Esse
47
64
  def pagy_esse(pagy_search_args, vars = {})
48
65
  cluster, indices, kwargs, block, *called = pagy_search_args
49
66
  vars = pagy_esse_get_vars(nil, vars)
67
+
50
68
  query = cluster.send(::Pagy::DEFAULT[:esse_search], *indices, **kwargs, &block)
51
- .limit(vars[:items])
52
- .offset(vars[:items] * (vars[:page] - 1))
69
+ .limit(vars[:limit])
70
+ .offset(vars[:limit] * (vars[:page] - 1))
53
71
  vars[:count] = query.response.total
54
72
 
55
- pagy = ::Pagy.new(vars)
73
+ # Handle Pagy 9+ API changes
74
+ if ::Pagy::VERSION.to_i >= 9
75
+ pagy = ::Pagy.new(**vars)
76
+ else
77
+ legacy_vars = vars.dup
78
+ legacy_vars[:items] = legacy_vars.delete(:limit)
79
+ pagy = ::Pagy.new(legacy_vars)
80
+ end
56
81
  # with :last_page overflow we need to re-run the method in order to get the hits
57
82
  return pagy_esse(pagy_search_args, vars.merge(page: pagy.page)) \
58
83
  if defined?(::Pagy::OverflowExtra) && pagy.overflow? && pagy.vars[:overflow] == :last_page
@@ -64,7 +89,15 @@ module Esse
64
89
  # the _query argument is not available when the method is called
65
90
  def pagy_esse_get_vars(_query, vars)
66
91
  pagy_set_items_from_params(vars) if defined?(ItemsExtra)
67
- vars[:items] ||= ::Pagy::DEFAULT[:items]
92
+
93
+ # Convert :items to :limit for consistency, this is not needed for Pagy 9+
94
+ vars[:limit] = vars.delete(:items) if vars.key?(:items)
95
+ if ::Pagy::VERSION.to_i < 9
96
+ vars[:limit] ||= ::Pagy::DEFAULT[:items]
97
+ else
98
+ vars[:limit] ||= ::Pagy::DEFAULT[:limit]
99
+ end
100
+
68
101
  vars[:page] ||= (params[vars[:page_param] || ::Pagy::DEFAULT[:page_param]] || 1).to_i
69
102
  vars
70
103
  end
@@ -72,7 +105,13 @@ module Esse
72
105
  end
73
106
  end
74
107
 
75
- ::Pagy::Backend.prepend(Esse::Pagy::Backend)
76
108
  ::Pagy.extend(Esse::Pagy::ClassMethods)
77
109
  ::Esse::Index.extend(Esse::Pagy::IndexSearch)
78
110
  ::Esse::Cluster.prepend(Esse::Pagy::ClusterSearch)
111
+ # Pagy::Backend was removed in Pagy 43; reference it (autoloads on older Pagy)
112
+ # and skip the integration when it is gone.
113
+ begin
114
+ ::Pagy::Backend.prepend(Esse::Pagy::Backend)
115
+ rescue NameError
116
+ nil
117
+ end
data/mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ ruby = "3.4.8"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esse-pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos G. Zimmermann
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-11-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: esse
@@ -135,7 +134,23 @@ files:
135
134
  - Gemfile.lock
136
135
  - LICENSE
137
136
  - README.md
137
+ - docs/README.md
138
+ - docs/api.md
139
+ - docs/usage.md
140
+ - gemfiles/Gemfile.pagy-43
141
+ - gemfiles/Gemfile.pagy-43.lock
142
+ - gemfiles/Gemfile.pagy-5
143
+ - gemfiles/Gemfile.pagy-5.lock
144
+ - gemfiles/Gemfile.pagy-6
145
+ - gemfiles/Gemfile.pagy-6.lock
146
+ - gemfiles/Gemfile.pagy-7
147
+ - gemfiles/Gemfile.pagy-7.lock
148
+ - gemfiles/Gemfile.pagy-8
149
+ - gemfiles/Gemfile.pagy-8.lock
150
+ - gemfiles/Gemfile.pagy-9
151
+ - gemfiles/Gemfile.pagy-9.lock
138
152
  - lib/esse/pagy.rb
153
+ - mise.toml
139
154
  homepage: https://github.com/marcosgz/esse-pagy
140
155
  licenses:
141
156
  - MIT
@@ -143,7 +158,6 @@ metadata:
143
158
  homepage_uri: https://github.com/marcosgz/esse-pagy
144
159
  source_code_uri: https://github.com/marcosgz/esse-pagy
145
160
  changelog_uri: https://github.com/marcosgz/esse-pagy/blob/main/CHANGELOG.md
146
- post_install_message:
147
161
  rdoc_options: []
148
162
  require_paths:
149
163
  - lib
@@ -158,8 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
172
  - !ruby/object:Gem::Version
159
173
  version: '0'
160
174
  requirements: []
161
- rubygems_version: 3.1.6
162
- signing_key:
175
+ rubygems_version: 3.6.9
163
176
  specification_version: 4
164
177
  summary: Pagy extensions for Esse
165
178
  test_files: []