findit 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +5 -5
- data/README.md +44 -2
- data/findit.gemspec +1 -0
- data/lib/findit.rb +1 -0
- data/lib/findit/version.rb +1 -1
- data/lib/findit/will_paginate.rb +9 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa72800635cdabfff2a7363ba8525315b782e37e
|
4
|
+
data.tar.gz: 05667fd93e82d9352acc0f9f1e97704fd48b3fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 069e2eaea3e6c393ab2d29fdba362bd4b7a34231f141f93cebceb4be85bdc1ecdda5877a48ea5a99c236ed932be92d845919785c9f6d68d7556ba219f18a86ea
|
7
|
+
data.tar.gz: fc4ba671c1af2282bac7ec289d7da2e868ca8f721b4cec0c937c5c1a61665322efd4ff02fe20a1ec716a1e4eb8d16cf05d2d7e583c27dc4600736fb6c450bef0
|
data/Appraisals
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
appraise 'rails3.1' do
|
2
|
-
gem 'rails', '~> 3.1
|
2
|
+
gem 'rails', '~> 3.1'
|
3
3
|
end
|
4
4
|
|
5
5
|
appraise 'rails3.2' do
|
6
|
-
gem 'rails', '~> 3.2
|
6
|
+
gem 'rails', '~> 3.2'
|
7
7
|
end
|
8
8
|
|
9
9
|
appraise 'rails4.0' do
|
10
|
-
gem 'rails', '~> 4.0
|
10
|
+
gem 'rails', '~> 4.0'
|
11
11
|
end
|
12
12
|
|
13
13
|
appraise 'rails4.1' do
|
14
|
-
gem 'rails', '~> 4.1
|
14
|
+
gem 'rails', '~> 4.1'
|
15
15
|
end
|
16
16
|
|
17
17
|
appraise 'rails4.2' do
|
18
|
-
gem 'rails', '~> 4.2
|
18
|
+
gem 'rails', '~> 4.2'
|
19
19
|
end
|
20
20
|
|
data/README.md
CHANGED
@@ -155,9 +155,51 @@ class PostsController < ApplicationController
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
#/app/views/posts/index.html.
|
158
|
+
#/app/views/posts/index.html.erb
|
159
159
|
<% cache(@posts, expire_in: 30.minutes) do %>
|
160
|
-
<%=render 'post'
|
160
|
+
<%=render 'post', collection: @posts, as: :post%> # it will automaticly iterate over finder results by each method
|
161
|
+
```
|
162
|
+
|
163
|
+
## WillPaginate
|
164
|
+
|
165
|
+
It adds delegation of [will_paginate](https://github.com/mislav/will_paginate) methods to finder.
|
166
|
+
|
167
|
+
Example usage:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
# app/finders/post_finder.rb
|
171
|
+
class PostFinder
|
172
|
+
include Findit::Collection
|
173
|
+
include Findit::WillPaginate
|
174
|
+
|
175
|
+
cache_key do
|
176
|
+
[@page, @per_page]
|
177
|
+
end
|
178
|
+
|
179
|
+
def initialize(page, per_page)
|
180
|
+
@page = page
|
181
|
+
@per_page = per_page
|
182
|
+
end
|
183
|
+
|
184
|
+
private
|
185
|
+
|
186
|
+
def find
|
187
|
+
scope = Post.paginate(per_page: per_page, page: page)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# app/controllers/posts_controller.rb
|
192
|
+
|
193
|
+
class PostsController < ApplicationController
|
194
|
+
def index
|
195
|
+
@posts = PostFinder.new(params[:page], params[:per_page])
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# app/views/posts/index.html.erb
|
200
|
+
<% cache(@posts, expire_in: 30.minutes) do %>
|
201
|
+
<%= render 'post', collection: @posts, as: :post %>
|
202
|
+
<%= will_paginate @posts %>
|
161
203
|
```
|
162
204
|
|
163
205
|
## Contributing
|
data/findit.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_runtime_dependency 'activesupport', '>= 3.1'
|
21
21
|
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'will_paginate'
|
23
24
|
spec.add_development_dependency "rspec", ">= 3.2"
|
24
25
|
spec.add_development_dependency "rspec-rails", ">= 3.2"
|
25
26
|
spec.add_development_dependency 'combustion', '>= 0.5'
|
data/lib/findit.rb
CHANGED
data/lib/findit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: findit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Korobicyn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
version: '10.0'
|
39
39
|
type: :development
|
40
40
|
prerelease: false
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: will_paginate
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
type: :development
|
54
|
+
prerelease: false
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
version_requirements: !ruby/object:Gem::Requirement
|
43
57
|
requirements:
|
@@ -170,6 +184,7 @@ files:
|
|
170
184
|
- lib/findit.rb
|
171
185
|
- lib/findit/collections.rb
|
172
186
|
- lib/findit/version.rb
|
187
|
+
- lib/findit/will_paginate.rb
|
173
188
|
homepage: https://github.com/abak-press/findit
|
174
189
|
licenses: []
|
175
190
|
metadata: {}
|