Class: Danger::DangerfileLocalOnlyPlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb

Overview

Handles interacting with local only plugin inside a Dangerfile. It is support plugin for dry_run command and does not expose any methods. But you can still use other plugins like git

Examples:

Check that added lines contains agreed form of words


git.diff.each do |chunk|
  chunk.patch.lines.grep(/^\+/).each do |added_line|
    if added_line.gsub!(/(?<cancel>cancel)(?<rest>[^l[[:space:]][[:punct:]]]+)/i, '>>\k<cancel>-l-\k<rest><<')
      fail "Single 'L' for cancellation-alike words in '#{added_line}'"
    end
  end
end

See Also:

  • danger/danger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

all_plugins, clear_external_plugins, inherited, #method_missing

Constructor Details

#initialize(dangerfile) ⇒ DangerfileLocalOnlyPlugin

Returns a new instance of DangerfileLocalOnlyPlugin.



30
31
32
33
34
# File 'lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb', line 30

def initialize(dangerfile)
  super(dangerfile)

  @local_repo = dangerfile.env.request_source
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Danger::Plugin

Class Method Details

.instance_nameString

The instance name used in the Dangerfile

Returns:



39
40
41
# File 'lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb', line 39

def self.instance_name
  "local_repo"
end

.new(dangerfile) ⇒ Object

So that this init can fail.



24
25
26
27
28
# File 'lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb', line 24

def self.new(dangerfile)
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::LocalOnly

  super
end