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 muliple 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
43 44 45 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 43 def self.instance_name "danger" end |
Instance Method Details
#import_dangerfile(opts) ⇒ void
This method returns an undefined value.
Import a Dangerfile.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 74 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) || opts.key?(:gitlab) import_dangerfile_from_github(opts[:github] || opts[:gitlab], opts[:branch], opts[:path]) elsif opts.key?(:path) import_dangerfile_from_path(opts[:path]) elsif opts.key?(:gem) import_dangerfile_from_gem(opts[:gem]) else raise "`import` requires a Hash with either :github or :gem" end else raise "`import` requires a Hash" unless opts.kind_of?(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.
55 56 57 58 59 60 61 62 63 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 55 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.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb', line 96 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 else :unknown end end |