Class: Danger::DangerfileDangerPlugin
- Defined in:
- lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb
Overview
A way to interact with Danger herself. Offering APIs to import plugins, and Dangerfiles from multiple sources.
Danger collapse
-
#import_dangerfile(opts) ⇒ void
Import a Dangerfile.
-
#import_plugin(path_or_url) ⇒ void
Download a local or remote plugin and make it usable inside the Dangerfile.
-
#scm_provider ⇒ Symbol
Returns the name of the current SCM Provider being used.
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
48 49 50 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 48 def self.instance_name "danger" end |
Instance Method Details
#import_dangerfile(opts) ⇒ void
This method returns an undefined value.
Import a Dangerfile.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 81 def import_dangerfile(opts) if opts.kind_of?(String) warn "Use `import_dangerfile(github: '#{opts}')` instead of `import_dangerfile '#{opts}'`." import_dangerfile_from_github(opts) elsif opts.kind_of?(Hash) if opts.key?(:github) import_dangerfile_from_github(opts[:github], opts[:ref] || opts[:branch], opts[:path]) elsif opts.key?(:gitlab) import_dangerfile_from_gitlab(opts[:gitlab], opts[:ref] || opts[:branch], opts[:path]) elsif opts.key?(:path) import_dangerfile_from_path(opts[:path]) elsif opts.key?(:gem) import_dangerfile_from_gem(opts[:gem]) elsif opts.key?(:url) import_dangerfile_from_url(opts[:url]) else raise "`import` requires a Hash with either :github, :gitlab, :gem, :path or :url" end else raise "`import` requires a Hash" end end |
#import_plugin(path_or_url) ⇒ void
This method returns an undefined value.
Download a local or remote plugin and make it usable inside the Dangerfile.
60 61 62 63 64 65 66 67 68 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 60 def import_plugin(path_or_url) raise "`import_plugin` 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 |
#scm_provider ⇒ Symbol
Returns the name of the current SCM Provider being used.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 107 def scm_provider return :unknown unless env.request_source case env.request_source when Danger::RequestSources::GitHub :github when Danger::RequestSources::GitLab :gitlab when Danger::RequestSources::BitbucketServer :bitbucket_server when Danger::RequestSources::BitbucketCloud :bitbucket_cloud when Danger::RequestSources::VSTS :vsts else :unknown end end |