Class: Gemdiff::OutdatedGem

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

Constant Summary collapse

LIST_NO_V =

gems that tag releases with tag names like 1.2.3 keep it alphabetical

%w[
  atomic
  autoprefixer-rails
  babosa
  bullet
  cancan
  capybara
  compass
  erubi
  ffi
  google-api-client
  mail
  mysql2
  net-ssh-gateway
  newrelic_rpm
  rack
  rvm-capistrano
  safe_yaml
  sass
  secure_headers
  slack-notifier
  signet
  twilio-ruby
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, old_version = nil, new_version = nil) ⇒ OutdatedGem

Returns a new instance of OutdatedGem.



37
38
39
40
# File 'lib/gemdiff/outdated_gem.rb', line 37

def initialize(name, old_version = nil, new_version = nil)
  @name = find_name(name)
  set_versions old_version, new_version
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/gemdiff/outdated_gem.rb', line 35

def name
  @name
end

#new_versionObject (readonly)

Returns the value of attribute new_version.



35
36
37
# File 'lib/gemdiff/outdated_gem.rb', line 35

def new_version
  @new_version
end

#old_versionObject (readonly)

Returns the value of attribute old_version.



35
36
37
# File 'lib/gemdiff/outdated_gem.rb', line 35

def old_version
  @old_version
end

Instance Method Details

#commits_urlObject



70
71
72
# File 'lib/gemdiff/outdated_gem.rb', line 70

def commits_url
  clean_url "#{repo}/commits/main"
end

#compareObject



90
91
92
# File 'lib/gemdiff/outdated_gem.rb', line 90

def compare
  open_url(compare_url) if repo?
end

#compare_messageObject



74
75
76
# File 'lib/gemdiff/outdated_gem.rb', line 74

def compare_message
  "#{name}: #{new_version} > #{old_version}"
end

#compare_urlObject



78
79
80
# File 'lib/gemdiff/outdated_gem.rb', line 78

def compare_url
  clean_url "#{repo}/compare/#{compare_part}"
end

#load_bundle_versionsObject



50
51
52
53
54
55
56
# File 'lib/gemdiff/outdated_gem.rb', line 50

def load_bundle_versions
  outdated_gem = BundleInspector.new.get(@name)
  return false if outdated_gem.nil?
  @old_version ||= outdated_gem.old_version
  @new_version ||= outdated_gem.new_version
  true
end

#mainObject



82
83
84
# File 'lib/gemdiff/outdated_gem.rb', line 82

def main
  open_url(commits_url) if repo?
end

#missing_versions?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/gemdiff/outdated_gem.rb', line 46

def missing_versions?
  @old_version.nil? || @new_version.nil?
end

#openObject



94
95
96
# File 'lib/gemdiff/outdated_gem.rb', line 94

def open
  open_url(repo) if repo?
end

#releasesObject



86
87
88
# File 'lib/gemdiff/outdated_gem.rb', line 86

def releases
  open_url(releases_url) if repo?
end

#releases_urlObject



66
67
68
# File 'lib/gemdiff/outdated_gem.rb', line 66

def releases_url
  clean_url "#{repo}/releases"
end

#repoObject



58
59
60
# File 'lib/gemdiff/outdated_gem.rb', line 58

def repo
  @repo ||= RepoFinder.github_url(@name)
end

#repo?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/gemdiff/outdated_gem.rb', line 62

def repo?
  repo
end

#set_versions(v_old, v_new) ⇒ Object



42
43
44
# File 'lib/gemdiff/outdated_gem.rb', line 42

def set_versions(v_old, v_new)
  @old_version, @new_version = old_new(v_old, v_new)
end