<commit_before>require 'json'

class InterviewGearScanner < Dimples::Plugin
  GEAR_LINK = /\[([^\[\(\)]+)\]\[([a-z0-9\.\-]+)?\]/

  def initialize(site)
    @site = site
  end

  def gear
    @gear ||= {}.tap do |gear|
      path = File.join(@site.paths[:base], 'gear', '**', '*.json')

      Dir.glob(path).sort.each do |path|
        slug = File.basename(path, '.json')
        gear[slug] = JSON.load(File.read(path))
      end
    end
  end

  def supported_events
    [:before_post_write]
  end

  def process(event, interview, &block)
    case event
    when :before_post_write
      links = ''

      interview.contents.scan(GEAR_LINK).each do |link|
        slug = (link[1] ? link[1] : link[0].downcase)
        if (data = gear[slug])
          links << "[#{slug}]: #{data['url']} \"#{data['description']}\"\n"
        end
      end

      interview.contents << "\n\n#{links}" unless links.empty?
    end
  end
end<commit_msg>Remove the initialize method<commit_after>require 'json'

class InterviewGearScanner < Dimples::Plugin
  GEAR_LINK = /\[([^\[\(\)]+)\]\[([a-z0-9\.\-]+)?\]/

  def gear
    @gear ||= {}.tap do |gear|
      path = File.join(@site.paths[:base], 'gear', '**', '*.json')

      Dir.glob(path).sort.each do |path|
        slug = File.basename(path, '.json')
        gear[slug] = JSON.load(File.read(path))
      end
    end
  end

  def supported_events
    [:before_post_write]
  end

  def process(event, interview, &block)
    case event
    when :before_post_write
      links = ''

      interview.contents.scan(GEAR_LINK).each do |link|
        slug = (link[1] ? link[1] : link[0].downcase)
        if (data = gear[slug])
          links << "[#{slug}]: #{data['url']} \"#{data['description']}\"\n"
        end
      end

      interview.contents << "\n\n#{links}" unless links.empty?
    end
  end
end
{'fraction_non_alphanumeric': 0.193020719738277, 'fraction_numerical': 0.0054525627044711015, 'mean_word_length': 2.508604206500956, 'pattern_counts': {'":': 0, '<': 13, '<?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': '502255', 'n_tokens_mistral': 665, 'n_tokens_neox': 661, 'n_words': 135}