kaminari-mongoid 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d6e0336e0ae78e0d015cf9d314cf6770ecc70b2
4
+ data.tar.gz: f357e3919e5782e9dd4dbd925105cfbe9154fa97
5
+ SHA512:
6
+ metadata.gz: fa369378bf7fe3592725bd5d754122748b0140f5d18a48af1f6536a0e720e789a42364d332cbd02c2f66e2129b569f991dcd1bc3789b9e6daf609a097c0da49b
7
+ data.tar.gz: 0b929d6851275d8a1c976931a8d3d7363d13fa16a6fe13416e9b8c097063e47d94fb91b3953dadab0ddf8722577d11013d09da616162fe1af7b61548acd23d7e
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ gemfiles/*.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,36 @@
1
+ language: ruby
2
+
3
+ before_install: gem install bundler -v 1.11.2
4
+
5
+ rvm:
6
+ - 2.0.0
7
+ - 2.1.8
8
+ - 2.2.4
9
+ - 2.3.0
10
+ - ruby-head
11
+ - jruby
12
+ - jruby-head
13
+ - rbx-2
14
+
15
+ gemfile:
16
+ - gemfiles/mongoid_30.gemfile
17
+ - gemfiles/mongoid_31.gemfile
18
+ - gemfiles/mongoid_40.gemfile
19
+ - gemfiles/mongoid_50.gemfile
20
+ - gemfiles/mongoid_51.gemfile
21
+
22
+ sudo: false
23
+
24
+ services: mongodb
25
+
26
+ script: "bundle exec rake spec"
27
+
28
+ cache: bundler
29
+
30
+ matrix:
31
+ allow_failures:
32
+ - rvm: ruby-head
33
+ - rvm: jruby
34
+ - rvm: jruby-head
35
+ - rvm: rbx-2
36
+ fast_finish: true
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kaminari-mongoid.gemspec
4
+ gemspec
5
+
6
+ gem 'database_cleaner', git: 'git@github.com:DatabaseCleaner/database_cleaner.git'
7
+
8
+ gem 'kaminari', github: 'amatsuda/kaminari'
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Akira Matsuda
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,39 @@
1
+ # Kaminari::Mongoid
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kaminari/mongoid`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'kaminari-mongoid'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kaminari-mongoid
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
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
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/kaminari-mongoid/fork )
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
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ spec.pattern = [FileList['spec/**/*_spec.rb'], FileList["#{File.join(Gem.loaded_specs['kaminari'].gem_dir, 'spec')}/**/*_spec.rb"]].flatten
8
+ end
9
+
10
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kaminari/mongoid"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #FIXME bundle GH branch for now
4
+ gem 'kaminari', github: 'amatsuda/kaminari', branch: 'extract_adapters'
5
+
6
+ gem 'railties', '>= 3.2.3'
7
+ gem 'mongoid', '~> 3.0.0'
8
+ gem 'rspec-rails', '~> 2.14.1'
9
+ gem 'origin'
10
+ gem 'moped'
11
+ gem 'activesupport', '~> 3.2.18'
12
+
13
+ if RUBY_VERSION > '1.9.3'
14
+ gem 'mime-types'
15
+ else
16
+ gem 'mime-types', '2.99'
17
+ end
18
+
19
+ platforms :mri do
20
+ gem 'test-unit' if RUBY_VERSION > "2.1.0"
21
+ end
22
+
23
+ platforms :rbx do
24
+ gem 'rubysl', '~> 2.0'
25
+ gem 'racc'
26
+ gem 'rubysl-test-unit', github: 'rubysl/rubysl-test-unit', branch: '2.0'
27
+ gem 'rubinius-developer_tools'
28
+ end
29
+
30
+ gemspec :path => '../'
@@ -0,0 +1,29 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #FIXME bundle GH branch for now
4
+ gem 'kaminari', github: 'amatsuda/kaminari', branch: 'extract_adapters'
5
+
6
+ gem 'railties', '~> 3.2'
7
+ gem 'mongoid', '~> 3.1.0'
8
+ gem 'rspec-rails', '~> 2.14.1'
9
+ gem 'origin'
10
+ gem 'moped'
11
+
12
+ if RUBY_VERSION > '1.9.3'
13
+ gem 'mime-types'
14
+ else
15
+ gem 'mime-types', '2.99'
16
+ end
17
+
18
+ platforms :mri do
19
+ gem 'test-unit' if RUBY_VERSION > "2.1.0"
20
+ end
21
+
22
+ platforms :rbx do
23
+ gem 'rubysl', '~> 2.0'
24
+ gem 'racc'
25
+ gem 'rubysl-test-unit', github: 'rubysl/rubysl-test-unit', branch: '2.0'
26
+ gem 'rubinius-developer_tools'
27
+ end
28
+
29
+ gemspec :path => '../'
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #FIXME bundle GH branch for now
4
+ gem 'kaminari', github: 'amatsuda/kaminari', branch: 'extract_adapters'
5
+
6
+ gem 'railties', '~> 4.0'
7
+ gem 'mongoid', '~> 4.0.0'
8
+ gem 'rspec-rails', '~> 2.14.1'
9
+
10
+ if RUBY_VERSION > '1.9.3'
11
+ gem 'mime-types'
12
+ else
13
+ gem 'mime-types', '2.99'
14
+ end
15
+
16
+ platforms :mri do
17
+ gem 'test-unit' if RUBY_VERSION > '2.1.0'
18
+ end
19
+
20
+ platforms :rbx do
21
+ gem 'rubysl', '~> 2.0'
22
+ gem 'racc'
23
+ gem 'minitest'
24
+ gem 'rubinius-developer_tools'
25
+ end
26
+
27
+ gemspec :path => '../'
@@ -0,0 +1,31 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #FIXME bundle GH branch for now
4
+ gem 'kaminari', github: 'amatsuda/kaminari', branch: 'extract_adapters'
5
+
6
+ gem 'railties', '~> 4.0'
7
+ gem 'mongoid', '~> 5.0.0'
8
+ gem 'rspec-rails', '~> 2.14.1'
9
+
10
+ if RUBY_VERSION > '1.9.3'
11
+ gem 'mime-types'
12
+ else
13
+ gem 'mime-types', '2.99'
14
+ end
15
+
16
+ group :development, :test do
17
+ gem 'database_cleaner', '~> 1.5.1'
18
+ end
19
+
20
+ platforms :mri do
21
+ gem 'test-unit' if RUBY_VERSION > '2.1.0'
22
+ end
23
+
24
+ platforms :rbx do
25
+ gem 'rubysl', '~> 2.0'
26
+ gem 'racc'
27
+ gem 'minitest'
28
+ gem 'rubinius-developer_tools'
29
+ end
30
+
31
+ gemspec :path => '../'
@@ -0,0 +1,31 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #FIXME bundle GH branch for now
4
+ gem 'kaminari', github: 'amatsuda/kaminari', branch: 'extract_adapters'
5
+
6
+ gem 'railties', '~> 4.0'
7
+ gem 'mongoid', '~> 5.1.0'
8
+ gem 'rspec-rails', '~> 2.14.1'
9
+
10
+ if RUBY_VERSION > '1.9.3'
11
+ gem 'mime-types'
12
+ else
13
+ gem 'mime-types', '2.99'
14
+ end
15
+
16
+ group :development, :test do
17
+ gem 'database_cleaner', '~> 1.5.1'
18
+ end
19
+
20
+ platforms :mri do
21
+ gem 'test-unit' if RUBY_VERSION > '2.1.0'
22
+ end
23
+
24
+ platforms :rbx do
25
+ gem 'rubysl', '~> 2.0'
26
+ gem 'racc'
27
+ gem 'minitest'
28
+ gem 'rubinius-developer_tools'
29
+ end
30
+
31
+ gemspec :path => '../'
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kaminari/mongoid/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kaminari-mongoid"
8
+ spec.version = Kaminari::Mongoid::VERSION
9
+ spec.authors = ["Akira Matsuda"]
10
+ spec.email = ["ronnie@dio.jp"]
11
+
12
+ spec.summary = 'Kaminari Mongoid adapter'
13
+ spec.description = 'Kaminari Mongoid adapter'
14
+ spec.homepage = 'https://github.com/kaminari/kaminari-mongoid'
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency 'kaminari'
25
+ spec.add_development_dependency 'mongoid'
26
+ spec.add_development_dependency 'rails'
27
+ spec.add_development_dependency 'rspec-rails', '~> 2.14.1'
28
+ spec.add_development_dependency 'capybara'
29
+ spec.add_development_dependency 'database_cleaner'
30
+ spec.add_development_dependency 'rr'
31
+ spec.add_development_dependency 'byebug'
32
+ end
@@ -0,0 +1,4 @@
1
+ require 'kaminari'
2
+ require 'mongoid'
3
+ require 'kaminari/mongoid/mongoid_extension'
4
+ ::Mongoid::Document.send :include, Kaminari::MongoidExtension::Document
@@ -0,0 +1,40 @@
1
+ module Kaminari
2
+ module MongoidCriteriaMethods
3
+ def initialize_copy(other) #:nodoc:
4
+ @total_count = nil
5
+ super
6
+ end
7
+
8
+ def entry_name
9
+ model_name.human.downcase
10
+ end
11
+
12
+ def limit_value #:nodoc:
13
+ options[:limit]
14
+ end
15
+
16
+ def offset_value #:nodoc:
17
+ options[:skip]
18
+ end
19
+
20
+ def total_count #:nodoc:
21
+ @total_count ||= if embedded?
22
+ unpage.size
23
+ else
24
+ if options[:max_scan] && options[:max_scan] < size
25
+ options[:max_scan]
26
+ else
27
+ size
28
+ end
29
+ end
30
+ end
31
+
32
+ private
33
+ def unpage
34
+ clone.tap do |crit|
35
+ crit.options.delete :limit
36
+ crit.options.delete :skip
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,26 @@
1
+ require 'kaminari/mongoid/mongoid_criteria_methods'
2
+
3
+ module Kaminari
4
+ module MongoidExtension
5
+ module Document
6
+ extend ActiveSupport::Concern
7
+ include Kaminari::ConfigurationMethods
8
+
9
+ included do
10
+ scope Kaminari.config.page_method_name, Proc.new {|num|
11
+ limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num))
12
+ } do
13
+ include Kaminari::MongoidCriteriaMethods
14
+ include Kaminari::PageScopeMethods
15
+ end
16
+ end
17
+
18
+ module ClassMethods
19
+ def inherited(kls)
20
+ super
21
+ kls.send(:include, Kaminari::MongoidExtension::Document.dup)
22
+ end
23
+ end if Mongoid::VERSION < '5.0.0'
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ module Kaminari
2
+ module Mongoid
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kaminari-mongoid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Akira Matsuda
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kaminari
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: mongoid
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: rails
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: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.14.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.14.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: capybara
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: database_cleaner
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
+ - !ruby/object:Gem::Dependency
126
+ name: rr
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Kaminari Mongoid adapter
154
+ email:
155
+ - ronnie@dio.jp
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".travis.yml"
163
+ - Gemfile
164
+ - MIT-LICENSE
165
+ - README.md
166
+ - Rakefile
167
+ - bin/console
168
+ - bin/setup
169
+ - gemfiles/mongoid_30.gemfile
170
+ - gemfiles/mongoid_31.gemfile
171
+ - gemfiles/mongoid_40.gemfile
172
+ - gemfiles/mongoid_50.gemfile
173
+ - gemfiles/mongoid_51.gemfile
174
+ - kaminari-mongoid.gemspec
175
+ - lib/kaminari/mongoid.rb
176
+ - lib/kaminari/mongoid/mongoid_criteria_methods.rb
177
+ - lib/kaminari/mongoid/mongoid_extension.rb
178
+ - lib/kaminari/mongoid/version.rb
179
+ homepage: https://github.com/kaminari/kaminari-mongoid
180
+ licenses:
181
+ - MIT
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.5.1
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: Kaminari Mongoid adapter
203
+ test_files: []