Class: Dragnet::Exporters::Serializers::TestRecordSerializer
- Inherits:
-
Object
- Object
- Dragnet::Exporters::Serializers::TestRecordSerializer
- Includes:
- Helpers::RepositoryHelper
- Defined in:
- lib/dragnet/exporters/serializers/test_record_serializer.rb
Overview
Serializes a TestRecord
object into a Hash
.
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#test_record ⇒ Object
readonly
Returns the value of attribute test_record.
Instance Method Summary collapse
-
#initialize(test_record, repository) ⇒ TestRecordSerializer
constructor
A new instance of TestRecordSerializer.
-
#serialize ⇒ Hash
A
Hash
representing the givenTestRecord
object.
Methods included from Helpers::RepositoryHelper
#relative_to_repo, #repo_base, #shorten_sha1
Constructor Details
#initialize(test_record, repository) ⇒ TestRecordSerializer
Returns a new instance of TestRecordSerializer.
24 25 26 27 |
# File 'lib/dragnet/exporters/serializers/test_record_serializer.rb', line 24 def initialize(test_record, repository) @test_record = test_record @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
17 18 19 |
# File 'lib/dragnet/exporters/serializers/test_record_serializer.rb', line 17 def repository @repository end |
#test_record ⇒ Object (readonly)
Returns the value of attribute test_record.
17 18 19 |
# File 'lib/dragnet/exporters/serializers/test_record_serializer.rb', line 17 def test_record @test_record end |
Instance Method Details
#serialize ⇒ Hash
Returns A Hash
representing the given TestRecord
object.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dragnet/exporters/serializers/test_record_serializer.rb', line 35 def serialize { refs: Array(test_record.id), result: test_record.result, review_status: render_review_status, mtr_file: relative_to_repo(test_record.source_file).to_s, verification_result: serialized_verification_result, # TODO: Remove the started_at and finished_at attributes after solving # https://esrlabs.atlassian.net/browse/JAY-493 started_at: serialized_verification_result[:started_at], finished_at: serialized_verification_result[:finished_at] }.tap do |hash| hash[:sha1] = test_record.sha1 if test_record.sha1.present? hash[:owner] = Array(test_record.name).join(', ') if test_record.name.present? hash[:description] = test_record.description if test_record.description.present? hash[:test_method] = Array(test_record.test_method) if test_record.test_method.present? if test_record.tc_derivation_method.present? hash[:tc_derivation_method] = Array(test_record.tc_derivation_method) end hash[:review_comments] = test_record.review_comments if test_record.review_comments.present? hash[:findings] = test_record.findings if test_record.findings? hash[:files] = serialize_files if test_record.files.present? hash[:repos] = serialize_repos if test_record.repos.present? end end |