<commit_before>require File.expand_path("../compact_index", __FILE__)

Artifice.deactivate

class CompactIndexExtraApi < CompactIndexAPI
  get "/extra/names" do
    etag_response do
      CompactIndex.names(gems(gem_repo4).map(&:name))
    end
  end

  get "/extra/versions" do
    etag_response do
      file = tmp("versions.list")
      file.delete if file.file?
      file = CompactIndex::VersionsFile.new(file.to_path)
      versions = gems(gem_repo4).group_by {|s| s[:name] }.map {|n, v| { :name => n, :versions => v } }
      file.update_with(versions)
      CompactIndex.versions(file, nil, {})
    end
  end

  get "/extra/info/:name" do
    etag_response do
      specs = gems(gem_repo4).select {|s| s[:name] == params[:name] }
      CompactIndex.info(specs)
    end
  end

  get "/extra/specs.4.8.gz" do
    File.read("#{gem_repo4}/specs.4.8.gz")
  end

  get "/extra/prerelease_specs.4.8.gz" do
    File.read("#{gem_repo4}/prerelease_specs.4.8.gz")
  end

  get "/extra/quick/Marshal.4.8/:id" do
    redirect "/extra/fetch/actual/gem/#{params[:id]}"
  end

  get "/extra/fetch/actual/gem/:id" do
    File.read("#{gem_repo4}/quick/Marshal.4.8/#{params[:id]}")
  end

  get "/extra/gems/:id" do
    File.read("#{gem_repo4}/gems/#{params[:id]}")
  end
end

Artifice.activate_with(CompactIndexExtraApi)<commit_msg>update extra_api artifice for structs<commit_after>require File.expand_path("../compact_index", __FILE__)

Artifice.deactivate

class CompactIndexExtraApi < CompactIndexAPI
  get "/extra/names" do
    etag_response do
      CompactIndex.names(gems(gem_repo4).map(&:name))
    end
  end

  get "/extra/versions" do
    etag_response do
      file = tmp("versions.list")
      file.delete if file.file?
      file = CompactIndex::VersionsFile.new(file.to_path)
      file.update_with(gems(gem_repo4))
      CompactIndex.versions(file, nil, {})
    end
  end

  get "/extra/info/:name" do
    etag_response do
      gem = gems(gem_repo4).find{|g| g.name == params[:name] }
      CompactIndex.info(gem ? gem.versions : [])
    end
  end

  get "/extra/specs.4.8.gz" do
    File.read("#{gem_repo4}/specs.4.8.gz")
  end

  get "/extra/prerelease_specs.4.8.gz" do
    File.read("#{gem_repo4}/prerelease_specs.4.8.gz")
  end

  get "/extra/quick/Marshal.4.8/:id" do
    redirect "/extra/fetch/actual/gem/#{params[:id]}"
  end

  get "/extra/fetch/actual/gem/:id" do
    File.read("#{gem_repo4}/quick/Marshal.4.8/#{params[:id]}")
  end

  get "/extra/gems/:id" do
    File.read("#{gem_repo4}/gems/#{params[:id]}")
  end
end

Artifice.activate_with(CompactIndexExtraApi)
{'fraction_non_alphanumeric': 0.16311507167764433, 'fraction_numerical': 0.014722975590856257, 'mean_word_length': 3.267768595041322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2005794', 'n_tokens_mistral': 997, 'n_tokens_neox': 969, 'n_words': 160}