lib/danger/plugin_support/plugin.rb in danger-0.8.1 vs lib/danger/plugin_support/plugin.rb in danger-0.8.2

- old
+ new

@@ -3,29 +3,30 @@ def initialize(dangerfile) @dangerfile = dangerfile end def self.instance_name - self.to_s.gsub("Danger", "").danger_underscore.split('/').last + 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 - def warn(*args, &blk) - method_missing(:warn, *args, &blk) + # 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 fail(*args, &blk) - method_missing(:fail, *args, &blk) + def self.all_plugins + @all_plugins ||= [] end - # 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) + def self.inherited(plugin) + Plugin.all_plugins.push(plugin) end end end