fitting 2.8.1 → 2.12.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/.gitignore +1 -0
 - data/CHANGELOG.md +33 -0
 - data/README.md +25 -4
 - data/fitting.gemspec +1 -2
 - data/lib/fitting.rb +2 -0
 - data/lib/fitting/configuration/legacy.rb +22 -5
 - data/lib/fitting/configuration/yaml.rb +28 -6
 - data/lib/fitting/cover/json_schema_one_of.rb +30 -0
 - data/lib/fitting/records/unit/json_schema.rb +26 -0
 - data/lib/fitting/statistics/cover_error.rb +2 -2
 - data/lib/fitting/statistics/cover_error_enum.rb +2 -2
 - data/lib/fitting/statistics/cover_error_one_of.rb +27 -0
 - data/lib/fitting/statistics/list.rb +2 -0
 - data/lib/fitting/statistics/measurement_cover_one_of.rb +92 -0
 - data/lib/fitting/statistics/template.rb +5 -0
 - data/lib/fitting/statistics/template_cover_error_one_of.rb +50 -0
 - data/lib/fitting/version.rb +1 -1
 - data/lib/tasks/fitting.rake +23 -2
 - metadata +10 -21
 - data/lib/fitting/cover.rb +0 -66
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8234af5ba817adef5ce3ff1bf03d4e84c7747169
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c8a247c8467765022ef0f5f2c7b58b669464cdaf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 00863f51cc9692a16ce6cb24aaf83309c4490daac1430081e45081e3c5d24dfe6dba0e17b1df659f3ee84a0b1e49ecaa8c76a1ef5bfc301a70752db6beeafe18
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fda881919cf0c1bef0ed9228a8d450e866e234da599822f843bed76a146b02ebc143d85d87bda60c294603066a98c4179f9e7dc27162f7b91489eb9d9b90563f
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,38 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Change log
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ### 2.12.0 - 2019-09-10
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * features
         
     | 
| 
      
 6 
     | 
    
         
            +
              * Add l size (for cover oneOf in json-schema) in rake tasks fitting:documentation_responses, fitting:documentation_responses_error
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ### 2.11.0 - 2019-09-09
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            * features
         
     | 
| 
      
 11 
     | 
    
         
            +
             * crafter_apib_path
         
     | 
| 
      
 12 
     | 
    
         
            +
             * drafter_4_apib_path
         
     | 
| 
      
 13 
     | 
    
         
            +
             * drafter_4_yaml_path
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            * fixes
         
     | 
| 
      
 16 
     | 
    
         
            +
              * crafter_yaml_path
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ### 2.10.0 - 2019-09-05
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            * features
         
     | 
| 
      
 21 
     | 
    
         
            +
              * add crafter_yaml_path
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ### 2.9.1 - 2019-07-15
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            * fixes
         
     | 
| 
      
 26 
     | 
    
         
            +
              * Improve gemspec
         
     | 
| 
      
 27 
     | 
    
         
            +
              * Delete experimental code with haml
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            ### 2.9.0 - 2019-07-15
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            * features
         
     | 
| 
      
 32 
     | 
    
         
            +
              * Delete old spec json
         
     | 
| 
      
 33 
     | 
    
         
            +
            * fixes
         
     | 
| 
      
 34 
     | 
    
         
            +
              * Improve gemspec
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       3 
36 
     | 
    
         
             
            ### 2.8.1 - 2018-12-18
         
     | 
| 
       4 
37 
     | 
    
         | 
| 
       5 
38 
     | 
    
         
             
            * features
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -141,9 +141,9 @@ API responses with validation errors or untested: 9 (36.00% of 25). 
     | 
|
| 
       141 
141 
     | 
    
         
             
            For details `rake fitting:documentation_responses_error[s]`
         
     | 
| 
       142 
142 
     | 
    
         | 
| 
       143 
143 
     | 
    
         
             
            ```
         
     | 
| 
       144 
     | 
    
         
            -
            request  
     | 
| 
      
 144 
     | 
    
         
            +
            request method: GET
         
     | 
| 
       145 
145 
     | 
    
         
             
            request path: /api/v1/book
         
     | 
| 
       146 
     | 
    
         
            -
            response  
     | 
| 
      
 146 
     | 
    
         
            +
            response status: 200
         
     | 
| 
       147 
147 
     | 
    
         
             
            source json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
         
     | 
| 
       148 
148 
     | 
    
         
             
            combination: ["required", "pages"]
         
     | 
| 
       149 
149 
     | 
    
         
             
            new json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
         
     | 
| 
         @@ -154,6 +154,11 @@ new json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=> 
     | 
|
| 
       154 
154 
     | 
    
         
             
            In addition to the previous comand, you will learn the coverage(enum) json-schemas with task `rake fitting:documentation_responses[m]`
         
     | 
| 
       155 
155 
     | 
    
         
             
            For details `rake fitting:documentation_responses_error[m]`
         
     | 
| 
       156 
156 
     | 
    
         | 
| 
      
 157 
     | 
    
         
            +
            ### l size
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
            In addition to the previous comand, you will learn the coverage(oneOf) json-schemas with task `rake fitting:documentation_responses[l]`
         
     | 
| 
      
 160 
     | 
    
         
            +
            For details `rake fitting:documentation_responses_error[l]`
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
       157 
162 
     | 
    
         
             
            ## Check tests cover
         
     | 
| 
       158 
163 
     | 
    
         | 
| 
       159 
164 
     | 
    
         
             
            ### xs size
         
     | 
| 
         @@ -167,11 +172,27 @@ If your project uses several prefixes, for each one you need to create a separat 
     | 
|
| 
       167 
172 
     | 
    
         | 
| 
       168 
173 
     | 
    
         
             
            ### apib_path
         
     | 
| 
       169 
174 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
            Path to API Blueprint documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
         
     | 
| 
      
 175 
     | 
    
         
            +
            Path to API Blueprint v3 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
         
     | 
| 
       171 
176 
     | 
    
         | 
| 
       172 
177 
     | 
    
         
             
            ### drafter_yaml_path
         
     | 
| 
       173 
178 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
            Path to API Blueprint documentation pre-parsed with `drafter` and saved to a YAML file.
         
     | 
| 
      
 179 
     | 
    
         
            +
            Path to API Blueprint v3 documentation pre-parsed with `drafter` and saved to a YAML file.
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
            ### drafter_4_apib_path
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
            Path to API Blueprint v4 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            ### drafter_4_yaml_path
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
            Path to API Blueprint v4 documentation pre-parsed with `drafter` and saved to a YAML file.
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
            ### crafter_apib_path
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
            Path to API Blueprint v4 documentation.
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
            ### crafter_yaml_path
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
            Path to API Blueprint v4 documentation pre-parsed with `crafter` and saved to a YAML file.
         
     | 
| 
       175 
196 
     | 
    
         | 
| 
       176 
197 
     | 
    
         
             
            ### tomogram_json_path
         
     | 
| 
       177 
198 
     | 
    
         | 
    
        data/fitting.gemspec
    CHANGED
    
    | 
         @@ -18,9 +18,8 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       18 
18 
     | 
    
         
             
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
       19 
19 
     | 
    
         
             
              spec.require_paths = ['lib']
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              spec.add_runtime_dependency 'haml'
         
     | 
| 
       22 
21 
     | 
    
         
             
              spec.add_runtime_dependency 'json-schema', '~> 2.6', '>= 2.6.2'
         
     | 
| 
       23 
     | 
    
         
            -
              spec.add_runtime_dependency 'multi_json'
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_runtime_dependency 'multi_json', '~> 1.11'
         
     | 
| 
       24 
23 
     | 
    
         
             
              spec.add_runtime_dependency 'tomograph', '~> 2.0', '>= 2.2.0'
         
     | 
| 
       25 
24 
     | 
    
         
             
              spec.add_development_dependency 'bundler', '~> 1.12'
         
     | 
| 
       26 
25 
     | 
    
         
             
              spec.add_development_dependency 'byebug', '~> 8.2', '>= 8.2.1'
         
     | 
    
        data/lib/fitting.rb
    CHANGED
    
    | 
         @@ -32,6 +32,8 @@ module Fitting 
     | 
|
| 
       32 
32 
     | 
    
         
             
                def save_test_data
         
     | 
| 
       33 
33 
     | 
    
         
             
                  responses = Fitting::Storage::Responses.new
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
      
 35 
     | 
    
         
            +
                  FileUtils.rm_r Dir.glob("fitting_tests/*"), :force => true
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       35 
37 
     | 
    
         
             
                  RSpec.configure do |config|
         
     | 
| 
       36 
38 
     | 
    
         
             
                    config.after(:each, type: :controller) do
         
     | 
| 
       37 
39 
     | 
    
         
             
                      responses.add(response, inspect)
         
     | 
| 
         @@ -5,6 +5,10 @@ module Fitting 
     | 
|
| 
       5 
5 
     | 
    
         
             
                class Legacy
         
     | 
| 
       6 
6 
     | 
    
         
             
                  attr_accessor :apib_path,
         
     | 
| 
       7 
7 
     | 
    
         
             
                                :drafter_yaml_path,
         
     | 
| 
      
 8 
     | 
    
         
            +
                                :crafter_apib_path,
         
     | 
| 
      
 9 
     | 
    
         
            +
                                :crafter_yaml_path,
         
     | 
| 
      
 10 
     | 
    
         
            +
                                :drafter_4_apib_path,
         
     | 
| 
      
 11 
     | 
    
         
            +
                                :drafter_4_yaml_path,
         
     | 
| 
       8 
12 
     | 
    
         
             
                                :strict,
         
     | 
| 
       9 
13 
     | 
    
         
             
                                :prefix,
         
     | 
| 
       10 
14 
     | 
    
         
             
                                :white_list,
         
     | 
| 
         @@ -20,11 +24,24 @@ module Fitting 
     | 
|
| 
       20 
24 
     | 
    
         
             
                  end
         
     | 
| 
       21 
25 
     | 
    
         | 
| 
       22 
26 
     | 
    
         
             
                  def tomogram
         
     | 
| 
       23 
     | 
    
         
            -
                    @tomogram ||=  
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
                    @tomogram ||= if @crafter_apib_path || @crafter_yaml_path
         
     | 
| 
      
 28 
     | 
    
         
            +
                                    Tomograph::Tomogram.new(
         
     | 
| 
      
 29 
     | 
    
         
            +
                                      prefix: @prefix,
         
     | 
| 
      
 30 
     | 
    
         
            +
                                      crafter_apib_path: @crafter_apib_path,
         
     | 
| 
      
 31 
     | 
    
         
            +
                                      crafter_yaml_path: @crafter_yaml_path
         
     | 
| 
      
 32 
     | 
    
         
            +
                                    )
         
     | 
| 
      
 33 
     | 
    
         
            +
                                  elsif @drafter_4_apib_path || @drafter_4_yaml_path
         
     | 
| 
      
 34 
     | 
    
         
            +
                                    Tomograph::Tomogram.new(
         
     | 
| 
      
 35 
     | 
    
         
            +
                                      prefix: @prefix,
         
     | 
| 
      
 36 
     | 
    
         
            +
                                      drafter_4_apib_path: @drafter_4_apib_path,
         
     | 
| 
      
 37 
     | 
    
         
            +
                                      drafter_4_yaml_path: @drafter_4_yaml_path
         
     | 
| 
      
 38 
     | 
    
         
            +
                                    )
         
     | 
| 
      
 39 
     | 
    
         
            +
                                  else Tomograph::Tomogram.new(
         
     | 
| 
      
 40 
     | 
    
         
            +
                                    prefix: @prefix,
         
     | 
| 
      
 41 
     | 
    
         
            +
                                    apib_path: @apib_path,
         
     | 
| 
      
 42 
     | 
    
         
            +
                                    drafter_yaml_path: @drafter_yaml_path
         
     | 
| 
      
 43 
     | 
    
         
            +
                                  )
         
     | 
| 
      
 44 
     | 
    
         
            +
                                  end
         
     | 
| 
       28 
45 
     | 
    
         
             
                  end
         
     | 
| 
       29 
46 
     | 
    
         | 
| 
       30 
47 
     | 
    
         
             
                  def title
         
     | 
| 
         @@ -6,6 +6,10 @@ module Fitting 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  attr_reader   :title
         
     | 
| 
       7 
7 
     | 
    
         
             
                  attr_accessor :apib_path,
         
     | 
| 
       8 
8 
     | 
    
         
             
                                :drafter_yaml_path,
         
     | 
| 
      
 9 
     | 
    
         
            +
                                :crafter_apib_path,
         
     | 
| 
      
 10 
     | 
    
         
            +
                                :crafter_yaml_path,
         
     | 
| 
      
 11 
     | 
    
         
            +
                                :drafter_4_apib_path,
         
     | 
| 
      
 12 
     | 
    
         
            +
                                :drafter_4_yaml_path,
         
     | 
| 
       9 
13 
     | 
    
         
             
                                :tomogram_json_path,
         
     | 
| 
       10 
14 
     | 
    
         
             
                                :strict,
         
     | 
| 
       11 
15 
     | 
    
         
             
                                :prefix,
         
     | 
| 
         @@ -18,6 +22,10 @@ module Fitting 
     | 
|
| 
       18 
22 
     | 
    
         
             
                  def initialize(yaml, title = 'fitting')
         
     | 
| 
       19 
23 
     | 
    
         
             
                    @apib_path = yaml['apib_path']
         
     | 
| 
       20 
24 
     | 
    
         
             
                    @drafter_yaml_path = yaml['drafter_yaml_path']
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @crafter_apib_path = yaml['crafter_apib_path']
         
     | 
| 
      
 26 
     | 
    
         
            +
                    @crafter_yaml_path = yaml['crafter_yaml_path']
         
     | 
| 
      
 27 
     | 
    
         
            +
                    @drafter_4_apib_path = yaml['drafter_4_apib_path']
         
     | 
| 
      
 28 
     | 
    
         
            +
                    @drafter_4_yaml_path = yaml['drafter_4_yaml_path']
         
     | 
| 
       21 
29 
     | 
    
         
             
                    @tomogram_json_path = yaml['tomogram_json_path']
         
     | 
| 
       22 
30 
     | 
    
         
             
                    @strict = yaml['strict']
         
     | 
| 
       23 
31 
     | 
    
         
             
                    @prefix = yaml['prefix']
         
     | 
| 
         @@ -31,12 +39,26 @@ module Fitting 
     | 
|
| 
       31 
39 
     | 
    
         
             
                  end
         
     | 
| 
       32 
40 
     | 
    
         | 
| 
       33 
41 
     | 
    
         
             
                  def tomogram
         
     | 
| 
       34 
     | 
    
         
            -
                    @tomogram ||=  
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
                    @tomogram ||= if @crafter_yaml_path || @crafter_apib_path
         
     | 
| 
      
 43 
     | 
    
         
            +
                                    Tomograph::Tomogram.new(
         
     | 
| 
      
 44 
     | 
    
         
            +
                                      prefix: @prefix,
         
     | 
| 
      
 45 
     | 
    
         
            +
                                      crafter_apib_path: @crafter_apib_path,
         
     | 
| 
      
 46 
     | 
    
         
            +
                                      crafter_yaml_path: @crafter_yaml_path,
         
     | 
| 
      
 47 
     | 
    
         
            +
                                    )
         
     | 
| 
      
 48 
     | 
    
         
            +
                                  elsif @drafter_4_apib_path || @drafter_4_yaml_path
         
     | 
| 
      
 49 
     | 
    
         
            +
                                    Tomograph::Tomogram.new(
         
     | 
| 
      
 50 
     | 
    
         
            +
                                      prefix: @prefix,
         
     | 
| 
      
 51 
     | 
    
         
            +
                                      drafter_4_apib_path: @drafter_4_apib_path,
         
     | 
| 
      
 52 
     | 
    
         
            +
                                      drafter_4_yaml_path: @drafter_4_yaml_path,
         
     | 
| 
      
 53 
     | 
    
         
            +
                                    )
         
     | 
| 
      
 54 
     | 
    
         
            +
                                  else
         
     | 
| 
      
 55 
     | 
    
         
            +
                                    Tomograph::Tomogram.new(
         
     | 
| 
      
 56 
     | 
    
         
            +
                                      prefix: @prefix,
         
     | 
| 
      
 57 
     | 
    
         
            +
                                      apib_path: @apib_path,
         
     | 
| 
      
 58 
     | 
    
         
            +
                                      drafter_yaml_path: @drafter_yaml_path,
         
     | 
| 
      
 59 
     | 
    
         
            +
                                      tomogram_json_path: @tomogram_json_path
         
     | 
| 
      
 60 
     | 
    
         
            +
                                    )
         
     | 
| 
      
 61 
     | 
    
         
            +
                                  end
         
     | 
| 
       40 
62 
     | 
    
         
             
                  end
         
     | 
| 
       41 
63 
     | 
    
         | 
| 
       42 
64 
     | 
    
         
             
                  def stats_path
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Fitting
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Cover
         
     | 
| 
      
 3 
     | 
    
         
            +
                class JSONSchemaOneOf
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def initialize(json_schema)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    @json_schema = json_schema
         
     | 
| 
      
 6 
     | 
    
         
            +
                  end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  def combi
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @combinations = []
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    return @combinations unless @json_schema['oneOf'] || @json_schema['allOf']
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    if @json_schema['oneOf']
         
     | 
| 
      
 14 
     | 
    
         
            +
                      one_of = @json_schema.delete("oneOf")
         
     | 
| 
      
 15 
     | 
    
         
            +
                      one_of.each_index do |index|
         
     | 
| 
      
 16 
     | 
    
         
            +
                        @combinations.push([@json_schema.merge(one_of[index]), ['one_of', "properties.#{index}"]])
         
     | 
| 
      
 17 
     | 
    
         
            +
                      end
         
     | 
| 
      
 18 
     | 
    
         
            +
                    elsif @json_schema['allOf']
         
     | 
| 
      
 19 
     | 
    
         
            +
                      all_of = @json_schema.delete("allOf")
         
     | 
| 
      
 20 
     | 
    
         
            +
                      one_of = all_of[0].delete("oneOf")
         
     | 
| 
      
 21 
     | 
    
         
            +
                      one_of.each_index do |index|
         
     | 
| 
      
 22 
     | 
    
         
            +
                        @combinations.push([@json_schema.merge(one_of[index]), ['one_of', "properties.#{index}"]])
         
     | 
| 
      
 23 
     | 
    
         
            +
                      end
         
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    @combinations
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'json-schema'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'fitting/cover/json_schema'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'fitting/cover/json_schema_enum'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'fitting/cover/json_schema_one_of'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require 'fitting/records/unit/combination'
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            module Fitting
         
     | 
| 
         @@ -51,6 +52,19 @@ module Fitting 
     | 
|
| 
       51 
52 
     | 
    
         
             
                      @combinations_with_enum
         
     | 
| 
       52 
53 
     | 
    
         
             
                    end
         
     | 
| 
       53 
54 
     | 
    
         | 
| 
      
 55 
     | 
    
         
            +
                    def combinations_with_one_of
         
     | 
| 
      
 56 
     | 
    
         
            +
                      return @combinations_with_one_of if @combinations_with_one_of
         
     | 
| 
      
 57 
     | 
    
         
            +
                      @combinations_with_one_of = []
         
     | 
| 
      
 58 
     | 
    
         
            +
                      qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi + Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi + Fitting::Cover::JSONSchemaOneOf.new(@json_schema).combi
         
     | 
| 
      
 59 
     | 
    
         
            +
                      qwe.map do |comb|
         
     | 
| 
      
 60 
     | 
    
         
            +
                        @combinations_with_one_of.push(Fitting::Records::Unit::Combination.new(
         
     | 
| 
      
 61 
     | 
    
         
            +
                          comb,
         
     | 
| 
      
 62 
     | 
    
         
            +
                          bodies
         
     | 
| 
      
 63 
     | 
    
         
            +
                        ))
         
     | 
| 
      
 64 
     | 
    
         
            +
                      end
         
     | 
| 
      
 65 
     | 
    
         
            +
                      @combinations_with_one_of
         
     | 
| 
      
 66 
     | 
    
         
            +
                    end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
       54 
68 
     | 
    
         
             
                    def cover
         
     | 
| 
       55 
69 
     | 
    
         
             
                      @cover ||= if bodies == []
         
     | 
| 
       56 
70 
     | 
    
         
             
                                   0
         
     | 
| 
         @@ -74,6 +88,18 @@ module Fitting 
     | 
|
| 
       74 
88 
     | 
    
         
             
                        (count + 1) * 100 / (combinations_with_enum.size + 1)
         
     | 
| 
       75 
89 
     | 
    
         
             
                      end
         
     | 
| 
       76 
90 
     | 
    
         
             
                    end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                    def cover_one_of
         
     | 
| 
      
 93 
     | 
    
         
            +
                      @cover_one_of ||= if bodies == []
         
     | 
| 
      
 94 
     | 
    
         
            +
                        0
         
     | 
| 
      
 95 
     | 
    
         
            +
                      else
         
     | 
| 
      
 96 
     | 
    
         
            +
                        count = 0
         
     | 
| 
      
 97 
     | 
    
         
            +
                        combinations_with_one_of.map do |combination|
         
     | 
| 
      
 98 
     | 
    
         
            +
                          count += 1 unless combination.valid_bodies == []
         
     | 
| 
      
 99 
     | 
    
         
            +
                        end
         
     | 
| 
      
 100 
     | 
    
         
            +
                        (count + 1) * 100 / (combinations_with_one_of.size + 1)
         
     | 
| 
      
 101 
     | 
    
         
            +
                      end
         
     | 
| 
      
 102 
     | 
    
         
            +
                    end
         
     | 
| 
       77 
103 
     | 
    
         
             
                  end
         
     | 
| 
       78 
104 
     | 
    
         
             
                end
         
     | 
| 
       79 
105 
     | 
    
         
             
              end
         
     | 
| 
         @@ -13,8 +13,8 @@ module Fitting 
     | 
|
| 
       13 
13 
     | 
    
         
             
                        response.json_schemas.map do |json_schema|
         
     | 
| 
       14 
14 
     | 
    
         
             
                          json_schema.combinations.map do |combination|
         
     | 
| 
       15 
15 
     | 
    
         
             
                            next unless combination.valid_bodies == []
         
     | 
| 
       16 
     | 
    
         
            -
                            res += "request  
     | 
| 
       17 
     | 
    
         
            -
                                    "response  
     | 
| 
      
 16 
     | 
    
         
            +
                            res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
         
     | 
| 
      
 17 
     | 
    
         
            +
                                    "response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
         
     | 
| 
       18 
18 
     | 
    
         
             
                                   "combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
         
     | 
| 
       19 
19 
     | 
    
         
             
                          end
         
     | 
| 
       20 
20 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -13,8 +13,8 @@ module Fitting 
     | 
|
| 
       13 
13 
     | 
    
         
             
                        response.json_schemas.map do |json_schema|
         
     | 
| 
       14 
14 
     | 
    
         
             
                          json_schema.combinations_with_enum.map do |combination|
         
     | 
| 
       15 
15 
     | 
    
         
             
                            next unless combination.valid_bodies == []
         
     | 
| 
       16 
     | 
    
         
            -
                            res += "request  
     | 
| 
       17 
     | 
    
         
            -
                                    "response  
     | 
| 
      
 16 
     | 
    
         
            +
                            res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
         
     | 
| 
      
 17 
     | 
    
         
            +
                                    "response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
         
     | 
| 
       18 
18 
     | 
    
         
             
                                   "combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
         
     | 
| 
       19 
19 
     | 
    
         
             
                          end
         
     | 
| 
       20 
20 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Fitting
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Statistics
         
     | 
| 
      
 3 
     | 
    
         
            +
                class CoverErrorOneOf
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def initialize(request_unit)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    @request_unit = request_unit
         
     | 
| 
      
 6 
     | 
    
         
            +
                  end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 9 
     | 
    
         
            +
                    res = ''
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @request_unit.map do |request|
         
     | 
| 
      
 11 
     | 
    
         
            +
                      request.responses.map do |response|
         
     | 
| 
      
 12 
     | 
    
         
            +
                        next unless response.tested_bodies != []
         
     | 
| 
      
 13 
     | 
    
         
            +
                        response.json_schemas.map do |json_schema|
         
     | 
| 
      
 14 
     | 
    
         
            +
                          json_schema.combinations_with_one_of.map do |combination|
         
     | 
| 
      
 15 
     | 
    
         
            +
                            next unless combination.valid_bodies == []
         
     | 
| 
      
 16 
     | 
    
         
            +
                            res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
         
     | 
| 
      
 17 
     | 
    
         
            +
                                    "response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
         
     | 
| 
      
 18 
     | 
    
         
            +
                                   "combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
         
     | 
| 
      
 19 
     | 
    
         
            +
                          end
         
     | 
| 
      
 20 
     | 
    
         
            +
                        end
         
     | 
| 
      
 21 
     | 
    
         
            +
                      end
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                    res
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -45,6 +45,8 @@ module Fitting 
     | 
|
| 
       45 
45 
     | 
    
         
             
                      res.push("#{json_schema.cover}% #{response.status}")
         
     | 
| 
       46 
46 
     | 
    
         
             
                    elsif @depth == 'cover_enum'
         
     | 
| 
       47 
47 
     | 
    
         
             
                      res.push("#{json_schema.cover_enum}% #{response.status}")
         
     | 
| 
      
 48 
     | 
    
         
            +
                    elsif @depth == 'cover_one_of'
         
     | 
| 
      
 49 
     | 
    
         
            +
                      res.push("#{json_schema.cover_one_of}% #{response.status}")
         
     | 
| 
       48 
50 
     | 
    
         
             
                    end
         
     | 
| 
       49 
51 
     | 
    
         
             
                  end
         
     | 
| 
       50 
52 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,92 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Fitting
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Statistics
         
     | 
| 
      
 3 
     | 
    
         
            +
                class MeasurementCoverOneOf
         
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_reader :requests, :all_responses, :cover_responses, :not_cover_responses, :max_response_path,
         
     | 
| 
      
 5 
     | 
    
         
            +
                              :coverage_fully, :coverage_non, :coverage_partially, :not_covered_responses
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                  def initialize(requests)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @requests = requests
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @all_responses = 0
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @cover_responses = 0
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @not_cover_responses = 0
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @max_response_path = 0
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @coverage_fully = []
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @coverage_non = []
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @coverage_partially = []
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @not_covered_responses = []
         
     | 
| 
      
 17 
     | 
    
         
            +
                    check_responses
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def check_responses
         
     | 
| 
      
 21 
     | 
    
         
            +
                    return if @ready
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    @requests.map do |request|
         
     | 
| 
      
 24 
     | 
    
         
            +
                      chech_request(request)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    @ready = true
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  private
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def chech_request(request)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    check_cover(request)
         
     | 
| 
      
 34 
     | 
    
         
            +
                    coverage_push(request)
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    @max_response_path = request.path.to_s.size / 8 if request.path.to_s.size / 8 > @max_response_path
         
     | 
| 
      
 37 
     | 
    
         
            +
                    request.responses.map do |response|
         
     | 
| 
      
 38 
     | 
    
         
            +
                      check_response(response, request)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  def check_response(response, request)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    json_schema_index = 0
         
     | 
| 
      
 44 
     | 
    
         
            +
                    response.json_schemas.map do |json_schema|
         
     | 
| 
      
 45 
     | 
    
         
            +
                      json_schema_index = check_json_schema(json_schema, request, response, json_schema_index)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  def check_json_schema(json_schema, request, response, json_schema_index)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    if json_schema.cover_one_of != 100
         
     | 
| 
      
 51 
     | 
    
         
            +
                      @not_cover_responses += 1
         
     | 
| 
      
 52 
     | 
    
         
            +
                      @not_covered_responses.push("#{request.method}\t#{request.path} #{response.status} #{json_schema_index}")
         
     | 
| 
      
 53 
     | 
    
         
            +
                    else
         
     | 
| 
      
 54 
     | 
    
         
            +
                      @cover_responses += 1
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
      
 56 
     | 
    
         
            +
                    @all_responses += 1
         
     | 
| 
      
 57 
     | 
    
         
            +
                    json_schema_index + 1
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  def coverage_push(request)
         
     | 
| 
      
 61 
     | 
    
         
            +
                    if @all == @cover
         
     | 
| 
      
 62 
     | 
    
         
            +
                      @coverage_fully.push(request)
         
     | 
| 
      
 63 
     | 
    
         
            +
                    elsif @all == @not_cover
         
     | 
| 
      
 64 
     | 
    
         
            +
                      @coverage_non.push(request)
         
     | 
| 
      
 65 
     | 
    
         
            +
                    else
         
     | 
| 
      
 66 
     | 
    
         
            +
                      @coverage_partially.push(request)
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                  def check_cover(request)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    @all = 0
         
     | 
| 
      
 72 
     | 
    
         
            +
                    @cover = 0
         
     | 
| 
      
 73 
     | 
    
         
            +
                    @not_cover = 0
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                    request.responses.map do |response|
         
     | 
| 
      
 76 
     | 
    
         
            +
                      response.json_schemas.map do |json_schema|
         
     | 
| 
      
 77 
     | 
    
         
            +
                        count_cover(json_schema)
         
     | 
| 
      
 78 
     | 
    
         
            +
                      end
         
     | 
| 
      
 79 
     | 
    
         
            +
                    end
         
     | 
| 
      
 80 
     | 
    
         
            +
                  end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                  def count_cover(json_schema)
         
     | 
| 
      
 83 
     | 
    
         
            +
                    @all += 1
         
     | 
| 
      
 84 
     | 
    
         
            +
                    if json_schema.cover_one_of != 100
         
     | 
| 
      
 85 
     | 
    
         
            +
                      @not_cover += 1
         
     | 
| 
      
 86 
     | 
    
         
            +
                    else
         
     | 
| 
      
 87 
     | 
    
         
            +
                      @cover += 1
         
     | 
| 
      
 88 
     | 
    
         
            +
                    end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  end
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
      
 92 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -3,6 +3,7 @@ require 'fitting/statistics/analysis' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'fitting/statistics/measurement'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'fitting/statistics/measurement_cover'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'fitting/statistics/measurement_cover_enum'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'fitting/statistics/measurement_cover_one_of'
         
     | 
| 
       6 
7 
     | 
    
         
             
            require 'fitting/records/unit/request'
         
     | 
| 
       7 
8 
     | 
    
         
             
            require 'fitting/storage/white_list'
         
     | 
| 
       8 
9 
     | 
    
         
             
            require 'fitting/records/documented/request'
         
     | 
| 
         @@ -53,6 +54,8 @@ module Fitting 
     | 
|
| 
       53 
54 
     | 
    
         
             
                        Fitting::Statistics::MeasurementCover.new(white_unit)
         
     | 
| 
       54 
55 
     | 
    
         
             
                      elsif @depth == 'cover_enum'
         
     | 
| 
       55 
56 
     | 
    
         
             
                        Fitting::Statistics::MeasurementCoverEnum.new(white_unit)
         
     | 
| 
      
 57 
     | 
    
         
            +
                      elsif @depth == 'cover_one_of'
         
     | 
| 
      
 58 
     | 
    
         
            +
                        Fitting::Statistics::MeasurementCoverOneOf.new(white_unit)
         
     | 
| 
       56 
59 
     | 
    
         
             
                      end
         
     | 
| 
       57 
60 
     | 
    
         
             
                  end
         
     | 
| 
       58 
61 
     | 
    
         | 
| 
         @@ -64,6 +67,8 @@ module Fitting 
     | 
|
| 
       64 
67 
     | 
    
         
             
                        Fitting::Statistics::MeasurementCover.new(black_unit)
         
     | 
| 
       65 
68 
     | 
    
         
             
                      elsif @depth == 'cover_enum'
         
     | 
| 
       66 
69 
     | 
    
         
             
                        Fitting::Statistics::MeasurementCoverEnum.new(black_unit)
         
     | 
| 
      
 70 
     | 
    
         
            +
                      elsif @depth == 'cover_one_of'
         
     | 
| 
      
 71 
     | 
    
         
            +
                        Fitting::Statistics::MeasurementCoverOneOf.new(black_unit)
         
     | 
| 
       67 
72 
     | 
    
         
             
                      end
         
     | 
| 
       68 
73 
     | 
    
         
             
                  end
         
     | 
| 
       69 
74 
     | 
    
         | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'fitting/statistics/cover_error_one_of'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'fitting/records/unit/request'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'fitting/storage/white_list'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'fitting/records/documented/request'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Fitting
         
     | 
| 
      
 7 
     | 
    
         
            +
              class Statistics
         
     | 
| 
      
 8 
     | 
    
         
            +
                class TemplateCoverErrorOneOf
         
     | 
| 
      
 9 
     | 
    
         
            +
                  def initialize(tested_requests, config)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @tested_requests = tested_requests
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @config = config
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def stats
         
     | 
| 
      
 15 
     | 
    
         
            +
                    "#{white_statistics}\n\n"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def white_statistics
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @white_statistics ||= Fitting::Statistics::CoverErrorOneOf.new(white_unit)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def white_unit
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @white_unit_requests ||= documented_requests_white.inject([]) do |res, documented_request|
         
     | 
| 
      
 24 
     | 
    
         
            +
                      res.push(Fitting::Records::Unit::Request.new(documented_request, @tested_requests))
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def documented_requests_white
         
     | 
| 
      
 29 
     | 
    
         
            +
                    @documented_requests_white ||= documented.find_all(&:white)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def documented
         
     | 
| 
      
 33 
     | 
    
         
            +
                    @documented_requests ||= @config.tomogram.to_a.inject([]) do |res, tomogram_request|
         
     | 
| 
      
 34 
     | 
    
         
            +
                      res.push(Fitting::Records::Documented::Request.new(tomogram_request, white_list.to_a))
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  def white_list
         
     | 
| 
      
 39 
     | 
    
         
            +
                    @white_list ||= Fitting::Storage::WhiteList.new(
         
     | 
| 
      
 40 
     | 
    
         
            +
                      @config.prefix,
         
     | 
| 
      
 41 
     | 
    
         
            +
                      @config.white_list,
         
     | 
| 
      
 42 
     | 
    
         
            +
                      @config.resource_white_list,
         
     | 
| 
      
 43 
     | 
    
         
            +
                      @config.include_resources,
         
     | 
| 
      
 44 
     | 
    
         
            +
                      @config.include_actions,
         
     | 
| 
      
 45 
     | 
    
         
            +
                      @config.tomogram.to_resources
         
     | 
| 
      
 46 
     | 
    
         
            +
                    )
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/fitting/version.rb
    CHANGED
    
    
    
        data/lib/tasks/fitting.rake
    CHANGED
    
    | 
         @@ -4,8 +4,10 @@ require 'fitting/records/realized_unit' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require 'fitting/templates/realized_template'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'fitting/statistics/template_cover_error'
         
     | 
| 
       6 
6 
     | 
    
         
             
            require 'fitting/statistics/template_cover_error_enum'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'fitting/statistics/template_cover_error_one_of'
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
9 
     | 
    
         
             
            namespace :fitting do
         
     | 
| 
      
 10 
     | 
    
         
            +
              # deprecated
         
     | 
| 
       9 
11 
     | 
    
         
             
              desc 'Fitting documentation'
         
     | 
| 
       10 
12 
     | 
    
         
             
              task :documentation do
         
     | 
| 
       11 
13 
     | 
    
         
             
                documented_unit = Fitting::Statistics::Template.new(
         
     | 
| 
         @@ -53,12 +55,24 @@ namespace :fitting do 
     | 
|
| 
       53 
55 
     | 
    
         
             
                  )
         
     | 
| 
       54 
56 
     | 
    
         
             
                  puts documented_unit.stats
         
     | 
| 
       55 
57 
     | 
    
         | 
| 
      
 58 
     | 
    
         
            +
                  unless documented_unit.not_covered == "\n"
         
     | 
| 
      
 59 
     | 
    
         
            +
                    puts 'Not all responses from the whitelist are covered!'
         
     | 
| 
      
 60 
     | 
    
         
            +
                    exit 1
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
                elsif args.size == 'l'
         
     | 
| 
      
 63 
     | 
    
         
            +
                  documented_unit = Fitting::Statistics::Template.new(
         
     | 
| 
      
 64 
     | 
    
         
            +
                    Fitting::Records::Spherical::Requests.new,
         
     | 
| 
      
 65 
     | 
    
         
            +
                    Fitting.configuration,
         
     | 
| 
      
 66 
     | 
    
         
            +
                    'cover_one_of'
         
     | 
| 
      
 67 
     | 
    
         
            +
                  )
         
     | 
| 
      
 68 
     | 
    
         
            +
                  puts documented_unit.stats
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
       56 
70 
     | 
    
         
             
                  unless documented_unit.not_covered == "\n"
         
     | 
| 
       57 
71 
     | 
    
         
             
                    puts 'Not all responses from the whitelist are covered!'
         
     | 
| 
       58 
72 
     | 
    
         
             
                    exit 1
         
     | 
| 
       59 
73 
     | 
    
         
             
                  end
         
     | 
| 
       60 
74 
     | 
    
         
             
                else
         
     | 
| 
       61 
     | 
    
         
            -
                  puts 'need key xs, s or  
     | 
| 
      
 75 
     | 
    
         
            +
                  puts 'need key xs, s, m or l'
         
     | 
| 
       62 
76 
     | 
    
         
             
                end
         
     | 
| 
       63 
77 
     | 
    
         
             
              end
         
     | 
| 
       64 
78 
     | 
    
         | 
| 
         @@ -76,11 +90,18 @@ namespace :fitting do 
     | 
|
| 
       76 
90 
     | 
    
         
             
                    Fitting.configuration
         
     | 
| 
       77 
91 
     | 
    
         
             
                  )
         
     | 
| 
       78 
92 
     | 
    
         
             
                  puts documented_unit.stats
         
     | 
| 
      
 93 
     | 
    
         
            +
                elsif args.size == 'l'
         
     | 
| 
      
 94 
     | 
    
         
            +
                  documented_unit = Fitting::Statistics::TemplateCoverErrorOneOf.new(
         
     | 
| 
      
 95 
     | 
    
         
            +
                    Fitting::Records::Spherical::Requests.new,
         
     | 
| 
      
 96 
     | 
    
         
            +
                    Fitting.configuration
         
     | 
| 
      
 97 
     | 
    
         
            +
                  )
         
     | 
| 
      
 98 
     | 
    
         
            +
                  puts documented_unit.stats
         
     | 
| 
       79 
99 
     | 
    
         
             
                else
         
     | 
| 
       80 
     | 
    
         
            -
                  puts 'need key s or  
     | 
| 
      
 100 
     | 
    
         
            +
                  puts 'need key s, m or l'
         
     | 
| 
       81 
101 
     | 
    
         
             
                end
         
     | 
| 
       82 
102 
     | 
    
         
             
              end
         
     | 
| 
       83 
103 
     | 
    
         | 
| 
      
 104 
     | 
    
         
            +
              # deprecated
         
     | 
| 
       84 
105 
     | 
    
         
             
              desc 'Fitting tests'
         
     | 
| 
       85 
106 
     | 
    
         
             
              task :tests do
         
     | 
| 
       86 
107 
     | 
    
         
             
                realized_unit = Fitting::Records::RealizedUnit.new(
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,29 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: fitting
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.12.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:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-09-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
     | 
    
         
            -
              name: haml
         
     | 
| 
       15 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
     | 
    
         
            -
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       18 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       20 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       21 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       22 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
     | 
    
         
            -
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       25 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       27 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
14 
     | 
    
         
             
              name: json-schema
         
     | 
| 
       29 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -48,16 +34,16 @@ dependencies: 
     | 
|
| 
       48 
34 
     | 
    
         
             
              name: multi_json
         
     | 
| 
       49 
35 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       50 
36 
     | 
    
         
             
                requirements:
         
     | 
| 
       51 
     | 
    
         
            -
                - - " 
     | 
| 
      
 37 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       52 
38 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       53 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 39 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
       54 
40 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       55 
41 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       56 
42 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       57 
43 
     | 
    
         
             
                requirements:
         
     | 
| 
       58 
     | 
    
         
            -
                - - " 
     | 
| 
      
 44 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       59 
45 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       60 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 46 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
       61 
47 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       62 
48 
     | 
    
         
             
              name: tomograph
         
     | 
| 
       63 
49 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -210,9 +196,9 @@ files: 
     | 
|
| 
       210 
196 
     | 
    
         
             
            - lib/fitting/configuration.rb
         
     | 
| 
       211 
197 
     | 
    
         
             
            - lib/fitting/configuration/legacy.rb
         
     | 
| 
       212 
198 
     | 
    
         
             
            - lib/fitting/configuration/yaml.rb
         
     | 
| 
       213 
     | 
    
         
            -
            - lib/fitting/cover.rb
         
     | 
| 
       214 
199 
     | 
    
         
             
            - lib/fitting/cover/json_schema.rb
         
     | 
| 
       215 
200 
     | 
    
         
             
            - lib/fitting/cover/json_schema_enum.rb
         
     | 
| 
      
 201 
     | 
    
         
            +
            - lib/fitting/cover/json_schema_one_of.rb
         
     | 
| 
       216 
202 
     | 
    
         
             
            - lib/fitting/cover/response.rb
         
     | 
| 
       217 
203 
     | 
    
         
             
            - lib/fitting/documentation.rb
         
     | 
| 
       218 
204 
     | 
    
         
             
            - lib/fitting/matchers/response_matcher.rb
         
     | 
| 
         @@ -236,12 +222,14 @@ files: 
     | 
|
| 
       236 
222 
     | 
    
         
             
            - lib/fitting/statistics/analysis.rb
         
     | 
| 
       237 
223 
     | 
    
         
             
            - lib/fitting/statistics/cover_error.rb
         
     | 
| 
       238 
224 
     | 
    
         
             
            - lib/fitting/statistics/cover_error_enum.rb
         
     | 
| 
      
 225 
     | 
    
         
            +
            - lib/fitting/statistics/cover_error_one_of.rb
         
     | 
| 
       239 
226 
     | 
    
         
             
            - lib/fitting/statistics/great.rb
         
     | 
| 
       240 
227 
     | 
    
         
             
            - lib/fitting/statistics/list.rb
         
     | 
| 
       241 
228 
     | 
    
         
             
            - lib/fitting/statistics/lists.rb
         
     | 
| 
       242 
229 
     | 
    
         
             
            - lib/fitting/statistics/measurement.rb
         
     | 
| 
       243 
230 
     | 
    
         
             
            - lib/fitting/statistics/measurement_cover.rb
         
     | 
| 
       244 
231 
     | 
    
         
             
            - lib/fitting/statistics/measurement_cover_enum.rb
         
     | 
| 
      
 232 
     | 
    
         
            +
            - lib/fitting/statistics/measurement_cover_one_of.rb
         
     | 
| 
       245 
233 
     | 
    
         
             
            - lib/fitting/statistics/not_covered_responses.rb
         
     | 
| 
       246 
234 
     | 
    
         
             
            - lib/fitting/statistics/percent.rb
         
     | 
| 
       247 
235 
     | 
    
         
             
            - lib/fitting/statistics/requests_stats.rb
         
     | 
| 
         @@ -249,6 +237,7 @@ files: 
     | 
|
| 
       249 
237 
     | 
    
         
             
            - lib/fitting/statistics/template.rb
         
     | 
| 
       250 
238 
     | 
    
         
             
            - lib/fitting/statistics/template_cover_error.rb
         
     | 
| 
       251 
239 
     | 
    
         
             
            - lib/fitting/statistics/template_cover_error_enum.rb
         
     | 
| 
      
 240 
     | 
    
         
            +
            - lib/fitting/statistics/template_cover_error_one_of.rb
         
     | 
| 
       252 
241 
     | 
    
         
             
            - lib/fitting/storage/responses.rb
         
     | 
| 
       253 
242 
     | 
    
         
             
            - lib/fitting/storage/white_list.rb
         
     | 
| 
       254 
243 
     | 
    
         
             
            - lib/fitting/templates/realized_template.rb
         
     | 
    
        data/lib/fitting/cover.rb
    DELETED
    
    | 
         @@ -1,66 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'fitting/cover/response'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'haml'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'json'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            module Fitting
         
     | 
| 
       6 
     | 
    
         
            -
              class Cover
         
     | 
| 
       7 
     | 
    
         
            -
                def initialize(all_responses, coverage)
         
     | 
| 
       8 
     | 
    
         
            -
                  @all_responses = all_responses
         
     | 
| 
       9 
     | 
    
         
            -
                  @coverage = coverage
         
     | 
| 
       10 
     | 
    
         
            -
                  @list = {}
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                def to_hash
         
     | 
| 
       14 
     | 
    
         
            -
                  return @list unless @list == {}
         
     | 
| 
       15 
     | 
    
         
            -
                  @all_responses.each_with_object({}) do |response, res|
         
     | 
| 
       16 
     | 
    
         
            -
                    next res unless response.documented?
         
     | 
| 
       17 
     | 
    
         
            -
                    if res.key?(response.route)
         
     | 
| 
       18 
     | 
    
         
            -
                      res[response.route].update(response)
         
     | 
| 
       19 
     | 
    
         
            -
                    else
         
     | 
| 
       20 
     | 
    
         
            -
                      res[response.route] = Fitting::Cover::Response.new(response)
         
     | 
| 
       21 
     | 
    
         
            -
                    end
         
     | 
| 
       22 
     | 
    
         
            -
                  end.map do |key, value|
         
     | 
| 
       23 
     | 
    
         
            -
                    @list[key] = value.to_hash
         
     | 
| 
       24 
     | 
    
         
            -
                  end
         
     | 
| 
       25 
     | 
    
         
            -
                  @list
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                def template
         
     | 
| 
       29 
     | 
    
         
            -
                  return @template if @template
         
     | 
| 
       30 
     | 
    
         
            -
                  @template = {}
         
     | 
| 
       31 
     | 
    
         
            -
                  to_hash.each do |key, value|
         
     | 
| 
       32 
     | 
    
         
            -
                    @template[key] = value
         
     | 
| 
       33 
     | 
    
         
            -
                    @template[key]['cover'] = 100.0
         
     | 
| 
       34 
     | 
    
         
            -
                    if value['flags'] == []
         
     | 
| 
       35 
     | 
    
         
            -
                      @template[key]['type'] = 'passed'
         
     | 
| 
       36 
     | 
    
         
            -
                    else
         
     | 
| 
       37 
     | 
    
         
            -
                      flag_true = value['flags'].find_all { |flag| flag == true }
         
     | 
| 
       38 
     | 
    
         
            -
                      flag_false = value['flags'].find_all { |flag| flag == false }
         
     | 
| 
       39 
     | 
    
         
            -
                      if flag_false.empty?
         
     | 
| 
       40 
     | 
    
         
            -
                        @template[key]['type'] = 'passed'
         
     | 
| 
       41 
     | 
    
         
            -
                      else
         
     | 
| 
       42 
     | 
    
         
            -
                        @template[key]['cover'] = if flag_true.empty?
         
     | 
| 
       43 
     | 
    
         
            -
                                                    0.0
         
     | 
| 
       44 
     | 
    
         
            -
                                                  else
         
     | 
| 
       45 
     | 
    
         
            -
                                                    flag_false.size / flag_true.size
         
     | 
| 
       46 
     | 
    
         
            -
                                                  end
         
     | 
| 
       47 
     | 
    
         
            -
                        @template[key]['type'] = 'failed'
         
     | 
| 
       48 
     | 
    
         
            -
                      end
         
     | 
| 
       49 
     | 
    
         
            -
                    end
         
     | 
| 
       50 
     | 
    
         
            -
                    @template[key]['json_schema'] = JSON.pretty_generate(value['json_schemas'].last)
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
                  @template
         
     | 
| 
       53 
     | 
    
         
            -
                end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                def save
         
     | 
| 
       56 
     | 
    
         
            -
                  to_hash
         
     | 
| 
       57 
     | 
    
         
            -
                  contents = File.read(File.expand_path('../view/report.html.haml', __FILE__))
         
     | 
| 
       58 
     | 
    
         
            -
                  html = "<style>\n#{File.read(File.expand_path('../view/style.css', __FILE__))}\n</style>\n"
         
     | 
| 
       59 
     | 
    
         
            -
                  html += Haml::Engine.new(contents).render(
         
     | 
| 
       60 
     | 
    
         
            -
                    Object.new,
         
     | 
| 
       61 
     | 
    
         
            -
                    :@to_hash => template
         
     | 
| 
       62 
     | 
    
         
            -
                  )
         
     | 
| 
       63 
     | 
    
         
            -
                  html
         
     | 
| 
       64 
     | 
    
         
            -
                end
         
     | 
| 
       65 
     | 
    
         
            -
              end
         
     | 
| 
       66 
     | 
    
         
            -
            end
         
     |