avocado-docs 3.1.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/avocado/specs_controller.rb +7 -17
- data/config/routes.rb +1 -1
- data/lib/avocado-docs.rb +8 -5
- data/lib/avocado/{storage.rb → cache.rb} +1 -1
- data/lib/avocado/controller_patch.rb +1 -1
- data/lib/avocado/minitest.rb +3 -3
- data/lib/avocado/rspec.rb +3 -3
- data/lib/avocado/storage/file.rb +28 -0
- data/lib/avocado/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53e9c7b26a64f5491ef065942a6bff4326b60fc
|
4
|
+
data.tar.gz: b3bf621f28f386052bd861def025eb6b6bfa48f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f149da4dcfb28fc8aef10fe0b41d407449a18198aba01cafb7cb060488f0fb42bfd0e40aec133eff0a3ed83fe5448c5ad5cc3806e6c9b70c725965b3c7254db9
|
7
|
+
data.tar.gz: 840a45e77a6f6475a991f4d6d84eb1f240fe4f6c4aeef50c031323386229d776de1b15a59619a72e52bc784c4ffb537e1b6f29c0535703b548bc0b16e3306b50
|
@@ -3,32 +3,22 @@ module Avocado
|
|
3
3
|
layout 'avocado'
|
4
4
|
|
5
5
|
def index
|
6
|
-
@data =
|
6
|
+
@data = storage.read
|
7
7
|
end
|
8
8
|
|
9
9
|
def create
|
10
|
-
|
11
|
-
|
10
|
+
storage.write params[:file].read, upload_id
|
11
|
+
storage.purge_old upload_id
|
12
12
|
head :ok
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
|
-
def
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def new_json_filename
|
21
|
-
Avocado.json_path.join "avocado-#{Time.current.to_s(:nsec)}-#{upload_id}.json"
|
16
|
+
def storage
|
17
|
+
Avocado.storage
|
22
18
|
end
|
23
19
|
|
24
|
-
def
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def json_files_from_past_uploads
|
29
|
-
json_files.reject do |spec|
|
30
|
-
spec.end_with? "-#{upload_id}.json"
|
31
|
-
end
|
20
|
+
def upload_id
|
21
|
+
params[:upload_id]
|
32
22
|
end
|
33
23
|
end
|
34
24
|
end
|
data/config/routes.rb
CHANGED
data/lib/avocado-docs.rb
CHANGED
@@ -2,19 +2,22 @@ require 'avocado/engine'
|
|
2
2
|
require 'avocado/controller_patch'
|
3
3
|
require 'avocado/controller_response'
|
4
4
|
require 'avocado/logger'
|
5
|
-
require 'avocado/
|
5
|
+
require 'avocado/cache'
|
6
6
|
require 'avocado/uploader'
|
7
|
+
require 'avocado/storage/file'
|
8
|
+
|
7
9
|
require 'avocado/adapters/base_adapter'
|
8
10
|
require 'avocado/adapters/minitest_adapter'
|
9
11
|
require 'avocado/adapters/rspec_adapter'
|
10
12
|
require 'avocado/adapters/cucumber_adapter'
|
13
|
+
|
11
14
|
require 'avocado/serializers/request_serializer'
|
12
15
|
require 'avocado/serializers/resource_serializer'
|
13
16
|
require 'avocado/serializers/response_serializer'
|
14
17
|
|
15
18
|
module Avocado
|
16
19
|
class << self
|
17
|
-
attr_accessor :url, :headers, :
|
20
|
+
attr_accessor :url, :headers, :upload_id, :document_if, :ignored_params, :cache, :uploader, :storage
|
18
21
|
|
19
22
|
def configure
|
20
23
|
yield self
|
@@ -23,14 +26,14 @@ module Avocado
|
|
23
26
|
def reset!
|
24
27
|
self.url = nil
|
25
28
|
self.headers = []
|
26
|
-
self.json_path = ::Rails.root
|
27
29
|
self.upload_id = proc { SecureRandom.uuid }
|
28
30
|
self.document_if = proc { true }
|
29
31
|
self.ignored_params = %w(controller action format)
|
30
|
-
self.
|
32
|
+
self.cache = Avocado::Cache.instance
|
31
33
|
self.uploader = Avocado::Uploader.instance
|
34
|
+
self.storage = Avocado::Storage::File.new ::Rails.root
|
32
35
|
|
33
|
-
|
36
|
+
cache.clear
|
34
37
|
uploader.reset
|
35
38
|
end
|
36
39
|
end
|
data/lib/avocado/minitest.rb
CHANGED
@@ -7,12 +7,12 @@ module Avocado::Minitest
|
|
7
7
|
def before_teardown
|
8
8
|
super
|
9
9
|
|
10
|
-
request = Avocado.
|
11
|
-
response = Avocado.
|
10
|
+
request = Avocado.cache.request
|
11
|
+
response = Avocado.cache.response
|
12
12
|
adapter = Avocado::Adapters::MinitestAdapter.new name, request, response
|
13
13
|
|
14
14
|
Avocado.uploader.payload << adapter.to_h if adapter.upload?
|
15
|
-
Avocado.
|
15
|
+
Avocado.cache.clear
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/lib/avocado/rspec.rb
CHANGED
@@ -7,12 +7,12 @@ RSpec.configure do |config|
|
|
7
7
|
# Older versions of RSpec use the global `example` object
|
8
8
|
spec = defined?(example) ? example : ex
|
9
9
|
|
10
|
-
request = Avocado.
|
11
|
-
response = Avocado.
|
10
|
+
request = Avocado.cache.request
|
11
|
+
response = Avocado.cache.response
|
12
12
|
adapter = Avocado::Adapters::RSpecAdapter.new spec, request, response
|
13
13
|
|
14
14
|
Avocado.uploader.payload << adapter.to_h if adapter.upload?
|
15
|
-
Avocado.
|
15
|
+
Avocado.cache.clear
|
16
16
|
end
|
17
17
|
|
18
18
|
config.after(:suite) do
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Avocado
|
2
|
+
module Storage
|
3
|
+
class File
|
4
|
+
def initialize(dir)
|
5
|
+
@dir = dir
|
6
|
+
end
|
7
|
+
|
8
|
+
def read
|
9
|
+
files.map { |filename| ::File.read filename }
|
10
|
+
end
|
11
|
+
|
12
|
+
def write(data, upload_id)
|
13
|
+
filename = @dir.join "avocado-#{Time.current.to_s(:nsec)}-#{upload_id}.json"
|
14
|
+
::File.open(filename, 'w+') { |f| f.write data }
|
15
|
+
end
|
16
|
+
|
17
|
+
def purge_old(upload_id)
|
18
|
+
old_files = files.reject { |fn| fn.end_with? "-#{upload_id}.json" }
|
19
|
+
::File.delete(*old_files)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def files
|
24
|
+
Dir.glob @dir.join('avocado*.json')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/avocado/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avocado-docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Serman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/avocado/adapters/cucumber_adapter.rb
|
140
140
|
- lib/avocado/adapters/minitest_adapter.rb
|
141
141
|
- lib/avocado/adapters/rspec_adapter.rb
|
142
|
+
- lib/avocado/cache.rb
|
142
143
|
- lib/avocado/controller_patch.rb
|
143
144
|
- lib/avocado/controller_response.rb
|
144
145
|
- lib/avocado/cucumber.rb
|
@@ -149,7 +150,7 @@ files:
|
|
149
150
|
- lib/avocado/serializers/request_serializer.rb
|
150
151
|
- lib/avocado/serializers/resource_serializer.rb
|
151
152
|
- lib/avocado/serializers/response_serializer.rb
|
152
|
-
- lib/avocado/storage.rb
|
153
|
+
- lib/avocado/storage/file.rb
|
153
154
|
- lib/avocado/uploader.rb
|
154
155
|
- lib/avocado/version.rb
|
155
156
|
homepage: http://github.com/metova/avocado
|
@@ -171,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
172
|
version: '0'
|
172
173
|
requirements: []
|
173
174
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.6.
|
175
|
+
rubygems_version: 2.6.11
|
175
176
|
signing_key:
|
176
177
|
specification_version: 4
|
177
178
|
summary: Automatic API documentation from RSpec tests
|