rpdoc 0.1.12 → 0.1.14

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
  SHA256:
3
- metadata.gz: 8bd4a2fdf6339f7ab5a963d52ad2ccc3950e7edcca3ffbd7882be39e995d1014
4
- data.tar.gz: 228c44ebef79a9852e08a736935c9334cb4cd1e8decca079ff5b38c18fa70cee
3
+ metadata.gz: 6aa96c76973dbdc52d2bf391d6cd1dd9561be44290e83b7a1b81cf02a067f36a
4
+ data.tar.gz: 0f93b3d7646b53be728867ce218acc78e7672bae09ae8075657311aa5f43d517
5
5
  SHA512:
6
- metadata.gz: e8480e75031c7dadda942348f6ec22799ac217ea78202aea5c53131ff67298e83d25d7cb5b4430eb3c6b870e2c4362650023c0883efe8b152eb673fd2ed2ea4d
7
- data.tar.gz: 792babfa02d6b6a54b52f42124b3e519bad2ee2c9a63b197073dfa075ede8a1e50523d4e9334af1b5776d5ba64ed97e737878b960449f31415c7873d7506f2db
6
+ metadata.gz: 79ed1646334c6d66e9a144fbe7f3a7212c94184486b0237e162278ad7a89ce1a7699e6b787aa0861083579bcb277cf27a202f0bb4321e2561f38b2724156a00d
7
+ data.tar.gz: 1d52b4c71c8188b9e51e07cdbf05a31b26231aa0f0af712b496d89b8c0ce494e50c96f8c5636a0b43dc03685e1cec7d90d183ddfb577e00918d49047ead3e488
data/.gitlab-ci.yml CHANGED
@@ -4,7 +4,7 @@ stages:
4
4
 
5
5
  rspec:
6
6
  stage: rspec
7
- image: ruby:3.0.2
7
+ image: ruby:3.2.1
8
8
  script:
9
9
  - bundle install
10
10
  - RPDOC_ENABLE=false rspec spec -fd
@@ -13,7 +13,7 @@ rspec:
13
13
 
14
14
  to_gem:
15
15
  stage: publish
16
- image: ruby:3.0.2
16
+ image: ruby:3.2.1
17
17
  script:
18
18
  - mkdir -p ~/.gem
19
19
  - touch ~/.gem/credentials
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.1.14] - 2023-02-09
2
+ - Fix File object method `exists` has been removed error at Ruby 3.2.1.
3
+ - [Removed deprecated Dir.exists? and File.exists?](https://github.com/ruby/ruby/commit/bf97415c02b11a8949f715431aca9eeb6311add2)
4
+ - Add the notice at README.md
5
+
6
+ ## [0.1.13] - 2022-10-03
7
+ - Clean empty folders by default
8
+
1
9
  ## [0.1.12] - 2022-09-06
2
10
  - Handle encoding error
3
11
 
data/Gemfile.lock CHANGED
@@ -1,26 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rpdoc (0.1.11)
4
+ rpdoc (0.1.14)
5
5
  json_requester (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (6.1.4.1)
11
- actionview (= 6.1.4.1)
12
- activesupport (= 6.1.4.1)
10
+ actionpack (6.1.7)
11
+ actionview (= 6.1.7)
12
+ activesupport (= 6.1.7)
13
13
  rack (~> 2.0, >= 2.0.9)
14
14
  rack-test (>= 0.6.3)
15
15
  rails-dom-testing (~> 2.0)
16
16
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
- actionview (6.1.4.1)
18
- activesupport (= 6.1.4.1)
17
+ actionview (6.1.7)
18
+ activesupport (= 6.1.7)
19
19
  builder (~> 3.1)
20
20
  erubi (~> 1.4)
21
21
  rails-dom-testing (~> 2.0)
22
22
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
- activesupport (6.1.4.1)
23
+ activesupport (6.1.7)
24
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
25
  i18n (>= 1.6, < 2)
26
26
  minitest (>= 5.1)
@@ -29,83 +29,88 @@ GEM
29
29
  ast (2.4.2)
30
30
  builder (3.2.4)
31
31
  coderay (1.1.3)
32
- concurrent-ruby (1.1.9)
32
+ concurrent-ruby (1.1.10)
33
33
  crass (1.0.6)
34
- diff-lcs (1.4.4)
35
- erubi (1.10.0)
36
- faraday (2.3.0)
37
- faraday-net_http (~> 2.0)
34
+ diff-lcs (1.5.0)
35
+ erubi (1.11.0)
36
+ faraday (2.5.2)
37
+ faraday-net_http (>= 2.0, < 3.1)
38
38
  ruby2_keywords (>= 0.0.4)
39
- faraday-net_http (2.0.3)
40
- i18n (1.8.10)
39
+ faraday-net_http (3.0.0)
40
+ i18n (1.12.0)
41
41
  concurrent-ruby (~> 1.0)
42
- json_requester (1.0.7)
42
+ json (2.6.2)
43
+ json_requester (1.0.8)
43
44
  faraday (>= 1.0.0)
44
- loofah (2.12.0)
45
+ loofah (2.19.0)
45
46
  crass (~> 1.0.2)
46
47
  nokogiri (>= 1.5.9)
47
48
  method_source (1.0.0)
48
- minitest (5.14.4)
49
- nokogiri (1.12.5-x86_64-darwin)
49
+ minitest (5.16.3)
50
+ nokogiri (1.13.8-arm64-darwin)
50
51
  racc (~> 1.4)
51
- parallel (1.21.0)
52
- parser (3.0.2.0)
52
+ nokogiri (1.13.8-x86_64-darwin)
53
+ racc (~> 1.4)
54
+ parallel (1.22.1)
55
+ parser (3.1.2.1)
53
56
  ast (~> 2.4.1)
54
57
  pry (0.14.1)
55
58
  coderay (~> 1.1)
56
59
  method_source (~> 1.0)
57
60
  racc (1.6.0)
58
- rack (2.2.3)
59
- rack-test (1.1.0)
60
- rack (>= 1.0, < 3)
61
+ rack (2.2.4)
62
+ rack-test (2.0.2)
63
+ rack (>= 1.3)
61
64
  rails-dom-testing (2.0.3)
62
65
  activesupport (>= 4.2.0)
63
66
  nokogiri (>= 1.6)
64
- rails-html-sanitizer (1.4.2)
67
+ rails-html-sanitizer (1.4.3)
65
68
  loofah (~> 2.3)
66
- railties (6.1.4.1)
67
- actionpack (= 6.1.4.1)
68
- activesupport (= 6.1.4.1)
69
+ railties (6.1.7)
70
+ actionpack (= 6.1.7)
71
+ activesupport (= 6.1.7)
69
72
  method_source
70
- rake (>= 0.13)
73
+ rake (>= 12.2)
71
74
  thor (~> 1.0)
72
- rainbow (3.0.0)
75
+ rainbow (3.1.1)
73
76
  rake (13.0.6)
74
- regexp_parser (2.1.1)
77
+ regexp_parser (2.6.0)
75
78
  rexml (3.2.5)
76
- rspec (3.10.0)
77
- rspec-core (~> 3.10.0)
78
- rspec-expectations (~> 3.10.0)
79
- rspec-mocks (~> 3.10.0)
80
- rspec-core (3.10.1)
81
- rspec-support (~> 3.10.0)
82
- rspec-expectations (3.10.1)
79
+ rspec (3.11.0)
80
+ rspec-core (~> 3.11.0)
81
+ rspec-expectations (~> 3.11.0)
82
+ rspec-mocks (~> 3.11.0)
83
+ rspec-core (3.11.0)
84
+ rspec-support (~> 3.11.0)
85
+ rspec-expectations (3.11.1)
83
86
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.10.0)
85
- rspec-mocks (3.10.2)
87
+ rspec-support (~> 3.11.0)
88
+ rspec-mocks (3.11.1)
86
89
  diff-lcs (>= 1.2.0, < 2.0)
87
- rspec-support (~> 3.10.0)
88
- rspec-support (3.10.2)
89
- rubocop (1.22.3)
90
+ rspec-support (~> 3.11.0)
91
+ rspec-support (3.11.1)
92
+ rubocop (1.36.0)
93
+ json (~> 2.3)
90
94
  parallel (~> 1.10)
91
- parser (>= 3.0.0.0)
95
+ parser (>= 3.1.2.1)
92
96
  rainbow (>= 2.2.2, < 4.0)
93
97
  regexp_parser (>= 1.8, < 3.0)
94
- rexml
95
- rubocop-ast (>= 1.12.0, < 2.0)
98
+ rexml (>= 3.2.5, < 4.0)
99
+ rubocop-ast (>= 1.20.1, < 2.0)
96
100
  ruby-progressbar (~> 1.7)
97
101
  unicode-display_width (>= 1.4.0, < 3.0)
98
- rubocop-ast (1.12.0)
99
- parser (>= 3.0.1.1)
102
+ rubocop-ast (1.21.0)
103
+ parser (>= 3.1.1.0)
100
104
  ruby-progressbar (1.11.0)
101
105
  ruby2_keywords (0.0.5)
102
- thor (1.1.0)
103
- tzinfo (2.0.4)
106
+ thor (1.2.1)
107
+ tzinfo (2.0.5)
104
108
  concurrent-ruby (~> 1.0)
105
- unicode-display_width (2.1.0)
106
- zeitwerk (2.5.1)
109
+ unicode-display_width (2.3.0)
110
+ zeitwerk (2.6.1)
107
111
 
108
112
  PLATFORMS
113
+ arm64-darwin-20
109
114
  x86_64-darwin-19
110
115
 
111
116
  DEPENDENCIES
@@ -116,4 +121,4 @@ DEPENDENCIES
116
121
  rubocop (~> 1.0)
117
122
 
118
123
  BUNDLED WITH
119
- 2.2.32
124
+ 2.3.4
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Kdan Mobile Software Ltd
3
+ Copyright (c) 2023 Kdan Mobile Software Ltd.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -72,6 +72,10 @@ Rpdoc.configure do |config|
72
72
  # (Optional) Auto push collection to Postman server or not.
73
73
  config.rpdoc_auto_push = false
74
74
 
75
+ # (Optional) Clean empty folders. You can specify folder names which will be ignored when cleaning.
76
+ config.rpdoc_clean_empty_folders = true
77
+ config.rpdoc_clean_empty_folders_except = []
78
+
75
79
  # (Optional) Auto push strategy, including :push_and_create and :push_and_update
76
80
  config.rpdoc_auto_push_strategy = :push_and_create
77
81
  end
@@ -128,6 +132,20 @@ end
128
132
 
129
133
  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
134
 
135
+ ## Notice
136
+
137
+ If you try to mock the `File.open` method, generating collection data will fail because creating `request.json` use the `File.open` method.
138
+
139
+ Solution:
140
+
141
+ You can add code in RSpec.
142
+
143
+ ```ruby
144
+ after(:each) do
145
+ allow(File).to receive(:open).and_call_original
146
+ end
147
+ ```
148
+
131
149
  ## License
132
150
 
133
151
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/VERSION.md CHANGED
@@ -1 +1 @@
1
- 0.1.12
1
+ 0.1.14
@@ -35,6 +35,10 @@ Rpdoc.configure do |config|
35
35
  # (Optional) Filename to store RSpec collection json data.
36
36
  # config.rpdoc_collection_filename = 'collection.json'
37
37
 
38
+ # (Optional) Clean empty folders. You can specify folder names which will be ignored when cleaning.
39
+ # config.rpdoc_clean_empty_folders = true
40
+ # config.rpdoc_clean_empty_folders_except = []
41
+
38
42
  # (Optional) Auto push collection to Postman server or not.
39
43
  # config.rpdoc_auto_push = false
40
44
 
@@ -19,6 +19,8 @@ module Rpdoc
19
19
  :rpdoc_request_filename,
20
20
  :rpdoc_description_filename,
21
21
  :rpdoc_collection_filename,
22
+ :rpdoc_clean_empty_folders,
23
+ :rpdoc_clean_empty_folders_except,
22
24
  :rpdoc_auto_push,
23
25
  :rpdoc_auto_push_strategy
24
26
 
@@ -41,6 +43,10 @@ module Rpdoc
41
43
  @rpdoc_request_filename = 'request.json'
42
44
  @rpdoc_description_filename = 'description.md'
43
45
  @rpdoc_collection_filename = 'collection.json'
46
+
47
+ @rpdoc_clean_empty_folders = true
48
+ @rpdoc_clean_empty_folders_except = []
49
+
44
50
  @rpdoc_auto_push = false
45
51
  @rpdoc_auto_push_strategy = :push_and_create # or :push_and_update
46
52
  end
data/lib/rpdoc/helper.rb CHANGED
@@ -6,7 +6,7 @@ RSpec.configure do |config|
6
6
  root = Rpdoc.configuration.rpdoc_root
7
7
  if Rpdoc.configuration.rpdoc_enable
8
8
  raise StandardError.new('Configuration Invalid') unless Rpdoc.configuration.valid?
9
- FileUtils.mkdir_p(root) unless File.exists?(root)
9
+ FileUtils.mkdir_p(root) unless File.exist?(root)
10
10
  Dir.glob("#{root}/**/*.json") do |filename|
11
11
  File.delete(filename)
12
12
  end
@@ -10,6 +10,7 @@ module Rpdoc
10
10
  @requester = JsonRequester.new(@configuration.postman_host)
11
11
 
12
12
  @data = generated_collection_data
13
+ clean_empty_folders_from(@data[:collection][:item])
13
14
  end
14
15
 
15
16
  def push_and_create
@@ -29,6 +30,7 @@ module Rpdoc
29
30
  remote_collection_data = remote_collection_data['status'] == 200 ? remote_collection_data.deep_symbolize_keys.slice(:collection) : nil
30
31
 
31
32
  merged_by(remote_collection_data)
33
+ clean_empty_folders_from(remote_collection_data[:collection][:item])
32
34
  @requester.http_send(:put, path, remote_collection_data, headers)
33
35
  end
34
36
 
@@ -94,7 +96,7 @@ module Rpdoc
94
96
  if item.has_key?(:item)
95
97
  clean_generated_responses_from(item[:item])
96
98
  elsif item.has_key?(:response)
97
- item[:response] = item[:response].reject do |response|
99
+ item[:response].reject! do |response|
98
100
  response.dig(:header)&.pluck(:key)&.include?('RSpec-Location')
99
101
  end
100
102
  end
@@ -130,5 +132,15 @@ module Rpdoc
130
132
  end
131
133
  end
132
134
  end
135
+
136
+ def clean_empty_folders_from(collection_items)
137
+ return unless @configuration.rpdoc_clean_empty_folders
138
+ collection_items.reject! do |item|
139
+ next false if item.has_key?(:request)
140
+ next false if @configuration.rpdoc_clean_empty_folders_except.include?(item[:name])
141
+ clean_empty_folders_from(item[:item]) if item[:item].present?
142
+ item[:item].nil? || item[:item].empty?
143
+ end
144
+ end
133
145
  end
134
146
  end
@@ -18,10 +18,10 @@ module Rpdoc
18
18
  def save
19
19
  root_path ||= @configuration.rpdoc_root
20
20
  folder_path = "#{root_path}/#{@rspec_example.metadata[:rpdoc_example_folders].join('/')}/#{@rspec_example.metadata[:rpdoc_action_key]}"
21
- FileUtils.mkdir_p(folder_path) unless File.exists?(folder_path)
21
+ FileUtils.mkdir_p(folder_path) unless File.exist?(folder_path)
22
22
 
23
23
  request_file_path = "#{folder_path}/#{@configuration.rpdoc_request_filename}"
24
- File.open(request_file_path, 'w+') { |f| f.write(JSON.pretty_generate(request_data)) } unless File.exists?(request_file_path)
24
+ File.open(request_file_path, 'w+') { |f| f.write(JSON.pretty_generate(request_data)) } unless File.exist?(request_file_path)
25
25
 
26
26
  response_file_path = "#{folder_path}/#{@rspec_example.metadata[:rpdoc_example_key]}.json"
27
27
  File.open(response_file_path, 'w+') { |f| f.write(JSON.pretty_generate(response_data)) }
@@ -45,7 +45,7 @@ module Rpdoc
45
45
  originalRequest: original_request_data,
46
46
  status: @rspec_response.status.to_s,
47
47
  code: @rspec_response.code.to_i,
48
- _postman_previewlanguage: "json",
48
+ _postman_previewlanguage: 'json',
49
49
  header: headers,
50
50
  }
51
51
  if @rspec_response.headers['Content-Type'].include?('application/json')
data/lib/rpdoc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rpdoc
4
- VERSION = "0.1.12"
4
+ VERSION = "0.1.14"
5
5
  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.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - yuntai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-07 00:00:00.000000000 Z
11
+ date: 2023-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_requester
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.2.22
132
+ rubygems_version: 3.4.6
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: RSpec to Postman Documentation Tool