Class: Danger::DangerfileImportPlugin

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

Overview

One way to support internal plugins is via ‘plugin.import` this gives you the chance to quickly iterate without the need for building rubygems. As such, it does not have the stringent rules around documentation expected of a public plugin. It’s worth noting, that you can also have plugins inside ‘./danger_plugins` and they will be automatically imported into your Dangerfile at launch.

Examples:

Import a plugin available over HTTP


device_grid = "https://raw.githubusercontent.com/fastlane/fastlane/master/danger-device_grid/lib/device_grid/plugin.rb"
plugin.import device_grid

Import from a local file reference


plugin.import "danger/plugins/watch_plugin.rb"

Import all files inside a folder


plugin.import "danger/plugins/*.rb"

See Also:

  • danger/danger

Plugins collapse

Class Method Summary collapse

Methods inherited from Plugin

all_plugins, clear_external_plugins, inherited, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Danger::Plugin

Dynamic Method Handling

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

Class Method Details

.instance_nameObject



27
28
29
# File 'lib/danger/danger_core/plugins/dangerfile_import_plugin.rb', line 27

def self.instance_name
  "plugin"
end

Instance Method Details

#import(path) ⇒ Object

Download a local or remote plugin and use it inside the Dangerfile.

Parameters:

  • path (String)

    a local path or a https URL to the Ruby file to import a danger plugin from.



37
38
39
40
41
42
43
44
45
46
# File 'lib/danger/danger_core/plugins/dangerfile_import_plugin.rb', line 37

def import(path)
  raise "`import` requires a string" unless path.kind_of?(String)
  path += ".rb" unless path.end_with?(".rb")

  if path.start_with?("http")
    import_url(path)
  else
    import_local(path)
  end
end