class Dradis::Plugins::Export::Base
Attributes
content_service[RW]
logger[RW]
options[RW]
plugin[RW]
project[RW]
scope[RW]
Public Class Methods
new(args={})
click to toggle source
# File lib/dradis/plugins/export/base.rb, line 10 def initialize(args={}) # Save everything just in case the implementing class needs any of it. @options = args # Can't use :fetch for :plugin or :default_plugin gets evaluated @logger = args.fetch(:logger, Rails.logger) @plugin = args[:plugin] || default_plugin @project = args.key?(:project_id) ? Project.find(args[:project_id]) : nil @scope = args.fetch(:scope, :published).to_sym @content_service = args.fetch(:content_service, default_content_service) post_initialize(args) end
Public Instance Methods
export(args={})
click to toggle source
# File lib/dradis/plugins/export/base.rb, line 25 def export(args={}) raise "The export() method is not implemented in this plugin [#{self.class.name}]." end
post_initialize(args={})
click to toggle source
This method can be overwriten by plugins to do initialization tasks.
# File lib/dradis/plugins/export/base.rb, line 30 def post_initialize(args={}) end
Private Instance Methods
default_content_service()
click to toggle source
# File lib/dradis/plugins/export/base.rb, line 34 def default_content_service @content ||= Dradis::Plugins::ContentService::Base.new( logger: logger, plugin: plugin, project: project, scope: scope ) end
default_plugin()
click to toggle source
This assumes the plugin’s Exporter class is directly nexted into the plugin’s namespace (e.g. Dradis::Plugins::HtmlExport::Exporter)
# File lib/dradis/plugins/export/base.rb, line 45 def default_plugin plugin_module = self.class.name.deconstantize plugin_constant = plugin_module.constantize plugin_engine = plugin_constant::Engine if Dradis::Plugins.registered?(plugin_engine) plugin_constant else raise "You need to pass a :plugin value to your Exporter or define it under your plugin's root namespace." end end