betterdocs 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/betterdocs.gemspec +5 -5
- data/lib/betterdocs/dsl/controller/action/response.rb +13 -3
- data/lib/betterdocs/representer.rb +4 -0
- data/lib/betterdocs/responding.rb +7 -0
- data/lib/betterdocs/version.rb +1 -1
- data/lib/betterdocs.rb +2 -0
- data/spec/betterdocs/dsl/controller/action/response_spec.rb +15 -2
- data/spec/betterdocs/json_params_representer_spec.rb +0 -5
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaf01d4e2af6e80f36f2cd756ac230d7bb0f7eaa796ed0d65116839d75e74a65
|
4
|
+
data.tar.gz: 8582edc5843c2261b50b5d75db2574597ac6404bea1f62e01a98448c999d9e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3587cff52970a661523e4796c6cb38522388ddf64b2a1da9f3b519a512325c2133531c716b654497af64f76ff28c99ed574d61bba0a327d6032fbc79ee8a2d8
|
7
|
+
data.tar.gz: 36d4f09a69a6d5ae7fe326948ebed98e83c7528b76602dfa6beba7fbed70870ff6629c24f45587eea93bc0538fbb5bf49f9056c51d62f3502af5aa81635a29fd
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.12.0
|
data/betterdocs.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: betterdocs 0.
|
2
|
+
# stub: betterdocs 0.12.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "betterdocs".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.12.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["betterplace Developers".freeze]
|
11
|
-
s.date = "2022-12-
|
11
|
+
s.date = "2022-12-09"
|
12
12
|
s.description = "This library provides tools to generate API documention for a web site's REST-ful JSON API.".freeze
|
13
13
|
s.email = "developers@betterplace.org".freeze
|
14
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/swagger.rb".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/version.rb".freeze]
|
15
|
-
s.files = [".codeclimate.yml".freeze, ".gitignore".freeze, ".rspec".freeze, ".semaphore/semaphore.yml".freeze, ".tool-versions".freeze, ".vscode/settings.json".freeze, "COPYING".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterdocs.gemspec".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/markdown/templates/README.md.erb".freeze, "lib/betterdocs/generator/markdown/templates/section.md.erb".freeze, "lib/betterdocs/generator/swagger.rb".freeze, "lib/betterdocs/generator/swagger_static/index.html".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/tasks/doc.rake".freeze, "lib/betterdocs/version.rb".freeze, "spec/assets/app/assets/images/logos/logo.png".freeze, "spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/assets/app/views/api_v4/documentation/assets/CHANGELOG.md".freeze, "spec/assets/config/betterdocs.yml".freeze, "spec/betterdocs/dsl/controller/action/param_spec.rb".freeze, "spec/betterdocs/dsl/controller/action/response_spec.rb".freeze, "spec/betterdocs/dsl/json_type_mapper_spec.rb".freeze, "spec/betterdocs/dsl/result/collection_property_spec.rb".freeze, "spec/betterdocs/dsl/result/link_spec.rb".freeze, "spec/betterdocs/dsl/result/property_spec.rb".freeze, "spec/betterdocs/generator/markdown_spec.rb".freeze, "spec/betterdocs/global_spec.rb".freeze, "spec/betterdocs/json_params_representer_spec.rb".freeze, "spec/betterdocs/result_representer_spec.rb".freeze, "spec/betterdocs/sanitizer_spec.rb".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
14
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/swagger.rb".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/responding.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/version.rb".freeze]
|
15
|
+
s.files = [".codeclimate.yml".freeze, ".gitignore".freeze, ".rspec".freeze, ".semaphore/semaphore.yml".freeze, ".tool-versions".freeze, ".vscode/settings.json".freeze, "COPYING".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterdocs.gemspec".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/markdown/templates/README.md.erb".freeze, "lib/betterdocs/generator/markdown/templates/section.md.erb".freeze, "lib/betterdocs/generator/swagger.rb".freeze, "lib/betterdocs/generator/swagger_static/index.html".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/responding.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/tasks/doc.rake".freeze, "lib/betterdocs/version.rb".freeze, "spec/assets/app/assets/images/logos/logo.png".freeze, "spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/assets/app/views/api_v4/documentation/assets/CHANGELOG.md".freeze, "spec/assets/config/betterdocs.yml".freeze, "spec/betterdocs/dsl/controller/action/param_spec.rb".freeze, "spec/betterdocs/dsl/controller/action/response_spec.rb".freeze, "spec/betterdocs/dsl/json_type_mapper_spec.rb".freeze, "spec/betterdocs/dsl/result/collection_property_spec.rb".freeze, "spec/betterdocs/dsl/result/link_spec.rb".freeze, "spec/betterdocs/dsl/result/property_spec.rb".freeze, "spec/betterdocs/generator/markdown_spec.rb".freeze, "spec/betterdocs/global_spec.rb".freeze, "spec/betterdocs/json_params_representer_spec.rb".freeze, "spec/betterdocs/result_representer_spec.rb".freeze, "spec/betterdocs/sanitizer_spec.rb".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
16
16
|
s.homepage = "https://github.com/betterplace/betterdocs".freeze
|
17
17
|
s.rdoc_options = ["--title".freeze, "Betterdocs".freeze, "--main".freeze, "README.md".freeze]
|
18
18
|
s.rubygems_version = "3.3.26".freeze
|
@@ -17,8 +17,13 @@ class Betterdocs::Dsl::Controller::Action::Response
|
|
17
17
|
|
18
18
|
def data
|
19
19
|
@data ||= instance_eval(&@data_block)
|
20
|
-
|
21
|
-
|
20
|
+
@data.is_a? Betterdocs::Responding or
|
21
|
+
raise Error, "result #{@data.class} is not Betterdocs::Responding"
|
22
|
+
hash = @data.to_hash
|
23
|
+
if hash.key?(:data) && hash[:data].empty?
|
24
|
+
raise Error, "result data for action #{controller}##{action} is empty"
|
25
|
+
elsif hash.empty?
|
26
|
+
raise Error, "result for action #{controller}##{action} is empty"
|
22
27
|
end
|
23
28
|
@data
|
24
29
|
rescue => e
|
@@ -48,7 +53,12 @@ class Betterdocs::Dsl::Controller::Action::Response
|
|
48
53
|
end
|
49
54
|
|
50
55
|
def to_json(*a)
|
56
|
+
data.nil? and raise Error, "result for action #{controller}##{action} was nil"
|
57
|
+
unless data.is_a?(Betterdocs::Responding)
|
58
|
+
infobar.puts "#{data.class}".red
|
59
|
+
infobar.puts "Result of type #{data.class} for action #{controller}##{action} is not hash / Betterdocs::Representer"
|
60
|
+
end
|
51
61
|
my_data = data.ask_and_send(:to_hash) || data
|
52
|
-
|
62
|
+
data.to_json(*a)
|
53
63
|
end
|
54
64
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'action_controller'
|
2
|
+
require 'betterdocs/responding'
|
2
3
|
|
3
4
|
module Betterdocs::Representer
|
5
|
+
include Betterdocs::Responding
|
4
6
|
extend ActiveSupport::Concern
|
5
7
|
|
6
8
|
def as_json(*)
|
@@ -9,6 +11,8 @@ module Betterdocs::Representer
|
|
9
11
|
end.hashify(self)
|
10
12
|
end
|
11
13
|
|
14
|
+
alias to_hash as_json
|
15
|
+
|
12
16
|
def to_json(*a)
|
13
17
|
JSON::generate(as_json, *a)
|
14
18
|
end
|
data/lib/betterdocs/version.rb
CHANGED
data/lib/betterdocs.rb
CHANGED
@@ -14,8 +14,10 @@ module Betterdocs
|
|
14
14
|
end
|
15
15
|
|
16
16
|
require 'betterdocs/version'
|
17
|
+
require 'betterdocs/responding'
|
17
18
|
require 'betterdocs/dsl'
|
18
19
|
require 'betterdocs/sanitizer'
|
20
|
+
require 'betterdocs/representer'
|
19
21
|
require 'betterdocs/result_representer'
|
20
22
|
require 'betterdocs/result_representer_collector'
|
21
23
|
require 'betterdocs/controller_collector'
|
@@ -18,7 +18,7 @@ describe Betterdocs::Dsl::Controller::Action::Response do
|
|
18
18
|
'Result',
|
19
19
|
representer: representer,
|
20
20
|
to_hash: { data: %w[ fake-it ] }
|
21
|
-
)
|
21
|
+
).extend Betterdocs::Responding
|
22
22
|
end
|
23
23
|
|
24
24
|
let :response do
|
@@ -41,10 +41,23 @@ describe Betterdocs::Dsl::Controller::Action::Response do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'complains about missing data in example responses' do
|
44
|
-
allow(result_data).to receive(:to_hash).and_return(
|
44
|
+
allow(result_data).to receive(:to_hash).and_return(data: [])
|
45
45
|
expect { response.data }.to raise_error(Betterdocs::Dsl::Controller::Action::Response::Error)
|
46
46
|
end
|
47
47
|
|
48
|
+
context 'foo' do
|
49
|
+
let :result_data do
|
50
|
+
double
|
51
|
+
end
|
52
|
+
|
53
|
+
it "complains about data that isn't Betterdocs::Responding" do
|
54
|
+
expect { response.data }.to raise_error(
|
55
|
+
Betterdocs::Dsl::Controller::Action::Response::Error,
|
56
|
+
/is not Betterdocs::Responding/
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
48
61
|
it 'has data' do
|
49
62
|
expect(response.data).to eq result_data
|
50
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterdocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- betterplace Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -199,6 +199,7 @@ extra_rdoc_files:
|
|
199
199
|
- lib/betterdocs/railtie.rb
|
200
200
|
- lib/betterdocs/rake_tasks.rb
|
201
201
|
- lib/betterdocs/representer.rb
|
202
|
+
- lib/betterdocs/responding.rb
|
202
203
|
- lib/betterdocs/result_representer.rb
|
203
204
|
- lib/betterdocs/result_representer_collector.rb
|
204
205
|
- lib/betterdocs/sanitizer.rb
|
@@ -251,6 +252,7 @@ files:
|
|
251
252
|
- lib/betterdocs/railtie.rb
|
252
253
|
- lib/betterdocs/rake_tasks.rb
|
253
254
|
- lib/betterdocs/representer.rb
|
255
|
+
- lib/betterdocs/responding.rb
|
254
256
|
- lib/betterdocs/result_representer.rb
|
255
257
|
- lib/betterdocs/result_representer_collector.rb
|
256
258
|
- lib/betterdocs/sanitizer.rb
|