Class: Doubleshot::Resolver::GemResolver::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/doubleshot/resolver/gem_resolver/source.rb

Direct Known Subclasses

GemSource

Constant Summary collapse

SUPPORTED_PLATFORMS =
[ /\bjava\b/i, /^jruby$/i, /^ruby$/i ]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Source

Returns a new instance of Source.



26
27
28
# File 'lib/doubleshot/resolver/gem_resolver/source.rb', line 26

def initialize(uri)
  @uri = uri
end

Class Method Details

.map(*mime_types) ⇒ Object



9
10
11
12
13
# File 'lib/doubleshot/resolver/gem_resolver/source.rb', line 9

def self.map(*mime_types)
  mime_types.each do |mime_type|
    mappings[mime_type.to_s] = self
  end
end

.mappingsObject



15
16
17
# File 'lib/doubleshot/resolver/gem_resolver/source.rb', line 15

def self.mappings
  @@mappings ||= {}
end

.new(uri) ⇒ Object



19
20
21
22
23
24
# File 'lib/doubleshot/resolver/gem_resolver/source.rb', line 19

def self.new(uri)
  uri = URI.parse(uri.to_s)
  instance = mappings[uri.scheme].allocate
  instance.send(:initialize, uri)
  instance
end