Class: Fitting::Records::RealizedUnit

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/records/realized_unit.rb

Instance Method Summary collapse

Constructor Details

#initialize(realized_requests, documented_requests) ⇒ RealizedUnit

Returns a new instance of RealizedUnit.



6
7
8
9
# File 'lib/fitting/records/realized_unit.rb', line 6

def initialize(realized_requests, documented_requests)
  @realized_requests = realized_requests
  @documented_requests = documented_requests
end

Instance Method Details

#all_documented_requestsObject



39
40
41
42
43
# File 'lib/fitting/records/realized_unit.rb', line 39

def all_documented_requests
  @all_documented_requests ||= @documented_requests.to_a.inject([]) do |res, tomogram_request|
    res.push(Fitting::Records::Documented::Request.new(tomogram_request, nil))
  end
end

#fully_covered?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fitting/records/realized_unit.rb', line 11

def fully_covered?
  all_good_documented = false
  all_good_response_documented = false
  all_good_response_json_schemas = false
  all_good_valid_json_schemas = false

  test_file_paths.each do |_key, requests|
    all_good_documented = requests.all?(&:documented?)
    all_good_response_documented = requests.all?(&:response_documented?)
    all_good_response_json_schemas = requests.all?(&:response_json_schemas?)
    all_good_valid_json_schemas = requests.all?(&:valid_json_schemas?)
  end

  all_good_documented && all_good_response_documented &&
    all_good_response_json_schemas && all_good_valid_json_schemas
end

#test_file_pathsObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/fitting/records/realized_unit.rb', line 28

def test_file_paths
  return @test_file_paths if @test_file_paths

  @test_file_paths = {}
  white_unit.map do |request|
    @test_file_paths[request.test_file_path] ||= []
    @test_file_paths[request.test_file_path].push(request)
  end
  @test_file_paths
end

#white_unitObject



45
46
47
48
49
# File 'lib/fitting/records/realized_unit.rb', line 45

def white_unit
  @white_unit_requests ||= @realized_requests.to_a.inject([]) do |res, tested_request|
    res.push(Fitting::Records::TestUnit::Request.new(tested_request, all_documented_requests))
  end
end