fitting 2.2.0 → 2.3.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/CHANGELOG.md +11 -0
- data/README.md +7 -0
- data/lib/fitting.rb +1 -3
- data/lib/fitting/configuration.rb +41 -11
- data/lib/fitting/configuration/legacy.rb +41 -0
- data/lib/fitting/configuration/yaml.rb +60 -0
- data/lib/fitting/matchers/response_matcher.rb +33 -14
- data/lib/fitting/records/documented/request.rb +53 -0
- data/lib/fitting/records/tested/request.rb +30 -0
- data/lib/fitting/records/tested/response.rb +19 -0
- data/lib/fitting/records/unit/json_schema.rb +25 -0
- data/lib/fitting/records/unit/request.rb +36 -0
- data/lib/fitting/records/unit/response.rb +31 -0
- data/lib/fitting/statistics.rb +14 -19
- data/lib/fitting/statistics/analysis.rb +24 -0
- data/lib/fitting/statistics/great.rb +13 -0
- data/lib/fitting/statistics/list.rb +45 -0
- data/lib/fitting/statistics/lists.rb +52 -0
- data/lib/fitting/statistics/measurement.rb +94 -0
- data/lib/fitting/statistics/not_covered_responses.rb +13 -0
- data/lib/fitting/statistics/percent.rb +19 -0
- data/lib/fitting/statistics/requests_stats.rb +40 -0
- data/lib/fitting/statistics/responses_stats.rb +32 -0
- data/lib/fitting/statistics/template.rb +90 -0
- data/lib/fitting/storage/responses.rb +6 -28
- data/lib/fitting/version.rb +1 -1
- metadata +20 -11
- data/lib/fitting/route.rb +0 -28
- data/lib/fitting/route/coverage.rb +0 -45
- data/lib/fitting/route/requests.rb +0 -25
- data/lib/fitting/route/requests/combine.rb +0 -113
- data/lib/fitting/route/requests/coverage.rb +0 -58
- data/lib/fitting/route/requests/lists.rb +0 -92
- data/lib/fitting/route/requests/statistics.rb +0 -40
- data/lib/fitting/route/responses.rb +0 -24
- data/lib/fitting/storage/documentation.rb +0 -22
@@ -1,41 +1,19 @@
|
|
1
|
-
require 'fitting/
|
1
|
+
require 'fitting/statistics'
|
2
|
+
require 'fitting/records/tested/request'
|
2
3
|
|
3
4
|
module Fitting
|
4
5
|
module Storage
|
5
6
|
class Responses
|
6
7
|
def initialize
|
7
|
-
@
|
8
|
+
@tested_requests = []
|
8
9
|
end
|
9
10
|
|
10
|
-
def add(
|
11
|
-
@
|
12
|
-
Fitting::Response.new(
|
13
|
-
response,
|
14
|
-
Fitting::Storage::Documentation.tomogram
|
15
|
-
)
|
16
|
-
)
|
11
|
+
def add(env_response)
|
12
|
+
@tested_requests.push(Fitting::Records::Tested::Request.new(env_response))
|
17
13
|
end
|
18
14
|
|
19
15
|
def statistics
|
20
|
-
@
|
21
|
-
Fitting::Statistics.new(
|
22
|
-
Fitting::Documentation.new(
|
23
|
-
Fitting::Storage::Documentation.tomogram,
|
24
|
-
@white_list
|
25
|
-
),
|
26
|
-
@responses.uniq,
|
27
|
-
Fitting.configuration.strict
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def white_list
|
34
|
-
Fitting::Storage::WhiteList.new(
|
35
|
-
Fitting.configuration.white_list,
|
36
|
-
Fitting.configuration.resource_white_list,
|
37
|
-
Fitting::Storage::Documentation.tomogram.to_resources
|
38
|
-
).to_a
|
16
|
+
Fitting::Statistics.new(@tested_requests)
|
39
17
|
end
|
40
18
|
end
|
41
19
|
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: 2.
|
4
|
+
version: 2.3.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-
|
11
|
+
date: 2017-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -193,21 +193,30 @@ files:
|
|
193
193
|
- fitting.gemspec
|
194
194
|
- lib/fitting.rb
|
195
195
|
- lib/fitting/configuration.rb
|
196
|
+
- lib/fitting/configuration/legacy.rb
|
197
|
+
- lib/fitting/configuration/yaml.rb
|
196
198
|
- lib/fitting/documentation.rb
|
197
199
|
- lib/fitting/matchers/response_matcher.rb
|
200
|
+
- lib/fitting/records/documented/request.rb
|
201
|
+
- lib/fitting/records/tested/request.rb
|
202
|
+
- lib/fitting/records/tested/response.rb
|
203
|
+
- lib/fitting/records/unit/json_schema.rb
|
204
|
+
- lib/fitting/records/unit/request.rb
|
205
|
+
- lib/fitting/records/unit/response.rb
|
198
206
|
- lib/fitting/request.rb
|
199
207
|
- lib/fitting/response.rb
|
200
208
|
- lib/fitting/response/fully_validates.rb
|
201
|
-
- lib/fitting/route.rb
|
202
|
-
- lib/fitting/route/coverage.rb
|
203
|
-
- lib/fitting/route/requests.rb
|
204
|
-
- lib/fitting/route/requests/combine.rb
|
205
|
-
- lib/fitting/route/requests/coverage.rb
|
206
|
-
- lib/fitting/route/requests/lists.rb
|
207
|
-
- lib/fitting/route/requests/statistics.rb
|
208
|
-
- lib/fitting/route/responses.rb
|
209
209
|
- lib/fitting/statistics.rb
|
210
|
-
- lib/fitting/
|
210
|
+
- lib/fitting/statistics/analysis.rb
|
211
|
+
- lib/fitting/statistics/great.rb
|
212
|
+
- lib/fitting/statistics/list.rb
|
213
|
+
- lib/fitting/statistics/lists.rb
|
214
|
+
- lib/fitting/statistics/measurement.rb
|
215
|
+
- lib/fitting/statistics/not_covered_responses.rb
|
216
|
+
- lib/fitting/statistics/percent.rb
|
217
|
+
- lib/fitting/statistics/requests_stats.rb
|
218
|
+
- lib/fitting/statistics/responses_stats.rb
|
219
|
+
- lib/fitting/statistics/template.rb
|
211
220
|
- lib/fitting/storage/responses.rb
|
212
221
|
- lib/fitting/storage/white_list.rb
|
213
222
|
- lib/fitting/version.rb
|
data/lib/fitting/route.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'fitting/route/coverage'
|
2
|
-
require 'fitting/route/requests'
|
3
|
-
require 'fitting/route/responses'
|
4
|
-
|
5
|
-
module Fitting
|
6
|
-
class Route
|
7
|
-
def initialize(all_responses, routes, strict)
|
8
|
-
@coverage = Fitting::Route::Coverage.new(all_responses, routes, strict)
|
9
|
-
@requests = Fitting::Route::Requests.new(@coverage)
|
10
|
-
@responses = Fitting::Route::Responses.new(routes, @coverage)
|
11
|
-
end
|
12
|
-
|
13
|
-
def statistics_with_conformity_lists
|
14
|
-
congratulation = 'All responses are 100% valid! Great job!' if @coverage.not_coverage.empty?
|
15
|
-
|
16
|
-
[
|
17
|
-
@requests.conformity_lists,
|
18
|
-
@requests.statistics,
|
19
|
-
@responses.statistics,
|
20
|
-
congratulation
|
21
|
-
].compact.join("\n\n")
|
22
|
-
end
|
23
|
-
|
24
|
-
def errors
|
25
|
-
@coverage.not_coverage.join("\n") + "\n"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'multi_json'
|
2
|
-
module Fitting
|
3
|
-
class Route
|
4
|
-
class Coverage
|
5
|
-
def initialize(coverage_responses, responses_routes, strict)
|
6
|
-
@coverage_responses = coverage_responses
|
7
|
-
@responses_routes = responses_routes
|
8
|
-
@strict = strict
|
9
|
-
end
|
10
|
-
|
11
|
-
def coverage
|
12
|
-
@coverage ||= @responses_routes - (@responses_routes - full_coverage)
|
13
|
-
end
|
14
|
-
|
15
|
-
def not_coverage
|
16
|
-
@not_coverage ||= @responses_routes - coverage
|
17
|
-
end
|
18
|
-
|
19
|
-
def cover_ratio
|
20
|
-
@cover_ratio ||= (coverage.size.to_f / @responses_routes.size.to_f * 100.0).round(2)
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_hash
|
24
|
-
{
|
25
|
-
'coverage' => coverage,
|
26
|
-
'not coverage' => not_coverage
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def full_coverage
|
33
|
-
if @strict
|
34
|
-
@coverage_responses.map do |response|
|
35
|
-
response.strict_route if response.documented? && response.strict_fully_validates.valid?
|
36
|
-
end.flatten.compact.uniq
|
37
|
-
else
|
38
|
-
@coverage_responses.map do |response|
|
39
|
-
response.route if response.documented? && response.fully_validates.valid?
|
40
|
-
end.flatten.compact.uniq
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'multi_json'
|
2
|
-
require 'fitting/route/requests/statistics'
|
3
|
-
require 'fitting/route/requests/lists'
|
4
|
-
require 'fitting/route/requests/coverage'
|
5
|
-
require 'fitting/route/requests/combine'
|
6
|
-
|
7
|
-
module Fitting
|
8
|
-
class Route
|
9
|
-
class Requests
|
10
|
-
def initialize(coverage)
|
11
|
-
@combine = Fitting::Route::Requests::Combine.new(Fitting::Route::Requests::Coverage.new(coverage))
|
12
|
-
@lists = Fitting::Route::Requests::Lists.new(@combine)
|
13
|
-
@statistics = Fitting::Route::Requests::Statistics.new(@combine)
|
14
|
-
end
|
15
|
-
|
16
|
-
def conformity_lists
|
17
|
-
@lists.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
def statistics
|
21
|
-
@statistics.to_s
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
module Fitting
|
2
|
-
class Route
|
3
|
-
class Requests
|
4
|
-
class Combine
|
5
|
-
def initialize(stat)
|
6
|
-
@stat = stat
|
7
|
-
@full_cover = []
|
8
|
-
@partial_cover = []
|
9
|
-
@no_cover = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_hash
|
13
|
-
stat_each
|
14
|
-
@to_hash ||= {
|
15
|
-
'full cover' => @full_cover,
|
16
|
-
'partial cover' => @partial_cover,
|
17
|
-
'no cover' => @no_cover
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def max
|
22
|
-
stat_each
|
23
|
-
@max
|
24
|
-
end
|
25
|
-
|
26
|
-
def full_cover
|
27
|
-
stat_each
|
28
|
-
@full_cover
|
29
|
-
end
|
30
|
-
|
31
|
-
def partial_cover
|
32
|
-
stat_each
|
33
|
-
@partial_cover
|
34
|
-
end
|
35
|
-
|
36
|
-
def no_cover
|
37
|
-
stat_each
|
38
|
-
@no_cover
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def stat_each
|
44
|
-
@stat_each ||= @stat.to_hash.map do |date|
|
45
|
-
date.last['cover_ratio'] = ratio(date)
|
46
|
-
res_cover(ratio(date), info(date))
|
47
|
-
path = date.first.split(' ')[1].size / 8
|
48
|
-
find_max(path)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def find_max(path)
|
53
|
-
@max ||= 1
|
54
|
-
@max = path.size if path.size > @max
|
55
|
-
end
|
56
|
-
|
57
|
-
def res_cover(ratio, info)
|
58
|
-
if ratio == 100.0
|
59
|
-
@full_cover.push(info)
|
60
|
-
elsif ratio == 0.0
|
61
|
-
@no_cover.push(info)
|
62
|
-
else
|
63
|
-
@partial_cover.push(info)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def ratio(date)
|
68
|
-
(date.last['cover'].size.to_f /
|
69
|
-
(date.last['cover'].size + date.last['not_cover'].size).to_f * 100.0).round(2)
|
70
|
-
end
|
71
|
-
|
72
|
-
def info(date)
|
73
|
-
{ date.first => {
|
74
|
-
'cover' => date.last['cover'],
|
75
|
-
'not_cover' => date.last['not_cover'],
|
76
|
-
'all' => beautiful_output(date.last).to_s
|
77
|
-
} }
|
78
|
-
end
|
79
|
-
|
80
|
-
def beautiful_output(hash)
|
81
|
-
methods = {}
|
82
|
-
res = []
|
83
|
-
methods = beautiful_cover(hash, methods)
|
84
|
-
methods = beautiful_not_cover(hash, methods)
|
85
|
-
methods.map do |method|
|
86
|
-
method.last.size.times do |index|
|
87
|
-
res.push("#{method.last[index]['cover'] ? '✔' : '✖'} #{method.first}")
|
88
|
-
end
|
89
|
-
end
|
90
|
-
res.join(' ')
|
91
|
-
end
|
92
|
-
|
93
|
-
def beautiful_cover(hash, methods)
|
94
|
-
hash['cover'].map do |response|
|
95
|
-
method, index = response.split(' ')
|
96
|
-
methods[method] ||= []
|
97
|
-
methods[method][index.to_i] = { 'method' => method, 'cover' => true }
|
98
|
-
end
|
99
|
-
methods
|
100
|
-
end
|
101
|
-
|
102
|
-
def beautiful_not_cover(hash, methods)
|
103
|
-
hash['not_cover'].map do |response|
|
104
|
-
method, index = response.split(' ')
|
105
|
-
methods[method] ||= []
|
106
|
-
methods[method][index.to_i] = { 'method' => method, 'cover' => false }
|
107
|
-
end
|
108
|
-
methods
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module Fitting
|
2
|
-
class Route
|
3
|
-
class Requests
|
4
|
-
class Coverage
|
5
|
-
def initialize(coverage)
|
6
|
-
@coverage = coverage
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_hash
|
10
|
-
stat = {}
|
11
|
-
@coverage.coverage.map do |route|
|
12
|
-
stat = coverage_stat(stat, route, '✔')
|
13
|
-
end
|
14
|
-
@coverage.not_coverage.map do |route|
|
15
|
-
stat = not_coverage_stat(stat, route, '✖')
|
16
|
-
end
|
17
|
-
stat
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def coverage_stat(stat, route, symbol)
|
23
|
-
macro_key = macro_key(route)
|
24
|
-
micro_key = micro_key(route)
|
25
|
-
stat = default_stat(stat, macro_key)
|
26
|
-
stat[macro_key]['cover'].push(micro_key)
|
27
|
-
stat[macro_key]['all'].push("#{symbol} #{route.split(' ')[2..3].join(' ')}")
|
28
|
-
stat
|
29
|
-
end
|
30
|
-
|
31
|
-
def not_coverage_stat(stat, route, symbol)
|
32
|
-
macro_key = macro_key(route)
|
33
|
-
micro_key = micro_key(route)
|
34
|
-
stat = default_stat(stat, macro_key)
|
35
|
-
stat[macro_key]['not_cover'].push(micro_key)
|
36
|
-
stat[macro_key]['all'].push("#{symbol} #{route.split(' ')[2..3].join(' ')}")
|
37
|
-
stat
|
38
|
-
end
|
39
|
-
|
40
|
-
def default_stat(stat, macro_key)
|
41
|
-
stat[macro_key] ||= {}
|
42
|
-
stat[macro_key]['cover'] ||= []
|
43
|
-
stat[macro_key]['not_cover'] ||= []
|
44
|
-
stat[macro_key]['all'] ||= []
|
45
|
-
stat
|
46
|
-
end
|
47
|
-
|
48
|
-
def macro_key(route)
|
49
|
-
route.split(' ')[0..1].join(' ')
|
50
|
-
end
|
51
|
-
|
52
|
-
def micro_key(route)
|
53
|
-
route.split(' ')[2..3].join(' ')
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
module Fitting
|
2
|
-
class Route
|
3
|
-
class Requests
|
4
|
-
class Lists
|
5
|
-
def initialize(combine)
|
6
|
-
@full_cover = combine.full_cover
|
7
|
-
@partial_cover = combine.partial_cover
|
8
|
-
@no_cover = combine.no_cover
|
9
|
-
@max = combine.max
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
@to_s ||=
|
14
|
-
[
|
15
|
-
list_fully_implemented,
|
16
|
-
list_partially_implemented,
|
17
|
-
list_no_implemented
|
18
|
-
].compact.join("\n\n")
|
19
|
-
end
|
20
|
-
|
21
|
-
def list_fully_implemented
|
22
|
-
return nil if fully_implemented == []
|
23
|
-
['Fully conforming requests:', fully_implemented].join("\n")
|
24
|
-
end
|
25
|
-
|
26
|
-
def list_partially_implemented
|
27
|
-
return nil if partially_implemented == []
|
28
|
-
['Partially conforming requests:', partially_implemented].join("\n")
|
29
|
-
end
|
30
|
-
|
31
|
-
def list_no_implemented
|
32
|
-
return nil if no_implemented == []
|
33
|
-
['Non-conforming requests:', no_implemented].join("\n")
|
34
|
-
end
|
35
|
-
|
36
|
-
def fully_implemented
|
37
|
-
@fully_implemented ||= stat_full_cover.sort do |first, second|
|
38
|
-
first.split("\t")[1] <=> second.split("\t")[1]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def partially_implemented
|
43
|
-
@partially_implemented ||= stat_partial_cover.sort do |first, second|
|
44
|
-
first.split("\t")[1] <=> second.split("\t")[1]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def no_implemented
|
49
|
-
@no_implemented ||= stat_no_cover.sort do |first, second|
|
50
|
-
first.split("\t")[1] <=> second.split("\t")[1]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def stat_full_cover
|
57
|
-
@full_cover.map do |response|
|
58
|
-
cover_request(response)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def stat_partial_cover
|
63
|
-
@partial_cover.map do |response|
|
64
|
-
cover_request(response)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def stat_no_cover
|
69
|
-
@no_cover.map do |response|
|
70
|
-
cover_request(response)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def cover_request(response)
|
75
|
-
"#{cover_method(response)}#{tabulation(response)}#{cover_status(response)}"
|
76
|
-
end
|
77
|
-
|
78
|
-
def cover_method(response)
|
79
|
-
response.first.to_a.first.split(' ').join("\t")
|
80
|
-
end
|
81
|
-
|
82
|
-
def tabulation(response)
|
83
|
-
"\t" * (@max - response.first.to_a.first.split(' ')[1].size / 8)
|
84
|
-
end
|
85
|
-
|
86
|
-
def cover_status(response)
|
87
|
-
response.first.to_a.last['all']
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|