Class: GemUpdater::RubyGemsFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_updater/ruby_gems_fetcher.rb

Overview

RubyGemsFetcher is a wrapper around rubygems API.

Constant Summary collapse

HTTP_TOO_MANY_REQUESTS =
'429'.freeze
GEM_HOMEPAGES =
%w[source_code_uri homepage_uri].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_name, source) ⇒ RubyGemsFetcher

Returns a new instance of RubyGemsFetcher.

Parameters:

  • gem_name (String)

    name of the gem

  • source (Bundler::Source)

    source of gem



16
17
18
19
# File 'lib/gem_updater/ruby_gems_fetcher.rb', line 16

def initialize(gem_name, source)
  @gem_name = gem_name
  @source   = source
end

Instance Attribute Details

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



12
13
14
# File 'lib/gem_updater/ruby_gems_fetcher.rb', line 12

def gem_name
  @gem_name
end

#sourceObject (readonly)

Returns the value of attribute source.



12
13
14
# File 'lib/gem_updater/ruby_gems_fetcher.rb', line 12

def source
  @source
end

Instance Method Details

#source_uriString|nil

Finds where code is hosted. Most likely in will be on rubygems, else look in other sources.

Returns:

  • (String|nil)

    url of gem source code



25
26
27
# File 'lib/gem_updater/ruby_gems_fetcher.rb', line 25

def source_uri
  uri_from_rubygems || uri_from_other_sources
end