rpdoc 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +27 -0
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +3 -75
- data/README.md +132 -0
- data/VERSION.md +1 -0
- data/lib/generators/templates/initializer.rb +2 -2
- data/lib/rpdoc/configuration.rb +7 -4
- data/lib/rpdoc/helper.rb +5 -3
- data/lib/rpdoc/postman_collection.rb +13 -7
- data/lib/rpdoc/version.rb +1 -1
- data/rpdoc.gemspec +5 -16
- metadata +22 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 713fb6351f7a74091e6e88a197875d863f7df857710b0aa23d0210b588bb2052
|
4
|
+
data.tar.gz: a8c3ddb59c58133f1b36c0cc8a7c743a538ff485488aba1f6d7063483a3bef3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a62f5718f6ae2ef1d2ffc8f6f02126a2c827d5cc57de70f6bc7718d1e120a0c273f0329944fa88748c1acc0a4083ef5c1cccf3ad8b26c3fc407e04007fb0dfa
|
7
|
+
data.tar.gz: b556c139e50d4934de146c8209dde5e6071889b5fb101af0c5d3a4a59c4e42b67d8bbbfc0d49f7f989fc7466336e0a7e16b59b1cdb345894a82750aea8a4bafe
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
stages:
|
2
|
+
- rspec
|
3
|
+
- publish
|
4
|
+
|
5
|
+
rspec:
|
6
|
+
stage: rspec
|
7
|
+
image: ruby:3.0.2
|
8
|
+
script:
|
9
|
+
- bundle install
|
10
|
+
- RPDOC_ENABLE=false rspec spec -fd
|
11
|
+
only:
|
12
|
+
- master
|
13
|
+
|
14
|
+
to_gem:
|
15
|
+
stage: publish
|
16
|
+
image: ruby:3.0.2
|
17
|
+
script:
|
18
|
+
- mkdir -p ~/.gem
|
19
|
+
- touch ~/.gem/credentials
|
20
|
+
- chmod 0600 ~/.gem/credentials
|
21
|
+
- 'printf -- "---\n:rubygems_api_key: $GEM_HOST_API_KEY\n" > ~/.gem/credentials'
|
22
|
+
- RELEASE_VERSION=$(cat VERSION.md)
|
23
|
+
- GEM_NAME=rpdoc-$RELEASE_VERSION.gem
|
24
|
+
- gem build rpdoc.gemspec
|
25
|
+
- gem push $GEM_NAME
|
26
|
+
only:
|
27
|
+
- master
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
## [
|
1
|
+
## [0.1.2] - 2021-11-04
|
2
|
+
- Add gem description
|
3
|
+
- Remove unecessary gem dependency
|
4
|
+
- Fix configuration and collection bugs
|
2
5
|
|
3
|
-
## [0.1.
|
6
|
+
## [0.1.1] - 2021-11-01
|
7
|
+
- Add configuration options
|
4
8
|
|
9
|
+
## [0.1.0] - 2021-10-30
|
5
10
|
- Initial release
|
data/Gemfile.lock
CHANGED
@@ -1,31 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rpdoc (0.1.
|
4
|
+
rpdoc (0.1.2)
|
5
5
|
json_requester (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (6.1.4.1)
|
11
|
-
actionpack (= 6.1.4.1)
|
12
|
-
activesupport (= 6.1.4.1)
|
13
|
-
nio4r (~> 2.0)
|
14
|
-
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.1.4.1)
|
16
|
-
actionpack (= 6.1.4.1)
|
17
|
-
activejob (= 6.1.4.1)
|
18
|
-
activerecord (= 6.1.4.1)
|
19
|
-
activestorage (= 6.1.4.1)
|
20
|
-
activesupport (= 6.1.4.1)
|
21
|
-
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.1.4.1)
|
23
|
-
actionpack (= 6.1.4.1)
|
24
|
-
actionview (= 6.1.4.1)
|
25
|
-
activejob (= 6.1.4.1)
|
26
|
-
activesupport (= 6.1.4.1)
|
27
|
-
mail (~> 2.5, >= 2.5.4)
|
28
|
-
rails-dom-testing (~> 2.0)
|
29
10
|
actionpack (6.1.4.1)
|
30
11
|
actionview (= 6.1.4.1)
|
31
12
|
activesupport (= 6.1.4.1)
|
@@ -33,33 +14,12 @@ GEM
|
|
33
14
|
rack-test (>= 0.6.3)
|
34
15
|
rails-dom-testing (~> 2.0)
|
35
16
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
-
actiontext (6.1.4.1)
|
37
|
-
actionpack (= 6.1.4.1)
|
38
|
-
activerecord (= 6.1.4.1)
|
39
|
-
activestorage (= 6.1.4.1)
|
40
|
-
activesupport (= 6.1.4.1)
|
41
|
-
nokogiri (>= 1.8.5)
|
42
17
|
actionview (6.1.4.1)
|
43
18
|
activesupport (= 6.1.4.1)
|
44
19
|
builder (~> 3.1)
|
45
20
|
erubi (~> 1.4)
|
46
21
|
rails-dom-testing (~> 2.0)
|
47
22
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
-
activejob (6.1.4.1)
|
49
|
-
activesupport (= 6.1.4.1)
|
50
|
-
globalid (>= 0.3.6)
|
51
|
-
activemodel (6.1.4.1)
|
52
|
-
activesupport (= 6.1.4.1)
|
53
|
-
activerecord (6.1.4.1)
|
54
|
-
activemodel (= 6.1.4.1)
|
55
|
-
activesupport (= 6.1.4.1)
|
56
|
-
activestorage (6.1.4.1)
|
57
|
-
actionpack (= 6.1.4.1)
|
58
|
-
activejob (= 6.1.4.1)
|
59
|
-
activerecord (= 6.1.4.1)
|
60
|
-
activesupport (= 6.1.4.1)
|
61
|
-
marcel (~> 1.0.0)
|
62
|
-
mini_mime (>= 1.1.0)
|
63
23
|
activesupport (6.1.4.1)
|
64
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
65
25
|
i18n (>= 1.6, < 2)
|
@@ -92,8 +52,6 @@ GEM
|
|
92
52
|
faraday-net_http_persistent (1.2.0)
|
93
53
|
faraday-patron (1.0.0)
|
94
54
|
faraday-rack (1.0.0)
|
95
|
-
globalid (0.5.2)
|
96
|
-
activesupport (>= 5.0)
|
97
55
|
i18n (1.8.10)
|
98
56
|
concurrent-ruby (~> 1.0)
|
99
57
|
json_requester (1.0.3)
|
@@ -101,14 +59,9 @@ GEM
|
|
101
59
|
loofah (2.12.0)
|
102
60
|
crass (~> 1.0.2)
|
103
61
|
nokogiri (>= 1.5.9)
|
104
|
-
mail (2.7.1)
|
105
|
-
mini_mime (>= 0.1.1)
|
106
|
-
marcel (1.0.2)
|
107
62
|
method_source (1.0.0)
|
108
|
-
mini_mime (1.1.2)
|
109
63
|
minitest (5.14.4)
|
110
64
|
multipart-post (2.1.1)
|
111
|
-
nio4r (2.5.8)
|
112
65
|
nokogiri (1.12.5-x86_64-darwin)
|
113
66
|
racc (~> 1.4)
|
114
67
|
parallel (1.21.0)
|
@@ -121,21 +74,6 @@ GEM
|
|
121
74
|
rack (2.2.3)
|
122
75
|
rack-test (1.1.0)
|
123
76
|
rack (>= 1.0, < 3)
|
124
|
-
rails (6.1.4.1)
|
125
|
-
actioncable (= 6.1.4.1)
|
126
|
-
actionmailbox (= 6.1.4.1)
|
127
|
-
actionmailer (= 6.1.4.1)
|
128
|
-
actionpack (= 6.1.4.1)
|
129
|
-
actiontext (= 6.1.4.1)
|
130
|
-
actionview (= 6.1.4.1)
|
131
|
-
activejob (= 6.1.4.1)
|
132
|
-
activemodel (= 6.1.4.1)
|
133
|
-
activerecord (= 6.1.4.1)
|
134
|
-
activestorage (= 6.1.4.1)
|
135
|
-
activesupport (= 6.1.4.1)
|
136
|
-
bundler (>= 1.15.0)
|
137
|
-
railties (= 6.1.4.1)
|
138
|
-
sprockets-rails (>= 2.0.0)
|
139
77
|
rails-dom-testing (2.0.3)
|
140
78
|
activesupport (>= 4.2.0)
|
141
79
|
nokogiri (>= 1.6)
|
@@ -177,28 +115,18 @@ GEM
|
|
177
115
|
parser (>= 3.0.1.1)
|
178
116
|
ruby-progressbar (1.11.0)
|
179
117
|
ruby2_keywords (0.0.5)
|
180
|
-
sprockets (4.0.2)
|
181
|
-
concurrent-ruby (~> 1.0)
|
182
|
-
rack (> 1, < 3)
|
183
|
-
sprockets-rails (3.2.2)
|
184
|
-
actionpack (>= 4.0)
|
185
|
-
activesupport (>= 4.0)
|
186
|
-
sprockets (>= 3.0.0)
|
187
118
|
thor (1.1.0)
|
188
119
|
tzinfo (2.0.4)
|
189
120
|
concurrent-ruby (~> 1.0)
|
190
121
|
unicode-display_width (2.1.0)
|
191
|
-
websocket-driver (0.7.5)
|
192
|
-
websocket-extensions (>= 0.1.0)
|
193
|
-
websocket-extensions (0.1.5)
|
194
122
|
zeitwerk (2.5.1)
|
195
123
|
|
196
124
|
PLATFORMS
|
197
125
|
x86_64-darwin-19
|
198
126
|
|
199
127
|
DEPENDENCIES
|
200
|
-
pry
|
201
|
-
|
128
|
+
pry (~> 0.14.1)
|
129
|
+
railties (~> 6.1.4)
|
202
130
|
rpdoc!
|
203
131
|
rspec (~> 3.0)
|
204
132
|
rubocop (~> 1.0)
|
data/README.md
CHANGED
@@ -1 +1,133 @@
|
|
1
1
|
# Rpdoc
|
2
|
+
|
3
|
+
`Rpdoc` is a simple `Postman` API documentation tool, which transforms RSpec examples to Postman collection (with json files in Postman data format stored locally).
|
4
|
+
|
5
|
+
### Benefits
|
6
|
+
- Save time for generating Postman examples manually.
|
7
|
+
- Improve maintainability of your API documentation (easy to create/update and put it into version control with CI/CD).
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add `rpdoc` to your application's `Gemfile`:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'rpdoc', '~> 0.1.2'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then install the gem:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
`Rpdoc` should be configured manually if you want to automatically push your collection to the Postman server.
|
27
|
+
|
28
|
+
You can also run the following command to generate the configuration file for your **Rails** application.
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ rails g rpdoc:install
|
32
|
+
```
|
33
|
+
|
34
|
+
Rpdoc can be configured by the following options.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Rpdoc.configure do |config|
|
38
|
+
|
39
|
+
# (Optional) You can disable rpdoc generation process manually.
|
40
|
+
config.rpdoc_enable = true
|
41
|
+
|
42
|
+
# (Optional) Apikey for your Postman account, used if want to push collection to the Postman server.
|
43
|
+
config.postman_apikey = 'postman_apikey'
|
44
|
+
|
45
|
+
# (Optional) Workspace that your collection will be pushed to. Default your account's personal workspace.
|
46
|
+
config.collection_workspace = 'collection_workspace'
|
47
|
+
|
48
|
+
# (Optional) Your existing collection uid. Will update it when using :push_and_update push strategy.
|
49
|
+
config.collection_uid = 'collection_uid'
|
50
|
+
|
51
|
+
# (Optional) Collection name.
|
52
|
+
config.collection_name = 'Rpdoc'
|
53
|
+
|
54
|
+
# (Optional) Your Rails server API host.
|
55
|
+
config.rspec_server_host = '{{server_host}}'
|
56
|
+
|
57
|
+
# (Optional) Since Rspec generates many noisy headers, you can filter them.
|
58
|
+
config.rspec_request_allow_headers = ['User-Agent', 'Content-Type', 'Authorization']
|
59
|
+
|
60
|
+
# (Optional) Folder that Rpdoc use for json data generation and save.
|
61
|
+
config.rpdoc_root = 'rpdoc'
|
62
|
+
|
63
|
+
# (Optional) Filename to store RSpec request json data.
|
64
|
+
config.rpdoc_request_filename = 'request.json'
|
65
|
+
|
66
|
+
# (Optional) Filename to store Postman description markdown data.
|
67
|
+
config.rpdoc_description_filename = 'description.md'
|
68
|
+
|
69
|
+
# (Optional) Filename to store RSpec collection json data.
|
70
|
+
config.rpdoc_collection_filename = 'collection.json'
|
71
|
+
|
72
|
+
# (Optional) Auto push collection to Postman server or not.
|
73
|
+
config.rpdoc_auto_push = false
|
74
|
+
|
75
|
+
# (Optional) Auto push strategy, including :push_and_create and :push_and_update
|
76
|
+
config.rpdoc_auto_push_strategy = :push_and_create
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
## Usage
|
81
|
+
|
82
|
+
`Rpdoc` only supports RSpec examples with [request](https://relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec) type.
|
83
|
+
|
84
|
+
1. Include [shared_context](https://relishapp.com/rspec/rspec-core/docs/example-groups/shared-context) in your spec to make `Rpdoc` identify which examples to transform.
|
85
|
+
```ruby
|
86
|
+
RSpec.describe 'POST /api/v1/books', type: :request do
|
87
|
+
include_context 'rpdoc'
|
88
|
+
...
|
89
|
+
end
|
90
|
+
```
|
91
|
+
2. Customiz your example [metdata](https://relishapp.com/rspec/rspec-core/docs/metadata/user-defined-metadata) to generate collection data in your preferenced format.
|
92
|
+
```ruby
|
93
|
+
it 'should return 200' do |example|
|
94
|
+
# Request identifier.
|
95
|
+
# Default is `controller.action_name`
|
96
|
+
example.metadata[:rpdoc_action_key] = 'create'
|
97
|
+
|
98
|
+
# Request name shown in Postman collection.
|
99
|
+
# Default is `controller.action_name`
|
100
|
+
example.metadata[:rpdoc_action_name] = 'Create a book.'
|
101
|
+
|
102
|
+
# Example identifier.
|
103
|
+
# Default is `controller.action_name`
|
104
|
+
example.metadata[:rpdoc_example_key] = "create_200"
|
105
|
+
|
106
|
+
# Example name shown in Postman colleciotn.
|
107
|
+
# Default is `example.metadata[:description]`
|
108
|
+
example.metadata[:rpdoc_example_name] = "Create a book success."
|
109
|
+
|
110
|
+
# Example location shown in Postman collection.
|
111
|
+
# Default is `controller.controller_path.split('/')`
|
112
|
+
example.metadata[:rpdoc_example_folders] = ['v1', 'books']
|
113
|
+
|
114
|
+
# Skip this example if you have already included shared context in the spec.
|
115
|
+
# Default is `false`.
|
116
|
+
example.metadata[:rpdoc_skip] = false
|
117
|
+
end
|
118
|
+
```
|
119
|
+
3. Run your specs, generate data in Postman format, and push your collection to the Postman server.
|
120
|
+
```bash
|
121
|
+
$ rspec
|
122
|
+
```
|
123
|
+
|
124
|
+
If you want to disable `Rpdoc` generation process manually, you can either set `rpdoc_enable = false` in configuration or just pass environment variable to rspec.
|
125
|
+
```bash
|
126
|
+
$ RPDOC_ENABLE=false rspec
|
127
|
+
```
|
128
|
+
|
129
|
+
4. You can write description for your Postman collection by creating markdown files (named `description.md`) and putting each of them in corresponding location under `rpdoc` folder.
|
130
|
+
|
131
|
+
## License
|
132
|
+
|
133
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/VERSION.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
@@ -5,10 +5,10 @@ Rpdoc.configure do |config|
|
|
5
5
|
# (Optional) You can disable rpdoc generation process manually.
|
6
6
|
# config.rpdoc_enable = true
|
7
7
|
|
8
|
-
# (Optional) Apikey for your Postman account, used if
|
8
|
+
# (Optional) Apikey for your Postman account, used if want to push collection to the Postman server.
|
9
9
|
# config.postman_apikey = 'postman_apikey'
|
10
10
|
|
11
|
-
# (Optional) Workspace that your collection will be
|
11
|
+
# (Optional) Workspace that your collection will be pushed to. Default your account's personal workspace.
|
12
12
|
# config.collection_workspace = 'collection_workspace'
|
13
13
|
|
14
14
|
# (Optional) Your existing collection uid. Will update it when using :push_and_update push strategy.
|
data/lib/rpdoc/configuration.rb
CHANGED
@@ -4,7 +4,7 @@ module Rpdoc
|
|
4
4
|
class Configuration
|
5
5
|
attr_reader \
|
6
6
|
:postman_host,
|
7
|
-
:
|
7
|
+
:postman_collection_path,
|
8
8
|
:collection_schema
|
9
9
|
|
10
10
|
attr_accessor \
|
@@ -23,10 +23,10 @@ module Rpdoc
|
|
23
23
|
:rpdoc_auto_push_strategy
|
24
24
|
|
25
25
|
def initialize
|
26
|
-
@rpdoc_enable =
|
26
|
+
@rpdoc_enable = ENV['RPDOC_ENABLE'] != 'false'
|
27
27
|
|
28
28
|
@postman_host = 'https://api.getpostman.com'
|
29
|
-
@
|
29
|
+
@postman_collection_path = "/collections"
|
30
30
|
@postman_apikey = nil
|
31
31
|
|
32
32
|
@collection_workspace = nil
|
@@ -46,7 +46,10 @@ module Rpdoc
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def valid?
|
49
|
-
@rpdoc_enable && @rpdoc_auto_push
|
49
|
+
return true unless @rpdoc_enable && @rpdoc_auto_push
|
50
|
+
return false if @postman_apikey.nil?
|
51
|
+
return false if @rpdoc_auto_push_strategy == :push_and_update && @collection_uid.nil?
|
52
|
+
true
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
data/lib/rpdoc/helper.rb
CHANGED
@@ -2,19 +2,21 @@
|
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
4
|
config.before(:suite) do
|
5
|
+
root = Rpdoc.configuration.rpdoc_root
|
5
6
|
if Rpdoc.configuration.rpdoc_enable
|
6
7
|
raise StandardError.new('Configuration Invalid') unless Rpdoc.configuration.valid?
|
7
|
-
|
8
|
+
FileUtils.mkdir_p(root) unless File.exists?(root)
|
9
|
+
Dir.glob("#{root}/**/*.json") do |filename|
|
8
10
|
File.delete(filename)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
15
|
config.after(:suite) do
|
14
|
-
if Rpdoc.configuration.rpdoc_enable
|
16
|
+
if Rpdoc.configuration.rpdoc_enable
|
15
17
|
postman_collection = Rpdoc::PostmanCollection.new
|
16
18
|
postman_collection.save
|
17
|
-
postman_collection.send(Rpdoc.configuration.rpdoc_auto_push_strategy)
|
19
|
+
postman_collection.send(Rpdoc.configuration.rpdoc_auto_push_strategy) if Rpdoc.configuration.rpdoc_auto_push
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json_requester'
|
4
|
+
|
3
5
|
module Rpdoc
|
4
6
|
class PostmanCollection
|
5
7
|
|
6
8
|
def initialize
|
7
9
|
@configuration = Rpdoc.configuration
|
8
|
-
@requester = JsonRequester.new(
|
10
|
+
@requester = JsonRequester.new(@configuration.postman_host)
|
9
11
|
|
10
12
|
@data = generated_collection_data
|
11
13
|
end
|
12
14
|
|
13
15
|
def push_and_create
|
14
|
-
path = "#{@configuration.
|
16
|
+
path = "#{@configuration.postman_collection_path}?workspace=#{@configuration.collection_workspace}"
|
15
17
|
headers = {
|
16
18
|
'X-Api-Key': @configuration.postman_apikey
|
17
19
|
}
|
@@ -19,7 +21,7 @@ module Rpdoc
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def push_and_update
|
22
|
-
path = "#{@configuration.
|
24
|
+
path = "#{@configuration.postman_collection_path}/#{@configuration.collection_uid}"
|
23
25
|
headers = {
|
24
26
|
'X-Api-Key': @configuration.postman_apikey
|
25
27
|
}
|
@@ -86,7 +88,9 @@ module Rpdoc
|
|
86
88
|
|
87
89
|
def merged_by(other_collection_data)
|
88
90
|
clean_generated_responses_from(other_collection_data[:collection][:item])
|
89
|
-
|
91
|
+
|
92
|
+
other_collection_data[:collection][:info][:description] = @data[:collection][:info][:description]
|
93
|
+
insert_generated_responses_into(other_collection_data[:collection][:item], from_collection_items: @data[:collection][:item])
|
90
94
|
end
|
91
95
|
|
92
96
|
def clean_generated_responses_from(collection_items)
|
@@ -101,23 +105,25 @@ module Rpdoc
|
|
101
105
|
end
|
102
106
|
end
|
103
107
|
|
104
|
-
def insert_generated_responses_into(collection_items, from_collection_items:
|
105
|
-
from_collection_items ||= @data[:collection][:item]
|
106
|
-
|
108
|
+
def insert_generated_responses_into(collection_items, from_collection_items: [])
|
107
109
|
if collection_items.empty?
|
108
110
|
collection_items = from_collection_items.deep_dup
|
109
111
|
else
|
112
|
+
# transform collection_items into hash, using item[:name] as key
|
110
113
|
item_hash = {}
|
111
114
|
collection_items.each do |item|
|
112
115
|
item_hash[item[:name]] = item
|
113
116
|
end
|
114
117
|
|
118
|
+
# insert generated responses and replace description into corresponding items based on item[:name]
|
115
119
|
from_collection_items.each do |from_item|
|
116
120
|
from_item_name = from_item[:name]
|
117
121
|
if item_hash.has_key?(from_item_name)
|
118
122
|
if from_item.has_key?(:item) && item_hash[from_item_name].has_key?(:item)
|
123
|
+
item_hash[from_item_name][:description] = from_item[:description]
|
119
124
|
insert_generated_responses_into(item_hash[from_item_name][:item], from_collection_items: from_item[:item])
|
120
125
|
elsif from_item.has_key?(:response) && item_hash[from_item_name].has_key?(:response)
|
126
|
+
item_hash[from_item_name][:request][:description] = from_item[:request][:description]
|
121
127
|
item_hash[from_item_name][:response] += from_item[:response].deep_dup
|
122
128
|
else
|
123
129
|
collection_items << from_item.deep_dup
|
data/lib/rpdoc/version.rb
CHANGED
data/rpdoc.gemspec
CHANGED
@@ -8,18 +8,12 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["yuntai"]
|
9
9
|
spec.email = ["yuntai.yang@kdanmobile.com"]
|
10
10
|
|
11
|
-
spec.summary = "
|
12
|
-
spec.description = "
|
13
|
-
spec.homepage = "https://
|
11
|
+
spec.summary = "RSpec to Postman Documentation Tool"
|
12
|
+
spec.description = "Rpdoc is a simple Postman API documentation tool, which transforms RSpec examples to Postman collection."
|
13
|
+
spec.homepage = "https://github.com/kdan-mobile-software-ltd/rpdoc"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
16
|
|
17
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
-
|
19
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
-
spec.metadata["source_code_uri"] = "https://www.kdanmobile.com"
|
21
|
-
spec.metadata["changelog_uri"] = "https://www.kdanmobile.com"
|
22
|
-
|
23
17
|
# Specify which files should be added to the gem when it is released.
|
24
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
@@ -29,15 +23,10 @@ Gem::Specification.new do |spec|
|
|
29
23
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
24
|
spec.require_paths = ["lib"]
|
31
25
|
|
32
|
-
# Uncomment to register a new dependency of your gem
|
33
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
34
26
|
spec.add_dependency 'json_requester', '~> 1.0'
|
35
27
|
|
36
|
-
spec.add_development_dependency '
|
28
|
+
spec.add_development_dependency 'railties', '~> 6.1.4'
|
37
29
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
-
spec.add_development_dependency 'pry'
|
30
|
+
spec.add_development_dependency 'pry', '~> 0.14.1'
|
39
31
|
spec.add_development_dependency 'rubocop', '~> 1.0'
|
40
|
-
|
41
|
-
# For more information and examples about making a new gem, checkout our
|
42
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
43
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yuntai
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_requester
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.1.4
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.14.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.14.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,8 +80,8 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
|
-
description:
|
84
|
-
|
83
|
+
description: Rpdoc is a simple Postman API documentation tool, which transforms RSpec
|
84
|
+
examples to Postman collection.
|
85
85
|
email:
|
86
86
|
- yuntai.yang@kdanmobile.com
|
87
87
|
executables: []
|
@@ -89,6 +89,7 @@ extensions: []
|
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
|
+
- ".gitlab-ci.yml"
|
92
93
|
- ".rubocop.yml"
|
93
94
|
- CHANGELOG.md
|
94
95
|
- Gemfile
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- LICENSE.txt
|
97
98
|
- README.md
|
98
99
|
- Rakefile
|
100
|
+
- VERSION.md
|
99
101
|
- bin/console
|
100
102
|
- bin/setup
|
101
103
|
- lib/generators/rpdoc/install_generator.rb
|
@@ -107,14 +109,11 @@ files:
|
|
107
109
|
- lib/rpdoc/postman_response.rb
|
108
110
|
- lib/rpdoc/version.rb
|
109
111
|
- rpdoc.gemspec
|
110
|
-
homepage: https://
|
112
|
+
homepage: https://github.com/kdan-mobile-software-ltd/rpdoc
|
111
113
|
licenses:
|
112
114
|
- MIT
|
113
|
-
metadata:
|
114
|
-
|
115
|
-
source_code_uri: https://www.kdanmobile.com
|
116
|
-
changelog_uri: https://www.kdanmobile.com
|
117
|
-
post_install_message:
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
118
117
|
rdoc_options: []
|
119
118
|
require_paths:
|
120
119
|
- lib
|
@@ -129,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
128
|
- !ruby/object:Gem::Version
|
130
129
|
version: '0'
|
131
130
|
requirements: []
|
132
|
-
rubygems_version: 3.2.
|
133
|
-
signing_key:
|
131
|
+
rubygems_version: 3.2.22
|
132
|
+
signing_key:
|
134
133
|
specification_version: 4
|
135
|
-
summary:
|
134
|
+
summary: RSpec to Postman Documentation Tool
|
136
135
|
test_files: []
|