Class: BundleUpdateInteractive::OutdatedGem

Inherits:
Object
  • Object
show all
Defined in:
lib/bundle_update_interactive/outdated_gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_lockfile_entry:, updated_lockfile_entry:, gemfile_groups:) ⇒ OutdatedGem

Returns a new instance of OutdatedGem.



8
9
10
11
12
13
14
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 8

def initialize(current_lockfile_entry:, updated_lockfile_entry:, gemfile_groups:)
  @current_lockfile_entry = current_lockfile_entry
  @updated_lockfile_entry = updated_lockfile_entry
  @gemfile_groups = gemfile_groups
  @changelog_locator = ChangelogLocator.new
  @vulnerable = nil
end

Instance Attribute Details

#current_lockfile_entryObject (readonly)

Returns the value of attribute current_lockfile_entry.



5
6
7
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 5

def current_lockfile_entry
  @current_lockfile_entry
end

#gemfile_groupsObject (readonly)

Returns the value of attribute gemfile_groups.



5
6
7
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 5

def gemfile_groups
  @gemfile_groups
end

#updated_lockfile_entryObject (readonly)

Returns the value of attribute updated_lockfile_entry.



5
6
7
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 5

def updated_lockfile_entry
  @updated_lockfile_entry
end

#vulnerable=(value) ⇒ Object (writeonly)

Sets the attribute vulnerable

Parameters:

  • value

    the value to set the attribute vulnerable to.



6
7
8
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 6

def vulnerable=(value)
  @vulnerable = value
end

Instance Method Details

#changelog_uriObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 28

def changelog_uri
  return @changelog_uri if defined?(@changelog_uri)

  @changelog_uri =
    if git_version_changed?
      "https://github.com/#{github_repo}/compare/#{current_git_version}...#{updated_git_version}"
    elsif updated_lockfile_entry.rubygems_source?
      changelog_locator.find_changelog_uri(name: name, version: updated_version.to_s)
    else
      begin
        Gem::Specification.find_by_name(name)&.homepage
      rescue Gem::MissingSpecError
        nil
      end
    end
end

#current_git_versionObject



53
54
55
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 53

def current_git_version
  current_lockfile_entry.git_version
end

#current_versionObject



45
46
47
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 45

def current_version
  current_lockfile_entry.version
end

#git_version_changed?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 61

def git_version_changed?
  current_git_version && updated_git_version && current_git_version != updated_git_version
end

#nameObject



16
17
18
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 16

def name
  current_lockfile_entry.name
end

#semver_changeObject



20
21
22
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 20

def semver_change
  @semver_change ||= SemverChange.new(current_version, updated_version)
end

#updated_git_versionObject



57
58
59
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 57

def updated_git_version
  updated_lockfile_entry.git_version
end

#updated_versionObject



49
50
51
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 49

def updated_version
  updated_lockfile_entry.version
end

#vulnerable?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bundle_update_interactive/outdated_gem.rb', line 24

def vulnerable?
  @vulnerable
end