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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c535957d744ce50ef0823e96f87088da6bdb8af
4
- data.tar.gz: 2f22cc9d1d0cab9c76ecaca3e89d5bc1eefc72c4
3
+ metadata.gz: d2c1b3556b4fefbfcfbb7ea54fee65c68b37f64e
4
+ data.tar.gz: 1707ad4ad0b7bab8b79b702e934744a697033459
5
5
  SHA512:
6
- metadata.gz: d655a2ce3bbeca4e03e723ccd76953976bdc0737f999e6f83d03964d9aa6d5ff11875b52006fd126531f09b5c5aa7d50c68a60bb2a1205adc836147ce541d8be
7
- data.tar.gz: 2d43246e7094620591d2d7c7465a54200f75792baeab538a670e8e113f9327f027db59ee6297b90760bbb568e5b91746f536d1fb2b506f77378170c4b4145c10
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
- AlignWith: variable
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.3.0
5
- - 2.2.4
6
- - 2.1.8
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
- ## 0.1.1 (2016-01-25)
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/connexio-labs/grape-apiary)
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 docuementation that is created by your [Grape](https://github.com/ruby-grape/grape) API.
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.14', '< 0.16'
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'
@@ -47,7 +47,7 @@ module GrapeApiary
47
47
  end
48
48
 
49
49
  def show_request_sample?(route)
50
- %w(PUT POST).include?(route.route_method)
50
+ %w(PUT POST).include?(route.request_method)
51
51
  end
52
52
 
53
53
  private
@@ -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, :route_namespace, to: :route
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(&:route_namespace).map do |_, routes|
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(&:route_path_without_format).map do |_, routes|
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.route_path_without_format}]"
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.route_method) && route.route_params.present?
49
+ methods.include?(route.request_method) && route.params.present?
50
50
  end
51
51
 
52
52
  if potential.present?
53
- potential.first.route_params
53
+ potential.first.params
54
54
  else
55
55
  []
56
56
  end
@@ -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 :route_namespace, :route_path, :route_method, to: '__getobj__'
5
+ delegate :namespace, :path, :request_method, to: '__getobj__'
6
6
 
7
- def route_params
8
- @route_params ||= begin
9
- __getobj__.route_params.stringify_keys.sort.map do |param|
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
- route_namespace.split('/').last ||
17
- route_path.match('\/(\w*?)[\.\/\(]').captures.first
16
+ namespace.split('/').last ||
17
+ path.match('\/(\w*?)[\.\/\(]').captures.first
18
18
  end
19
19
 
20
- def route_description
21
- "#{__getobj__.route_description} [#{route_method.upcase}]"
20
+ def description
21
+ "#{__getobj__.description} [#{request_method.upcase}]"
22
22
  end
23
23
 
24
- def route_path_without_format
25
- route_path.gsub(/\((.*?)\)/, '')
24
+ def path_without_format
25
+ path.gsub(/\((.*?)\)/, '')
26
26
  end
27
27
 
28
28
  def route_model
29
- route_namespace.split('/').last.singularize
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 = route_method == 'POST' ? 201 : 200
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?(route_method) && !route_path.include?(':id')
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?(route_method)
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.route_params.present? %>
14
+ <% if resource_by_path.routes.first.params.present? %>
15
15
  + Parameters
16
- <% resource_by_path.routes.first.route_params.each do |param| %>
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.route_description %>
21
+ ### <%= route.description %>
22
22
  <% if show_request_sample?(route) %>
23
23
  <%= route.request_description %>
24
24
  <%= formatted_request_headers %>
@@ -1,5 +1,5 @@
1
1
  # Needed until support for v2.3+ https://goo.gl/DyKn74
2
2
  # frozen_string_literal: true
3
3
  module GrapeApiary
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.2.0'.freeze
5
5
  end
@@ -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(Grape::Route.new))
18
+ subject.sample_response(GrapeApiary::Route.new(SampleApi.routes.first))
19
19
  end
20
20
  end
21
21
  end
@@ -12,7 +12,7 @@ describe GrapeApiary::Route do
12
12
  end
13
13
 
14
14
  it 'adds a path helper without format' do
15
- expect(subject.route_path_without_format).to eq('/widgets')
15
+ expect(subject.path_without_format).to eq('/widgets')
16
16
  end
17
17
 
18
18
  it 'adds a type helper' do
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.1.2
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: 2016-04-26 00:00:00.000000000 Z
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: '0.14'
20
- - - "<"
19
+ version: 0.16.0
20
+ - - "<="
21
21
  - !ruby/object:Gem::Version
22
- version: '0.16'
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: '0.14'
30
- - - "<"
29
+ version: 0.16.0
30
+ - - "<="
31
31
  - !ruby/object:Gem::Version
32
- version: '0.16'
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.3
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