Class: GemUpdater::ChangelogParser

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

Overview

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

Defined Under Namespace

Classes: GithubParser

Constant Summary collapse

MARKUP_FILES =
%w[.md .rdoc .textile].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri:, version:) ⇒ ChangelogParser

Returns a new instance of ChangelogParser.

Parameters:

  • uri (String)

    uri of changelog

  • version (String)

    version of gem



17
18
19
20
# File 'lib/gem_updater/changelog_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.rb', line 13

def uri
  @uri
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#changelogString?

Get the changelog in an uri.

Returns:

  • (String, nil)

    URL of changelog



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gem_updater/changelog_parser.rb', line 25

def changelog
  return uri unless changelog_may_contain_anchor?

  parse_changelog
rescue OpenURI::HTTPError # Uri points to nothing
  log_error_and_return_uri("Cannot find #{uri}")
rescue Errno::ETIMEDOUT # timeout
  log_error_and_return_uri("#{URI.parse(uri).host} is down")
rescue ArgumentError => e # x-oauth-basic raises userinfo not supported. [RFC3986]
  log_error_and_return_uri(e)
end