Class: Gitlab::Ci::Ansi2html::Converter
- Inherits:
-
Object
- Object
- Gitlab::Ci::Ansi2html::Converter
- Includes:
- EncodingHelper
- Defined in:
- lib/gitlab/ci/ansi2html.rb
Constant Summary collapse
- STATE_PARAMS =
[:offset, :n_open_tags, :fg_color, :bg_color, :style_mask, :sections, :lineno_in_section].freeze
Constants included from EncodingHelper
EncodingHelper::BOM_UTF8, EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER
Instance Method Summary collapse
Methods included from EncodingHelper
#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_escaping!, #encode_utf8_with_replacement_character, #force_encode_utf8, #strip_bom, #unquote_path
Instance Method Details
#convert(stream, new_state) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/gitlab/ci/ansi2html.rb', line 50 def convert(stream, new_state) reset_state restore_state(new_state, stream) if new_state.present? append = false truncated = false cur_offset = stream.tell if cur_offset > @offset @offset = cur_offset truncated = true else stream.seek(@offset) append = @offset > 0 end start_offset = @offset process_stream_with_lookahead(stream) Ansi2html::Result.new( html: @out.force_encoding(Encoding.default_external), state: state, append: append, truncated: truncated, offset: start_offset, size: stream.tell - start_offset, total: stream.size ) end |
#section_to_class_name(section) ⇒ Object
81 82 83 |
# File 'lib/gitlab/ci/ansi2html.rb', line 81 def section_to_class_name(section) section.to_s.downcase.gsub(/[^a-z0-9]/, '-') end |