Class: Gemstash::GemSource::PrivateSource

Inherits:
Base
  • Object
show all
Includes:
Env::Helper, DependencyCaching
Defined in:
lib/gemstash/gem_source/private_source.rb

Overview

GemSource for privately stored gems.

Constant Summary

Constants included from DependencyCaching

DependencyCaching::API_REQUEST_LIMIT

Constants included from Logging

Logging::LEVELS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DependencyCaching

#serve_dependencies, #serve_dependencies_json

Methods inherited from Base

#initialize

Methods included from Logging

#log, #log_error, logger, reset, setup_logger

Constructor Details

This class inherits a constructor from Gemstash::GemSource::Base

Instance Attribute Details

#authObject

Returns the value of attribute auth.



9
10
11
# File 'lib/gemstash/gem_source/private_source.rb', line 9

def auth
  @auth
end

Class Method Details

.matches?(env) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/gemstash/gem_source/private_source.rb', line 15

def self.matches?(env)
  rewriter = rack_env_rewriter.for(env)
  return false unless rewriter.matches?
  rewriter.rewrite
  true
end

.rack_env_rewriterObject



11
12
13
# File 'lib/gemstash/gem_source/private_source.rb', line 11

def self.rack_env_rewriter
  @rack_env_rewriter ||= Gemstash::RackEnvRewriter.new(%r{\A/private})
end

Instance Method Details

#serve_actual_gem(id) ⇒ Object



69
70
71
# File 'lib/gemstash/gem_source/private_source.rb', line 69

def serve_actual_gem(id)
  halt 403, "Not yet supported"
end

#serve_add_gemObject



26
27
28
# File 'lib/gemstash/gem_source/private_source.rb', line 26

def serve_add_gem
  protected(Gemstash::GemPusher)
end

#serve_add_spec_jsonObject



38
39
40
# File 'lib/gemstash/gem_source/private_source.rb', line 38

def serve_add_spec_json
  halt 403, "Not yet supported"
end

#serve_gem(id) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/gemstash/gem_source/private_source.rb', line 73

def serve_gem(id)
  authorization.protect(self) do
    auth.check("fetch") if gemstash_env.config[:protected_fetch]
    gem_full_name = id.sub(/\.gem\z/, "")
    gem = fetch_gem(gem_full_name)
    content_type "application/octet-stream"
    gem.content(:gem)
  end
end

#serve_info(name) ⇒ Object



54
55
56
# File 'lib/gemstash/gem_source/private_source.rb', line 54

def serve_info(name)
  halt 403, "Not yet supported"
end

#serve_latest_specsObject



88
89
90
91
# File 'lib/gemstash/gem_source/private_source.rb', line 88

def serve_latest_specs
  params[:latest] = true
  protected(Gemstash::SpecsBuilder)
end

#serve_marshal(id) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/gemstash/gem_source/private_source.rb', line 58

def serve_marshal(id)
  authorization.protect(self) do
    auth.check("fetch") if gemstash_env.config[:protected_fetch]
    gem_full_name = id.sub(/\.gemspec\.rz\z/, "")
    gem = fetch_gem(gem_full_name)
    halt 404 unless gem.exist?(:spec)
    content_type "application/octet-stream"
    gem.content(:spec)
  end
end

#serve_namesObject



46
47
48
# File 'lib/gemstash/gem_source/private_source.rb', line 46

def serve_names
  halt 403, "Not yet supported"
end

#serve_prerelease_specsObject



93
94
95
96
# File 'lib/gemstash/gem_source/private_source.rb', line 93

def serve_prerelease_specs
  params[:prerelease] = true
  protected(Gemstash::SpecsBuilder)
end

#serve_remove_spec_jsonObject



42
43
44
# File 'lib/gemstash/gem_source/private_source.rb', line 42

def serve_remove_spec_json
  halt 403, "Not yet supported"
end

#serve_rootObject



22
23
24
# File 'lib/gemstash/gem_source/private_source.rb', line 22

def serve_root
  halt 403, "Not yet supported"
end

#serve_specsObject



83
84
85
86
# File 'lib/gemstash/gem_source/private_source.rb', line 83

def serve_specs
  params[:prerelease] = false
  protected(Gemstash::SpecsBuilder)
end

#serve_unyankObject



34
35
36
# File 'lib/gemstash/gem_source/private_source.rb', line 34

def serve_unyank
  protected(Gemstash::GemUnyanker)
end

#serve_versionsObject



50
51
52
# File 'lib/gemstash/gem_source/private_source.rb', line 50

def serve_versions
  halt 403, "Not yet supported"
end

#serve_yankObject



30
31
32
# File 'lib/gemstash/gem_source/private_source.rb', line 30

def serve_yank
  protected(Gemstash::GemYanker)
end