Class: GemUpdater::SourcePageParser

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

Overview

SourcePageParser is responsible for parsing a source page where the gem code is hosted.

Direct Known Subclasses

GitHubParser

Defined Under Namespace

Classes: GitHubParser

Instance Method Summary collapse

Constructor Details

#initialize(url: nil, version: nil) ⇒ SourcePageParser


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

def initialize( url: nil, version: nil )
  @uri     = correct_uri( url )
  @version = version
end

Instance Method Details

#changelogString?

Get the changelog in an uri.


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gem_updater/source_page_parser.rb', line 20

def changelog
  @changelog ||= begin
    Bundler.ui.warn "Looking for a changelog in #{@uri}"
    doc = Nokogiri::HTML( open( @uri ) )

    find_changelog( doc )

  rescue OpenURI::HTTPError # Uri points to nothing
    Bundler.ui.error "Cannot find #{@uri}"
    false
  rescue Errno::ETIMEDOUT # timeout
    Bundler.ui.error "#{@uri} is down"
    false
  end
end