Class: GemChanges::Gem

Inherits:
Struct
  • Object
show all
Defined in:
lib/gem_changes/gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/gem_changes/gem.rb', line 6

def name
  @name
end

Instance Method Details

#changelog_uriObject



11
12
13
14
15
# File 'lib/gem_changes/gem.rb', line 11

def changelog_uri
  rubygems_document.css("a#changelog").first["href"]
rescue StandardError
  nil
end

#rubygems_uriObject



7
8
9
# File 'lib/gem_changes/gem.rb', line 7

def rubygems_uri
  URI.parse("https://rubygems.org/gems/#{name}")
end

#source_code_uriObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gem_changes/gem.rb', line 17

def source_code_uri
  github_span = rubygems_document.at_css("span.github-btn")

  if github_span
    user = github_span.attr("data-user")
    repo = github_span.attr("data-repo")
    return "https://github.com/#{user}/#{repo}"
  end

  code = rubygems_document.at_css("a#code")&.attr("href")
  home = rubygems_document.at_css("a#home")&.attr("href")

  [code, home].compact.first
rescue StandardError
  nil
end