fetcheable_on_api 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fetcheable_on_api.rb +16 -0
- data/lib/fetcheable_on_api/configuration.rb +11 -0
- data/lib/fetcheable_on_api/pagineable.rb +5 -1
- data/lib/fetcheable_on_api/version.rb +1 -1
- data/lib/generators/fetcheable_on_api/install_generator.rb +12 -0
- data/lib/generators/templates/fetcheable_on_api_initializer.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5da599e1695d12e998a218d88038c4999f8e063a
|
4
|
+
data.tar.gz: 97677585e0c3b456f220326dd78ac708492af438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4cf30622b1a5a2d8e815e3611ec27091e299540d519233166705b91049986c81ae35dc18e68bfe61068f6693a551b22c3247c4629842f6795891e7a565f0a8b
|
7
|
+
data.tar.gz: fa4048332338e34a424d1f540d2798d789894ec7ca2fb5f95f81205dec8d174900b19cb769ab845aa402fe81eddc7b136d9fec6f8e9683d3f74f24e66132d6ff
|
data/lib/fetcheable_on_api.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fetcheable_on_api/configuration'
|
3
4
|
require 'fetcheable_on_api/filtreable'
|
4
5
|
require 'fetcheable_on_api/pagineable'
|
5
6
|
require 'fetcheable_on_api/sortable'
|
@@ -7,6 +8,21 @@ require 'fetcheable_on_api/version'
|
|
7
8
|
require 'active_support'
|
8
9
|
|
9
10
|
module FetcheableOnApi
|
11
|
+
#
|
12
|
+
# Configuration
|
13
|
+
#
|
14
|
+
class << self
|
15
|
+
attr_accessor :configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configuration
|
19
|
+
@configuration ||= Configuration.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.configure
|
23
|
+
yield(configuration)
|
24
|
+
end
|
25
|
+
|
10
26
|
#
|
11
27
|
# Supports
|
12
28
|
#
|
@@ -22,7 +22,11 @@ module FetcheableOnApi
|
|
22
22
|
def apply_pagination(collection)
|
23
23
|
return collection if params[:page].blank?
|
24
24
|
|
25
|
-
limit
|
25
|
+
limit = params[:page].fetch(
|
26
|
+
:size,
|
27
|
+
FetcheableOnApi.configuration.pagination_default_size
|
28
|
+
).to_i
|
29
|
+
|
26
30
|
offset = (params[:page].fetch(:number, 1).to_i - 1) * limit
|
27
31
|
|
28
32
|
collection.limit(limit).offset(offset)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module FetcheableOnApi
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../../templates", __FILE__)
|
5
|
+
desc "Creates FetcheableOnApi initializer for your application"
|
6
|
+
|
7
|
+
def copy_initializer
|
8
|
+
template "fetcheable_on_api_initializer.rb", "config/initializers/fetcheable_on_api.rb"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fetcheable_on_api
|
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
|
- Fabien
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,10 +94,13 @@ files:
|
|
94
94
|
- README.md
|
95
95
|
- Rakefile
|
96
96
|
- lib/fetcheable_on_api.rb
|
97
|
+
- lib/fetcheable_on_api/configuration.rb
|
97
98
|
- lib/fetcheable_on_api/filtreable.rb
|
98
99
|
- lib/fetcheable_on_api/pagineable.rb
|
99
100
|
- lib/fetcheable_on_api/sortable.rb
|
100
101
|
- lib/fetcheable_on_api/version.rb
|
102
|
+
- lib/generators/fetcheable_on_api/install_generator.rb
|
103
|
+
- lib/generators/templates/fetcheable_on_api_initializer.rb
|
101
104
|
homepage: https://github.com/FabienPiette/fetcheable_on_api.git
|
102
105
|
licenses:
|
103
106
|
- MIT
|