Class: Danger::DangerfileImportPlugin
- 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.
Plugins collapse
-
#download(path_or_url) ⇒ String
Download a local or remote plugin or Dangerfile This method will not import the file for you, use plugin.import instead.
-
#import(path_or_url) ⇒ void
Download a local or remote plugin and use it inside the Dangerfile.
Class Method Summary collapse
-
.instance_name ⇒ String
The instance name used in the Dangerfile.
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_name ⇒ String
The instance name used in the Dangerfile
30 31 32 |
# File 'lib/danger/danger_core/plugins/dangerfile_import_plugin.rb', line 30 def self.instance_name "plugin" end |
Instance Method Details
#download(path_or_url) ⇒ String
Download a local or remote plugin or Dangerfile This method will not import the file for you, use plugin.import instead
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/danger/danger_core/plugins/dangerfile_import_plugin.rb', line 61 def download(path_or_url) raise "`download` requires a string" unless path_or_url.kind_of?(String) raise "URL is not https, for security reasons `danger` only supports encrypted requests" if URI.parse(path_or_url).scheme != "https" require "tmpdir" require "faraday" @http_client ||= Faraday.new do |b| b.adapter :net_http end content = @http_client.get(path_or_url) path = File.join(Dir.mktmpdir, "temporary_danger.rb") File.write(path, content.body) return path end |
#import(path_or_url) ⇒ void
This method returns an undefined value.
Download a local or remote plugin and use it inside the Dangerfile.
42 43 44 45 46 47 48 49 50 |
# File 'lib/danger/danger_core/plugins/dangerfile_import_plugin.rb', line 42 def import(path_or_url) raise "`import` requires a string" unless path_or_url.kind_of?(String) if path_or_url.start_with?("http") import_url(path_or_url) else import_local(path_or_url) end end |