grape-apiary 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/.travis.yml +6 -4
- data/CHANGELOG.md +15 -2
- data/README.md +2 -2
- data/grape-apiary.gemspec +1 -1
- data/lib/grape-apiary/blueprint.rb +1 -1
- data/lib/grape-apiary/parameter.rb +1 -1
- data/lib/grape-apiary/resource.rb +5 -5
- data/lib/grape-apiary/route.rb +14 -14
- data/lib/grape-apiary/templates/blueprint.md.erb +3 -3
- data/lib/grape-apiary/version.rb +1 -1
- data/spec/grape-apiary/resource_spec.rb +1 -1
- data/spec/grape-apiary/route_spec.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2c1b3556b4fefbfcfbb7ea54fee65c68b37f64e
|
4
|
+
data.tar.gz: 1707ad4ad0b7bab8b79b702e934744a697033459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2681493022439dd8bddacaa3ac6e5cd7528fa8022eae5edbc91d1a25f54006037713fc9c71eeb38053fd4adbe4581318dc1122d5d53bc71d612d6f72972c8ad
|
7
|
+
data.tar.gz: 5a34bc8a197ff3a124bf4ec4623a19e796928548cc304e1ff2f5e238edf3a4f6fa3ce0e719f35d02faddc144434ec96d9fa153ad505174585cce347e035537f8
|
data/.rubocop.yml
CHANGED
@@ -37,7 +37,7 @@ Style/ElseAlignment:
|
|
37
37
|
Enabled: false
|
38
38
|
|
39
39
|
Lint/EndAlignment:
|
40
|
-
|
40
|
+
EnforcedStyleAlignWith: variable
|
41
41
|
|
42
42
|
ClassAndModuleChildren:
|
43
43
|
# ok to use compact style when modules are predefined.
|
@@ -46,3 +46,9 @@ ClassAndModuleChildren:
|
|
46
46
|
#
|
47
47
|
# class Foo::Bar; end
|
48
48
|
Enabled: false
|
49
|
+
|
50
|
+
Metrics/BlockLength:
|
51
|
+
# Certain DSL use blocks and can be lengthy
|
52
|
+
Exclude:
|
53
|
+
- 'grape-apiary.gemspec'
|
54
|
+
- 'spec/**/*'
|
data/.travis.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem update --system
|
2
4
|
cache: bundler
|
3
5
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- jruby
|
6
|
+
- 2.4.0
|
7
|
+
- 2.3.3
|
8
|
+
- 2.2.6
|
9
|
+
- jruby-9.1.2.0
|
8
10
|
env:
|
9
11
|
- CODECLIMATE_REPO_TOKEN=7522ea83858a08d70747c1f5fb0593502ca0e43c18b6a124dbeb72a0b0e78262
|
data/CHANGELOG.md
CHANGED
@@ -2,16 +2,29 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
-
##
|
5
|
+
## Recent updates
|
6
|
+
|
7
|
+
## 0.2.0 (2017-02-21)
|
8
|
+
|
9
|
+
#### Maintenance
|
10
|
+
|
11
|
+
- [PR #14](https://github.com/technekes/grape-apiary/pull/14) - Update supported Ruby versions and dependencies [@jallen3d](https://github.com/johnallen3d).
|
12
|
+
- [PR #13](https://github.com/technekes/grape-apiary/pull/13) - Update grape gem requirement to at least 0.16 [@rubensmabueno](https://github.com/rubensmabueno).
|
13
|
+
|
14
|
+
## 0.1.2 (2016-01-25)
|
15
|
+
|
6
16
|
#### Hotfix
|
17
|
+
|
7
18
|
- Lock down grape dependency to prior to 0.16 because of internal change [@jallen3d](https://github.com/johnallen3d).
|
8
19
|
|
9
|
-
## 0.1.1 (2016-01-25)
|
10
20
|
#### Fixes
|
21
|
+
|
11
22
|
- [PR #8](https://github.com/technekes/grape-apiary/pull/8) - Handle mixed keys (symbol/string) in params [@jallen3d](https://github.com/johnallen3d).
|
12
23
|
|
13
24
|
## 0.1.0 (2016-01-25)
|
25
|
+
|
14
26
|
#### Features
|
27
|
+
|
15
28
|
- [PR #5](https://github.com/technekes/grape-apiary/pull/5) - Rake task persists docs to disk from [@bigfleet](https://github.com/bigfleet).
|
16
29
|
|
17
30
|
## 0.0.1 - 0.0.4 (2014-02-10)
|
data/README.md
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/technekes/grape-apiary/badges/gpa.svg)](https://codeclimate.com/github/technekes/grape-apiary)
|
4
4
|
[![Build Status](https://travis-ci.org/technekes/grape-apiary.svg?branch=master)](https://travis-ci.org/technekes/grape-apiary)
|
5
5
|
[![Test Coverage](https://codeclimate.com/github/technekes/grape-apiary/badges/coverage.svg)](https://codeclimate.com/github/technekes/grape-apiary/coverage)
|
6
|
-
[![Dependency Status](https://gemnasium.com/technekes/grape-apiary.png)](https://gemnasium.com/
|
6
|
+
[![Dependency Status](https://gemnasium.com/technekes/grape-apiary.png)](https://gemnasium.com/technekes/grape-apiary)
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/grape-apiary.png)](http://badge.fury.io/rb/grape-apiary)
|
8
8
|
|
9
|
-
Auto generates an [Apiary Blueprint](http://apiary.io) from the
|
9
|
+
Auto generates an [Apiary Blueprint](http://apiary.io) from the documentation that is created by your [Grape](https://github.com/ruby-grape/grape) API.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
data/grape-apiary.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
docuementation that is created by your Grape API
|
26
26
|
DESCRIPTION
|
27
27
|
|
28
|
-
spec.add_runtime_dependency 'grape', '>= 0.
|
28
|
+
spec.add_runtime_dependency 'grape', '>= 0.16.0', '<= 0.19.1'
|
29
29
|
spec.add_runtime_dependency 'activesupport'
|
30
30
|
|
31
31
|
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
@@ -2,7 +2,7 @@ module GrapeApiary
|
|
2
2
|
class Parameter
|
3
3
|
attr_reader :route, :full_name, :name, :settings
|
4
4
|
|
5
|
-
delegate :route_model, :
|
5
|
+
delegate :route_model, :namespace, to: :route
|
6
6
|
delegate :requirement, :type, :documentation, :desc, to: :settings
|
7
7
|
delegate :example, to: :documentation, allow_nil: true
|
8
8
|
|
@@ -14,13 +14,13 @@ module GrapeApiary
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def namespaced
|
17
|
-
@namespaced ||= routes.group_by(&:
|
17
|
+
@namespaced ||= routes.group_by(&:namespace).map do |_, routes|
|
18
18
|
Resource.new(name, routes)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def paths
|
23
|
-
@paths ||= routes.group_by(&:
|
23
|
+
@paths ||= routes.group_by(&:path_without_format).map do |_, routes|
|
24
24
|
Resource.new(name, routes)
|
25
25
|
end
|
26
26
|
end
|
@@ -29,7 +29,7 @@ module GrapeApiary
|
|
29
29
|
# TODO: ???
|
30
30
|
route = routes.first
|
31
31
|
|
32
|
-
"#{title} #{route.route_type} [#{route.
|
32
|
+
"#{title} #{route.route_type} [#{route.path_without_format}]"
|
33
33
|
end
|
34
34
|
|
35
35
|
def sample_request
|
@@ -46,11 +46,11 @@ module GrapeApiary
|
|
46
46
|
methods = %w(POST PUT)
|
47
47
|
|
48
48
|
potential = routes.select do |route|
|
49
|
-
methods.include?(route.
|
49
|
+
methods.include?(route.request_method) && route.params.present?
|
50
50
|
end
|
51
51
|
|
52
52
|
if potential.present?
|
53
|
-
potential.first.
|
53
|
+
potential.first.params
|
54
54
|
else
|
55
55
|
[]
|
56
56
|
end
|
data/lib/grape-apiary/route.rb
CHANGED
@@ -2,31 +2,31 @@ module GrapeApiary
|
|
2
2
|
class Route < SimpleDelegator
|
3
3
|
# would like to rely on SimpleDelegator but Grape::Route uses
|
4
4
|
# method_missing for these methods :'(
|
5
|
-
delegate :
|
5
|
+
delegate :namespace, :path, :request_method, to: '__getobj__'
|
6
6
|
|
7
|
-
def
|
8
|
-
@
|
9
|
-
__getobj__.
|
7
|
+
def params
|
8
|
+
@params ||= begin
|
9
|
+
__getobj__.params.stringify_keys.sort.map do |param|
|
10
10
|
Parameter.new(self, *param)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def route_name
|
16
|
-
|
17
|
-
|
16
|
+
namespace.split('/').last ||
|
17
|
+
path.match('\/(\w*?)[\.\/\(]').captures.first
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
"#{__getobj__.
|
20
|
+
def description
|
21
|
+
"#{__getobj__.description} [#{request_method.upcase}]"
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
24
|
+
def path_without_format
|
25
|
+
path.gsub(/\((.*?)\)/, '')
|
26
26
|
end
|
27
27
|
|
28
28
|
def route_model
|
29
|
-
|
29
|
+
namespace.split('/').last.singularize
|
30
30
|
end
|
31
31
|
|
32
32
|
def route_type
|
@@ -38,19 +38,19 @@ module GrapeApiary
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def response_description
|
41
|
-
code =
|
41
|
+
code = request_method == 'POST' ? 201 : 200
|
42
42
|
|
43
43
|
"+ Response #{code} (application/json)"
|
44
44
|
end
|
45
45
|
|
46
46
|
def list?
|
47
|
-
%w(GET POST).include?(
|
47
|
+
%w(GET POST).include?(request_method) && !path.include?(':id')
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def request_body?
|
53
|
-
!%w(GET DELETE).include?(
|
53
|
+
!%w(GET DELETE).include?(request_method)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -11,14 +11,14 @@ HOST: <%= host %>
|
|
11
11
|
<% grouped_resource.paths.each do |resource_by_path| %>
|
12
12
|
## <%= resource_by_path.header %>
|
13
13
|
Actions on the <%= resource.name %> resource
|
14
|
-
<% if resource_by_path.routes.first.
|
14
|
+
<% if resource_by_path.routes.first.params.present? %>
|
15
15
|
+ Parameters
|
16
|
-
<% resource_by_path.routes.first.
|
16
|
+
<% resource_by_path.routes.first.params.each do |param| %>
|
17
17
|
+ <%= param.description %>
|
18
18
|
<% end %>
|
19
19
|
<% end %>
|
20
20
|
<% resource_by_path.routes.each do |route| %>
|
21
|
-
### <%= route.
|
21
|
+
### <%= route.description %>
|
22
22
|
<% if show_request_sample?(route) %>
|
23
23
|
<%= route.request_description %>
|
24
24
|
<%= formatted_request_headers %>
|
data/lib/grape-apiary/version.rb
CHANGED
@@ -15,7 +15,7 @@ describe GrapeApiary::Resource do
|
|
15
15
|
it 'response generation is delegated to a generator' do
|
16
16
|
expect(subject.sample_generator).to receive(:response)
|
17
17
|
|
18
|
-
subject.sample_response(GrapeApiary::Route.new(
|
18
|
+
subject.sample_response(GrapeApiary::Route.new(SampleApi.routes.first))
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-apiary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "
|
19
|
+
version: 0.16.0
|
20
|
+
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 0.19.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "
|
29
|
+
version: 0.16.0
|
30
|
+
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 0.19.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
238
|
version: '0'
|
239
239
|
requirements: []
|
240
240
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.6.
|
241
|
+
rubygems_version: 2.6.8
|
242
242
|
signing_key:
|
243
243
|
specification_version: 4
|
244
244
|
summary: Allows for generating an Apiary Blueprint for you Grape API
|