mirror of
https://github.com/hkalexling/Mango.git
synced 2026-01-25 00:00:36 -05:00
Instantiate Plugins by plugin names
This commit is contained in:
@@ -22,9 +22,8 @@ class Plugin
|
||||
|
||||
def self.list
|
||||
dir = Config.current.plugin_path
|
||||
unless Dir.exists? dir
|
||||
Dir.mkdir_p dir
|
||||
end
|
||||
Dir.mkdir_p dir unless Dir.exists? dir
|
||||
|
||||
Dir.children(dir)
|
||||
.select do |f|
|
||||
fp = File.join dir, f
|
||||
@@ -35,7 +34,16 @@ class Plugin
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(@path : String)
|
||||
def initialize(filename : String)
|
||||
dir = Config.current.plugin_path
|
||||
pp dir
|
||||
Dir.mkdir_p dir unless Dir.exists? dir
|
||||
|
||||
@path = File.join dir, "#{filename}.js"
|
||||
unless File.exists? @path
|
||||
raise Error.new "Plugin script not found at #{@path}"
|
||||
end
|
||||
|
||||
@rt = Duktape::Runtime.new do |sbx|
|
||||
sbx.push_global_object
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ class Queue
|
||||
property success_count : Int32 = 0
|
||||
property fail_count : Int32 = 0
|
||||
property time : Time
|
||||
property plugin_name : String?
|
||||
|
||||
def parse_query_result(res : DB::ResultSet)
|
||||
@id = res.read String
|
||||
@@ -59,6 +60,11 @@ class Queue
|
||||
time = res.read Int64
|
||||
@status = JobStatus.new status
|
||||
@time = Time.unix_ms time
|
||||
|
||||
ary = @id.split("-")
|
||||
if ary.size > 1
|
||||
plugin_name = ary[0]
|
||||
end
|
||||
end
|
||||
|
||||
# Raises if the result set does not contain the correct set of columns
|
||||
|
||||
Reference in New Issue
Block a user