lazy_api_doc 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 568bfda81852a9cd4823ac786f1bfe2de01a32dc42da6c192304c954dd2d731c
4
- data.tar.gz: 5d4ccbd550f9cf6b16f589b155e71f3dd120a3eb2a475aa43a7ef39e1b0f8bcf
3
+ metadata.gz: 5b9bdbff963854199877b4fbcf1712ef7734a350b305e0fd0e6dc331cf3a3dd4
4
+ data.tar.gz: 7e8247e2001ff3dd2cd4caea9a269c25d094c0d718eb7385de417c6873cf6d84
5
5
  SHA512:
6
- metadata.gz: 7a99bee831aba3c9e8781b413ed4d53c051b47624673296dfbbe94176ae5dd8e54b1130abd767d46e2ec88a473dfc0d813297a12c2f66a9a017ada45997e1091
7
- data.tar.gz: 8a05e6d6ea878f4eeba9c032a1b0533e83eafc497bd86b8a51a322b3b2f169059a3df2fb665ca9ff1c799c4df69a01d1a59d094c1d3c8ffd9985124842595770
6
+ metadata.gz: a6e4a437cce43bf45cb7f53deec99b8b981af170debac416cd4ac6e835f45b2d12ac3b51f9314c9b7136116585d4401f32a27e5d0f3d24678b9b4b765b363ab9
7
+ data.tar.gz: c972f6b00a4bdd8e0f2a3f7a9a117d4d72063bb6f05c8174d75d8e28c1ffbd739a2aa9f422d612110234ec5bb1a20ab254518aa497d2423cd33b9026ac4f2fb3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lazy_api_doc (0.2.0)
4
+ lazy_api_doc (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -44,7 +44,7 @@ module LazyApiDoc
44
44
  # This peace of code handle using ParallelTests (tests runs in independent processes).
45
45
  # Just delete this block if you don't use ParallelTests
46
46
  if ENV['TEST_ENV_NUMBER'] && defined?(ParallelTests)
47
- LazyApiDoc.save_examples
47
+ LazyApiDoc.save_examples('rspec')
48
48
  ParallelTests.wait_for_other_processes_to_finish if ParallelTests.first_process?
49
49
  LazyApiDoc.load_examples
50
50
  end
@@ -75,7 +75,7 @@ module LazyApiDoc
75
75
  # This peace of code handle using ParallelTests (tests runs in independent processes).
76
76
  # Just delete this block if you don't use ParallelTests
77
77
  if ENV['TEST_ENV_NUMBER'] && defined?(ParallelTests)
78
- LazyApiDoc.save_examples
78
+ LazyApiDoc.save_examples('minitest')
79
79
  ParallelTests.wait_for_other_processes_to_finish if ParallelTests.first_process?
80
80
  LazyApiDoc.load_examples
81
81
  end
@@ -85,12 +85,10 @@ module LazyApiDoc
85
85
 
86
86
  def query_params(examples)
87
87
  query_variants = examples.map do |example|
88
- full_path = example.request['full_path'].split('?')
89
- next {} if full_path.size == 1
88
+ _path, query = example.request['full_path'].split('?')
89
+ next {} unless query
90
90
 
91
- # TODO: simplify it
92
- full_path.last.split('&').map { |part| part.split('=').map { |each| CGI.unescape(each) } }.group_by(&:first)
93
- .transform_values { |v| v.map(&:last) }.map { |k, v| [k, k.match?(/\[\]\z/) ? v : v.first] }.to_h
91
+ CGI.parse(query).map { |k, v| [k.gsub('[]', ''), k.match?('\[\]') ? v : v.first] }.to_h
94
92
  end
95
93
 
96
94
  parsed = ::LazyApiDoc::VariantsParser.new(query_variants).result
@@ -73,10 +73,10 @@ module LazyApiDoc
73
73
  result["properties"] = variant.map do |key, val|
74
74
  [
75
75
  key.to_s,
76
- parse(val, variants.compact.map { |v| v.fetch(key, OPTIONAL) })
76
+ parse(val, variants.select { |v| v.is_a?(Hash) }.map { |v| v.fetch(key, OPTIONAL) })
77
77
  ]
78
78
  end.to_h
79
- result["required"] = variant.keys.select { |key| variants.compact.all? { |v| v.key?(key) } }
79
+ result["required"] = variant.keys.select { |key| variants.select { |v| v.is_a?(Hash) }.all? { |v| v.key?(key) } }
80
80
  result
81
81
  end
82
82
 
@@ -1,3 +1,3 @@
1
1
  module LazyApiDoc
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
data/lib/lazy_api_doc.rb CHANGED
@@ -79,10 +79,10 @@ module LazyApiDoc
79
79
  File.write("#{path}/api.yml", layout.to_yaml)
80
80
  end
81
81
 
82
- def save_examples
82
+ def save_examples(process_name)
83
83
  FileUtils.mkdir("#{path}/examples") unless File.exist?("#{path}/examples")
84
84
  File.write(
85
- "#{path}/examples/rspec_#{ENV['TEST_ENV_NUMBER'] || SecureRandom.uuid}.json",
85
+ "#{path}/examples/#{process_name}_#{ENV['TEST_ENV_NUMBER'] || SecureRandom.uuid}.json",
86
86
  {
87
87
  created_at: Time.now.to_i,
88
88
  examples: generator.examples
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_api_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Guban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The gem collects all requests and responses from your request specs and
14
14
  generates documentationbased on it