bundler/compact_index

Name: compact_index

Owner: Bundler

Description: null

Created: 2015-06-19 18:38:13.0

Updated: 2017-04-16 20:30:20.0

Pushed: 2017-04-17 01:43:21.0

Homepage: null

Size: 124

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

CompactIndex

This gem implements the response logic for the compact index format and to manage the versions file. The compact index format has three endpoints: /names, /versions and /info/gem_name. The versions file is a file which hold the versions in a cache-friendly way. You can see the body response formats on this blog post from @indirect.

Installation

Add this line to your application's Gemfile:

'compact_index'

And then execute:

$ bundle
Usage
/names

To render the body for this call, all you have to do is generate a list of gems available in alphabetical order and use call CompactIndex.names.

'compact_index'
actIndex.names(%W(a_test b_test c_test))
/versions

The body of this endpoint can be rendered calling the CompactIndex.versions method. It receives two paremeters: a CompactIndex::VersionsFile object and a set of extra gems that aren't in the file yet. The gems lists should be ordered consistently by the user.

'compact_index'
eate the object
ions_file = CompactIndex::VersionsFile.new("/path/to/versions/file")

t last updated date. This is used to discover what gems aren't  in the file yet
_date = versions_file.updated_at

ery the extra gems using the from date. Format should be as follows
a_gems = [
mpactIndex::Gem.new("gem1", [
CompactIndex::GemVersion.new("0.9.8", "ruby", "abc123"),
CompactIndex::GemVersion.new("0.9.9", "jruby", "abc123"),
,
mpactIndex::Gem.new("gem2", [
CompactIndex::GemVersion.new("0.9.8", "ruby", "abc123"),
CompactIndex::GemVersion.new("0.9.9", "jruby", "abc123"),



nder the body for the versions response
actIndex.versions(versions_file, extra_gems)
/info/gem_name

Much like /versions, the /info/gem_name expects a pre-defined structure to render the text on the screen. The lists also should be ordered by the user. This is the expected format:

'compact_index'

pected versions format
ions = [
mpactIndex::GemVersion.new("1.0.1", "ruby", "abc123", "info123", [
CompactIndex::Dependency.new("foo", "=1.0.1", "abc123"),
CompactIndex::Dependency.new("bar", ">1.0, <2.0", "abc123"),


actIndex.info(versions)
Updating the versions file

The versions file creation and update are different. When created, all versions are at the side of the gem name, which appears only on one line. When updated, the file appends the new information on the end of the file, to avoid file changes.

'compact_index'

ions_file = CompactIndex::VersionsFile.new(file_path)
_update = versions_file.updated_at
 = ... # Query your database, same format from `/versions` expected
ions_file.update_with(gems)

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.