Class: Gemstash::GemSource::RedirectSource
- Inherits:
-
Base
- Object
- Base
- Gemstash::GemSource::RedirectSource
show all
- Defined in:
- lib/gemstash/gem_source/upstream_source.rb
Overview
GemSource that purely redirects to the upstream server.
Constant Summary
Constants included
from Logging
Logging::LEVELS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Methods included from Logging
#log, #log_error, logger, reset, setup_logger
Class Method Details
.capture_user_agent(env) ⇒ Object
21
22
23
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 21
def self.capture_user_agent(env)
env["gemstash.user-agent"] = env["HTTP_USER_AGENT"]
end
|
.matches?(env) ⇒ Boolean
12
13
14
15
16
17
18
19
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 12
def self.matches?(env)
rewriter = rack_env_rewriter.for(env)
return false unless rewriter.matches?
rewriter.rewrite
env["gemstash.upstream"] = rewriter.captures["upstream_url"]
capture_user_agent(env)
true
end
|
.rack_env_rewriter ⇒ Object
8
9
10
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 8
def self.rack_env_rewriter
@rack_env_rewriter ||= Gemstash::RackEnvRewriter.new(%r{\A/redirect/(?<upstream_url>[^/]+)})
end
|
Instance Method Details
#serve_actual_gem(id) ⇒ Object
74
75
76
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 74
def serve_actual_gem(id)
redirect upstream.url("fetch/actual/gem/#{id}", request.query_string)
end
|
#serve_add_gem ⇒ Object
30
31
32
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 30
def serve_add_gem
halt 403, "Cannot add gem to an upstream server!"
end
|
#serve_add_spec_json ⇒ Object
42
43
44
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 42
def serve_add_spec_json
halt 403, "Cannot add spec to an upstream server!"
end
|
#serve_dependencies ⇒ Object
50
51
52
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 50
def serve_dependencies
redirect upstream.url("api/v1/dependencies", request.query_string)
end
|
#serve_dependencies_json ⇒ Object
54
55
56
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 54
def serve_dependencies_json
redirect upstream.url("api/v1/dependencies.json", request.query_string)
end
|
#serve_gem(id) ⇒ Object
78
79
80
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 78
def serve_gem(id)
redirect upstream.url("gems/#{id}", request.query_string)
end
|
#serve_info(name) ⇒ Object
66
67
68
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 66
def serve_info(name)
redirect index_upstream.url("info/#{name}", request.query_string)
end
|
#serve_latest_specs ⇒ Object
82
83
84
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 82
def serve_latest_specs
redirect upstream.url("latest_specs.4.8.gz", request.query_string)
end
|
#serve_marshal(id) ⇒ Object
70
71
72
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 70
def serve_marshal(id)
redirect upstream.url("quick/Marshal.4.8/#{id}", request.query_string)
end
|
#serve_names ⇒ Object
58
59
60
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 58
def serve_names
redirect upstream.url("names", request.query_string)
end
|
#serve_prerelease_specs ⇒ Object
90
91
92
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 90
def serve_prerelease_specs
redirect upstream.url("prerelease_specs.4.8.gz", request.query_string)
end
|
#serve_remove_spec_json ⇒ Object
46
47
48
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 46
def serve_remove_spec_json
halt 403, "Cannot remove spec from an upstream server!"
end
|
#serve_root ⇒ Object
25
26
27
28
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 25
def serve_root
cache_control :public, :max_age => 31_536_000
redirect upstream.url(nil, request.query_string)
end
|
#serve_specs ⇒ Object
86
87
88
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 86
def serve_specs
redirect upstream.url("specs.4.8.gz", request.query_string)
end
|
#serve_unyank ⇒ Object
38
39
40
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 38
def serve_unyank
halt 403, "Cannot unyank from an upstream server!"
end
|
#serve_versions ⇒ Object
62
63
64
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 62
def serve_versions
redirect index_upstream.url("versions", request.query_string)
end
|
#serve_yank ⇒ Object
34
35
36
|
# File 'lib/gemstash/gem_source/upstream_source.rb', line 34
def serve_yank
halt 403, "Cannot yank from an upstream server!"
end
|