fitting 2.12.0 → 2.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -1
  5. data/.tool-versions +1 -0
  6. data/.travis.yml +1 -1
  7. data/CHANGELOG.md +48 -0
  8. data/README.md +134 -79
  9. data/fitting.gemspec +1 -1
  10. data/lib/fitting.rb +5 -0
  11. data/lib/fitting/cover/json_schema.rb +21 -80
  12. data/lib/fitting/cover/json_schema_enum.rb +20 -70
  13. data/lib/fitting/cover/json_schema_one_of.rb +22 -14
  14. data/lib/fitting/records/spherical/requests.rb +3 -1
  15. data/lib/fitting/report/action.rb +53 -0
  16. data/lib/fitting/report/actions.rb +55 -0
  17. data/lib/fitting/report/combination.rb +37 -0
  18. data/lib/fitting/report/combinations.rb +47 -0
  19. data/lib/fitting/report/console.rb +41 -0
  20. data/lib/fitting/report/prefix.rb +53 -0
  21. data/lib/fitting/report/prefixes.rb +44 -0
  22. data/lib/fitting/report/response.rb +71 -0
  23. data/lib/fitting/report/responses.rb +48 -0
  24. data/lib/fitting/report/test.rb +61 -0
  25. data/lib/fitting/report/tests.rb +62 -0
  26. data/lib/fitting/tests.rb +0 -1
  27. data/lib/fitting/version.rb +1 -1
  28. data/lib/tasks/fitting.rake +128 -0
  29. data/lib/templates/bomboniere/.gitignore +21 -0
  30. data/lib/templates/bomboniere/.tool-versions +1 -0
  31. data/lib/templates/bomboniere/README.md +19 -0
  32. data/lib/templates/bomboniere/dist/css/app.62e086ac.css +1 -0
  33. data/lib/templates/bomboniere/dist/css/chunk-vendors.ec5f6c3f.css +1 -0
  34. data/lib/templates/bomboniere/dist/favicon.ico +0 -0
  35. data/lib/templates/bomboniere/dist/index.html +1 -0
  36. data/lib/templates/bomboniere/dist/js/app.4356d509.js +2 -0
  37. data/lib/templates/bomboniere/dist/js/app.4356d509.js.map +1 -0
  38. data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js +13 -0
  39. data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js.map +1 -0
  40. data/lib/templates/bomboniere/package-lock.json +9271 -0
  41. data/lib/templates/bomboniere/package.json +26 -0
  42. data/lib/templates/bomboniere/public/favicon.ico +0 -0
  43. data/lib/templates/bomboniere/public/index.html +17 -0
  44. data/lib/templates/bomboniere/src/App.vue +102 -0
  45. data/lib/templates/bomboniere/src/assets/logo.png +0 -0
  46. data/lib/templates/bomboniere/src/components/HelloWorld.vue +188 -0
  47. data/lib/templates/bomboniere/src/main.js +10 -0
  48. data/lib/templates/bomboniere/src/router/index.js +31 -0
  49. data/lib/templates/bomboniere/src/views/About.vue +5 -0
  50. data/lib/templates/bomboniere/src/views/Action.vue +154 -0
  51. data/lib/templates/bomboniere/src/views/Home.vue +17 -0
  52. data/lib/templates/bomboniere/vue.config.js +3 -0
  53. metadata +43 -8
@@ -0,0 +1,47 @@
1
+ module Fitting
2
+ module Report
3
+ class Combinations
4
+ def initialize(combinations)
5
+ @combinations = combinations
6
+ end
7
+
8
+ def to_a
9
+ @combinations
10
+ end
11
+
12
+ def size
13
+ @combinations.size
14
+ end
15
+
16
+ def size_with_tests
17
+ @combinations.count { |c| c.tests.size != 0 }
18
+ end
19
+
20
+ def join(tests)
21
+ tests.to_a.map do |test|
22
+ if is_there_a_suitable_combination?(test)
23
+ cram_into_the_appropriate_combinations(test)
24
+ test.mark_combination
25
+ end
26
+ end
27
+ end
28
+
29
+ def is_there_a_suitable_combination?(test)
30
+ return false if @combinations.nil?
31
+ @combinations.map do |combination|
32
+ return true if JSON::Validator.fully_validate(combination.json_schema, test.body) == []
33
+ end
34
+
35
+ false
36
+ end
37
+
38
+ def cram_into_the_appropriate_combinations(test)
39
+ @combinations.map do |combination|
40
+ if JSON::Validator.fully_validate(combination.json_schema, test.body) == []
41
+ combination.add_test(test)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,41 @@
1
+ module Fitting
2
+ module Report
3
+ class Console
4
+ def initialize(tests_without_prefixes, prefixes_details)
5
+ @tests_without_prefixes = tests_without_prefixes
6
+ @prefixes_details = prefixes_details
7
+ @good = true
8
+ @tests_without_actions = []
9
+ @tests_without_responses = []
10
+ end
11
+
12
+ def output
13
+ doc_res = @prefixes_details.inject('') do |res, prefix_details|
14
+ res += "#{prefix_details[:name]}\n"
15
+ @tests_without_actions += prefix_details[:actions][:tests_without_actions]
16
+ res += prefix_details[:actions][:actions_details].inject('') do |res_actions, action|
17
+ res_actions += "#{action[:method]}\t#{action[:path]}"
18
+ tab = "\t" * ((3 - action[:path].size / 8) + 3)
19
+ @tests_without_responses += action[:responses][:tests_without_responses]
20
+ res_actions += tab + action[:responses][:responses_details].inject('') do |res_responses, response|
21
+ @good = false if response[:combinations][:cover_percent] != '100%'
22
+ res_responses += " #{response[:combinations][:cover_percent]} #{response[:method]}"
23
+ end
24
+ res_actions += "\n"
25
+ end
26
+ end
27
+ doc_res += "\n"
28
+ doc_res += "tests_without_prefixes: #{@tests_without_prefixes.size}\n"
29
+ doc_res += "tests_without_actions: #{@tests_without_actions.size}\n"
30
+ doc_res += "tests_without_responses: #{@tests_without_responses.size}\n"
31
+ end
32
+
33
+ def good?
34
+ return false if @tests_without_prefixes.size != 0
35
+ return false if @tests_without_actions.size != 0
36
+ return false if @tests_without_responses.size != 0
37
+ @good
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,53 @@
1
+ require 'fitting/report/actions'
2
+
3
+ module Fitting
4
+ module Report
5
+ class Prefix
6
+ def initialize(name, tomogram_json_path, skip = false)
7
+ @name = name
8
+ @tomogram_json_path = tomogram_json_path
9
+ @tests = Fitting::Report::Tests.new([])
10
+ @skip = skip
11
+ unless skip
12
+ @actions = Fitting::Report::Actions.new(name, tomogram_json_path)
13
+ end
14
+ end
15
+
16
+ def name
17
+ @name
18
+ end
19
+
20
+ def tests
21
+ @tests
22
+ end
23
+
24
+ def skip?
25
+ @skip
26
+ end
27
+
28
+ def actions
29
+ @actions
30
+ end
31
+
32
+ def details
33
+ if @skip
34
+ {
35
+ name: @name,
36
+ tests_size: @tests.size,
37
+ actions: {tests_without_actions: [], actions_details: []}
38
+ }
39
+ else
40
+ {
41
+ name: @name,
42
+ tests_size: @tests.size,
43
+ actions: @actions.details(self)
44
+ }
45
+ end
46
+ end
47
+
48
+ def add_test(test)
49
+ @tests.push(test)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,44 @@
1
+ require 'fitting/report/prefix'
2
+
3
+ module Fitting
4
+ module Report
5
+ class Prefixes
6
+ def initialize(config_path)
7
+ @prefixes = []
8
+ YAML.safe_load(File.read(config_path))['prefixes'].map do |prefix|
9
+ @prefixes.push(Fitting::Report::Prefix.new(prefix['name'], prefix['tomogram_json_path'], prefix['skip']))
10
+ end
11
+ end
12
+
13
+ def is_there_a_suitable_prefix?(test_path)
14
+ @prefixes.map do |prefix|
15
+ return true if test_path[0..prefix.name.size - 1] == prefix.name
16
+ end
17
+
18
+ false
19
+ end
20
+
21
+ def cram_into_the_appropriate_prefix(test)
22
+ @prefixes.map do |prefix|
23
+ if test.path[0..prefix.name.size - 1] == prefix.name
24
+ prefix.add_test(test)
25
+ return
26
+ end
27
+ end
28
+ end
29
+
30
+ def join(tests)
31
+ tests.to_a.map do |test|
32
+ if is_there_a_suitable_prefix?(test.path)
33
+ cram_into_the_appropriate_prefix(test)
34
+ test.mark_prefix
35
+ end
36
+ end
37
+ end
38
+
39
+ def to_a
40
+ @prefixes
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,71 @@
1
+ require 'fitting/statistics/template_cover_error'
2
+ require 'fitting/statistics/template_cover_error_enum'
3
+ require 'fitting/statistics/template_cover_error_one_of'
4
+ require 'fitting/report/combinations'
5
+ require 'fitting/report/combination'
6
+
7
+ module Fitting
8
+ module Report
9
+ class Response
10
+ def initialize(response)
11
+ @response = response
12
+ @tests = Fitting::Report::Tests.new([])
13
+ @id = SecureRandom.hex
14
+ end
15
+
16
+ def status
17
+ @response['status']
18
+ end
19
+
20
+ def body
21
+ @response['body']
22
+ end
23
+
24
+ def id
25
+ @id
26
+ end
27
+
28
+ def add_test(test)
29
+ @tests.push(test)
30
+ end
31
+
32
+ def tests
33
+ @tests
34
+ end
35
+
36
+ def combinations
37
+ return @combinations if @combinations
38
+
39
+ cmbntns = []
40
+ combinations = Fitting::Cover::JSONSchema.new(body).combi + Fitting::Cover::JSONSchemaEnum.new(body).combi + Fitting::Cover::JSONSchemaOneOf.new(body).combi
41
+ if combinations != []
42
+ combinations.map do |combination|
43
+ cmbntns.push(
44
+ Fitting::Report::Combination.new(
45
+ json_schema: combination[0],
46
+ type: combination[1][0],
47
+ combination: combination[1][1]
48
+ )
49
+ )
50
+ end
51
+ end
52
+
53
+ @combinations = Fitting::Report::Combinations.new(cmbntns)
54
+ end
55
+
56
+ def cover_percent
57
+ return '0%' if @tests.size == 0
58
+ return '100%' if @combinations.size == 0
59
+ "#{(@combinations.size_with_tests + 1) * 100 / (@combinations.size + 1)}%"
60
+ end
61
+
62
+ def details
63
+ {
64
+ cover_percent: cover_percent,
65
+ tests_without_combinations: @tests.without_combinations,
66
+ combinations_details: @combinations.to_a.map { |c| {json_schema: c.id, tests_size: c.tests.size, type: c.type, name: c.name} }
67
+ }
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,48 @@
1
+ require 'fitting/report/response'
2
+
3
+ module Fitting
4
+ module Report
5
+ class Responses
6
+ def initialize(responses)
7
+ @responses = responses
8
+ @responses = []
9
+ responses.to_a.map do |response|
10
+ @responses.push(Fitting::Report::Response.new(response))
11
+ end
12
+ end
13
+
14
+ def to_a
15
+ @responses
16
+ end
17
+
18
+ def join(tests)
19
+ tests.to_a.map do |test|
20
+ if is_there_a_suitable_response?(test)
21
+ cram_into_the_appropriate_response(test)
22
+ test.mark_response
23
+ end
24
+ end
25
+ end
26
+
27
+ def is_there_a_suitable_response?(test)
28
+ return false if @responses.nil?
29
+ @responses.map do |response|
30
+ return true if response.status.to_s == test.status &&
31
+ JSON::Validator.fully_validate(response.body, test.body) == []
32
+ end
33
+
34
+ false
35
+ end
36
+
37
+ def cram_into_the_appropriate_response(test)
38
+ @responses.map do |response|
39
+ if response.status.to_s == test.status &&
40
+ JSON::Validator.fully_validate(response.body, test.body) == []
41
+ response.add_test(test)
42
+ return
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,61 @@
1
+ module Fitting
2
+ module Report
3
+ class Test
4
+ def initialize(test)
5
+ @test = test
6
+ @prefix = false
7
+ @action = false
8
+ @response = false
9
+ @combination = false
10
+ end
11
+
12
+ def path
13
+ @test['path']
14
+ end
15
+
16
+ def method
17
+ @test['method']
18
+ end
19
+
20
+ def status
21
+ @test['response']['status'].to_s
22
+ end
23
+
24
+ def body
25
+ @test['response']['body']
26
+ end
27
+
28
+ def mark_prefix
29
+ @prefix = true
30
+ end
31
+
32
+ def mark_action
33
+ @action = true
34
+ end
35
+
36
+ def mark_response
37
+ @response = true
38
+ end
39
+
40
+ def mark_combination
41
+ @combination = true
42
+ end
43
+
44
+ def is_there_a_prefix?
45
+ @prefix
46
+ end
47
+
48
+ def is_there_an_actions?
49
+ @action
50
+ end
51
+
52
+ def is_there_an_responses?
53
+ @response
54
+ end
55
+
56
+ def is_there_an_combinations?
57
+ @combination
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,62 @@
1
+ require 'fitting/report/test'
2
+
3
+ module Fitting
4
+ module Report
5
+ class Tests
6
+ def initialize(tests)
7
+ @tests = tests
8
+ end
9
+
10
+ def self.new_from_config(tests_path)
11
+ tests = []
12
+ Dir[tests_path].each do |file|
13
+ JSON.load(File.read(file)).map do |test|
14
+ tests.push(Fitting::Report::Test.new(test))
15
+ end
16
+ end
17
+ tests.sort { |a, b| b.path <=> a.path }
18
+ new(tests)
19
+ end
20
+
21
+ def without_prefixes
22
+ @tests.inject([]) do |result, test|
23
+ result.push(test.path) unless test.is_there_a_prefix?
24
+ result
25
+ end
26
+ end
27
+
28
+ def without_actions
29
+ @tests.inject([]) do |result, test|
30
+ result.push("#{test.method} #{test.path}") unless test.is_there_an_actions?
31
+ result
32
+ end
33
+ end
34
+
35
+ def without_responses
36
+ @tests.inject([]) do |result, test|
37
+ result.push("#{test.method} #{test.path}") unless test.is_there_an_responses?
38
+ result
39
+ end
40
+ end
41
+
42
+ def without_combinations
43
+ @tests.inject([]) do |result, test|
44
+ result.push(test.path) unless test.is_there_an_combinations?
45
+ result
46
+ end
47
+ end
48
+
49
+ def push(test)
50
+ @tests.push(test)
51
+ end
52
+
53
+ def size
54
+ @tests.size
55
+ end
56
+
57
+ def to_a
58
+ @tests
59
+ end
60
+ end
61
+ end
62
+ end
@@ -9,7 +9,6 @@ module Fitting
9
9
  def save
10
10
  make_dir('fitting_tests')
11
11
  array = @tested_requests.inject([]) do |res, request|
12
- next res unless request.path.to_s.start_with?(Fitting.configuration.prefix)
13
12
  res.push(request.to_spherical.to_hash)
14
13
  end
15
14
  json = JSON.dump(array)
@@ -1,3 +1,3 @@
1
1
  module Fitting
2
- VERSION = '2.12.0'.freeze
2
+ VERSION = '2.14.1'.freeze
3
3
  end