Class: Gemstash::GemSource::RackMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/gemstash/gem_source/rack_middleware.rb

Overview

Rack middleware to detect the gem source from the URL.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RackMiddleware

Returns a new instance of RackMiddleware.



7
8
9
# File 'lib/gemstash/gem_source/rack_middleware.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/gemstash/gem_source/rack_middleware.rb', line 11

def call(env)
  Gemstash::GemSource.sources.each do |source|
    next unless source.matches?(env)
    env["gemstash.gem_source"] = source
    break
  end

  @app.call(env)
end