<commit_before>
module Spectrum
  module Config
    class HeaderRegion

      def initialize(name, config)
        @name = name

        if config.is_a?(Hash)
          @region, type_key = config.first
          @type = type_key[:type]
        end

        @header_component = HeaderComponent.new(@name,type_key)
      end

      def resolve(data)
        # FIXME
        # The following bit of code is ugly, no doubt about it.
        # The description we get from PlainHeaderComponent,
        # in concept similar to PlainMetadataComponent,
        # is in this format:
        #=> [{:text=>"The voodoo sacerdos suscitat"}]
        # I wonder if there are cases (that I don't foresee right now)
        # that would cause problems if I would change get_description()
        # to return just a plain string?
        #
        unless @header_component.nil?
          description = @header_component.get_description(data)
          unless description.nil?
            if description.is_a?(Array)
              description = description[0]
              if description.is_a?(Hash)
                description = description[:text]
                unless description.nil?
                  ret = {:region => @region, :name => @name , :description => description }
                end
              end
            end
          end
        end
        ret
      end

    end
  end
end
<commit_msg>Some code cleanup<commit_after>
module Spectrum
  module Config
    class HeaderRegion

      def initialize(name, config)
        @name = name

        if config.is_a?(Hash)
          @region, type_key = config.first
          @type = type_key[:type]
        end

        @header_component = HeaderComponent.new(@name,type_key)
      end

      def resolve(data)
        unless @header_component.nil?
          description = @header_component.get_description(data)
          unless description.nil?
            if description.is_a?(Array)
              description = description[0]
              if description.is_a?(Hash)
                description = description[:text]
                unless description.nil?
                  ret = {:region => @region, :name => @name , :description => description }
                end
              end
            end
          end
        end
        ret
      end

    end
  end
end

{'fraction_non_alphanumeric': 0.07669108143041792, 'fraction_numerical': 0.0008616975441619991, 'mean_word_length': 1.6689655172413793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4874961', 'n_tokens_mistral': 603, 'n_tokens_neox': 583, 'n_words': 176}