api_helper 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c365d5a68f094eb8d390ae7b126f47ea8bc48c70
4
- data.tar.gz: a450ec9db2270080b79d61a7d1d50af88be9ff10
3
+ metadata.gz: 1895625d870d6629c579f3f165f1f37090dc4d12
4
+ data.tar.gz: b1fc9a045cebe92869ff7a4f666b3e813c5c7bb0
5
5
  SHA512:
6
- metadata.gz: 04ea4c190caf03cb2eba99fb542d59ce56052d1b77cb0f5335428f617a097181530e4a0ec5207d777b114b12b8ccea7ebf5ab173cd055b68c88a4b1c54f93a70
7
- data.tar.gz: 7e0bb35d2464dc17ca87d4e81857e8310d33146c917a94f8df0b05808ef2423e7f80f00f3b3793e0558ea22197821e6646aa32b5ea68246e8a50e97a505d2f08
6
+ metadata.gz: c908f21b13a0f04dc0531cfe8fe97d2fd93182d1c119139caeb56387f6c905e4d516c40668ad5a1f2ba1ff05d580faa389eb1afa12a16774110136ef3b7478ac
7
+ data.tar.gz: 8800b5d99bd5e252474bdefb57792e6274eba29819da938c8931dde286e4ecea7a0fcd618c6af44f6f9ca60f658ea7f356fb6d8a38d27a26713491e188b30821
data/.travis.yml CHANGED
@@ -5,6 +5,7 @@ rvm:
5
5
  gemfile:
6
6
  - gemfiles/rails_4.1.0.gemfile
7
7
  - gemfiles/rails_4.2.0.gemfile
8
+ - gemfiles/rails_5.0.0.gemfile
8
9
  - gemfiles/grape_0.10.0.gemfile
9
10
  - gemfiles/grape_0.11.0.gemfile
10
11
  before_install: gem install bundler -v 1.10.2
data/Appraisals CHANGED
@@ -10,6 +10,12 @@ appraise 'rails-4.2.0' do
10
10
  gem 'rspec-rails'
11
11
  end
12
12
 
13
+ appraise 'rails-5.0.0' do
14
+ gemspec
15
+ gem 'rails', '5.0.0.beta2'
16
+ gem 'rspec-rails'
17
+ end
18
+
13
19
  appraise 'grape-0.10.0' do
14
20
  gemspec
15
21
  gem 'grape', '0.10.0'
data/README.md CHANGED
@@ -1,48 +1,44 @@
1
- # APIHelper [![Gem Version](https://badge.fury.io/rb/api_helper.svg)](http://badge.fury.io/rb/api_helper) [![Build Status](https://travis-ci.org/Neson/api_helper.svg?branch=master)](https://travis-ci.org/Neson/api_helper) [![Docs Status](https://inch-ci.org/github/Neson/api_helper.svg?branch=master)](https://inch-ci.org/github/Neson/api_helper)
1
+ # APIHelper [![Gem Version](https://badge.fury.io/rb/api_helper.svg)](http://badge.fury.io/rb/api_helper) [![Build Status](https://travis-ci.org/Neson/api_helper.svg?branch=master)](https://travis-ci.org/Neson/api_helper) [![Coverage Status](https://coveralls.io/repos/Neson/api_helper/badge.svg?branch=master)](https://coveralls.io/r/Neson/api_helper?branch=master) [![Docs Status](https://inch-ci.org/github/Neson/api_helper.svg?branch=master)](https://inch-ci.org/github/Neson/api_helper)
2
2
 
3
3
  Helpers for creating standard RESTful API for Rails or Grape with Active Record.
4
4
 
5
5
 
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
9
-
10
- ```ruby
11
- gem 'api_helper'
12
- ```
6
+ ## API Standards
13
7
 
14
- And then execute:
8
+ <dl>
15
9
 
16
- $ bundle
10
+ <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Fieldsettable">Fieldsettable</a></dt>
11
+ <dd>Let clients choose the fields they wanted to be returned with the <code>fields</code> query parameter, making their API calls optimizable to gain efficiency and speed.</dd>
17
12
 
18
- Or install it yourself as:
13
+ <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Includable">Includable</a></dt>
14
+ <dd>Clients can use the <code>include</code> query parameter to enable inclusion of related items - for instance, get the author's data along with a post.</dd>
19
15
 
20
- $ gem install api_helper
16
+ <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Paginatable">Paginatable</a></dt>
17
+ <dd>Paginate the results of a resource collection, client can get a specific page with the <code>page</code> query parameter and set a custom page size with the "per_page" query parameter.</dd>
21
18
 
19
+ <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Sortable">Sortable</a></dt>
20
+ <dd>Client can set custom sorting with the <code>sort</code> query parameter while getting a resource collection.</dd>
22
21
 
23
- ## API Standards
22
+ <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Filterable">Filterable</a></dt>
23
+ <dd>Enables clients to filter through a resource collection with their fields with the <code>filter</code> query parameter.</dd>
24
24
 
25
- <dl>
25
+ <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Multigettable">Multigettable</a></dt>
26
+ <dd>Let Client execute operations on multiple resources with a single request.</dd>
26
27
 
27
- <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Fieldsettable" target="_blank">Fieldsettable</a></dt>
28
- <dd>Let clients choose the fields they wanted to be returned with the "fields" query parameter, making their API calls optimizable to gain efficiency and speed.</dd>
28
+ </dl>
29
29
 
30
- <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Includable" target="_blank">Includable</a></dt>
31
- <dd>Clients can use the "include" query parameter to enable inclusion of related items - for instance, get the author's data along with a post.</dd>
32
30
 
33
- <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Paginatable" target="_blank">Paginatable</a></dt>
34
- <dd>Paginate the results of a resource collection, client can get a specific page with the "page" query parameter and set a custom page size with the "per_page" query parameter.</dd>
31
+ ## Installation
35
32
 
36
- <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Sortable" target="_blank">Sortable</a></dt>
37
- <dd>Client can set custom sorting with the "sort" query parameter while getting a resource collection.</dd>
33
+ Add this line to your application's Gemfile:
38
34
 
39
- <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Filterable" target="_blank">Filterable</a></dt>
40
- <dd>Enables clients to filter through a resource collection with their fields.</dd>
35
+ ```ruby
36
+ gem 'api_helper'
37
+ ```
41
38
 
42
- <dt><a href="http://www.rubydoc.info/github/Neson/api_helper/master/APIHelper/Multigettable" target="_blank">Multigettable</a></dt>
43
- <dd>Let Client execute operations on multiple resources with a single request.</dd>
39
+ And then execute:
44
40
 
45
- </dl>
41
+ $ bundle
46
42
 
47
43
 
48
44
  ## Usage
data/bin/setup CHANGED
@@ -3,5 +3,6 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
5
  bundle install
6
+ appraisal install
6
7
 
7
8
  # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "5.0.0.beta2"
6
+ gem "rspec-rails"
7
+
8
+ gemspec :path => "../"
@@ -169,7 +169,8 @@ module APIHelper::Fieldsettable
169
169
  @fieldset ||= ActiveSupport::HashWithIndifferentAccess.new
170
170
 
171
171
  # put the fields in place
172
- if params[:fields].is_a?(Hash)
172
+ if params[:fields].is_a?(Hash) ||
173
+ defined?(Rails) && Rails.version.to_i >= 5 && params[:fields].is_a?(ActionController::Parameters)
173
174
  # get the specific resource fields from fields hash
174
175
  @fieldset[resource] = params[:fields][resource] || params[:fields][resource]
175
176
  elsif default
@@ -73,7 +73,8 @@ module APIHelper::Filterable
73
73
  #
74
74
  def filter(resource, filterable_fields: [])
75
75
  # parse the request parameter
76
- if params[:filter].is_a?(Hash)
76
+ if params[:filter].is_a?(Hash) ||
77
+ defined?(Rails) && Rails.version.to_i >= 5 && params[:filter].is_a?(ActionController::Parameters)
77
78
  @filter = params[:filter]
78
79
  filterable_fields = filterable_fields.map(&:to_s)
79
80
 
@@ -192,7 +192,8 @@ module APIHelper::Includable
192
192
  @inclusion_specified ||= ActiveSupport::HashWithIndifferentAccess.new
193
193
 
194
194
  # put the fields in place
195
- if params[:include].is_a?(Hash)
195
+ if params[:include].is_a?(Hash) ||
196
+ defined?(Rails) && Rails.version.to_i >= 5 && params[:include].is_a?(ActionController::Parameters)
196
197
  # get the specific resource inclusion fields from the "include" hash
197
198
  @inclusion[resource] = params[:include][resource]
198
199
  @inclusion_specified[resource] = true if params[:include][resource].present?
@@ -1,3 +1,3 @@
1
1
  module APIHelper
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-15 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,6 +174,7 @@ files:
174
174
  - gemfiles/rails_4.1.0.gemfile
175
175
  - gemfiles/rails_4.1.8.gemfile
176
176
  - gemfiles/rails_4.2.0.gemfile
177
+ - gemfiles/rails_5.0.0.gemfile
177
178
  - lib/api_helper.rb
178
179
  - lib/api_helper/fieldsettable.rb
179
180
  - lib/api_helper/filterable.rb
@@ -201,9 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  version: '0'
202
203
  requirements: []
203
204
  rubyforge_project:
204
- rubygems_version: 2.4.6
205
+ rubygems_version: 2.5.1
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: Helpers for creating standard web API.
208
209
  test_files: []
209
- has_rdoc: