kaminari-mongoid 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +7 -17
- data/Rakefile +0 -1
- data/kaminari-mongoid.gemspec +1 -1
- data/lib/kaminari/mongoid.rb +1 -1
- data/lib/kaminari/mongoid/mongoid_criteria_methods.rb +29 -27
- data/lib/kaminari/mongoid/mongoid_extension.rb +19 -17
- data/lib/kaminari/mongoid/version.rb +1 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f9fcf5388c2b1acb0a2f1c83f5a64e9cc524453
|
4
|
+
data.tar.gz: a8a5b33ea8798ec9d9ffd17eb65ca2b86a7f91b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90abc7adfe4514b010941787c0d86add43168704ddd50a8f7eaa3aaeebdc059966ceaf2ec40bebc62f646aea7e6665d4c1ad560c386388f1db6deae5c216fcfb
|
7
|
+
data.tar.gz: 1f639e7601dad7b83f1616b4f3fbe3985498f1ae82c86a21ec2d593e76ae3c925b23ec93f667719888a342b3f7c31a7fb34aa00d1305d3637dda197d61e864dc
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Kaminari::Mongoid
|
2
2
|
|
3
|
-
|
3
|
+
Kaminari Mongoid adapter.
|
4
4
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -12,28 +11,19 @@ Add this line to your application's Gemfile:
|
|
12
11
|
gem 'kaminari-mongoid'
|
13
12
|
```
|
14
13
|
|
15
|
-
And
|
14
|
+
And bundle.
|
16
15
|
|
17
|
-
$ bundle
|
18
16
|
|
19
|
-
|
17
|
+
## Supported versions
|
20
18
|
|
21
|
-
|
19
|
+
* Mongoid 3+
|
22
20
|
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
21
|
|
27
|
-
##
|
22
|
+
## Usage
|
28
23
|
|
29
|
-
|
24
|
+
See [Kaminari README](https://github.com/amatsuda/kaminari/blob/master/README.rdoc).
|
30
25
|
|
31
|
-
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
26
|
|
33
27
|
## Contributing
|
34
28
|
|
35
|
-
|
36
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
-
5. Create a new Pull Request
|
29
|
+
Pull requests are welcome on GitHub at https://github.com/kaminari/kaminari-mongoid
|
data/Rakefile
CHANGED
@@ -3,7 +3,6 @@ require 'rspec/core'
|
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
7
6
|
spec.pattern = [FileList['spec/**/*_spec.rb'], FileList["#{File.join(Gem.loaded_specs['kaminari'].gem_dir, 'spec')}/**/*_spec.rb"]].flatten
|
8
7
|
end
|
9
8
|
|
data/kaminari-mongoid.gemspec
CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.add_dependency 'kaminari'
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.9"
|
23
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
spec.add_development_dependency 'kaminari'
|
25
25
|
spec.add_development_dependency 'mongoid'
|
26
26
|
spec.add_development_dependency 'rails'
|
27
27
|
spec.add_development_dependency 'rspec-rails', '~> 2.14.1'
|
data/lib/kaminari/mongoid.rb
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
module Kaminari
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
module Mongoid
|
3
|
+
module MongoidCriteriaMethods
|
4
|
+
def initialize_copy(other) #:nodoc:
|
5
|
+
@total_count = nil
|
6
|
+
super
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def entry_name
|
10
|
+
model_name.human.downcase
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def limit_value #:nodoc:
|
14
|
+
options[:limit]
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def offset_value #:nodoc:
|
18
|
+
options[:skip]
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else
|
24
|
-
if options[:max_scan] && options[:max_scan] < size
|
25
|
-
options[:max_scan]
|
21
|
+
def total_count #:nodoc:
|
22
|
+
@total_count ||= if embedded?
|
23
|
+
unpage.size
|
26
24
|
else
|
27
|
-
size
|
25
|
+
if options[:max_scan] && options[:max_scan] < size
|
26
|
+
options[:max_scan]
|
27
|
+
else
|
28
|
+
size
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
private
|
34
|
+
def unpage
|
35
|
+
clone.tap do |crit|
|
36
|
+
crit.options.delete :limit
|
37
|
+
crit.options.delete :skip
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -1,26 +1,28 @@
|
|
1
1
|
require 'kaminari/mongoid/mongoid_criteria_methods'
|
2
2
|
|
3
3
|
module Kaminari
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
7
|
-
|
4
|
+
module Mongoid
|
5
|
+
module MongoidExtension
|
6
|
+
module Document
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
include Kaminari::ConfigurationMethods
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
included do
|
11
|
+
scope Kaminari.config.page_method_name, Proc.new {|num|
|
12
|
+
limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num))
|
13
|
+
} do
|
14
|
+
include Kaminari::Mongoid::MongoidCriteriaMethods
|
15
|
+
include Kaminari::PageScopeMethods
|
16
|
+
end
|
15
17
|
end
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
module ClassMethods
|
20
|
+
def inherited(kls)
|
21
|
+
super
|
22
|
+
kls.send(:include, Kaminari::Mongoid::MongoidExtension::Document.dup)
|
23
|
+
end
|
24
|
+
end if ::Mongoid::VERSION < '5.0.0'
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaminari-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: kaminari
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.9'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mongoid
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.6.4
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Kaminari Mongoid adapter
|