Class: GemUpdater::SourcePageParser::GitHubParser

Inherits:
GemUpdater::SourcePageParser show all
Defined in:
lib/gem_updater/source_page_parser.rb

Overview

GitHubParser is responsible for parsing source code hosted on github.com.

Constant Summary collapse

BASE_URL =
'https://github.com'

Instance Method Summary collapse

Constructor Details

#initialize(doc, version) ⇒ GitHubParser

Returns a new instance of GitHubParser

Parameters:

  • doc (Nokogiri::XML::Element)

    document of source page

  • version (String)

    version of gem


94
95
96
97
# File 'lib/gem_updater/source_page_parser.rb', line 94

def initialize( doc, version )
  @doc     = doc
  @version = version
end

Instance Method Details

#changelogString

Finds url of changelog.

Returns:

  • (String)

    the URL of changelog


102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/gem_updater/source_page_parser.rb', line 102

def changelog
  url = find_changelog_link

  if url
    full_url = BASE_URL + url

    if changelog_may_contain_anchor?( full_url )
      anchor = find_anchor( full_url )
      full_url += anchor if anchor
    end

    full_url
  end
end