-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from bsm/feature/up-to-date
Preparations for v0.2.0
- Loading branch information
Showing
15 changed files
with
245 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
AllCops: | ||
TargetRubyVersion: "2.5" | ||
NewCops: enable | ||
|
||
Metrics/AbcSize: | ||
Enabled: false | ||
Metrics/BlockLength: | ||
Exclude: | ||
- spec/**/*_spec.rb | ||
Metrics/MethodLength: | ||
Max: 20 | ||
|
||
Naming/FileName: | ||
Exclude: | ||
- lib/grape-kaminari.rb | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
Style/TrailingCommaInArguments: | ||
EnforcedStyleForMultiline: consistent_comma | ||
Style/TrailingCommaInArrayLiteral: | ||
EnforcedStyleForMultiline: consistent_comma | ||
Style/TrailingCommaInHashLiteral: | ||
EnforcedStyleForMultiline: consistent_comma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: ruby | ||
cache: bundler | ||
rvm: | ||
- 2.7 | ||
- 2.6 | ||
- 2.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
grape-kaminari (0.2.0) | ||
grape (>= 1.0) | ||
kaminari-grape | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
activesupport (6.0.3.2) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 0.7, < 2) | ||
minitest (~> 5.1) | ||
tzinfo (~> 1.1) | ||
zeitwerk (~> 2.2, >= 2.2.2) | ||
ast (2.4.1) | ||
builder (3.2.4) | ||
concurrent-ruby (1.1.6) | ||
diff-lcs (1.3) | ||
dry-configurable (0.11.5) | ||
concurrent-ruby (~> 1.0) | ||
dry-core (~> 0.4, >= 0.4.7) | ||
dry-equalizer (~> 0.2) | ||
dry-container (0.7.2) | ||
concurrent-ruby (~> 1.0) | ||
dry-configurable (~> 0.1, >= 0.1.3) | ||
dry-core (0.4.9) | ||
concurrent-ruby (~> 1.0) | ||
dry-equalizer (0.3.0) | ||
dry-inflector (0.2.0) | ||
dry-logic (1.0.6) | ||
concurrent-ruby (~> 1.0) | ||
dry-core (~> 0.2) | ||
dry-equalizer (~> 0.2) | ||
dry-types (1.4.0) | ||
concurrent-ruby (~> 1.0) | ||
dry-container (~> 0.3) | ||
dry-core (~> 0.4, >= 0.4.4) | ||
dry-equalizer (~> 0.3) | ||
dry-inflector (~> 0.1, >= 0.1.2) | ||
dry-logic (~> 1.0, >= 1.0.2) | ||
grape (1.3.3) | ||
activesupport | ||
builder | ||
dry-types (>= 1.1) | ||
mustermann-grape (~> 1.0.0) | ||
rack (>= 1.3.0) | ||
rack-accept | ||
i18n (1.8.3) | ||
concurrent-ruby (~> 1.0) | ||
kaminari-core (1.2.1) | ||
kaminari-grape (1.0.1) | ||
grape | ||
kaminari-core (~> 1.0) | ||
minitest (5.14.1) | ||
mustermann (1.1.1) | ||
ruby2_keywords (~> 0.0.1) | ||
mustermann-grape (1.0.1) | ||
mustermann (>= 1.0.0) | ||
parallel (1.19.2) | ||
parser (2.7.1.3) | ||
ast (~> 2.4.0) | ||
rack (2.2.3) | ||
rack-accept (0.4.5) | ||
rack (>= 0.4) | ||
rack-test (1.1.0) | ||
rack (>= 1.0, < 3) | ||
rainbow (3.0.0) | ||
rake (13.0.1) | ||
regexp_parser (1.7.1) | ||
rexml (3.2.4) | ||
rspec (3.9.0) | ||
rspec-core (~> 3.9.0) | ||
rspec-expectations (~> 3.9.0) | ||
rspec-mocks (~> 3.9.0) | ||
rspec-core (3.9.2) | ||
rspec-support (~> 3.9.3) | ||
rspec-expectations (3.9.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.9.0) | ||
rspec-mocks (3.9.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.9.0) | ||
rspec-support (3.9.3) | ||
rubocop (0.85.1) | ||
parallel (~> 1.10) | ||
parser (>= 2.7.0.1) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 1.7) | ||
rexml | ||
rubocop-ast (>= 0.0.3) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 1.4.0, < 2.0) | ||
rubocop-ast (0.0.3) | ||
parser (>= 2.7.0.1) | ||
ruby-progressbar (1.10.1) | ||
ruby2_keywords (0.0.2) | ||
thread_safe (0.3.6) | ||
tzinfo (1.2.7) | ||
thread_safe (~> 0.1) | ||
unicode-display_width (1.7.0) | ||
zeitwerk (2.3.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler | ||
grape-kaminari! | ||
rack-test | ||
rake | ||
rspec | ||
rubocop | ||
|
||
BUNDLED WITH | ||
2.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
require "bundler/gem_tasks" | ||
|
||
task default: :spec | ||
require 'bundler/gem_tasks' | ||
require 'rubocop/rake_task' | ||
require 'rspec/core/rake_task' | ||
|
||
RuboCop::RakeTask.new | ||
RSpec::Core::RakeTask.new | ||
|
||
task default: %i[rubocop spec] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
lib = File.expand_path('lib', __dir__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'grape/kaminari/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "grape-kaminari" | ||
spec.name = 'grape-kaminari' | ||
spec.version = Grape::Kaminari::VERSION | ||
spec.authors = ["Tymon Tobolski"] | ||
spec.email = ["tymon.tobolski@monterail.com"] | ||
spec.description = %q{kaminari paginator integration for grape API framework} | ||
spec.summary = %q{kaminari integration for grape} | ||
spec.homepage = "" | ||
spec.license = "MIT" | ||
spec.authors = ['Tymon Tobolski', 'Black Square Media'] | ||
spec.email = ['info@blacksquaremedia.com'] | ||
spec.description = 'kaminari paginator integration for grape API framework' | ||
spec.summary = 'kaminari integration for grape' | ||
spec.homepage = '' | ||
spec.license = 'MIT' | ||
|
||
spec.files = `git ls-files`.split($/) | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?('spec/') } | ||
spec.test_files = `git ls-files -z -- spec/*`.split("\x0") | ||
spec.require_paths = ['lib'] | ||
spec.required_ruby_version = '>= 2.5' | ||
|
||
spec.add_runtime_dependency 'grape', '>= 1.0' | ||
spec.add_runtime_dependency 'kaminari-grape' | ||
|
||
spec.add_runtime_dependency "grape" | ||
spec.add_runtime_dependency "kaminari" | ||
|
||
spec.add_development_dependency "bundler", "~> 1.3" | ||
spec.add_development_dependency "rake" | ||
spec.add_development_dependency 'rspec', '~> 2.9' | ||
spec.add_development_dependency 'bundler' | ||
spec.add_development_dependency 'rack-test' | ||
spec.add_development_dependency 'rake' | ||
spec.add_development_dependency 'rspec' | ||
spec.add_development_dependency 'rubocop' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1 @@ | ||
module Grape | ||
module Kaminari | ||
class << self | ||
def post_0_9_0_grape? | ||
Gem::Version.new(Grape::VERSION) > Gem::Version.new('0.9.0') | ||
end | ||
end | ||
end | ||
end | ||
|
||
require "grape/kaminari" | ||
require 'grape/kaminari' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,51 @@ | ||
require "grape" | ||
require "grape/kaminari/version" | ||
require "grape/kaminari/max_value_validator" | ||
require "kaminari/grape" | ||
require 'grape' | ||
require 'grape/kaminari/version' | ||
require 'grape/kaminari/max_value_validator' | ||
require 'kaminari/grape' | ||
|
||
module Grape | ||
module Kaminari | ||
def self.included(base) | ||
base.class_eval do | ||
helpers do | ||
def paginate(collection) | ||
collection.page(params[:page].to_i).per(params[:per_page].to_i).padding(params[:offset].to_i).tap do |data| | ||
header "X-Total", data.total_count.to_s | ||
header "X-Total-Pages", data.total_pages.to_s | ||
header "X-Per-Page", data.limit_value.to_s | ||
header "X-Page", data.current_page.to_s | ||
header "X-Next-Page", data.next_page.to_s | ||
header "X-Prev-Page", data.prev_page.to_s | ||
header "X-Offset", params[:offset].to_s | ||
end | ||
end | ||
module HelperMethods # :nodoc: | ||
def paginate(collection) | ||
collection.page(params[:page].to_i) | ||
.per(params[:per_page].to_i) | ||
.padding(params[:offset].to_i) | ||
.tap do |data| | ||
header 'X-Total', data.total_count.to_s | ||
header 'X-Total-Pages', data.total_pages.to_s | ||
header 'X-Per-Page', data.limit_value.to_s | ||
header 'X-Page', data.current_page.to_s | ||
header 'X-Next-Page', data.next_page.to_s | ||
header 'X-Prev-Page', data.prev_page.to_s | ||
header 'X-Offset', params[:offset].to_s | ||
end | ||
end | ||
end | ||
|
||
def self.paginate(options = {}) | ||
options.reverse_merge!( | ||
per_page: ::Kaminari.config.default_per_page || 10, | ||
max_per_page: ::Kaminari.config.max_per_page, | ||
offset: 0 | ||
) | ||
params do | ||
optional :page, type: Integer, default: 1, | ||
desc: 'Page offset to fetch.' | ||
optional :per_page, type: Integer, default: options[:per_page], | ||
desc: 'Number of results to return per page.', | ||
max_value: options[:max_per_page] | ||
if options[:offset].is_a? Numeric | ||
optional :offset, type: Integer, default: options[:offset], | ||
desc: 'Pad a number of results.' | ||
end | ||
module ClassMethods # :nodoc: | ||
def paginate(**options) | ||
options.reverse_merge!( | ||
per_page: ::Kaminari.config.default_per_page || 10, | ||
max_per_page: ::Kaminari.config.max_per_page, | ||
offset: 0, | ||
) | ||
params do | ||
optional :page, type: Integer, default: 1, | ||
desc: 'Page offset to fetch.' | ||
optional :per_page, type: Integer, default: options[:per_page], | ||
desc: 'Number of results to return per page.', | ||
max_value: options[:max_per_page] | ||
if options[:offset].is_a? Numeric | ||
optional :offset, type: Integer, default: options[:offset], | ||
desc: 'Pad a number of results.' | ||
end | ||
end | ||
end | ||
end | ||
|
||
def self.included(base) | ||
base.helpers HelperMethods | ||
base.extend ClassMethods | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Grape | ||
module Kaminari | ||
VERSION = "0.1.9" | ||
VERSION = '0.2.0'.freeze | ||
end | ||
end |
Oops, something went wrong.