Class: GemUpdater::SourcePageParser
- Inherits:
-
Object
- Object
- GemUpdater::SourcePageParser
- 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
Defined Under Namespace
Classes: GitHubParser
Constant Summary collapse
- HOSTS =
{ github: /github.com/, bitbucket: /bitbucket.org/, rubygems: /rubygems.org/ }.freeze
- MARKUP_FILES =
%w[.md .rdoc .textile].freeze
- CHANGELOG_NAMES =
%w[changelog ChangeLog history changes news].freeze
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#changelog ⇒ String?
Get the changelog in an uri.
-
#initialize(url: nil, version: nil) ⇒ SourcePageParser
constructor
A new instance of SourcePageParser.
Constructor Details
#initialize(url: nil, version: nil) ⇒ SourcePageParser
Returns a new instance of SourcePageParser.
21 22 23 24 |
# File 'lib/gem_updater/source_page_parser.rb', line 21 def initialize(url: nil, version: nil) @uri = correct_uri(url) @version = version end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
17 18 19 |
# File 'lib/gem_updater/source_page_parser.rb', line 17 def uri @uri end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
17 18 19 |
# File 'lib/gem_updater/source_page_parser.rb', line 17 def version @version end |
Instance Method Details
#changelog ⇒ String?
Get the changelog in an uri.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gem_updater/source_page_parser.rb', line 29 def changelog @changelog ||= begin if uri Bundler.ui.warn "Looking for a changelog in #{uri}" doc = Nokogiri::HTML(open(uri)) find_changelog(doc) end 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 |