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



41
42
43
44
45
# File 'lib/fitting/records/realized_unit.rb', line 41

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
27
28
29
# File 'lib/fitting/records/realized_unit.rb', line 11

def fully_covered?
  test_file_paths.each do |_key, requests|
    all_good = requests.all?(&:documented?)
    return false unless all_good
  end
  test_file_paths.each do |_key, requests|
    all_good = requests.all?(&:response_documented?)
    return false unless all_good
  end
  test_file_paths.each do |_key, requests|
    all_good = requests.all?(&:response_json_schemas?)
    return false unless all_good
  end
  test_file_paths.each do |_key, requests|
    all_good = requests.all?(&:valid_json_schemas?)
    return false unless all_good
  end
  true
end

#test_file_pathsObject



31
32
33
34
35
36
37
38
39
# File 'lib/fitting/records/realized_unit.rb', line 31

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



47
48
49
50
51
# File 'lib/fitting/records/realized_unit.rb', line 47

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