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 84 85 86 87 88 |
# 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(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.(file.source_path, Config.instance.project_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>
102 103 104 |
# File 'lib/epuber/plugin.rb', line 102 def checkers instances(Checker) end |
#instances(klass) ⇒ Array<CheckerTransformerBase>
94 95 96 97 98 |
# 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 ⇒ Array<Transformer>
108 109 110 |
# File 'lib/epuber/plugin.rb', line 108 def transformers instances(Transformer) end |