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.



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

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

Instance Method Details

#apply_semver_highlight(value) ⇒ Object



53
54
55
56
# File 'lib/bundle_update_interactive/cli/row.rb', line 53

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

#formatted_changelog_uriObject



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

def formatted_changelog_uri
  pastel.blue(changelog_uri)
end

#formatted_current_versionObject



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

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

#formatted_gem_nameObject



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

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

#formatted_gemfile_groupsObject



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

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

#formatted_updated_versionObject



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

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

#to_aObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/bundle_update_interactive/cli/row.rb', line 19

def to_a
  [
    formatted_gem_name,
    formatted_current_version,
    "",
    formatted_updated_version,
    formatted_gemfile_groups,
    formatted_changelog_uri
  ]
end