fitting 2.13.0 → 2.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/fitting.gemspec +1 -1
- data/lib/fitting/cover/json_schema.rb +8 -6
- data/lib/fitting/cover/json_schema_enum.rb +8 -6
- data/lib/fitting/cover/json_schema_one_of.rb +7 -5
- data/lib/fitting/version.rb +1 -1
- data/lib/tasks/fitting.rake +93 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 483a7f1462b7204b2dbeb31d372ad2526783c775
|
4
|
+
data.tar.gz: eef485bd208b70fbe0fd10e350e3bda9e82ac084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16b2442c467a9a507262b721fe4d0528af989ae7ab9a7f8f703d740ca692aedf97c47c7cb8eec180955ade9b151c85948af723ca301dcdb73c56cf9b06e14250
|
7
|
+
data.tar.gz: 2e42661f2d0a13f794cb6c808ea5b4d6e3b7fbc8d2ae368c4948a2cfc69a7e8a398333cc8de76a3e70cc6db63bceea03f4df76b14acdc6757dc53107fc883400
|
data/CHANGELOG.md
CHANGED
data/fitting.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency 'tomograph', '~> 2.0', '>= 2.2.0'
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
25
25
|
spec.add_development_dependency 'byebug', '~> 8.2', '>= 8.2.1'
|
26
|
-
spec.add_development_dependency 'rake', '
|
26
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
|
28
28
|
spec.add_development_dependency 'rubocop', '~> 0.49.1', '>= 0.49.1'
|
29
29
|
spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
|
@@ -16,17 +16,19 @@ module Fitting
|
|
16
16
|
def inception(json_schema, combinations)
|
17
17
|
json_schema.each do |key, value|
|
18
18
|
if key == 'properties' and json_schema['required'] != value.keys
|
19
|
-
|
20
|
-
|
19
|
+
schema = json_schema.dup
|
20
|
+
one_of = schema.delete('required') || []
|
21
|
+
schema['properties'].each_key do |property|
|
21
22
|
next if one_of.include?(property)
|
22
|
-
combinations.push([
|
23
|
+
combinations.push([schema.merge('required' => one_of + [property]), "required.#{property}"])
|
23
24
|
end
|
24
25
|
elsif value.is_a?(Hash)
|
25
|
-
inception(value,
|
26
|
-
|
27
|
-
combination[0] = { key => combination[0]}
|
26
|
+
com = inception(value, [])
|
27
|
+
com.each do |combination|
|
28
|
+
combination[0] = { key => value.merge(combination[0])}
|
28
29
|
combination[1] = "#{key}.#{combination[1]}"
|
29
30
|
end
|
31
|
+
combinations += com
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -15,17 +15,19 @@ module Fitting
|
|
15
15
|
|
16
16
|
def inception(json_schema, combinations)
|
17
17
|
json_schema.each do |key, value|
|
18
|
-
if key == 'enum'
|
19
|
-
|
18
|
+
if key == 'enum' && value.size > 1
|
19
|
+
schema = json_schema.dup
|
20
|
+
one_of = schema.delete('enum')
|
20
21
|
one_of.each_index do |index|
|
21
|
-
combinations.push([
|
22
|
+
combinations.push([schema.merge('enum' => [one_of[index]]), "enum.#{one_of[index]}"])
|
22
23
|
end
|
23
24
|
elsif value.is_a?(Hash)
|
24
|
-
inception(value,
|
25
|
-
|
26
|
-
combination[0] = { key => combination[0]}
|
25
|
+
com = inception(value, [])
|
26
|
+
com.each do |combination|
|
27
|
+
combination[0] = { key => value.merge(combination[0])}
|
27
28
|
combination[1] = "#{key}.#{combination[1]}"
|
28
29
|
end
|
30
|
+
combinations += com
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -16,16 +16,18 @@ module Fitting
|
|
16
16
|
def inception(json_schema, combinations)
|
17
17
|
json_schema.each do |key, value|
|
18
18
|
if key == 'oneOf'
|
19
|
-
|
19
|
+
schema = json_schema.dup
|
20
|
+
one_of = schema.delete('oneOf')
|
20
21
|
one_of.each_index do |index|
|
21
|
-
combinations.push([
|
22
|
+
combinations.push([schema.merge('oneOf' => [one_of[index]]), "oneOf.#{index}"])
|
22
23
|
end
|
23
24
|
elsif value.is_a?(Hash)
|
24
|
-
inception(value,
|
25
|
-
|
26
|
-
combination[0] = { key => combination[0]}
|
25
|
+
com = inception(value, [])
|
26
|
+
com.each do |combination|
|
27
|
+
combination[0] = { key => value.merge(combination[0])}
|
27
28
|
combination[1] = "#{key}.#{combination[1]}"
|
28
29
|
end
|
30
|
+
combinations += com
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
data/lib/fitting/version.rb
CHANGED
data/lib/tasks/fitting.rake
CHANGED
@@ -5,8 +5,101 @@ require 'fitting/templates/realized_template'
|
|
5
5
|
require 'fitting/statistics/template_cover_error'
|
6
6
|
require 'fitting/statistics/template_cover_error_enum'
|
7
7
|
require 'fitting/statistics/template_cover_error_one_of'
|
8
|
+
require 'fitting/cover/json_schema'
|
8
9
|
|
9
10
|
namespace :fitting do
|
11
|
+
task :report do
|
12
|
+
yaml = YAML.safe_load(File.read('.fitting.yml'))
|
13
|
+
tomogram = Tomograph::Tomogram.new(
|
14
|
+
prefix: yaml['prefix'],
|
15
|
+
tomogram_json_path: yaml['tomogram_json_path']
|
16
|
+
)
|
17
|
+
tests = []
|
18
|
+
Dir['fitting_tests/*.json'].each do |file|
|
19
|
+
tests += JSON.load(File.read(file))
|
20
|
+
end
|
21
|
+
actions = tomogram.to_a
|
22
|
+
actions.map do |action|
|
23
|
+
action = action.to_hash
|
24
|
+
action["tests"] = []
|
25
|
+
end
|
26
|
+
|
27
|
+
tests.map do |test|
|
28
|
+
actions.map do |action|
|
29
|
+
if test['method'] == action.method && action.path.match(test['path'])
|
30
|
+
action.to_hash["tests"].push(test)
|
31
|
+
tests = tests - [test]
|
32
|
+
break
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
actions.map do |action|
|
39
|
+
action.to_hash["tests"].map do |test|
|
40
|
+
action.to_hash["responses"].map do |response|
|
41
|
+
if response['status'].to_s == test['response']['status'].to_s
|
42
|
+
if JSON::Validator.fully_validate(response['body'], test['response']['body']) == []
|
43
|
+
response['tests'] ||= []
|
44
|
+
response['tests'].push(test)
|
45
|
+
action.to_hash["tests"] = action.to_hash["tests"] - [test]
|
46
|
+
break
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
actions.map do |action|
|
54
|
+
action.to_hash["responses"].map do |response|
|
55
|
+
response['combination'] ||= []
|
56
|
+
combinations = Fitting::Cover::JSONSchema.new(response['body']).combi + Fitting::Cover::JSONSchemaEnum.new(response['body']).combi + Fitting::Cover::JSONSchemaOneOf.new(response['body']).combi
|
57
|
+
if combinations != []
|
58
|
+
combinations.map do |combination|
|
59
|
+
response['combination'].push(
|
60
|
+
{
|
61
|
+
'json_schema' => combination[0],
|
62
|
+
'type' => combination[1][0],
|
63
|
+
'combination' => combination[1][1],
|
64
|
+
'tests' => [],
|
65
|
+
'error' => []
|
66
|
+
}
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
actions.map do |action|
|
74
|
+
action.to_hash["responses"].map do |response|
|
75
|
+
response['tests'] ||= []
|
76
|
+
response['tests'].map do |test|
|
77
|
+
if response['combination'][0]
|
78
|
+
response['combination'].map do |combination|
|
79
|
+
begin
|
80
|
+
res = JSON::Validator.fully_validate(combination['json_schema'], test['response']['body'])
|
81
|
+
if res == []
|
82
|
+
combination['tests'].push(test)
|
83
|
+
response['tests'] = response['tests'] - [test]
|
84
|
+
next
|
85
|
+
else
|
86
|
+
combination['error'].push({test: test, error: res})
|
87
|
+
end
|
88
|
+
rescue JSON::Schema::SchemaError => error
|
89
|
+
combination['error'].push({test: test, error: error})
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
actions_test = {actions: actions, tests: tests}
|
98
|
+
|
99
|
+
makedirs('fitting')
|
100
|
+
File.open('fitting/report.json', 'w') { |file| file.write(MultiJson.dump(actions_test)) }
|
101
|
+
end
|
102
|
+
|
10
103
|
# deprecated
|
11
104
|
desc 'Fitting documentation'
|
12
105
|
task :documentation do
|
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.13.
|
4
|
+
version: 2.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- d.efimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -102,16 +102,16 @@ dependencies:
|
|
102
102
|
name: rake
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- - "
|
105
|
+
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
107
|
+
version: 12.3.3
|
108
108
|
type: :development
|
109
109
|
prerelease: false
|
110
110
|
version_requirements: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- - "
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
114
|
+
version: 12.3.3
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: rspec
|
117
117
|
requirement: !ruby/object:Gem::Requirement
|