Module: CI::Queue::QueueEntry
- Defined in:
- lib/ci/queue/queue_entry.rb
Constant Summary collapse
- DELIMITER =
"\t"- 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
46 47 48 49 50 51 52 53 |
# File 'lib/ci/queue/queue_entry.rb', line 46 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
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ci/queue/queue_entry.rb', line 35 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
25 26 27 28 29 |
# File 'lib/ci/queue/queue_entry.rb', line 25 def self.format(test_id, file_path) return test_id if file_path.nil? || file_path == "" "#{test_id}#{DELIMITER}#{file_path}" end |
.load_error_payload?(file_path) ⇒ Boolean
31 32 33 |
# File 'lib/ci/queue/queue_entry.rb', line 31 def self.load_error_payload?(file_path) file_path&.start_with?(LOAD_ERROR_PREFIX) end |
.parse(entry) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/ci/queue/queue_entry.rb', line 17 def self.parse(entry) return { test_id: entry, file_path: nil } unless entry.include?(DELIMITER) test_id, file_path = entry.split(DELIMITER, 2) file_path = nil if file_path == "" { test_id: test_id, file_path: file_path } end |
.test_id(entry) ⇒ Object
12 13 14 15 |
# File 'lib/ci/queue/queue_entry.rb', line 12 def self.test_id(entry) pos = entry.index(DELIMITER) pos ? entry[0, pos] : entry end |