Show plugin info on the plugin download page

This commit is contained in:
Alex Ling
2020-07-24 15:02:05 +00:00
parent 3b315ad880
commit 8694b4beaf
3 changed files with 25 additions and 6 deletions

View File

@@ -31,13 +31,13 @@ class Plugin
"plugin directory #{dir}"
end
json = JSON.parse File.read info_path
@json = JSON.parse File.read info_path
begin
{% for name in ["id", "title", "author", "version", "placeholder"] %}
@{{name.id}} = json[{{name}}].as_s
@{{name.id}} = @json[{{name}}].as_s
{% end %}
@wait_seconds = json["wait_seconds"].as_i.to_u64
@wait_seconds = @json["wait_seconds"].as_i.to_u64
unless @id.alphanumeric_underscore?
raise "Plugin ID can only contain alphanumeric characters and " \
@@ -48,6 +48,10 @@ class Plugin
"at #{@dir}. Error: #{e.message}"
end
end
def each(&block : String, JSON::Any -> _)
@json.as_h.each &block
end
end
struct Storage