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 pluggin 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.



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

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:



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

def self.instance_name
  "local_repo"
end

.new(dangerfile) ⇒ Object

So that this init can fail.



24
25
26
27
# 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