fitting 1.1.0 → 1.2.0
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 +4 -4
- data/README.md +6 -0
- data/lib/fitting.rb +5 -13
- data/lib/fitting/configuration.rb +6 -1
- data/lib/fitting/documentation/request/route.rb +87 -1
- data/lib/fitting/documentation/response/route.rb +11 -0
- data/lib/fitting/version.rb +1 -1
- metadata +2 -3
- data/lib/fitting/report/response.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdb557f593641ef3769db74073ce39029981fd16
|
4
|
+
data.tar.gz: 18155ebc235d3c992c2ce2f16cef2ac3ab9f7614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 102887cabc4a1b99e2214017b5e4023162a60f1e6a68ecb39c522f91b406572cc03d3217b30b26c172189d80dfb32d88b6046d8af23a106027b5e9f32512abf6
|
7
|
+
data.tar.gz: 1cf4d5d1dac4bd4c758cacfe35f12df107514b9f6cde8db62ad09a15df7519ecf562706cc83078872b5b857331c8703f4b65b19fb0ab32b3a332f8de13ddf750
|
data/README.md
CHANGED
data/lib/fitting.rb
CHANGED
@@ -5,7 +5,6 @@ require 'fitting/documentation/request/route'
|
|
5
5
|
require 'fitting/storage/responses'
|
6
6
|
require 'fitting/storage/documentation'
|
7
7
|
require 'fitting/storage/skip'
|
8
|
-
require 'fitting/report/response'
|
9
8
|
require 'fitting/matchers/response_matcher'
|
10
9
|
|
11
10
|
module Fitting
|
@@ -37,18 +36,11 @@ module RSpec
|
|
37
36
|
)
|
38
37
|
request_routes = Fitting::Documentation::Request::Route.new(response_routes)
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
puts "API responses conforming to the blueprint: #{valid_count} (#{valid_percentage}% of #{total_count})."
|
46
|
-
puts "API responses with validation errors or untested: #{invalid_count} (#{invalid_percentage}% of #{total_count})."
|
47
|
-
puts
|
48
|
-
puts "Conforming responses: \n#{response_routes.coverage.join("\n")} \n\n"
|
49
|
-
puts "Non-conforming responses: \n#{response_routes.not_coverage.join("\n")}\n\n"
|
50
|
-
Fitting::Report::Response.new('report_response.yaml', response_routes).save
|
51
|
-
Fitting::Report::Response.new('report_request_by_response.yaml', request_routes).save
|
39
|
+
request_routes.conformity_lists
|
40
|
+
request_routes.statistics
|
41
|
+
response_routes.statistics
|
42
|
+
|
43
|
+
exit if response_routes.not_coverage.present? && Fitting.configuration.crash_not_implemented_response
|
52
44
|
end
|
53
45
|
end
|
54
46
|
end
|
@@ -17,6 +17,8 @@ module Fitting
|
|
17
17
|
stat[macro_key]['cover'] ||= []
|
18
18
|
stat[macro_key]['not_cover'] ||= []
|
19
19
|
stat[macro_key]['cover'].push(micro_key)
|
20
|
+
stat[macro_key]['all'] ||= []
|
21
|
+
stat[macro_key]['all'].push("✔ #{route.split(' ')[2..3].join(' ')}")
|
20
22
|
end
|
21
23
|
@response_routes.not_coverage.map do |route|
|
22
24
|
macro_key = route.split(' ')[0..1].join(' ')
|
@@ -25,6 +27,8 @@ module Fitting
|
|
25
27
|
stat[macro_key]['cover'] ||= []
|
26
28
|
stat[macro_key]['not_cover'] ||= []
|
27
29
|
stat[macro_key]['not_cover'].push(micro_key)
|
30
|
+
stat[macro_key]['all'] ||= []
|
31
|
+
stat[macro_key]['all'].push("✖ #{route.split(' ')[2..3].join(' ')}")
|
28
32
|
end
|
29
33
|
@stat = stat.inject(
|
30
34
|
{
|
@@ -36,7 +40,11 @@ module Fitting
|
|
36
40
|
ratio = date.last['cover_ratio'] =
|
37
41
|
(date.last['cover'].size.to_f /
|
38
42
|
(date.last['cover'].size + date.last['not_cover'].size).to_f * 100.0).round(2)
|
39
|
-
info = {date.first => {
|
43
|
+
info = {date.first => {
|
44
|
+
'cover' => date.last['cover'],
|
45
|
+
'not_cover' => date.last['not_cover'],
|
46
|
+
'all' => "#{beautiful_output(date.last)}"
|
47
|
+
}}
|
40
48
|
if ratio == 100.0
|
41
49
|
res['full cover'].push(info)
|
42
50
|
elsif ratio == 0.0
|
@@ -44,6 +52,11 @@ module Fitting
|
|
44
52
|
else
|
45
53
|
res['partial cover'].push(info)
|
46
54
|
end
|
55
|
+
path = date.first.split(' ')[1].size / 8
|
56
|
+
@max ||= 1
|
57
|
+
if path.size > @max
|
58
|
+
@max = path.size
|
59
|
+
end
|
47
60
|
res
|
48
61
|
end
|
49
62
|
end
|
@@ -51,6 +64,79 @@ module Fitting
|
|
51
64
|
def to_hash
|
52
65
|
@stat ||= coverage_statistic
|
53
66
|
end
|
67
|
+
|
68
|
+
def fully_implemented
|
69
|
+
@stat ||= coverage_statistic
|
70
|
+
@fully_implemented ||= @stat['full cover'].map do |response|
|
71
|
+
"#{response.first.to_a.first.split(' ').join("\t")}#{"\t"*(@max-response.first.to_a.first.split(' ')[1].size/8)}#{response.first.to_a.last['all']}"
|
72
|
+
end.sort do |first, second|
|
73
|
+
first.split("\t")[1] <=> second.split("\t")[1]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def partially_implemented
|
78
|
+
@stat ||= coverage_statistic
|
79
|
+
@partially_implemented ||= @stat['partial cover'].map do |response|
|
80
|
+
"#{response.first.to_a.first.split(' ').join("\t")}#{"\t"*(@max-response.first.to_a.first.split(' ')[1].size/8)}#{response.first.to_a.last['all']}"
|
81
|
+
end.sort do |first, second|
|
82
|
+
first.split("\t")[1] <=> second.split("\t")[1]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def no_implemented
|
87
|
+
@stat ||= coverage_statistic
|
88
|
+
@no_implemented ||= @stat['no cover'].map do |response|
|
89
|
+
"#{response.first.to_a.first.split(' ').join("\t")}#{"\t"*(@max-response.first.to_a.first.split(' ')[1].size/8)}#{response.first.to_a.last['all']}"
|
90
|
+
end.sort do |first, second|
|
91
|
+
first.split("\t")[1] <=> second.split("\t")[1]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def conformity_lists
|
96
|
+
puts "Conforming requests: \n#{fully_implemented.join("\n")}"
|
97
|
+
puts
|
98
|
+
puts "Partially conforming requests: \n#{partially_implemented.join("\n")}"
|
99
|
+
puts
|
100
|
+
puts "Non-conforming requests: \n#{no_implemented.join("\n")}"
|
101
|
+
puts
|
102
|
+
end
|
103
|
+
|
104
|
+
def statistics
|
105
|
+
full_count = to_hash['full cover'].size
|
106
|
+
part_count = to_hash['partial cover'].size
|
107
|
+
no_count = to_hash['no cover'].size
|
108
|
+
total_count = full_count + part_count + no_count
|
109
|
+
full_percentage = (full_count.to_f / total_count.to_f * 100.0).round(2)
|
110
|
+
part_percentage = (part_count.to_f / total_count.to_f * 100.0).round(2)
|
111
|
+
no_percentage = (no_count.to_f / total_count.to_f * 100.0).round(2)
|
112
|
+
puts "API requests with fully implemented responses: #{full_count} (#{full_percentage}% of #{total_count})."
|
113
|
+
puts "API requests with partially implemented responses: #{part_count} (#{part_percentage}% of #{total_count})."
|
114
|
+
puts "API requests with no implemented responses: #{no_count} (#{no_percentage}% of #{total_count})."
|
115
|
+
puts
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def beautiful_output(hash)
|
121
|
+
methods = {}
|
122
|
+
res = []
|
123
|
+
hash['cover'].map do |response|
|
124
|
+
method, index = response.split(' ')
|
125
|
+
methods[method] ||= []
|
126
|
+
methods[method][index.to_i] = {'method' => method, 'cover' => true}
|
127
|
+
end
|
128
|
+
hash['not_cover'].map do |response|
|
129
|
+
method, index = response.split(' ')
|
130
|
+
methods[method] ||= []
|
131
|
+
methods[method][index.to_i] = {'method' => method, 'cover' => false}
|
132
|
+
end
|
133
|
+
methods.map do |method|
|
134
|
+
method.last.size.times do |index|
|
135
|
+
res.push("#{method.last[index]['cover'] ? '✔' : '✖'} #{method.first}")
|
136
|
+
end
|
137
|
+
end
|
138
|
+
res.join(' ')
|
139
|
+
end
|
54
140
|
end
|
55
141
|
end
|
56
142
|
end
|
@@ -45,6 +45,17 @@ module Fitting
|
|
45
45
|
'not coverage' => not_coverage
|
46
46
|
}
|
47
47
|
end
|
48
|
+
|
49
|
+
def statistics
|
50
|
+
valid_count = coverage.size
|
51
|
+
valid_percentage = cover_ratio
|
52
|
+
total_count = all.size
|
53
|
+
invalid_count = not_coverage.size
|
54
|
+
invalid_percentage = 100.0 - cover_ratio
|
55
|
+
puts "API responses conforming to the blueprint: #{valid_count} (#{valid_percentage}% of #{total_count})."
|
56
|
+
puts "API responses with validation errors or untested: #{invalid_count} (#{invalid_percentage}% of #{total_count})."
|
57
|
+
puts
|
58
|
+
end
|
48
59
|
end
|
49
60
|
end
|
50
61
|
end
|
data/lib/fitting/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- d.efimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -195,7 +195,6 @@ files:
|
|
195
195
|
- lib/fitting/documentation/request/route.rb
|
196
196
|
- lib/fitting/documentation/response/route.rb
|
197
197
|
- lib/fitting/matchers/response_matcher.rb
|
198
|
-
- lib/fitting/report/response.rb
|
199
198
|
- lib/fitting/request.rb
|
200
199
|
- lib/fitting/response.rb
|
201
200
|
- lib/fitting/storage/documentation.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
module Report
|
5
|
-
class Response
|
6
|
-
def initialize(name, routes)
|
7
|
-
@name = name
|
8
|
-
@json = routes.to_hash
|
9
|
-
end
|
10
|
-
|
11
|
-
def save
|
12
|
-
File.open(@name, 'w') do |file|
|
13
|
-
file.write(YAML.dump(@json))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|