mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Instantiate Plugin
s by plugin names
This commit is contained in:
parent
d184d6fba5
commit
7e4532fb14
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user