Class: GemUpdater::ChangelogParser::GithubParser

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

Overview

ChangelogParser is responsible for parsing a changelog hosted on github.

Constant Summary collapse

REACT_DATA_XPATH =
'//script[@data-target="react-app.embeddedData"]'
REACT_PAYLOAD_TOC_PATH =
%w[payload blob headerInfo toc].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri:, version:) ⇒ GithubParser

Returns a new instance of GithubParser.

Parameters:

  • uri (String)

    changelog uri

  • version (String)

    version of gem



17
18
19
20
# File 'lib/gem_updater/changelog_parser/github_parser.rb', line 17

def initialize(uri:, version:)
  @uri     = uri
  @version = version
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



13
14
15
# File 'lib/gem_updater/changelog_parser/github_parser.rb', line 13

def uri
  @uri
end

#versionObject (readonly)

Returns the value of attribute version.



13
14
15
# File 'lib/gem_updater/changelog_parser/github_parser.rb', line 13

def version
  @version
end

Instance Method Details

#changelogString

Finds anchor in changelog, otherwise return the base uri.

Returns:

  • (String)

    the URL of changelog



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

def changelog
  uri + find_anchor(document).to_s
end