blob: 487be4771a3e7cc1087ad58b90002a12ee772cb7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
require File.expand_path("../compact_index", __FILE__)
Artifice.deactivate
class CompactIndexRangeNotSatisfiable < CompactIndexAPI
get "/versions" do
if env["HTTP_RANGE"]
status 416
else
etag_response do
file = tmp("versions.list")
file.delete if file.file?
file = CompactIndex::VersionsFile.new(file.to_s)
file.create(gems)
file.contents
end
end
end
get "/info/:name" do
if env["HTTP_RANGE"]
status 416
else
etag_response do
gem = gems.find {|g| g.name == params[:name] }
CompactIndex.info(gem ? gem.versions : [])
end
end
end
end
Artifice.activate_with(CompactIndexRangeNotSatisfiable)
|