<commit_before>require 'open-uri'
require 'json'

module Jekyll
  class DownloadConverter < Converter
    safe true
    priority :low

    def matches(ext)
      ext =~ /^\.DOWNLOAD/i
    end

    def output_ext(ext)
      ".json"
    end

    def convert(content)
      if not Dir.exists? "./data"
        `git clone https://github.com/samdroid-apps/sugar-activities data`
      else
        Dir.chdir("data"){
          `git pull`
        }
      end

      activities = {}   

      Dir.glob "./data/*.json" do |path|
        j = JSON.parse open(path).read
        bundle_id = /\.\/data\/(.*).json/.match(path)[1]

        if bundle_id != "featured"
          activities[bundle_id] = {
            "categories" => j["categories"],
            "icon"       => j["icon"],
            "title"      => j["title"]
          }
        end<commit_msg>Don't pull data using the ruby plugin<commit_after>require 'open-uri'
require 'json'

module Jekyll
  class DownloadConverter < Converter
    safe true
    priority :low

    def matches(ext)
      ext =~ /^\.DOWNLOAD/i
    end

    def output_ext(ext)
      ".json"
    end

    def convert(content)
      activities = {}   

      Dir.glob "./data/*.json" do |path|
        j = JSON.parse open(path).read
        bundle_id = /\.\/data\/(.*).json/.match(path)[1]

        if bundle_id != "featured"
          activities[bundle_id] = {
            "categories" => j["categories"],
            "icon"       => j["icon"],
            "title"      => j["title"]
          }
        end
{'fraction_non_alphanumeric': 0.14519293655984303, 'fraction_numerical': 0.0013080444735120995, 'mean_word_length': 1.679509632224168, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '892163', 'n_tokens_mistral': 487, 'n_tokens_neox': 474, 'n_words': 108}