Class: BundleUpdateInteractive::CLI::Row
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- BundleUpdateInteractive::CLI::Row
- 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
- #apply_semver_highlight(value) ⇒ Object
- #formatted_changelog_uri ⇒ Object
- #formatted_current_version ⇒ Object
- #formatted_gem_name ⇒ Object
- #formatted_gemfile_groups ⇒ Object
- #formatted_updated_version ⇒ Object
-
#initialize(outdated_gem) ⇒ Row
constructor
A new instance of Row.
- #to_a ⇒ Object
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_uri ⇒ Object
49 50 51 |
# File 'lib/bundle_update_interactive/cli/row.rb', line 49 def formatted_changelog_uri pastel.blue(changelog_uri) end |
#formatted_current_version ⇒ Object
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_name ⇒ Object
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_groups ⇒ Object
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_version ⇒ Object
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_a ⇒ Object
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 |