mirror of
https://github.com/extism/extism.git
synced 2026-04-23 03:00:11 -04:00
Work in progress * Adds some inline docs which generates a yarddoc site * Adds linting and code formatting abilities using rufo * Adds a Makefile with common operations Co-authored-by: Steve Manuel <steve@dylib.so>
18 lines
614 B
Ruby
18 lines
614 B
Ruby
require "./lib/extism"
|
|
require "json"
|
|
|
|
# a Context provides a scope for plugins to be managed within. creating multiple contexts
|
|
# is expected and groups plugins based on source/tenant/lifetime etc.
|
|
# We recommend you use `Extism.with_context` unless you have a reason to keep your context around.
|
|
# If you do you can create a context with `Extism#new`, example: `ctx = Extism.new`
|
|
Extism.with_context do |ctx|
|
|
manifest = {
|
|
:wasm => [{ :path => "../wasm/code.wasm" }],
|
|
}
|
|
|
|
plugin = ctx.plugin(manifest)
|
|
res = JSON.parse(plugin.call("count_vowels", ARGV[0] || "this is a test"))
|
|
|
|
puts res["count"]
|
|
end
|