<commit_before>module Vic
  class Colorscheme
    attr_accessor :colors_name, :information

    # A new instance of Colorscheme. If a block is given with no arguments, the
    # the block will be evaluated in the context of the new colorscheme.
    # Otherwise the block will yield self.
    #
    # @param [String] colors_name the name of the colorscheme
    # @param [Proc] block the block to be evaluated
    # @return [Colorscheme]
    def initialize(colors_name, &block)
      @colors_name = colors_name
      if block_given?
        block.arity == 0 ? instance_eval(&block) : yield(self)
      end
    end

    # Returns/sets the information attribute
    #
    # @param [Hash] information the information, :author => '<NAME>'
    # @return [Hash]
    def information(inf={})
      (@information ||= {}).merge!(inf) if inf.respond_to? :merge
    end
    alias_method :info, :information

    # Returns the background setting.
    #
    # @return [String] 'light' or 'dark'
    def background
      @background ||= background!
    end

    # Sets the background.
    #
    # @param [String] a value of 'light' or 'dark'
    # @return [String] the background attribute
    def background=(setting)
      unless setting =~ /^light$|^dark$/
        raise "background setting must be either 'light' or 'dark'"
      end
      @background = setting
    end

    # Sets the background by attempting to determine it.
    #
    # @return[String] the background attribute
    def background!
      normal = highlights.find_by_group 'Normal'
      unless normal && normal.guibg
        return @background = 'dark'
      end
      hex = normal.guibg.match(/[a-f0-9]{6}/i)[0]
      @background = hex.to_i(16) <= 8421504 ? 'dark' : 'light'
    end

    # Returns the set of highlights for the colorscheme
    def highlight_set
      @highlight_set ||= HighlightSet.new
    end
    alias_method :highlights, :highlight_set

    # Creates a new highlight
    #
    # If inside of a language block the langauge name is automatcially prepended
    # to the group name of the new highlight.
    #
    # @see Vic::Highlight
    # @return [Vic::Highlight] the new highlight
    def highlight(group, args={})
      return if args.empty?

      if h = find_highlight(group)
        h.update_arguments! args
      else
        h = Highlight.new "#{language}#{group}", args
        highlight_set.add h
      end
    end
    alias_method :hi, :highlight

    def find_highlight(group)
      highlight_set.find_by_group(group)
    end

    # Sets the current language to name. Any new highlights created will have
    # the language name automatically prepended.
    #
    # @return [String] the new language name
    def language=(name)
      @language = name
    end

    # Returns the current language or temporarily sets the language to name if
    # a block is given. If a block is given with no arguments, it will be
    # evaluated in the context of the colorscheme, otherwise it will yield the
    # colorscheme.<commit_msg>drop highlight_set in favor of just highlights<commit_after>module Vic
  class Colorscheme
    attr_accessor :colors_name, :information

    # A new instance of Colorscheme. If a block is given with no arguments, the
    # the block will be evaluated in the context of the new colorscheme.
    # Otherwise the block will yield self.
    #
    # @param [String] colors_name the name of the colorscheme
    # @param [Proc] block the block to be evaluated
    # @return [Colorscheme]
    def initialize(colors_name, &block)
      @colors_name = colors_name
      if block_given?
        block.arity == 0 ? instance_eval(&block) : yield(self)
      end
    end

    # Returns/sets the information attribute
    #
    # @param [Hash] information the information, :author => '<NAME>'
    # @return [Hash]
    def information(inf={})
      (@information ||= {}).merge!(inf) if inf.respond_to? :merge
    end
    alias_method :info, :information

    # Returns the background setting.
    #
    # @return [String] 'light' or 'dark'
    def background
      @background ||= background!
    end

    # Sets the background.
    #
    # @param [String] a value of 'light' or 'dark'
    # @return [String] the background attribute
    def background=(setting)
      unless setting =~ /^light$|^dark$/
        raise "background setting must be either 'light' or 'dark'"
      end
      @background = setting
    end

    # Sets the background by attempting to determine it.
    #
    # @return[String] the background attribute
    def background!
      normal = highlights.find_by_group 'Normal'
      unless normal && normal.guibg
        return @background = 'dark'
      end
      hex = normal.guibg.match(/[a-f0-9]{6}/i)[0]
      @background = hex.to_i(16) <= 8421504 ? 'dark' : 'light'
    end

    # Returns the set of highlights for the colorscheme
    def highlights
      @highlights ||= HighlightSet.new
    end

    # Creates a new highlight
    #
    # If inside of a language block the langauge name is automatcially prepended
    # to the group name of the new highlight.
    #
    # @see Vic::Highlight
    # @return [Vic::Highlight] the new highlight
    def highlight(group, args={})
      return if args.empty?

      if h = find_highlight(group)
        h.update_arguments! args
      else
        h = Highlight.new "#{language}#{group}", args
        highlights.add h
      end
    end
    alias_method :hi, :highlight

    def find_highlight(group)
      highlights.find_by_group(group)
    end

    # Sets the current language to name. Any new highlights created will have
    # the language name automatically prepended.
    #
    # @return [String] the new language name
    def language=(name)
      @language = name
    end

    # Returns the current language or temporarily sets the language to name if
    # a block is given. If a block is given with no arguments, it will be
    # evaluated in the context of the colorscheme, otherwise it will yield the
    # colorscheme.
{'fraction_non_alphanumeric': 0.08719573191063688, 'fraction_numerical': 0.004668222740913638, 'mean_word_length': 2.6490267639902676, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3790436', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1683, 'n_words': 634}