esse-will_paginate 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 159d99fc2a6d995b75e48f2fce0e18736e3d0786012c910116abebc1fdc73c44
4
+ data.tar.gz: aa085968ac6c40b1a2743976d4dac911813fa4abca80c281a32f961ba9d1813a
5
+ SHA512:
6
+ metadata.gz: 4b1ca146cc9cd444576c6587cc3fb5b2bdff02a2d0f7f900d222fc4264448c380cb287d76056be8c2e7e1e6f99938843369667d0102ab7652080fecdcfa3fff0
7
+ data.tar.gz: 201127cb56b66ba0ac60ca443408b54d6844d25e74ea4772104d7d7416aa034baa56fedba62862ce97687f08340de1acf8268cc90c3d2026dacdb67b6cfd2aee
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude
4
+
5
+ require:
6
+ - rubocop-performance
7
+ - rubocop-rspec
8
+ - standard/cop/block_single_line_braces
9
+
10
+ inherit_gem:
11
+ standard: config/base.yml
12
+
13
+ AllCops:
14
+ TargetRubyVersion: 2.5
15
+ SuggestExtensions: false
16
+ Exclude:
17
+ - "db/**/*"
18
+ - "tmp/**/*"
19
+ - "vendor/**/*"
20
+ NewCops: enable
21
+
22
+ RSpec/MultipleExpectations:
23
+ Enabled: false
24
+
25
+ RSpec/ExampleLength:
26
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
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.0.1 - 2022-07-05
8
+ The first release of the esse-will_paginate plugin
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "esse", git: "https://github.com/marcosgz/esse.git", branch: "main"
6
+ gem "will_paginate", "~> 3.1"
7
+ gem "esse-rspec"
8
+
9
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ GIT
2
+ remote: https://github.com/marcosgz/esse.git
3
+ revision: 34a9fff95b2c46ad1b5fca85f0906fbdea1704ee
4
+ branch: main
5
+ specs:
6
+ esse (0.2.4)
7
+ multi_json
8
+ thor (>= 0.19)
9
+
10
+ PATH
11
+ remote: .
12
+ specs:
13
+ esse-will_paginate (0.0.1)
14
+ esse (>= 0.2.4)
15
+ pagy (>= 5)
16
+
17
+ GEM
18
+ remote: https://rubygems.org/
19
+ specs:
20
+ ast (2.4.2)
21
+ coderay (1.1.3)
22
+ diff-lcs (1.5.0)
23
+ esse-rspec (0.0.6)
24
+ esse (>= 0.2.4)
25
+ rspec (>= 3)
26
+ json (2.6.3)
27
+ language_server-protocol (3.17.0.3)
28
+ lint_roller (1.1.0)
29
+ method_source (1.0.0)
30
+ multi_json (1.15.0)
31
+ pagy (6.2.0)
32
+ parallel (1.23.0)
33
+ parser (3.2.2.4)
34
+ ast (~> 2.4.1)
35
+ racc
36
+ pry (0.14.2)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ racc (1.7.3)
40
+ rainbow (3.1.1)
41
+ regexp_parser (2.8.2)
42
+ rexml (3.2.6)
43
+ rspec (3.12.0)
44
+ rspec-core (~> 3.12.0)
45
+ rspec-expectations (~> 3.12.0)
46
+ rspec-mocks (~> 3.12.0)
47
+ rspec-core (3.12.2)
48
+ rspec-support (~> 3.12.0)
49
+ rspec-expectations (3.12.3)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.12.0)
52
+ rspec-mocks (3.12.6)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.12.0)
55
+ rspec-support (3.12.1)
56
+ rubocop (1.57.2)
57
+ json (~> 2.3)
58
+ language_server-protocol (>= 3.17.0)
59
+ parallel (~> 1.10)
60
+ parser (>= 3.2.2.4)
61
+ rainbow (>= 2.2.2, < 4.0)
62
+ regexp_parser (>= 1.8, < 3.0)
63
+ rexml (>= 3.2.5, < 4.0)
64
+ rubocop-ast (>= 1.28.1, < 2.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (>= 2.4.0, < 3.0)
67
+ rubocop-ast (1.30.0)
68
+ parser (>= 3.2.1.0)
69
+ rubocop-capybara (2.19.0)
70
+ rubocop (~> 1.41)
71
+ rubocop-factory_bot (2.24.0)
72
+ rubocop (~> 1.33)
73
+ rubocop-performance (1.19.1)
74
+ rubocop (>= 1.7.0, < 2.0)
75
+ rubocop-ast (>= 0.4.0)
76
+ rubocop-rspec (2.25.0)
77
+ rubocop (~> 1.40)
78
+ rubocop-capybara (~> 2.17)
79
+ rubocop-factory_bot (~> 2.22)
80
+ ruby-progressbar (1.13.0)
81
+ standard (1.32.0)
82
+ language_server-protocol (~> 3.17.0.2)
83
+ lint_roller (~> 1.0)
84
+ rubocop (~> 1.57.2)
85
+ standard-custom (~> 1.0.0)
86
+ standard-performance (~> 1.2)
87
+ standard-custom (1.0.2)
88
+ lint_roller (~> 1.0)
89
+ rubocop (~> 1.50)
90
+ standard-performance (1.2.1)
91
+ lint_roller (~> 1.1)
92
+ rubocop-performance (~> 1.19.1)
93
+ thor (1.3.0)
94
+ unicode-display_width (2.5.0)
95
+ will_paginate (3.3.1)
96
+
97
+ PLATFORMS
98
+ x86_64-linux
99
+
100
+ DEPENDENCIES
101
+ esse!
102
+ esse-rspec
103
+ esse-will_paginate!
104
+ pry
105
+ rspec
106
+ rubocop
107
+ rubocop-performance
108
+ rubocop-rspec
109
+ standard
110
+ will_paginate (~> 3.1)
111
+
112
+ BUNDLED WITH
113
+ 2.4.13
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Marcos G. Zimmermann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Esse WillPaginate Plugin
2
+
3
+ This gem is a [esse](https://github.com/marcosgz/esse) plugin for the [will_paginate](https://github.com/mislav/will_paginate) pagination.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'esse-will_paginate'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle install
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ # Single index
23
+ @search = UsersIndex.search(params[:q]).paginate(page: params[:page], per_page: 10)
24
+ @search = UsersIndex.search(params[:q], body: { query: {}, from: 0, size: 10}) # or if you prefer pass elasticsearch/opensearch pagination in the query body
25
+
26
+ # Multiple indexes
27
+ @search = Esse.cluster.search(CitiesIndex, CountiesIndex, body: { ... }).paginate(page: params[:page], per_page: 10)
28
+ @search = Esse.cluster.search(CitiesIndex, CountiesIndex, body: { query: {}, from: 0, size: 10}) # or if you prefer pass elasticsearch/opensearch pagination in the query body
29
+ ```
30
+
31
+ ```erb
32
+
33
+ <%= will_paginate @search.results %>
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake none` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/marcosgz/esse-will_paginate.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ module WillPaginate
5
+ module Pagination
6
+ module SearchQuery
7
+ def self.included(base)
8
+ base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
9
+ # Define the `paginate` WillPaginate method
10
+ #
11
+ # @param [Hash] options
12
+ # @option options [Integer] :page
13
+ # @option options [Integer] :per_page
14
+ # @return [Esse::WillPaginate::SearchQuery]
15
+ def paginate(options = {})
16
+ curr_page = ::WillPaginate::PageNumber(options[:page] || 1)
17
+ limit_val = (options[:per_page] || ::WillPaginate.per_page).to_i
18
+ offset_val = (curr_page - 1) * limit_val
19
+ limit(limit_val).offset(offset_val)
20
+ end
21
+ RUBY
22
+ end
23
+
24
+ def paginated_results
25
+ page = (offset_value / limit_value.to_f).ceil + 1
26
+ ::WillPaginate::Collection.create(page, limit_value, response.total) do |pager|
27
+ pager.replace response.hits
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ module WillPaginate
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "esse"
4
+ require "will_paginate"
5
+ require "will_paginate/collection"
6
+
7
+ require_relative "will_paginate/version"
8
+ require_relative "will_paginate/pagination"
9
+
10
+ Esse::Search::Query.__send__ :include, Esse::WillPaginate::Pagination::SearchQuery
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esse-will_paginate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marcos G. Zimmermann
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: esse
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: pagy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: standard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-performance
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: WillPaginate extensions for Esse
126
+ email:
127
+ - mgzmaster@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".rubocop.yml"
133
+ - CHANGELOG.md
134
+ - Gemfile
135
+ - Gemfile.lock
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - lib/esse/will_paginate.rb
140
+ - lib/esse/will_paginate/pagination.rb
141
+ - lib/esse/will_paginate/version.rb
142
+ homepage: https://github.com/marcosgz/esse-will_paginate
143
+ licenses:
144
+ - MIT
145
+ metadata:
146
+ homepage_uri: https://github.com/marcosgz/esse-will_paginate
147
+ source_code_uri: https://github.com/marcosgz/esse-will_paginate
148
+ changelog_uri: https://github.com/marcosgz/esse-will_paginate/blob/main/CHANGELOG.md
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 2.4.0
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubygems_version: 3.3.7
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: WillPaginate extensions for Esse
168
+ test_files: []