Class: BundleUpdateInteractive::CLI::Row

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/bundle_update_interactive/cli/row.rb

Constant Summary collapse

SEMVER_COLORS =
{
  major: :red,
  minor: :yellow,
  patch: :green
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(outdated_gem) ⇒ Row

Returns a new instance of Row.



15
16
17
18
# File 'lib/bundle_update_interactive/cli/row.rb', line 15

def initialize(outdated_gem)
  super
  @pastel = BundleUpdateInteractive.pastel
end

Instance Method Details

#apply_semver_highlight(value) ⇒ Object



47
48
49
50
# File 'lib/bundle_update_interactive/cli/row.rb', line 47

def apply_semver_highlight(value)
  color = git_version_changed? ? :cyan : SEMVER_COLORS.fetch(semver_change.severity)
  pastel.decorate(value, color)
end

#formatted_changelog_uriObject



43
44
45
# File 'lib/bundle_update_interactive/cli/row.rb', line 43

def formatted_changelog_uri
  pastel.blue(changelog_uri)
end

#formatted_current_versionObject



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

def formatted_current_version
  [current_version.to_s, current_git_version].compact.join(" ")
end

#formatted_gem_nameObject



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

def formatted_gem_name
  vulnerable? ? pastel.white.on_red(name) : apply_semver_highlight(name)
end

#formatted_gemfile_groupsObject



35
36
37
# File 'lib/bundle_update_interactive/cli/row.rb', line 35

def formatted_gemfile_groups
  gemfile_groups&.map(&:inspect)&.join(", ")
end

#formatted_gemfile_requirementObject



39
40
41
# File 'lib/bundle_update_interactive/cli/row.rb', line 39

def formatted_gemfile_requirement
  gemfile_requirement.to_s == ">= 0" ? "" : gemfile_requirement.to_s
end

#formatted_updated_versionObject



28
29
30
31
32
33
# File 'lib/bundle_update_interactive/cli/row.rb', line 28

def formatted_updated_version
  version = semver_change.format { |part| apply_semver_highlight(part) }
  git_version = apply_semver_highlight(updated_git_version)

  [version, git_version].compact.join(" ")
end