Class: Atom::Plugger

Inherits:
Object
  • Object
show all
Defined in:
lib/atom/plugger.rb

Class Method Summary collapse

Class Method Details

.load_plugins(plugin_path, plugins) ⇒ Object



3
4
5
6
7
# File 'lib/atom/plugger.rb', line 3

def self.load_plugins(plugin_path, plugins)
  plugins.each do |plugin|
    require File.join("#{plugin_path}", "#{plugin}.rb")
  end
end

.run(plugins, file_path) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/atom/plugger.rb', line 9

def self.run(plugins, file_path)
  text = File.read(file_path)
  
  plugins.each do |plugin|
    classname = plugin.split('_').map(&:capitalize).join
    text = Kernel.const_get(classname).new(text).to_s
  end
  
  Atom::write_file(file_path, text)
end