dox 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +12 -0
- data/README.md +4 -4
- data/lib/dox/entities/action.rb +2 -1
- data/lib/dox/entities/example.rb +2 -8
- data/lib/dox/formatter.rb +14 -3
- data/lib/dox/printers/example_printer.rb +24 -2
- data/lib/dox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6271f722c9d2fe3887a8e0732ceff6228f4f9c9
|
4
|
+
data.tar.gz: 8d44754eeefedee5c76d5f87ab529bb80a2ec0ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa994fabaa650442c1e8e669ee99bc9b32ab16b06b7387e3b2bf128bed393cb5bffb8099b20d2db71b93cfef2abac2807ba9f037ed85e654eac33187ef2a98e
|
7
|
+
data.tar.gz: b430db71dbfbadf6579c11da1d8a904c6914dd54b694cc24156e46f970228860fd0d33bee37aca42826bca1293687632be2c39b458bf7144a1b7abc331d83bc1
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 1.1.0
|
4
|
+
|
5
|
+
Released on February 19, 2018
|
6
|
+
|
7
|
+
New:
|
8
|
+
- Full RSpec failure dump to stderr if any test fails when running tests with Dox::Formatter
|
9
|
+
- Support any payload format with pretty formatting for JSON and XML (based on `content-type` header)
|
10
|
+
|
11
|
+
Fix:
|
12
|
+
- Ignore subdomain request header in headers output
|
13
|
+
|
14
|
+
|
3
15
|
## Version 1.0.1
|
4
16
|
|
5
17
|
Released on June 10, 2017
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Add this line to your application's Gemfile:
|
|
19
19
|
|
20
20
|
```ruby
|
21
21
|
group :test do
|
22
|
-
gem 'dox', require:
|
22
|
+
gem 'dox', require: false
|
23
23
|
end
|
24
24
|
```
|
25
25
|
|
@@ -47,7 +47,7 @@ $ gem install dox
|
|
47
47
|
and configure rspec with this:
|
48
48
|
|
49
49
|
``` ruby
|
50
|
-
|
50
|
+
RSpec.configure do |config|
|
51
51
|
config.after(:each, :dox) do |example|
|
52
52
|
example.metadata[:request] = request
|
53
53
|
example.metadata[:response] = response
|
@@ -249,8 +249,8 @@ Documentation is generated in 2 steps:
|
|
249
249
|
```aglio -i docs.md -o docs.html```
|
250
250
|
|
251
251
|
|
252
|
-
#### Use
|
253
|
-
It's recommendable to write a few
|
252
|
+
#### Use rake tasks
|
253
|
+
It's recommendable to write a few rake tasks to make things easier. Here's an example:
|
254
254
|
|
255
255
|
```ruby
|
256
256
|
namespace :api do
|
data/lib/dox/entities/action.rb
CHANGED
@@ -30,7 +30,8 @@ module Dox
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def path_params
|
33
|
-
@path_params ||=
|
33
|
+
@path_params ||=
|
34
|
+
request.path_parameters.symbolize_keys.except(:action, :controller, :format, :subdomain)
|
34
35
|
end
|
35
36
|
|
36
37
|
def template_path_params
|
data/lib/dox/entities/example.rb
CHANGED
@@ -16,7 +16,7 @@ module Dox
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def request_body
|
19
|
-
@request_body ||=
|
19
|
+
@request_body ||= request.body.read
|
20
20
|
end
|
21
21
|
|
22
22
|
def request_identifier
|
@@ -44,7 +44,7 @@ module Dox
|
|
44
44
|
|
45
45
|
# Rails 5.0.2 returns "" for request.path
|
46
46
|
def request_path
|
47
|
-
request.path.presence || request.fullpath.split(
|
47
|
+
request.path.presence || request.fullpath.split('?')[0]
|
48
48
|
end
|
49
49
|
|
50
50
|
attr_reader :desc, :request, :response
|
@@ -65,12 +65,6 @@ module Dox
|
|
65
65
|
def request_url_query_parameters
|
66
66
|
CGI.unescape(request.query_parameters.to_query)
|
67
67
|
end
|
68
|
-
|
69
|
-
def parse_request_body
|
70
|
-
body = request.body.read
|
71
|
-
return body if body.blank?
|
72
|
-
JSON.parse(body)
|
73
|
-
end
|
74
68
|
end
|
75
69
|
end
|
76
70
|
end
|
data/lib/dox/formatter.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'rspec/core'
|
2
2
|
require 'rspec/core/formatters/base_formatter'
|
3
|
+
require 'rspec/core/formatters/console_codes'
|
3
4
|
|
4
5
|
module Dox
|
5
6
|
class Formatter < RSpec::Core::Formatters::BaseFormatter
|
6
7
|
extend Forwardable
|
7
8
|
|
8
|
-
RSpec::Core::Formatters.register self, :example_passed, :stop
|
9
|
+
RSpec::Core::Formatters.register self, :example_passed, :stop, :dump_summary
|
9
10
|
|
10
11
|
def initialize(output)
|
11
12
|
super
|
@@ -17,8 +18,18 @@ module Dox
|
|
17
18
|
move_example_to_passed if current_example.document?
|
18
19
|
end
|
19
20
|
|
20
|
-
def stop(
|
21
|
-
|
21
|
+
def stop(notification)
|
22
|
+
if notification.failed_examples.any?
|
23
|
+
$stderr.puts(notification.fully_formatted_failed_examples)
|
24
|
+
else
|
25
|
+
printer.print(passed_examples)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def dump_summary(summary)
|
30
|
+
return if summary.failed_examples.none?
|
31
|
+
$stderr.puts(summary.fully_formatted)
|
32
|
+
exit(-1)
|
22
33
|
end
|
23
34
|
|
24
35
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
1
3
|
module Dox
|
2
4
|
module Printers
|
3
5
|
class ExamplePrinter < BasePrinter
|
@@ -52,7 +54,7 @@ module Dox
|
|
52
54
|
|
53
55
|
+ Body
|
54
56
|
|
55
|
-
#{indent_lines(12,
|
57
|
+
#{indent_lines(12, formatted_body(example.request_body, example.request_content_type))}
|
56
58
|
HEREDOC
|
57
59
|
end
|
58
60
|
|
@@ -77,10 +79,21 @@ module Dox
|
|
77
79
|
|
78
80
|
+ Body
|
79
81
|
|
80
|
-
#{indent_lines(12,
|
82
|
+
#{indent_lines(12, formatted_body(example.response_body, example.response_content_type))}
|
81
83
|
HEREDOC
|
82
84
|
end
|
83
85
|
|
86
|
+
def formatted_body(body_str, content_type)
|
87
|
+
case content_type
|
88
|
+
when %r{application\/.*json}
|
89
|
+
pretty_json(safe_json_parse(body_str))
|
90
|
+
when /xml/
|
91
|
+
pretty_xml(body_str)
|
92
|
+
else
|
93
|
+
body_str
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
84
97
|
def safe_json_parse(json_string)
|
85
98
|
json_string.length >= 2 ? JSON.parse(json_string) : nil
|
86
99
|
end
|
@@ -93,6 +106,15 @@ module Dox
|
|
93
106
|
end
|
94
107
|
end
|
95
108
|
|
109
|
+
def pretty_xml(xml_string)
|
110
|
+
doc = REXML::Document.new(xml_string)
|
111
|
+
formatter = REXML::Formatters::Pretty.new
|
112
|
+
formatter.compact = true
|
113
|
+
result = ''
|
114
|
+
formatter.write(doc, result)
|
115
|
+
result
|
116
|
+
end
|
117
|
+
|
96
118
|
def print_headers(headers)
|
97
119
|
headers.map do |key, value|
|
98
120
|
"#{key}: #{value}"
|
data/lib/dox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Melita Kokot
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|