<commit_before>Puppet::Type.type(:quagga_pim_router).provide :quagga do
  @doc = 'Manages quagga PIM router settings'

  @resource_map = {
    :ip_multicast_routing => {
        :regexp => /\Aip\smulticast-routing\Z/,
        :template => 'ip multicast-routing',
        :type => :boolean,
        :default => :false,
    }
  }

  commands :vtysh => 'vtysh'

  def initialize(value)
    super(value)
    @property_flush = {}
  end

  def self.instances
    debug '[instances]'

    hash = {
      :name => 'pim'
    }

    @resource_map.each do |property, options|
      hash[property] = options[:default]
    end

    config = vtysh('-c', 'show running-config')
    config.split(/\n/).collect do |line|
      # comment
      next if line =~ /\A!\Z/

      @resource_map.each do |property, options|
        if line =~ options[:regexp]
          value = $1

          if value.nil?
            hash[property] = :true
          else
            case options[:type]
              when :boolean
                hash[property] = :true

              when :fixnum
                hash[property] = value.to_i

              when :symbol
                hash[property] = value.to_sym

              else
                hash[property] = value

            end
          end

          break
        end
      end
    end

    hash[:name] = hash[:hostname]

    [new(hash)]
  end

  def self.prefetch(resources)
    resources[resources.keys.first].provider = instances.first
  end

  def flush
    resource_map = self.class.instance_variable_get('@resource_map')
    name = @property_hash[:name].nil? ? @resource[:name] : @property_hash[:name]

    debug "[flush][#{name}]"

    cmds = []<commit_msg>fixed bug in provider<commit_after>Puppet::Type.type(:quagga_pim_router).provide :quagga do
  @doc = 'Manages quagga PIM router settings'

  @resource_map = {
    :ip_multicast_routing => {
        :regexp => /\Aip\smulticast-routing\Z/,
        :template => 'ip multicast-routing',
        :type => :boolean,
        :default => :false,
    }
  }

  commands :vtysh => 'vtysh'

  def initialize(value)
    super(value)
    @property_flush = {}
  end

  def self.instances
    debug '[instances]'

    hash = {
      :name => 'pim'
    }

    @resource_map.each do |property, options|
      hash[property] = options[:default]
    end

    config = vtysh('-c', 'show running-config')
    config.split(/\n/).collect do |line|
      # comment
      next if line =~ /\A!\Z/

      @resource_map.each do |property, options|
        if line =~ options[:regexp]
          value = $1

          if value.nil?
            hash[property] = :true
          else
            case options[:type]
              when :boolean
                hash[property] = :true

              when :fixnum
                hash[property] = value.to_i

              when :symbol
                hash[property] = value.to_sym

              else
                hash[property] = value

            end
          end

          break
        end
      end
    end

    [new(hash)]
  end

  def self.prefetch(resources)
    resources[resources.keys.first].provider = instances.first
  end

  def flush
    resource_map = self.class.instance_variable_get('@resource_map')
    name = @property_hash[:name].nil? ? @resource[:name] : @property_hash[:name]

    debug "[flush][#{name}]"

    cmds = []
{'fraction_non_alphanumeric': 0.12429210134128167, 'fraction_numerical': 0.0005961251862891207, 'mean_word_length': 1.858603066439523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6807932', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1033, 'n_words': 223}