class Epuber::Plugin

Attributes

files[R]

@return [Array<PluginFile>]

path[R]

@return [String]

Public Class Methods

new(path) click to toggle source

@param [String] path

# File lib/epuber/plugin.rb, line 71
def initialize(path)
  @path = path

  @files = if ::File.file?(path)
             [PluginFile.new(path)]
           elsif ::File.directory?(path)
             Dir.glob(File.expand_path('**/*.rb', path)).map do |file_path|
               PluginFile.new(Config.instance.pretty_path_from_project(file_path))
             end
           else
             raise LoadError, "#{self}: Can't find anything for #{path}"
           end

  # expand abs_source_paths to every file
  @files.each do |file|
    file.abs_source_path = File.expand_path(file.source_path, Config.instance.project_path)
  end
end

Public Instance Methods

checkers() click to toggle source

@return [Array<Checker>]

# File lib/epuber/plugin.rb, line 102
def checkers
  instances(Checker)
end
instances(klass) click to toggle source

@param [Class] klass base class of all instances

@return [Array<CheckerTransformerBase>]

# File lib/epuber/plugin.rb, line 94
def instances(klass)
  files.map do |plugin_file|
    plugin_file.instances.select { |inst| inst.is_a?(klass) }
  end.flatten
end
transformers() click to toggle source

@return [Array<Transformer>]

# File lib/epuber/plugin.rb, line 108
def transformers
  instances(Transformer)
end