<commit_before>module Jarvis
  module Utility
    module Viewer
      class Message
        def initialize(options)
          @options = options
          build_message
        end

        def build_message
          from_color = color(:from, @options[:from])
          to_color   = color(:to, @options[:to])
          block_from = Rainbow('██').color(from_color)
          block_to   = Rainbow('██').color(to_color)
          timestamp  = @options[:timestamp].strftime('%H:%M:%S')
          from       = Rainbow(format_service(@options[:from])).color(from_color)
          to         = Rainbow(format_service(@options[:to])).color(to_color)
          message    = @options[:message]
          arrow      = '→'

          puts "#{block_from}#{block_to} #{timestamp} [#{from}]#{arrow}[#{to}] #{message}"
          # ████ 21:29:34 [TWITTER]→[SAVER] @author incredible tweet much retweeted
        end

        def format_service(service)
          service.upcase[0..14].strip
        end

        def color(type, name)
          all = Boot::Session.all_sorted

          case type
          when :from
            addon_type = :sources
          when :to
            addon_type = :receivers
          end
          all[addon_type][name.downcase.to_sym]['specs']['color_message']
        end
      end
    end
  end
end<commit_msg>update message viewer for 2.0<commit_after>module Jarvis
  module Utility
    module Viewer
      class Message
        def initialize(options)
          @options = options
          build_message
        end

        def build_message
          from_color = color(:from, @options[:from])
          to_color   = color(:to, @options[:to])
          block_from = Rainbow('██').color("#{from_color}")
          block_to   = Rainbow('██').color("#{to_color}")
          timestamp  = @options[:timestamp].strftime('%H:%M:%S')
          from       = Rainbow(format_service(@options[:from])).color("#{from_color}")
          to         = Rainbow(format_service(@options[:to])).color("#{to_color}")
          message    = @options[:message]
          arrow      = '→'

          puts "#{block_from}#{block_to} #{timestamp} [#{from}]#{arrow}[#{to}] #{message}"
          # ████ 21:29:34 [TWITTER]→[SAVER] @author incredible tweet much retweeted
        end

        def format_service(service)
          service.upcase[0..14].strip
        end

        def color(type, name)
          case type
          when :from
            addon_type = :source
          when :to
            addon_type = :receiver
          end
          Jarvis::API::Addons.specs(addon_type, name)[addon_type.to_s]['color_message']
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13288288288288289, 'fraction_numerical': 0.0075075075075075074, 'mean_word_length': 2.0215419501133787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6629435', 'n_tokens_mistral': 811, 'n_tokens_neox': 780, 'n_words': 154}