Class: Danger::DangerGemChanges

Inherits:
Plugin
  • Object
show all
Defined in:
lib/danger_plugin.rb

Overview

A Danger plugin that can help code review for PRs that have changes to Gemfile.lock.

Examples:

Print a markdown table summarizing all gem dependency changes


gem_changes.summarize_changes

See Also:

  • Aesthetikx/danger-gem_changes

Instance Method Summary collapse

Instance Method Details

#additionsArray<GemChanges::Change>

New dependencies that have been added.

Returns:



36
37
38
# File 'lib/danger_plugin.rb', line 36

def additions
  changes.select(&:addition?)
end

#changesArray<GemChanges::Change>

All dependencies that have changed.

Returns:



30
31
32
# File 'lib/danger_plugin.rb', line 30

def changes
  GemChanges::Gemfile.changes(git:)
end

#downgradesArray<GemChanges::Change>

Dependencies that were downgraded.

Returns:



54
55
56
# File 'lib/danger_plugin.rb', line 54

def downgrades
  changes.select(&:downgrade?)
end

#removalsArray<GemChanges::Change>

Dependencies that have been removed.

Returns:



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

def removals
  changes.select(&:removal?)
end

#summarize_changes(changes: self.changes, title: "Gemfile.lock Changes") ⇒ void

This method returns an undefined value.

Print a summary of the changes to the Gemfile.lock.

Parameters:

  • changes (Array<GemChanges::Change>) (defaults to: self.changes)

    An optional list of changes to summarize, defaulting to all changes.

  • title (String) (defaults to: "Gemfile.lock Changes")

    An optional title for the header.



18
19
20
21
22
23
24
25
26
# File 'lib/danger_plugin.rb', line 18

def summarize_changes(changes: self.changes, title: "Gemfile.lock Changes")
  return if changes.empty?

  string = "### #{title}\n"

  string += GemChanges::SummaryTable.new(changes:).markdown

  markdown string
end

#upgradesArray<GemChanges::Change>

Dependencies that were upgraded.

Returns:



48
49
50
# File 'lib/danger_plugin.rb', line 48

def upgrades
  changes.select(&:upgrade?)
end