Sha256: fc959220fccfba91a9f123e73edbddd463a6640a110526b77bbe94c0f23ffa1e

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module Danger
  class Plugin
    def initialize(dangerfile)
      @dangerfile = dangerfile
    end

    def self.instance_name
      to_s.gsub("Danger", "").danger_underscore.split("/").last
    end

    # Both of these methods exist on all objects
    # http://ruby-doc.org/core-2.2.3/Kernel.html#method-i-warn
    # http://ruby-doc.org/core-2.2.3/Kernel.html#method-i-fail
    # However, as we're using using them in the DSL, they won't
    # get method_missing called correctly.
    undef :warn, :fail

    # Since we have a reference to the Dangerfile containing all the information
    # We need to redirect the self calls to the Dangerfile
    def method_missing(method_sym, *arguments, &block)
      @dangerfile.send(method_sym, *arguments, &block)
    end

    def self.all_plugins
      @all_plugins ||= []
    end

    def self.clear_external_plugins
      @all_plugins = @all_plugins.select { |plugin| Dangerfile.core_plugin_classes.include? plugin }
    end

    def self.inherited(plugin)
      Plugin.all_plugins.push(plugin)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danger-0.10.0 lib/danger/plugin_support/plugin.rb
danger-0.9.1 lib/danger/plugin_support/plugin.rb
danger-0.9.0 lib/danger/plugin_support/plugin.rb