ar_pagination 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +86 -0
  7. data/Rakefile +2 -0
  8. data/ar_pagination.gemspec +28 -0
  9. data/lib/ar_pagination.rb +10 -0
  10. data/lib/ar_pagination/cursor_pagination/page.rb +41 -0
  11. data/lib/ar_pagination/cursor_pagination/query.rb +77 -0
  12. data/lib/ar_pagination/helpers/sort.rb +28 -0
  13. data/lib/ar_pagination/offset_pagination/page.rb +31 -0
  14. data/lib/ar_pagination/respond_with_page.rb +30 -0
  15. data/lib/ar_pagination/version.rb +3 -0
  16. data/spec/dummy/.DS_Store +0 -0
  17. data/spec/dummy/README.rdoc +28 -0
  18. data/spec/dummy/Rakefile +6 -0
  19. data/spec/dummy/app/assets/images/.keep +0 -0
  20. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  21. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  22. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  23. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/mailers/.keep +0 -0
  26. data/spec/dummy/app/models/.keep +0 -0
  27. data/spec/dummy/app/models/concerns/.keep +0 -0
  28. data/spec/dummy/app/models/foo.rb +2 -0
  29. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  30. data/spec/dummy/bin/bundle +3 -0
  31. data/spec/dummy/bin/rails +4 -0
  32. data/spec/dummy/bin/rake +4 -0
  33. data/spec/dummy/bin/setup +29 -0
  34. data/spec/dummy/config.ru +4 -0
  35. data/spec/dummy/config/application.rb +26 -0
  36. data/spec/dummy/config/boot.rb +5 -0
  37. data/spec/dummy/config/database.yml +85 -0
  38. data/spec/dummy/config/environment.rb +5 -0
  39. data/spec/dummy/config/environments/development.rb +41 -0
  40. data/spec/dummy/config/environments/production.rb +79 -0
  41. data/spec/dummy/config/environments/test.rb +42 -0
  42. data/spec/dummy/config/initializers/assets.rb +11 -0
  43. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  45. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/spec/dummy/config/initializers/inflections.rb +16 -0
  47. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  48. data/spec/dummy/config/initializers/session_store.rb +3 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  50. data/spec/dummy/config/locales/en.yml +23 -0
  51. data/spec/dummy/config/routes.rb +56 -0
  52. data/spec/dummy/config/secrets.yml +22 -0
  53. data/spec/dummy/db/migrate/20150527214335_create_foos.rb +10 -0
  54. data/spec/dummy/db/schema.rb +26 -0
  55. data/spec/dummy/lib/assets/.keep +0 -0
  56. data/spec/dummy/public/404.html +67 -0
  57. data/spec/dummy/public/422.html +67 -0
  58. data/spec/dummy/public/500.html +66 -0
  59. data/spec/dummy/public/favicon.ico +0 -0
  60. data/spec/dummy/test/fixtures/foos.yml +9 -0
  61. data/spec/dummy/test/models/foo_test.rb +7 -0
  62. data/spec/lib/ar_pagination/.DS_Store +0 -0
  63. data/spec/lib/ar_pagination/cursor_pagination/query_spec.rb +260 -0
  64. data/spec/lib/ar_pagination/offset_pagination/page_spec.rb +30 -0
  65. data/spec/rails_helper.rb +29 -0
  66. data/spec/spec_helper.rb +102 -0
  67. metadata +259 -0
@@ -0,0 +1,30 @@
1
+ require "rails_helper"
2
+
3
+ describe "ArPagination::OffsetPagination::Page" do
4
+ let!(:madeline) { Foo.create(name: 'Madeline', age: 125) }
5
+ let!(:youngin) { Foo.create(name: "youngin'", age: 90) }
6
+ let(:scope) { Foo.all }
7
+
8
+ describe "#data" do
9
+
10
+ it 'offsets the data' do
11
+ page = ArPagination::OffsetPagination::Page.new(scope, {offset: 1})
12
+ expect(page.data).to contain_exactly(youngin)
13
+ end
14
+
15
+ it 'limits the data' do
16
+ page = ArPagination::OffsetPagination::Page.new(scope, {count: 1})
17
+ expect(page.data).to contain_exactly(madeline)
18
+ end
19
+
20
+ it 'orders the data' do
21
+ page = ArPagination::OffsetPagination::Page.new(scope, {sort: "-name"})
22
+ expect(page.data.size).to eql(2)
23
+ expect(page.data.first).to eql(youngin)
24
+ expect(page.data.last).to eql(madeline)
25
+ end
26
+ end
27
+
28
+ describe "#params_for" do
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] = 'test'
3
+ require 'spec_helper'
4
+ require 'rspec/rails'
5
+
6
+ # Requires supporting ruby files with custom matchers and macros, etc, in
7
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
8
+ # run as spec files by default. This means that files in spec/support that end
9
+ # in _spec.rb will both be required and run as specs, causing the specs to be
10
+ # run twice. It is recommended that you do not name files matching this glob to
11
+ # end with _spec.rb. You can configure this pattern with the --pattern
12
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
13
+ #
14
+ # The following line is provided for convenience purposes. It has the downside
15
+ # of increasing the boot-up time by auto-requiring all files in the support
16
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
17
+ # require only the support files necessary.
18
+ Dir[Rails.root.join('spec/helpers/**/*.rb')].each { |f| require f }
19
+
20
+ # Checks for pending migrations before tests are run.
21
+ # If you are not using ActiveRecord, you can remove this line.
22
+ ActiveRecord::Migration.maintain_test_schema!
23
+
24
+ RSpec.configure do |config|
25
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
26
+ config.use_transactional_fixtures = true
27
+ config.infer_spec_type_from_file_location!
28
+
29
+ end
@@ -0,0 +1,102 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # require 'rspec/rails'
19
+
20
+ # # Configure Rails Environment
21
+ ENV["RAILS_ENV"] = "test"
22
+
23
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
24
+
25
+ require File.expand_path("../../spec/dummy/config/environment.rb", __FILE__)
26
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../spec/dummy/db/migrate", __FILE__)]
27
+
28
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
29
+ RSpec.configure do |config|
30
+ # config.use_transactional_fixtures = true
31
+ # rspec-expectations config goes here. You can use an alternate
32
+ # assertion/expectation library such as wrong or the stdlib/minitest
33
+ # assertions if you prefer.
34
+ config.expect_with :rspec do |expectations|
35
+ # This option will default to `true` in RSpec 4. It makes the `description`
36
+ # and `failure_message` of custom matchers include text for helper methods
37
+ # defined using `chain`, e.g.:
38
+ # be_bigger_than(2).and_smaller_than(4).description
39
+ # # => "be bigger than 2 and smaller than 4"
40
+ # ...rather than:
41
+ # # => "be bigger than 2"
42
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
43
+ end
44
+
45
+ # rspec-mocks config goes here. You can use an alternate test double
46
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
47
+ config.mock_with :rspec do |mocks|
48
+ # Prevents you from mocking or stubbing a method that does not exist on
49
+ # a real object. This is generally recommended, and will default to
50
+ # `true` in RSpec 4.
51
+ mocks.verify_partial_doubles = true
52
+ end
53
+
54
+ # The settings below are suggested to provide a good initial experience
55
+ # with RSpec, but feel free to customize to your heart's content.
56
+ =begin
57
+ # These two settings work together to allow you to limit a spec run
58
+ # to individual examples or groups you care about by tagging them with
59
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
60
+ # get run.
61
+ config.filter_run :focus
62
+ config.run_all_when_everything_filtered = true
63
+
64
+ # Limits the available syntax to the non-monkey patched syntax that is
65
+ # recommended. For more details, see:
66
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
67
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
68
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
69
+ config.disable_monkey_patching!
70
+
71
+ # This setting enables warnings. It's recommended, but in some cases may
72
+ # be too noisy due to issues in dependencies.
73
+ config.warnings = true
74
+
75
+ # Many RSpec users commonly either run the entire suite or an individual
76
+ # file, and it's useful to allow more verbose output when running an
77
+ # individual spec file.
78
+ if config.files_to_run.one?
79
+ # Use the documentation formatter for detailed output,
80
+ # unless a formatter has already been configured
81
+ # (e.g. via a command-line flag).
82
+ config.default_formatter = 'doc'
83
+ end
84
+
85
+ # Print the 10 slowest examples and example groups at the
86
+ # end of the spec run, to help surface which specs are running
87
+ # particularly slow.
88
+ config.profile_examples = 10
89
+
90
+ # Run specs in random order to surface order dependencies. If you find an
91
+ # order dependency and want to debug it, you can fix the order by providing
92
+ # the seed, which is printed after each run.
93
+ # --seed 1234
94
+ config.order = :random
95
+
96
+ # Seed global randomization in this process using the `--seed` CLI option.
97
+ # Setting this allows you to use `--seed` to deterministically reproduce
98
+ # test failures related to randomization by passing the same `--seed` value
99
+ # as the one that triggered the failure.
100
+ Kernel.srand config.seed
101
+ =end
102
+ end
metadata ADDED
@@ -0,0 +1,259 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ar_pagination
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Madeline Carson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-01 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: rspec
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-rails
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: pg
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: activesupport
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
+ description: Pagination for Rails controllers.
112
+ email:
113
+ - madeline.carson@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - ar_pagination.gemspec
125
+ - lib/ar_pagination.rb
126
+ - lib/ar_pagination/cursor_pagination/page.rb
127
+ - lib/ar_pagination/cursor_pagination/query.rb
128
+ - lib/ar_pagination/helpers/sort.rb
129
+ - lib/ar_pagination/offset_pagination/page.rb
130
+ - lib/ar_pagination/respond_with_page.rb
131
+ - lib/ar_pagination/version.rb
132
+ - spec/dummy/.DS_Store
133
+ - spec/dummy/README.rdoc
134
+ - spec/dummy/Rakefile
135
+ - spec/dummy/app/assets/images/.keep
136
+ - spec/dummy/app/assets/javascripts/application.js
137
+ - spec/dummy/app/assets/stylesheets/application.css
138
+ - spec/dummy/app/controllers/application_controller.rb
139
+ - spec/dummy/app/controllers/concerns/.keep
140
+ - spec/dummy/app/helpers/application_helper.rb
141
+ - spec/dummy/app/mailers/.keep
142
+ - spec/dummy/app/models/.keep
143
+ - spec/dummy/app/models/concerns/.keep
144
+ - spec/dummy/app/models/foo.rb
145
+ - spec/dummy/app/views/layouts/application.html.erb
146
+ - spec/dummy/bin/bundle
147
+ - spec/dummy/bin/rails
148
+ - spec/dummy/bin/rake
149
+ - spec/dummy/bin/setup
150
+ - spec/dummy/config.ru
151
+ - spec/dummy/config/application.rb
152
+ - spec/dummy/config/boot.rb
153
+ - spec/dummy/config/database.yml
154
+ - spec/dummy/config/environment.rb
155
+ - spec/dummy/config/environments/development.rb
156
+ - spec/dummy/config/environments/production.rb
157
+ - spec/dummy/config/environments/test.rb
158
+ - spec/dummy/config/initializers/assets.rb
159
+ - spec/dummy/config/initializers/backtrace_silencers.rb
160
+ - spec/dummy/config/initializers/cookies_serializer.rb
161
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
162
+ - spec/dummy/config/initializers/inflections.rb
163
+ - spec/dummy/config/initializers/mime_types.rb
164
+ - spec/dummy/config/initializers/session_store.rb
165
+ - spec/dummy/config/initializers/wrap_parameters.rb
166
+ - spec/dummy/config/locales/en.yml
167
+ - spec/dummy/config/routes.rb
168
+ - spec/dummy/config/secrets.yml
169
+ - spec/dummy/db/migrate/20150527214335_create_foos.rb
170
+ - spec/dummy/db/schema.rb
171
+ - spec/dummy/lib/assets/.keep
172
+ - spec/dummy/public/404.html
173
+ - spec/dummy/public/422.html
174
+ - spec/dummy/public/500.html
175
+ - spec/dummy/public/favicon.ico
176
+ - spec/dummy/test/fixtures/foos.yml
177
+ - spec/dummy/test/models/foo_test.rb
178
+ - spec/lib/ar_pagination/.DS_Store
179
+ - spec/lib/ar_pagination/cursor_pagination/query_spec.rb
180
+ - spec/lib/ar_pagination/offset_pagination/page_spec.rb
181
+ - spec/rails_helper.rb
182
+ - spec/spec_helper.rb
183
+ homepage: ''
184
+ licenses:
185
+ - MIT
186
+ metadata: {}
187
+ post_install_message:
188
+ rdoc_options: []
189
+ require_paths:
190
+ - lib
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ requirements: []
202
+ rubyforge_project:
203
+ rubygems_version: 2.4.5
204
+ signing_key:
205
+ specification_version: 4
206
+ summary: Pagination for Rails controllers. Includes cursor pagination and offset pagination.
207
+ test_files:
208
+ - spec/dummy/.DS_Store
209
+ - spec/dummy/README.rdoc
210
+ - spec/dummy/Rakefile
211
+ - spec/dummy/app/assets/images/.keep
212
+ - spec/dummy/app/assets/javascripts/application.js
213
+ - spec/dummy/app/assets/stylesheets/application.css
214
+ - spec/dummy/app/controllers/application_controller.rb
215
+ - spec/dummy/app/controllers/concerns/.keep
216
+ - spec/dummy/app/helpers/application_helper.rb
217
+ - spec/dummy/app/mailers/.keep
218
+ - spec/dummy/app/models/.keep
219
+ - spec/dummy/app/models/concerns/.keep
220
+ - spec/dummy/app/models/foo.rb
221
+ - spec/dummy/app/views/layouts/application.html.erb
222
+ - spec/dummy/bin/bundle
223
+ - spec/dummy/bin/rails
224
+ - spec/dummy/bin/rake
225
+ - spec/dummy/bin/setup
226
+ - spec/dummy/config.ru
227
+ - spec/dummy/config/application.rb
228
+ - spec/dummy/config/boot.rb
229
+ - spec/dummy/config/database.yml
230
+ - spec/dummy/config/environment.rb
231
+ - spec/dummy/config/environments/development.rb
232
+ - spec/dummy/config/environments/production.rb
233
+ - spec/dummy/config/environments/test.rb
234
+ - spec/dummy/config/initializers/assets.rb
235
+ - spec/dummy/config/initializers/backtrace_silencers.rb
236
+ - spec/dummy/config/initializers/cookies_serializer.rb
237
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
238
+ - spec/dummy/config/initializers/inflections.rb
239
+ - spec/dummy/config/initializers/mime_types.rb
240
+ - spec/dummy/config/initializers/session_store.rb
241
+ - spec/dummy/config/initializers/wrap_parameters.rb
242
+ - spec/dummy/config/locales/en.yml
243
+ - spec/dummy/config/routes.rb
244
+ - spec/dummy/config/secrets.yml
245
+ - spec/dummy/db/migrate/20150527214335_create_foos.rb
246
+ - spec/dummy/db/schema.rb
247
+ - spec/dummy/lib/assets/.keep
248
+ - spec/dummy/public/404.html
249
+ - spec/dummy/public/422.html
250
+ - spec/dummy/public/500.html
251
+ - spec/dummy/public/favicon.ico
252
+ - spec/dummy/test/fixtures/foos.yml
253
+ - spec/dummy/test/models/foo_test.rb
254
+ - spec/lib/ar_pagination/.DS_Store
255
+ - spec/lib/ar_pagination/cursor_pagination/query_spec.rb
256
+ - spec/lib/ar_pagination/offset_pagination/page_spec.rb
257
+ - spec/rails_helper.rb
258
+ - spec/spec_helper.rb
259
+ has_rdoc: