Class: RailVerdict::GateResult
- Inherits:
-
Object
- Object
- RailVerdict::GateResult
- Defined in:
- lib/rail_verdict/contracts/gate_result.rb
Constant Summary collapse
- SCHEMA_VERSION =
"1.0"- COMPLETION_STATUSES =
%w[complete incomplete interrupted].freeze
- GATES =
%w[PASS WARN FAIL INCOMPLETE].freeze
- POLICY_STATUSES =
%w[pass warn fail not_evaluated].freeze
- FAILURE_CODES =
%w[ unavailable unsupported timed_out signaled failed parse_failed truncated malformed configuration interrupted incomplete_evidence ].freeze
Instance Attribute Summary collapse
-
#analyzer_results ⇒ Object
readonly
Returns the value of attribute analyzer_results.
-
#completion_status ⇒ Object
readonly
Returns the value of attribute completion_status.
-
#decision_reasons ⇒ Object
readonly
Returns the value of attribute decision_reasons.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#gate ⇒ Object
readonly
Returns the value of attribute gate.
-
#operational_failures ⇒ Object
readonly
Returns the value of attribute operational_failures.
-
#policy_status ⇒ Object
readonly
Returns the value of attribute policy_status.
Instance Method Summary collapse
- #baseline ⇒ Object
- #comparison ⇒ Object
- #complete? ⇒ Boolean
- #git ⇒ Object
- #incomplete? ⇒ Boolean
-
#initialize(completion_status:, gate:, policy_status:, findings:, analyzer_results:, operational_failures:, decision_reasons:, baseline: nil, comparison: nil, git: nil, rails_context: nil) ⇒ GateResult
constructor
A new instance of GateResult.
- #rails_context ⇒ Object
- #to_schema_h ⇒ Object
Constructor Details
#initialize(completion_status:, gate:, policy_status:, findings:, analyzer_results:, operational_failures:, decision_reasons:, baseline: nil, comparison: nil, git: nil, rails_context: nil) ⇒ GateResult
Returns a new instance of GateResult.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 17 def initialize(completion_status:, gate:, policy_status:, findings:, analyzer_results:, operational_failures:, decision_reasons:, baseline: nil, comparison: nil, git: nil, rails_context: nil) @completion_status = require_member(completion_status, COMPLETION_STATUSES, "completion_status") @gate = require_member(gate, GATES, "gate") @policy_status = require_member(policy_status, POLICY_STATUSES, "policy_status") @findings = validate_findings(findings) @analyzer_results = validate_analyzer_results(analyzer_results) @operational_failures = validate_operational_failures(operational_failures) @decision_reasons = validate_decision_reasons(decision_reasons) @baseline = baseline ? baseline.dup.freeze : nil @comparison = comparison ? comparison.dup.freeze : nil @git = git ? deep_freeze_git(git) : nil @rails_context = rails_context ? deep_freeze_git(rails_context) : nil enforce_state_coupling freeze end |
Instance Attribute Details
#analyzer_results ⇒ Object (readonly)
Returns the value of attribute analyzer_results.
14 15 16 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 14 def analyzer_results @analyzer_results end |
#completion_status ⇒ Object (readonly)
Returns the value of attribute completion_status.
14 15 16 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 14 def completion_status @completion_status end |
#decision_reasons ⇒ Object (readonly)
Returns the value of attribute decision_reasons.
14 15 16 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 14 def decision_reasons @decision_reasons end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
14 15 16 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 14 def findings @findings end |
#gate ⇒ Object (readonly)
Returns the value of attribute gate.
14 15 16 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 14 def gate @gate end |
#operational_failures ⇒ Object (readonly)
Returns the value of attribute operational_failures.
14 15 16 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 14 def operational_failures @operational_failures end |
#policy_status ⇒ Object (readonly)
Returns the value of attribute policy_status.
14 15 16 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 14 def policy_status @policy_status end |
Instance Method Details
#baseline ⇒ Object
34 35 36 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 34 def baseline @baseline end |
#comparison ⇒ Object
38 39 40 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 38 def comparison @comparison end |
#complete? ⇒ Boolean
50 51 52 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 50 def complete? completion_status == "complete" end |
#git ⇒ Object
42 43 44 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 42 def git @git end |
#incomplete? ⇒ Boolean
54 55 56 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 54 def incomplete? completion_status != "complete" end |
#rails_context ⇒ Object
46 47 48 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 46 def rails_context @rails_context end |
#to_schema_h ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rail_verdict/contracts/gate_result.rb', line 58 def to_schema_h result = { "schema_version" => SCHEMA_VERSION, "completion_status" => completion_status, "gate" => gate, "policy_status" => policy_status, "findings" => findings, "analyzer_results" => analyzer_results.map(&:to_schema_h), "operational_failures" => operational_failures, "decision_reasons" => decision_reasons } result["baseline"] = @baseline if @baseline result["comparison"] = @comparison if @comparison result["git"] = @git if @git result["rails_context"] = @rails_context if @rails_context result end |