esse-kaminari 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 687b463fe9326db75c88bf64acab19dfda495ed463b84c4ca3450a39cd75e129
4
+ data.tar.gz: eebe2e2b042dc73f21f06f7a3476e917d0e48c16141719ecd8f1fc4454800745
5
+ SHA512:
6
+ metadata.gz: ec7c5abf2ce720343c82c2b9df29a97391991737b153172b372d051ab1d813d37a22446e7b3fe23dc97807f8d9b5b02686cb2458228e25c41b2e02a5eb08f59e
7
+ data.tar.gz: eb0d9ddef0786b305ce9a5d89dcba05e0daea2c5bf049aaa345499c6000004849359471f8c9bb795333c58b878b09057d12ea8c10e0c8b36425f7065e46bd226
data/.rubocop.yml ADDED
@@ -0,0 +1,35 @@
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.6
15
+ SuggestExtensions: false
16
+ Exclude:
17
+ - "db/**/*"
18
+ - "tmp/**/*"
19
+ - "vendor/**/*"
20
+
21
+ Layout/SpaceInsideHashLiteralBraces:
22
+ Enabled: false
23
+
24
+ Style/TrailingCommaInArguments:
25
+ Enabled: false
26
+
27
+ Style/TrailingCommaInArrayLiteral:
28
+ Enabled: false
29
+
30
+ Style/TrailingCommaInHashLiteral:
31
+ Enabled: false
32
+
33
+ Style/StringLiterals:
34
+ Enabled: true
35
+ EnforcedStyle: single_quotes
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'esse', git: "https://github.com/marcosgz/esse.git", branch: "master"
6
+ # gem 'esse', path: '../esse'
7
+ gem 'kaminari', '~> 1.2', '>= 1.2.2'
8
+
9
+ # Specify your gem's dependencies in esse-active_record.gemspec
10
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,141 @@
1
+ GIT
2
+ remote: https://github.com/marcosgz/esse.git
3
+ revision: 2f3fdc305117050f3dde21d5b58485dcf95ad705
4
+ branch: master
5
+ specs:
6
+ esse (0.2.1)
7
+ multi_json
8
+ thor (>= 0.19)
9
+
10
+ PATH
11
+ remote: .
12
+ specs:
13
+ esse-kaminari (0.1.0)
14
+ esse
15
+ kaminari
16
+
17
+ GEM
18
+ remote: https://rubygems.org/
19
+ specs:
20
+ actionview (6.1.6)
21
+ activesupport (= 6.1.6)
22
+ builder (~> 3.1)
23
+ erubi (~> 1.4)
24
+ rails-dom-testing (~> 2.0)
25
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
+ activemodel (6.1.6)
27
+ activesupport (= 6.1.6)
28
+ activerecord (6.1.6)
29
+ activemodel (= 6.1.6)
30
+ activesupport (= 6.1.6)
31
+ activesupport (6.1.6)
32
+ concurrent-ruby (~> 1.0, >= 1.0.2)
33
+ i18n (>= 1.6, < 2)
34
+ minitest (>= 5.1)
35
+ tzinfo (~> 2.0)
36
+ zeitwerk (~> 2.3)
37
+ ast (2.4.2)
38
+ awesome_print (1.9.2)
39
+ builder (3.2.4)
40
+ coderay (1.1.3)
41
+ concurrent-ruby (1.1.10)
42
+ crass (1.0.6)
43
+ diff-lcs (1.5.0)
44
+ dotenv (2.7.6)
45
+ erubi (1.10.0)
46
+ i18n (1.10.0)
47
+ concurrent-ruby (~> 1.0)
48
+ kaminari (1.2.2)
49
+ activesupport (>= 4.1.0)
50
+ kaminari-actionview (= 1.2.2)
51
+ kaminari-activerecord (= 1.2.2)
52
+ kaminari-core (= 1.2.2)
53
+ kaminari-actionview (1.2.2)
54
+ actionview
55
+ kaminari-core (= 1.2.2)
56
+ kaminari-activerecord (1.2.2)
57
+ activerecord
58
+ kaminari-core (= 1.2.2)
59
+ kaminari-core (1.2.2)
60
+ loofah (2.18.0)
61
+ crass (~> 1.0.2)
62
+ nokogiri (>= 1.5.9)
63
+ method_source (1.0.0)
64
+ minitest (5.16.2)
65
+ multi_json (1.15.0)
66
+ nokogiri (1.13.6-x86_64-darwin)
67
+ racc (~> 1.4)
68
+ parallel (1.22.1)
69
+ parser (3.1.2.0)
70
+ ast (~> 2.4.1)
71
+ pry (0.14.1)
72
+ coderay (~> 1.1)
73
+ method_source (~> 1.0)
74
+ racc (1.6.0)
75
+ rails-dom-testing (2.0.3)
76
+ activesupport (>= 4.2.0)
77
+ nokogiri (>= 1.6)
78
+ rails-html-sanitizer (1.4.3)
79
+ loofah (~> 2.3)
80
+ rainbow (3.1.1)
81
+ rake (12.3.3)
82
+ regexp_parser (2.5.0)
83
+ rexml (3.2.5)
84
+ rspec (3.11.0)
85
+ rspec-core (~> 3.11.0)
86
+ rspec-expectations (~> 3.11.0)
87
+ rspec-mocks (~> 3.11.0)
88
+ rspec-core (3.11.0)
89
+ rspec-support (~> 3.11.0)
90
+ rspec-expectations (3.11.0)
91
+ diff-lcs (>= 1.2.0, < 2.0)
92
+ rspec-support (~> 3.11.0)
93
+ rspec-mocks (3.11.1)
94
+ diff-lcs (>= 1.2.0, < 2.0)
95
+ rspec-support (~> 3.11.0)
96
+ rspec-support (3.11.0)
97
+ rubocop (1.29.1)
98
+ parallel (~> 1.10)
99
+ parser (>= 3.1.0.0)
100
+ rainbow (>= 2.2.2, < 4.0)
101
+ regexp_parser (>= 1.8, < 3.0)
102
+ rexml (>= 3.2.5, < 4.0)
103
+ rubocop-ast (>= 1.17.0, < 2.0)
104
+ ruby-progressbar (~> 1.7)
105
+ unicode-display_width (>= 1.4.0, < 3.0)
106
+ rubocop-ast (1.18.0)
107
+ parser (>= 3.1.1.0)
108
+ rubocop-performance (1.13.3)
109
+ rubocop (>= 1.7.0, < 2.0)
110
+ rubocop-ast (>= 0.4.0)
111
+ rubocop-rspec (2.11.1)
112
+ rubocop (~> 1.19)
113
+ ruby-progressbar (1.11.0)
114
+ standard (1.12.1)
115
+ rubocop (= 1.29.1)
116
+ rubocop-performance (= 1.13.3)
117
+ thor (1.2.1)
118
+ tzinfo (2.0.4)
119
+ concurrent-ruby (~> 1.0)
120
+ unicode-display_width (2.2.0)
121
+ zeitwerk (2.6.0)
122
+
123
+ PLATFORMS
124
+ x86_64-darwin-19
125
+
126
+ DEPENDENCIES
127
+ awesome_print
128
+ dotenv
129
+ esse!
130
+ esse-kaminari!
131
+ kaminari (~> 1.2, >= 1.2.2)
132
+ pry
133
+ rake (~> 12.3)
134
+ rspec (~> 3.0)
135
+ rubocop (~> 1.20)
136
+ rubocop-performance (~> 1.11, >= 1.11.5)
137
+ rubocop-rspec (~> 2.4)
138
+ standard (~> 1.3)
139
+
140
+ BUNDLED WITH
141
+ 2.3.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,41 @@
1
+ # Esse Kaminari Plugin
2
+
3
+ This gem is a [esse](https://github.com/marcosgz/esse) plugin for the [kaminari](https://github.com/amatsuda/kaminari) pagination.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'esse-kaminari'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install esse-kaminari
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ @search = UsersIndex.search(params[:q]).page(params[:page]).per(10)
25
+
26
+ <%= paginate @search.results %>
27
+ ```
28
+
29
+ ## Development
30
+
31
+ 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.
32
+
33
+ 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).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/marcosgz/esse-kaminari.
38
+
39
+ ## License
40
+
41
+ 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,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ module Kaminari
5
+ module Pagination
6
+ module SearchQuery
7
+ def self.included(base)
8
+ base.__send__ :include, ::Kaminari::PageScopeMethods
9
+ base.__send__ :extend, Forwardable
10
+ base.__send__ :def_delegators, :_kaminari_config, :default_per_page, :max_per_page, :max_pages
11
+
12
+ base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
13
+ # Define the `page` Kaminari method
14
+ #
15
+ # @param [Integer] page
16
+ # @return [self]
17
+ def #{::Kaminari.config.page_method_name}(num=nil)
18
+ reset!
19
+
20
+ definition.update(
21
+ size: limit_value,
22
+ from: (limit_value * ([num.to_i, 1].max - 1))
23
+ )
24
+
25
+ self
26
+ end
27
+ RUBY
28
+ end
29
+
30
+ def limit_value
31
+ (raw_limit_value || default_per_page).to_i
32
+ end
33
+
34
+ def offset_value
35
+ raw_offset_value.to_i
36
+ end
37
+
38
+ def total_count
39
+ response.total
40
+ end
41
+
42
+ def paginated_results
43
+ ::Kaminari.paginate_array(response.hits, limit: limit_value, offset: offset_value, total_count: total_count)
44
+ end
45
+
46
+ def limit(value)
47
+ definition.update(size: value)
48
+ self
49
+ end
50
+
51
+ def offset(value)
52
+ definition.update(from: value)
53
+ self
54
+ end
55
+
56
+ private
57
+
58
+ def _kaminari_config
59
+ ::Kaminari.config
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ module Kaminari
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'esse'
4
+ require 'kaminari'
5
+ require_relative 'kaminari/version'
6
+ require_relative 'kaminari/pagination'
7
+
8
+ Esse::Search::Query.__send__ :include, Esse::Kaminari::Pagination::SearchQuery
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esse-kaminari
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcos G. Zimmermann
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-14 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kaminari
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: awesome_print
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: dotenv
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: pry
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: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '12.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: standard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.20'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.20'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-performance
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.11'
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 1.11.5
149
+ type: :development
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '1.11'
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: 1.11.5
159
+ - !ruby/object:Gem::Dependency
160
+ name: rubocop-rspec
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '2.4'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '2.4'
173
+ description: Kaminari extensions for Esse
174
+ email:
175
+ - mgzmaster@gmail.com
176
+ executables: []
177
+ extensions: []
178
+ extra_rdoc_files: []
179
+ files:
180
+ - ".rubocop.yml"
181
+ - Gemfile
182
+ - Gemfile.lock
183
+ - LICENSE.txt
184
+ - README.md
185
+ - Rakefile
186
+ - lib/esse/kaminari.rb
187
+ - lib/esse/kaminari/pagination.rb
188
+ - lib/esse/kaminari/version.rb
189
+ homepage: https://github.com/marcosgz/esse-kaminari
190
+ licenses:
191
+ - MIT
192
+ metadata:
193
+ homepage_uri: https://github.com/marcosgz/esse-kaminari
194
+ source_code_uri: https://github.com/marcosgz/esse-kaminari
195
+ changelog_uri: https://github.com/marcosgz/esse-kaminari/blob/main/CHANGELOG.md
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: 2.4.0
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubygems_version: 3.3.7
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Kaminari extensions for Esse
215
+ test_files: []