Files
extism/ruby/example.rb
Benjamin Eckel ffa01403a3 feat(ruby-sdk): create Extism module / namespace (#5)
I noticed when calling set_log_file that it's on the top-level namespace.
And so is the rest of the gem. It's not a good idea to do this as it
pollutes the user's application. Best practice is to wrap all code in a
module which by convention is the gem name.

I was also getting `Uninitialized constant FFI:NIL` and in the
set_log_file method and I could not tell why it was needed. I changed it
to a regular ruby nil. If it's needed for some reason I'll change it
back or move to another PR.
2022-09-04 17:05:10 -06:00

11 lines
230 B
Ruby

require './lib/extism'
require 'json'
manifest = {
:wasm => [{:path => "../wasm/code.wasm"}]
}
plugin = Extism::Plugin.new(manifest)
res = JSON.parse(plugin.call("count_vowels", ARGV[0] || "this is a test"))
puts res['count']