autodoc-grape 0.1.0 → 0.1.2

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: 6797d121ea4b92281c65cc4bc1344f1a61c2c39c
4
- data.tar.gz: e5ffe33e7aacdd5df46a3f4b1c9aa738a858dfec
3
+ metadata.gz: 014e1b1a44ccf074cf3c75c54fdea66446bab6fd
4
+ data.tar.gz: bbf5715a2249f913c788deb3efa3044cb90181be
5
5
  SHA512:
6
- metadata.gz: 0cf1eb42e68f8b4286b20386256a76325febc32875a35d91d96c75907ebb4d62d2a956918ddac1f4ba08fc024118c4cdca92ca2ad66288cd8cf1be5bb3ce09f3
7
- data.tar.gz: b656ac74787a9f9721f97256a526a229b8a4535a3fa3ce5f8c850b71d453b0828caf07f7decf0a840fc453ae83191643b87ffe863caf8811920919677cb54069
6
+ metadata.gz: b1493f092df2c6d0e1b8362405118c7b0a3701959a3792c12d1aa230220e5bfd93efd7b8d50a278cab325e9d22d4d996fa63b0ace87c68e4353486b0e15fe858
7
+ data.tar.gz: 33a0a7bf8d306feb662fbffb19e1e488b0d8fba722f8195d7a49283feec492da35e3bc20765af411839ad0cd0c8bdb5766812f2e86862e7c7095f3d1025253eb
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Autodoc::Grape
2
2
 
3
- Extend [r7kamura/autodoc](https:/github.com/r7kamura/autodoc/) to generate documention for [Grape API](https://github.com/ruby-grape/grape).
3
+ Extend [r7kamura/autodoc](https://github.com/r7kamura/autodoc) to generate documention for [Grape API](https://github.com/ruby-grape/grape).
4
4
 
5
5
  ## Installation
6
6
 
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new("spec")
5
+ task :default => :spec
data/lib/autodoc/grape.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require "autodoc"
2
2
  require "autodoc/grape/version"
3
3
  require "autodoc/grape/document/parameter"
4
- require "autodoc/grape/monkey_patches/document_grape_extension"
4
+ require "autodoc/grape/monkey_patches/documents_grape_extension"
5
+ require "autodoc/grape/document_grape_extension"
5
6
 
6
7
  module Autodoc
7
8
  module Grape
@@ -0,0 +1,33 @@
1
+ module DocumentGrapeExtension
2
+ private
3
+
4
+ def has_validators?
5
+ !!validators
6
+ end
7
+
8
+ def method
9
+ grape_options[:method]
10
+ end
11
+
12
+ def path
13
+ grape_options[:path].gsub(/\(.*\)$/,'')
14
+ end
15
+
16
+ def route_info
17
+ @route_info ||= begin
18
+ request.env["rack.routing_args"][:route_info]
19
+ end
20
+ end
21
+
22
+ def grape_options
23
+ route_info.instance_variable_get(:@options)
24
+ end
25
+
26
+ def validators
27
+ route_info.instance_variable_get(:@options)[:params]
28
+ end
29
+
30
+ def parameters
31
+ validators.map { |validator| Autodoc::Grape::Document::Parameter.new(validator) }.join("\n")
32
+ end
33
+ end
@@ -0,0 +1,13 @@
1
+ module DocumentsGrapeExtension
2
+ def append(context, example)
3
+ document = Autodoc::Document.new(context.clone, example.clone)
4
+ document.extend DocumentGrapeExtension if grape_request?(document.send(:request))
5
+ @table[document.pathname] << document
6
+ end
7
+
8
+ def grape_request?(request)
9
+ defined?(Grape) && request.env["rack.routing_args"][:route_info].instance_of?(Grape::Route) rescue false
10
+ end
11
+ end
12
+
13
+ Autodoc::Documents.send(:prepend, DocumentsGrapeExtension)
@@ -1,5 +1,5 @@
1
1
  module Autodoc
2
2
  module Grape
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autodoc-grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keisuke Ishizawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-13 00:00:00.000000000 Z
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autodoc
@@ -116,7 +116,8 @@ files:
116
116
  - bin/setup
117
117
  - lib/autodoc/grape.rb
118
118
  - lib/autodoc/grape/document/parameter.rb
119
- - lib/autodoc/grape/monkey_patches/document_grape_extension.rb
119
+ - lib/autodoc/grape/document_grape_extension.rb
120
+ - lib/autodoc/grape/monkey_patches/documents_grape_extension.rb
120
121
  - lib/autodoc/grape/version.rb
121
122
  homepage: https://github.com/kei-p/autodoc-grape
122
123
  licenses:
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  version: '0'
139
140
  requirements: []
140
141
  rubyforge_project:
141
- rubygems_version: 2.2.2
142
+ rubygems_version: 2.2.0
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: Autodoc for Grape API specs.
@@ -1,35 +0,0 @@
1
- module DocumentGrapeExtension
2
- private
3
-
4
- def has_validators?
5
- !!(grape_request? && validators) || super
6
- end
7
-
8
- def route_info
9
- @route_info ||= begin
10
- grape_request? ? request.env["rack.routing_args"][:route_info] : nil
11
- end
12
- end
13
-
14
- def validators
15
- if grape_request?
16
- route_info.instance_variable_get(:@options)[:params]
17
- else
18
- super
19
- end
20
- end
21
-
22
- def parameters
23
- if grape_request?
24
- validators.map { |validator| Autodoc::Grape::Document::Parameter.new(validator) }.join("\n")
25
- else
26
- super
27
- end
28
- end
29
-
30
- def grape_request?
31
- defined?(Grape) && request.env["rack.routing_args"][:route_info].instance_of?(Grape::Route) rescue false
32
- end
33
- end
34
-
35
- Autodoc::Document.send(:prepend, DocumentGrapeExtension)