api-pagination 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api-pagination.rb +13 -9
- data/lib/api-pagination/version.rb +1 -1
- data/spec/controllers/numbers_controller_spec.rb +30 -1
- data/spec/dummy/log/development.log +120 -0
- data/spec/spec_helper.rb +43 -6
- metadata +7 -85
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/numbers_controller.rb +0 -8
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -28
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -29
- data/spec/dummy/config/environments/production.rb +0 -80
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/db/schema.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89fc0b6667ca5db8b964c8ddc52902359b808251
|
4
|
+
data.tar.gz: e0c4f2a8a4bba136691e8f7484d0d58fe1ec4d14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b95fd8252f48c98eef1a817eb5740b9944b3237daed662907342c39da6ca047f505e413beba2a560e2c5bda2532f7d57612ab5e2b2867a753d212056dbb580
|
7
|
+
data.tar.gz: fb0faffe5f8d686981666fb690a1c346de9d8350711feb83003d28689d364a91dc5ca9380320a0c76753d8282a9b876baeaf01f1aab6b6e7b3500611b7b0c24c
|
data/lib/api-pagination.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
require 'api-pagination/version'
|
2
|
-
require 'kaminari'
|
3
2
|
|
4
3
|
module ApiPagination
|
5
4
|
protected
|
6
5
|
def paginate(scope)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
pages = {}
|
11
|
-
links = []
|
6
|
+
scope = instance_variable_get(:"@#{scope}")
|
7
|
+
url = request.original_url.sub(/\?.*$/, '')
|
8
|
+
pages = {}
|
12
9
|
|
13
10
|
unless scope.first_page?
|
14
11
|
pages[:first] = 1
|
@@ -20,9 +17,9 @@ module ApiPagination
|
|
20
17
|
pages[:next] = scope.current_page + 1
|
21
18
|
end
|
22
19
|
|
23
|
-
pages.
|
24
|
-
new_params =
|
25
|
-
|
20
|
+
links = pages.map do |k, v|
|
21
|
+
new_params = request.query_parameters.merge({ :page => v })
|
22
|
+
%(<#{url}?#{new_params.to_param}>; rel="#{k}")
|
26
23
|
end
|
27
24
|
|
28
25
|
headers['Link'] = links.join(', ')
|
@@ -31,3 +28,10 @@ end
|
|
31
28
|
|
32
29
|
ActionController::Base.send(:include, ApiPagination) if defined?(ActionController::Base)
|
33
30
|
ActionController::API.send(:include, ApiPagination) if defined?(ActionController::API)
|
31
|
+
|
32
|
+
if defined?(WillPaginate::CollectionMethods)
|
33
|
+
WillPaginate::CollectionMethods.module_eval do
|
34
|
+
def first_page?() !previous_page end
|
35
|
+
def last_page?() !next_page end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,6 +1,35 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
Rails.application.routes.draw do
|
4
|
+
resources :numbers, only: [:index]
|
5
|
+
end
|
6
|
+
|
7
|
+
# quacks like Kaminari
|
8
|
+
PaginatedSet = Struct.new(:current_page, :total_count) do
|
9
|
+
def limit_value() 25 end
|
10
|
+
|
11
|
+
def total_pages
|
12
|
+
total_count.zero? ? 1 : (total_count.to_f / limit_value).ceil
|
13
|
+
end
|
14
|
+
|
15
|
+
def first_page?() current_page == 1 end
|
16
|
+
def last_page?() current_page == total_pages end
|
17
|
+
end
|
18
|
+
|
19
|
+
class NumbersController < ActionController::Base
|
20
|
+
include Rails.application.routes.url_helpers
|
21
|
+
|
22
|
+
after_filter only: [:index] { paginate(:numbers) }
|
23
|
+
|
24
|
+
def index
|
25
|
+
page = params.fetch(:page, 1).to_i
|
26
|
+
total = params.fetch(:count).to_i
|
27
|
+
@numbers = PaginatedSet.new(page, total)
|
28
|
+
render json: @numbers
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe NumbersController, :type => :controller do
|
4
33
|
describe 'GET #index' do
|
5
34
|
context 'without enough items to give more than one page' do
|
6
35
|
it 'should not paginate' do
|
@@ -17685,3 +17685,123 @@ Completed 200 OK in 0ms (Views: 0.2ms)
|
|
17685
17685
|
Processing by NumbersController#index as HTML
|
17686
17686
|
Parameters: {"count"=>"100"}
|
17687
17687
|
Completed 200 OK in 0ms (Views: 0.2ms)
|
17688
|
+
Processing by NumbersController#index as HTML
|
17689
|
+
Parameters: {"count"=>"20"}
|
17690
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17691
|
+
Processing by NumbersController#index as HTML
|
17692
|
+
Parameters: {"count"=>"100"}
|
17693
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17694
|
+
Processing by NumbersController#index as HTML
|
17695
|
+
Parameters: {"count"=>"100"}
|
17696
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17697
|
+
Processing by NumbersController#index as HTML
|
17698
|
+
Parameters: {"count"=>"100"}
|
17699
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17700
|
+
Processing by NumbersController#index as HTML
|
17701
|
+
Parameters: {"count"=>"100"}
|
17702
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17703
|
+
Processing by NumbersController#index as HTML
|
17704
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17705
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17706
|
+
Processing by NumbersController#index as HTML
|
17707
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17708
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17709
|
+
Processing by NumbersController#index as HTML
|
17710
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17711
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17712
|
+
Processing by NumbersController#index as HTML
|
17713
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17714
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17715
|
+
Processing by NumbersController#index as HTML
|
17716
|
+
Parameters: {"count"=>"100", "page"=>"2"}
|
17717
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
17718
|
+
Processing by NumbersController#index as HTML
|
17719
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17720
|
+
Completed 200 OK in 1ms (Views: 0.2ms)
|
17721
|
+
Processing by NumbersController#index as HTML
|
17722
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17723
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17724
|
+
Processing by NumbersController#index as HTML
|
17725
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17726
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17727
|
+
Processing by NumbersController#index as HTML
|
17728
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17729
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17730
|
+
Processing by NumbersController#index as HTML
|
17731
|
+
Parameters: {"count"=>"100", "page"=>"2"}
|
17732
|
+
Completed 200 OK in 1ms (Views: 0.2ms)
|
17733
|
+
Processing by NumbersController#index as HTML
|
17734
|
+
Parameters: {"count"=>"100"}
|
17735
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17736
|
+
Processing by NumbersController#index as HTML
|
17737
|
+
Parameters: {"count"=>"100"}
|
17738
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17739
|
+
Processing by NumbersController#index as HTML
|
17740
|
+
Parameters: {"count"=>"100"}
|
17741
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17742
|
+
Processing by NumbersController#index as HTML
|
17743
|
+
Parameters: {"count"=>"100"}
|
17744
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17745
|
+
Processing by NumbersController#index as HTML
|
17746
|
+
Parameters: {"count"=>"20"}
|
17747
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
17748
|
+
Processing by NumbersController#index as HTML
|
17749
|
+
Parameters: {"count"=>"20"}
|
17750
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17751
|
+
Processing by NumbersController#index as HTML
|
17752
|
+
Parameters: {"count"=>"100"}
|
17753
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
17754
|
+
Processing by NumbersController#index as HTML
|
17755
|
+
Parameters: {"count"=>"100"}
|
17756
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17757
|
+
Processing by NumbersController#index as HTML
|
17758
|
+
Parameters: {"count"=>"100"}
|
17759
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17760
|
+
Processing by NumbersController#index as HTML
|
17761
|
+
Parameters: {"count"=>"100"}
|
17762
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17763
|
+
Processing by NumbersController#index as HTML
|
17764
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17765
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17766
|
+
Processing by NumbersController#index as HTML
|
17767
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17768
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17769
|
+
Processing by NumbersController#index as HTML
|
17770
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17771
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17772
|
+
Processing by NumbersController#index as HTML
|
17773
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17774
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17775
|
+
Processing by NumbersController#index as HTML
|
17776
|
+
Parameters: {"count"=>"100", "page"=>"2"}
|
17777
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
17778
|
+
Processing by NumbersController#index as HTML
|
17779
|
+
Parameters: {"count"=>"20"}
|
17780
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17781
|
+
Processing by NumbersController#index as HTML
|
17782
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17783
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17784
|
+
Processing by NumbersController#index as HTML
|
17785
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17786
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17787
|
+
Processing by NumbersController#index as HTML
|
17788
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17789
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
17790
|
+
Processing by NumbersController#index as HTML
|
17791
|
+
Parameters: {"count"=>"100", "page"=>"4"}
|
17792
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
17793
|
+
Processing by NumbersController#index as HTML
|
17794
|
+
Parameters: {"count"=>"100"}
|
17795
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
17796
|
+
Processing by NumbersController#index as HTML
|
17797
|
+
Parameters: {"count"=>"100"}
|
17798
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17799
|
+
Processing by NumbersController#index as HTML
|
17800
|
+
Parameters: {"count"=>"100"}
|
17801
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17802
|
+
Processing by NumbersController#index as HTML
|
17803
|
+
Parameters: {"count"=>"100"}
|
17804
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
17805
|
+
Processing by NumbersController#index as HTML
|
17806
|
+
Parameters: {"count"=>"100", "page"=>"2"}
|
17807
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
require 'action_controller'
|
2
|
+
require 'api-pagination'
|
3
|
+
require 'rspec/autorun'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
def self.application
|
8
|
+
@application ||= begin
|
9
|
+
routes = ActionDispatch::Routing::RouteSet.new
|
10
|
+
OpenStruct.new(routes: routes, env_config: {})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module ControllerExampleGroup
|
16
|
+
def self.included(base)
|
17
|
+
base.extend ClassMethods
|
18
|
+
base.send(:include, ActionController::TestCase::Behavior)
|
19
|
+
|
20
|
+
base.prepend_before do
|
21
|
+
@routes = Rails.application.routes
|
22
|
+
@controller = described_class.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module ClassMethods
|
27
|
+
def setup(*methods)
|
28
|
+
methods.each do |method|
|
29
|
+
if method.to_s =~ /^setup_(fixtures|controller_request_and_response)$/
|
30
|
+
prepend_before { send method }
|
31
|
+
else
|
32
|
+
before { send method }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def teardown(*methods)
|
38
|
+
methods.each { |method| after { send method } }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
7
42
|
|
8
43
|
RSpec.configure do |config|
|
9
44
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
@@ -15,4 +50,6 @@ RSpec.configure do |config|
|
|
15
50
|
# the seed, which is printed after each run.
|
16
51
|
# --seed 1234
|
17
52
|
config.order = 'random'
|
53
|
+
|
54
|
+
config.include ControllerExampleGroup, :type => :controller
|
18
55
|
end
|
metadata
CHANGED
@@ -1,59 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api-pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: actionpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 3.0.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.13.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.13.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.3'
|
19
|
+
version: '0'
|
48
20
|
type: :development
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
|
-
- -
|
24
|
+
- - '>='
|
53
25
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
26
|
+
version: '0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
28
|
+
name: rspec
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - '>='
|
@@ -76,32 +48,7 @@ files:
|
|
76
48
|
- lib/api-pagination/version.rb
|
77
49
|
- lib/api-pagination.rb
|
78
50
|
- spec/controllers/numbers_controller_spec.rb
|
79
|
-
- spec/dummy/app/controllers/application_controller.rb
|
80
|
-
- spec/dummy/app/controllers/numbers_controller.rb
|
81
|
-
- spec/dummy/app/helpers/application_helper.rb
|
82
|
-
- spec/dummy/bin/bundle
|
83
|
-
- spec/dummy/bin/rails
|
84
|
-
- spec/dummy/bin/rake
|
85
|
-
- spec/dummy/config/application.rb
|
86
|
-
- spec/dummy/config/boot.rb
|
87
|
-
- spec/dummy/config/database.yml
|
88
|
-
- spec/dummy/config/environment.rb
|
89
|
-
- spec/dummy/config/environments/development.rb
|
90
|
-
- spec/dummy/config/environments/production.rb
|
91
|
-
- spec/dummy/config/environments/test.rb
|
92
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
93
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
94
|
-
- spec/dummy/config/initializers/inflections.rb
|
95
|
-
- spec/dummy/config/initializers/mime_types.rb
|
96
|
-
- spec/dummy/config/initializers/secret_token.rb
|
97
|
-
- spec/dummy/config/initializers/session_store.rb
|
98
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
99
|
-
- spec/dummy/config/locales/en.yml
|
100
|
-
- spec/dummy/config/routes.rb
|
101
|
-
- spec/dummy/config.ru
|
102
|
-
- spec/dummy/db/schema.rb
|
103
51
|
- spec/dummy/log/development.log
|
104
|
-
- spec/dummy/Rakefile
|
105
52
|
- spec/spec_helper.rb
|
106
53
|
homepage: https://github.com/davidcelis/api-pagination
|
107
54
|
licenses:
|
@@ -129,30 +76,5 @@ specification_version: 4
|
|
129
76
|
summary: Link header pagination for Rails APIs. Don't use the request body.
|
130
77
|
test_files:
|
131
78
|
- spec/controllers/numbers_controller_spec.rb
|
132
|
-
- spec/dummy/app/controllers/application_controller.rb
|
133
|
-
- spec/dummy/app/controllers/numbers_controller.rb
|
134
|
-
- spec/dummy/app/helpers/application_helper.rb
|
135
|
-
- spec/dummy/bin/bundle
|
136
|
-
- spec/dummy/bin/rails
|
137
|
-
- spec/dummy/bin/rake
|
138
|
-
- spec/dummy/config/application.rb
|
139
|
-
- spec/dummy/config/boot.rb
|
140
|
-
- spec/dummy/config/database.yml
|
141
|
-
- spec/dummy/config/environment.rb
|
142
|
-
- spec/dummy/config/environments/development.rb
|
143
|
-
- spec/dummy/config/environments/production.rb
|
144
|
-
- spec/dummy/config/environments/test.rb
|
145
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
146
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
147
|
-
- spec/dummy/config/initializers/inflections.rb
|
148
|
-
- spec/dummy/config/initializers/mime_types.rb
|
149
|
-
- spec/dummy/config/initializers/secret_token.rb
|
150
|
-
- spec/dummy/config/initializers/session_store.rb
|
151
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
152
|
-
- spec/dummy/config/locales/en.yml
|
153
|
-
- spec/dummy/config/routes.rb
|
154
|
-
- spec/dummy/config.ru
|
155
|
-
- spec/dummy/db/schema.rb
|
156
79
|
- spec/dummy/log/development.log
|
157
|
-
- spec/dummy/Rakefile
|
158
80
|
- spec/spec_helper.rb
|
data/spec/dummy/Rakefile
DELETED
data/spec/dummy/bin/bundle
DELETED
data/spec/dummy/bin/rails
DELETED
data/spec/dummy/bin/rake
DELETED
data/spec/dummy/config.ru
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
# Pick the frameworks you want:
|
4
|
-
# require "active_record/railtie"
|
5
|
-
require "action_controller/railtie"
|
6
|
-
# require "action_mailer/railtie"
|
7
|
-
# require "sprockets/railtie"
|
8
|
-
|
9
|
-
Bundler.require(*Rails.groups)
|
10
|
-
require 'kaminari'
|
11
|
-
require 'api-pagination'
|
12
|
-
|
13
|
-
module Dummy
|
14
|
-
class Application < Rails::Application
|
15
|
-
# Settings in config/environments/* take precedence over those specified here.
|
16
|
-
# Application configuration should go into files in config/initializers
|
17
|
-
# -- all .rb files in that directory are automatically loaded.
|
18
|
-
|
19
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
20
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
21
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
22
|
-
|
23
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
24
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
25
|
-
# config.i18n.default_locale = :de
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
data/spec/dummy/config/boot.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
development:
|
7
|
-
adapter: sqlite3
|
8
|
-
database: db/development.sqlite3
|
9
|
-
pool: 5
|
10
|
-
timeout: 5000
|
11
|
-
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
|
-
test:
|
16
|
-
adapter: sqlite3
|
17
|
-
database: db/test.sqlite3
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
20
|
-
|
21
|
-
production:
|
22
|
-
adapter: sqlite3
|
23
|
-
database: db/production.sqlite3
|
24
|
-
pool: 5
|
25
|
-
timeout: 5000
|
@@ -1,29 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
-
|
4
|
-
# In the development environment your application's code is reloaded on
|
5
|
-
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the web server when you make code changes.
|
7
|
-
config.cache_classes = false
|
8
|
-
|
9
|
-
# Do not eager load code on boot.
|
10
|
-
config.eager_load = false
|
11
|
-
|
12
|
-
# Show full error reports and disable caching.
|
13
|
-
config.consider_all_requests_local = true
|
14
|
-
config.action_controller.perform_caching = false
|
15
|
-
|
16
|
-
# Don't care if the mailer can't send.
|
17
|
-
# config.action_mailer.raise_delivery_errors = false
|
18
|
-
|
19
|
-
# Print deprecation notices to the Rails logger.
|
20
|
-
config.active_support.deprecation = :log
|
21
|
-
|
22
|
-
# Raise an error on page load if there are pending migrations
|
23
|
-
# config.active_record.migration_error = :page_load
|
24
|
-
|
25
|
-
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
-
# This option may cause significant delays in view rendering with a large
|
27
|
-
# number of complex assets.
|
28
|
-
config.assets.debug = true
|
29
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
-
|
4
|
-
# Code is not reloaded between requests.
|
5
|
-
config.cache_classes = true
|
6
|
-
|
7
|
-
# Eager load code on boot. This eager loads most of Rails and
|
8
|
-
# your application in memory, allowing both thread web servers
|
9
|
-
# and those relying on copy on write to perform better.
|
10
|
-
# Rake tasks automatically ignore this option for performance.
|
11
|
-
config.eager_load = true
|
12
|
-
|
13
|
-
# Full error reports are disabled and caching is turned on.
|
14
|
-
config.consider_all_requests_local = false
|
15
|
-
config.action_controller.perform_caching = true
|
16
|
-
|
17
|
-
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
-
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
-
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
-
# config.action_dispatch.rack_cache = true
|
21
|
-
|
22
|
-
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
-
# config.serve_static_assets = false
|
24
|
-
|
25
|
-
# Compress JavaScripts and CSS.
|
26
|
-
# config.assets.js_compressor = :uglifier
|
27
|
-
# config.assets.css_compressor = :sass
|
28
|
-
|
29
|
-
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
-
# config.assets.compile = false
|
31
|
-
|
32
|
-
# Generate digests for assets URLs.
|
33
|
-
# config.assets.digest = true
|
34
|
-
|
35
|
-
# Version of your assets, change this if you want to expire all your assets.
|
36
|
-
# config.assets.version = '1.0'
|
37
|
-
|
38
|
-
# Specifies the header that your server uses for sending files.
|
39
|
-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
40
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
41
|
-
|
42
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
43
|
-
# config.force_ssl = true
|
44
|
-
|
45
|
-
# Set to :debug to see everything in the log.
|
46
|
-
config.log_level = :info
|
47
|
-
|
48
|
-
# Prepend all log lines with the following tags.
|
49
|
-
# config.log_tags = [ :subdomain, :uuid ]
|
50
|
-
|
51
|
-
# Use a different logger for distributed setups.
|
52
|
-
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
53
|
-
|
54
|
-
# Use a different cache store in production.
|
55
|
-
# config.cache_store = :mem_cache_store
|
56
|
-
|
57
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
58
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
59
|
-
|
60
|
-
# Precompile additional assets.
|
61
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
62
|
-
# config.assets.precompile += %w( search.js )
|
63
|
-
|
64
|
-
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
66
|
-
# config.action_mailer.raise_delivery_errors = false
|
67
|
-
|
68
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
69
|
-
# the I18n.default_locale when a translation can not be found).
|
70
|
-
config.i18n.fallbacks = true
|
71
|
-
|
72
|
-
# Send deprecation notices to registered listeners.
|
73
|
-
config.active_support.deprecation = :notify
|
74
|
-
|
75
|
-
# Disable automatic flushing of the log to improve performance.
|
76
|
-
# config.autoflush_log = false
|
77
|
-
|
78
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
79
|
-
config.log_formatter = ::Logger::Formatter.new
|
80
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
-
|
4
|
-
# The test environment is used exclusively to run your application's
|
5
|
-
# test suite. You never need to work with it otherwise. Remember that
|
6
|
-
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs. Don't rely on the data there!
|
8
|
-
config.cache_classes = true
|
9
|
-
|
10
|
-
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
-
# just for the purpose of running a single test. If you are using a tool that
|
12
|
-
# preloads Rails for running tests, you may have to set it to true.
|
13
|
-
config.eager_load = false
|
14
|
-
|
15
|
-
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
# config.serve_static_assets = true
|
17
|
-
# config.static_cache_control = "public, max-age=3600"
|
18
|
-
|
19
|
-
# Show full error reports and disable caching.
|
20
|
-
config.consider_all_requests_local = true
|
21
|
-
config.action_controller.perform_caching = false
|
22
|
-
|
23
|
-
# Raise exceptions instead of rendering exception templates.
|
24
|
-
config.action_dispatch.show_exceptions = false
|
25
|
-
|
26
|
-
# Disable request forgery protection in test environment.
|
27
|
-
config.action_controller.allow_forgery_protection = false
|
28
|
-
|
29
|
-
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
-
# The :test delivery method accumulates sent emails in the
|
31
|
-
# ActionMailer::Base.deliveries array.
|
32
|
-
# config.action_mailer.delivery_method = :test
|
33
|
-
|
34
|
-
# Print deprecation notices to the stderr.
|
35
|
-
config.active_support.deprecation = :stderr
|
36
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
-
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
-
|
6
|
-
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
-
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Add new inflection rules using the following format. Inflections
|
4
|
-
# are locale specific, and you may define rules for as many different
|
5
|
-
# locales as you wish. All of these examples are active by default:
|
6
|
-
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
-
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
-
# inflect.singular /^(ox)en/i, '\1'
|
9
|
-
# inflect.irregular 'person', 'people'
|
10
|
-
# inflect.uncountable %w( fish sheep )
|
11
|
-
# end
|
12
|
-
|
13
|
-
# These inflection rules are supported but not enabled by default:
|
14
|
-
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
-
# inflect.acronym 'RESTful'
|
16
|
-
# end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
-
# If you change this key, all old signed cookies will become invalid!
|
5
|
-
|
6
|
-
# Make sure the secret is at least 30 characters and all random,
|
7
|
-
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
-
# You can use `rake secret` to generate a secure secret key.
|
9
|
-
|
10
|
-
# Make sure your secret_key_base is kept private
|
11
|
-
# if you're sharing your code publicly.
|
12
|
-
Dummy::Application.config.secret_key_base = 'e129c9275846133eeee8830dc4e1191e0010305fdd8c3d02f4b628a161d93d9765aa8f96436bafc3c227ec6f8166b6ff1c9ea34a4d58f07a20a8bb23b9862537'
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
-
# is enabled by default.
|
5
|
-
|
6
|
-
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
-
ActiveSupport.on_load(:action_controller) do
|
8
|
-
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
-
end
|
10
|
-
|
11
|
-
# To enable root element in JSON for ActiveRecord objects.
|
12
|
-
# ActiveSupport.on_load(:active_record) do
|
13
|
-
# self.include_root_in_json = true
|
14
|
-
# end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Files in the config/locales directory are used for internationalization
|
2
|
-
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
-
# than English, add the necessary files in this directory.
|
4
|
-
#
|
5
|
-
# To use the locales, use `I18n.t`:
|
6
|
-
#
|
7
|
-
# I18n.t 'hello'
|
8
|
-
#
|
9
|
-
# In views, this is aliased to just `t`:
|
10
|
-
#
|
11
|
-
# <%= t('hello') %>
|
12
|
-
#
|
13
|
-
# To use a different locale, set it with `I18n.locale`:
|
14
|
-
#
|
15
|
-
# I18n.locale = :es
|
16
|
-
#
|
17
|
-
# This would use the information in config/locales/es.yml.
|
18
|
-
#
|
19
|
-
# To learn more, please read the Rails Internationalization guide
|
20
|
-
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
-
|
22
|
-
en:
|
23
|
-
hello: "Hello world"
|
data/spec/dummy/config/routes.rb
DELETED
data/spec/dummy/db/schema.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# This file is auto-generated from the current state of the database. Instead
|
3
|
-
# of editing this file, please use the migrations feature of Active Record to
|
4
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
-
#
|
6
|
-
# Note that this schema.rb definition is the authoritative source for your
|
7
|
-
# database schema. If you need to create the application database on another
|
8
|
-
# system, you should be using db:schema:load, not running all the migrations
|
9
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
-
#
|
12
|
-
# It's strongly recommended that you check this file into your version control system.
|