Module: Avm::EacRubyBase1::Sources::Base::GemProvider

Defined in:
lib/avm/eac_ruby_base1/sources/base/gem_provider.rb

Constant Summary collapse

DEFAULT_GEM_PROVIDER_TYPE =
'rubygems_org'
GEM_PROVIDER_CONFIG_ROOT_KEY =
'ruby.gem_provider'
GEM_PROVIDER_CONFIG_TYPE_SUBKEY =
'type'
GEM_PROVIDER_CONFIG_URL_SUBKEY =
'url'

Instance Method Summary collapse

Instance Method Details

#default_gem_providerAvm::EacRubyBase1::Rubygems::Providers::Base



14
15
16
# File 'lib/avm/eac_ruby_base1/sources/base/gem_provider.rb', line 14

def default_gem_provider
  ::Avm::EacRubyBase1::Rubygems::Providers::RubygemsOrg.new
end

#gem_providerObject



33
34
35
36
37
38
39
40
41
# File 'lib/avm/eac_ruby_base1/sources/base/gem_provider.rb', line 33

def gem_provider
  ::Avm::EacRubyBase1::Rubygems::Providers.const_get(
    (gem_provider_key(GEM_PROVIDER_CONFIG_TYPE_SUBKEY) || DEFAULT_GEM_PROVIDER_TYPE).to_s
      .camelize
  ).new(
    gem_provider_key(GEM_PROVIDER_CONFIG_URL_SUBKEY) ||
      ::Avm::EacRubyBase1::Rubygems::Providers::RubygemsOrg::DEFAULT_ROOT_HTTP_URL
  )
end

#gem_provider_key(subkey) ⇒ String

Parameters:

  • subkey (String)

Returns:

  • (String)


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/avm/eac_ruby_base1/sources/base/gem_provider.rb', line 20

def gem_provider_key(subkey)
  key = [GEM_PROVIDER_CONFIG_ROOT_KEY, subkey].join('.')
  r = nil
  [application, configuration].each do |provider|
    value = provider.entry(key).value
    if value.present?
      r = value
      break
    end
  end
  r
end