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'.freeze

Constants inherited from GemUpdater::SourcePageParser

CHANGELOG_NAMES, HOSTS, MARKUP_FILES

Instance Attribute Summary collapse

Attributes inherited from GemUpdater::SourcePageParser

#uri

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



124
125
126
127
# File 'lib/gem_updater/source_page_parser.rb', line 124

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

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



120
121
122
# File 'lib/gem_updater/source_page_parser.rb', line 120

def doc
  @doc
end

#versionObject (readonly)

Returns the value of attribute version.



120
121
122
# File 'lib/gem_updater/source_page_parser.rb', line 120

def version
  @version
end

Instance Method Details

#changelogString

Finds url of changelog.

Returns:

  • (String)

    the URL of changelog



132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/gem_updater/source_page_parser.rb', line 132

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