Module: CI::Queue::QueueEntry
- Defined in:
- lib/ci/queue/queue_entry.rb
Constant Summary collapse
- LOAD_ERROR_PREFIX =
'__ciq_load_error__:'.freeze
Class Method Summary collapse
- .decode_load_error(file_path) ⇒ Object
- .encode_load_error(file_path, error) ⇒ Object
- .format(test_id, file_path) ⇒ Object
- .load_error_payload?(file_path) ⇒ Boolean
- .parse(entry) ⇒ Object
- .test_id(entry) ⇒ Object
Class Method Details
.decode_load_error(file_path) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/ci/queue/queue_entry.rb', line 38 def self.decode_load_error(file_path) return nil unless load_error_payload?(file_path) encoded = file_path.sub(LOAD_ERROR_PREFIX, '') JSON.parse(Base64.strict_decode64(encoded)) rescue ArgumentError, JSON::ParserError nil end |
.encode_load_error(file_path, error) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ci/queue/queue_entry.rb', line 27 def self.encode_load_error(file_path, error) original = error.respond_to?(:original_error) ? error.original_error : error payload = { 'file_path' => file_path, 'error_class' => original.class.name, 'error_message' => original., 'backtrace' => original.backtrace, } "#{LOAD_ERROR_PREFIX}#{Base64.strict_encode64(JSON.dump(payload))}" end |
.format(test_id, file_path) ⇒ Object
19 20 21 |
# File 'lib/ci/queue/queue_entry.rb', line 19 def self.format(test_id, file_path) JSON.dump({ test_id: test_id, file_path: file_path }) end |
.load_error_payload?(file_path) ⇒ Boolean
23 24 25 |
# File 'lib/ci/queue/queue_entry.rb', line 23 def self.load_error_payload?(file_path) file_path&.start_with?(LOAD_ERROR_PREFIX) end |
.parse(entry) ⇒ Object
15 16 17 |
# File 'lib/ci/queue/queue_entry.rb', line 15 def self.parse(entry) JSON.parse(entry, symbolize_names: true) end |
.test_id(entry) ⇒ Object
11 12 13 |
# File 'lib/ci/queue/queue_entry.rb', line 11 def self.test_id(entry) JSON.parse(entry, symbolize_names: true)[:test_id] end |