Class: RailVerdict::Intelligence::Manifest
- Inherits:
-
Object
- Object
- RailVerdict::Intelligence::Manifest
- Defined in:
- lib/rail_verdict/intelligence/manifest.rb
Instance Attribute Summary collapse
-
#comparison_slice ⇒ Object
readonly
Returns the value of attribute comparison_slice.
-
#finding ⇒ Object
readonly
Returns the value of attribute finding.
-
#finding_id ⇒ Object
readonly
Returns the value of attribute finding_id.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#git_slice ⇒ Object
readonly
Returns the value of attribute git_slice.
-
#policy_reason ⇒ Object
readonly
Returns the value of attribute policy_reason.
-
#rails_facts ⇒ Object
readonly
Returns the value of attribute rails_facts.
-
#snippets ⇒ Object
readonly
Returns the value of attribute snippets.
Instance Method Summary collapse
- #context_hash ⇒ Object
-
#initialize(finding_id:, fingerprint:, finding:, snippets:, rails_facts:, git_slice:, comparison_slice:, policy_reason:) ⇒ Manifest
constructor
A new instance of Manifest.
- #to_h ⇒ Object
- #to_json_hash ⇒ Object
- #total_bytes ⇒ Object
Constructor Details
#initialize(finding_id:, fingerprint:, finding:, snippets:, rails_facts:, git_slice:, comparison_slice:, policy_reason:) ⇒ Manifest
Returns a new instance of Manifest.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 12 def initialize(finding_id:, fingerprint:, finding:, snippets:, rails_facts:, git_slice:, comparison_slice:, policy_reason:) @finding_id = finding_id.dup.freeze @fingerprint = fingerprint.dup.freeze @finding = deep_freeze(finding.dup) @snippets = deep_freeze(snippets.map(&:dup)) @rails_facts = deep_freeze(rails_facts) @git_slice = deep_freeze(git_slice) @comparison_slice = deep_freeze(comparison_slice) @policy_reason = policy_reason&.dup&.freeze freeze end |
Instance Attribute Details
#comparison_slice ⇒ Object (readonly)
Returns the value of attribute comparison_slice.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def comparison_slice @comparison_slice end |
#finding ⇒ Object (readonly)
Returns the value of attribute finding.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def finding @finding end |
#finding_id ⇒ Object (readonly)
Returns the value of attribute finding_id.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def finding_id @finding_id end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def fingerprint @fingerprint end |
#git_slice ⇒ Object (readonly)
Returns the value of attribute git_slice.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def git_slice @git_slice end |
#policy_reason ⇒ Object (readonly)
Returns the value of attribute policy_reason.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def policy_reason @policy_reason end |
#rails_facts ⇒ Object (readonly)
Returns the value of attribute rails_facts.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def rails_facts @rails_facts end |
#snippets ⇒ Object (readonly)
Returns the value of attribute snippets.
9 10 11 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 9 def snippets @snippets end |
Instance Method Details
#context_hash ⇒ Object
50 51 52 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 50 def context_hash Digest::SHA256.hexdigest(JSON.generate(to_json_hash.sort.to_h)) end |
#to_h ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 24 def to_h { finding_id: finding_id, fingerprint: fingerprint, finding: finding, snippets: snippets, rails_facts: rails_facts, git_slice: git_slice, comparison_slice: comparison_slice, policy_reason: policy_reason } end |
#to_json_hash ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 37 def to_json_hash { "finding_id" => finding_id, "fingerprint" => fingerprint, "finding" => finding, "snippets" => snippets, "rails_facts" => rails_facts, "git_slice" => git_slice, "comparison_slice" => comparison_slice, "policy_reason" => policy_reason } end |
#total_bytes ⇒ Object
54 55 56 |
# File 'lib/rail_verdict/intelligence/manifest.rb', line 54 def total_bytes JSON.generate(to_json_hash).bytesize end |