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
40 41 42 43 44 45 46 47 |
# File 'lib/ci/queue/queue_entry.rb', line 40 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
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ci/queue/queue_entry.rb', line 29 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 22 23 |
# File 'lib/ci/queue/queue_entry.rb', line 19 def self.format(test_id, file_path) raise ArgumentError, "file_path is required for '#{test_id}' — the test file path must be resolvable" if file_path.nil? || file_path.empty? canonical = load_error_payload?(file_path) ? file_path : ::File.(file_path) JSON.dump({ test_id: test_id, file_path: canonical }) end |
.load_error_payload?(file_path) ⇒ Boolean
25 26 27 |
# File 'lib/ci/queue/queue_entry.rb', line 25 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 |