Class: Epuber::Plugin
- Inherits:
-
Object
- Object
- Epuber::Plugin
- Defined in:
- lib/epuber/plugin.rb
Defined Under Namespace
Classes: PluginFile
Instance Attribute Summary collapse
- #files ⇒ Array<PluginFile> readonly
- #path ⇒ String readonly
Instance Method Summary collapse
- #checkers ⇒ Array<Checker>
-
#initialize(path) ⇒ Plugin
constructor
A new instance of Plugin.
- #instances(klass) ⇒ Array<CheckerTransformerBase>
- #transformers ⇒ Array<Transformer>
Constructor Details
#initialize(path) ⇒ Plugin
Returns a new instance of Plugin.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# 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.('**/*.rb', path)).map do |file_path| PluginFile.new(file_path) end else raise LoadError, "#{self}: Can't find anything for #{path}" end end |
Instance Attribute Details
#files ⇒ Array<PluginFile> (readonly)
67 68 69 |
# File 'lib/epuber/plugin.rb', line 67 def files @files end |
#path ⇒ String (readonly)
63 64 65 |
# File 'lib/epuber/plugin.rb', line 63 def path @path end |
Instance Method Details
#checkers ⇒ Array<Checker>
98 99 100 |
# File 'lib/epuber/plugin.rb', line 98 def checkers instances(Checker) end |
#instances(klass) ⇒ Array<CheckerTransformerBase>
89 90 91 92 93 |
# File 'lib/epuber/plugin.rb', line 89 def instances(klass) files.map do |plugin_file| plugin_file.instances.select { |inst| inst.is_a?(klass) } end.flatten end |
#transformers ⇒ Array<Transformer>
104 105 106 |
# File 'lib/epuber/plugin.rb', line 104 def transformers instances(Transformer) end |