Sha256: aac6a2b8f45cdeb90a35a5c54c4c1f27575c8705709a5d011926affda0b3f7f1

Contents?: true

Size: 755 Bytes

Versions: 6

Compression:

Stored size: 755 Bytes

Contents

## Load plugin from uri and evaluate it -- Soutaro Matsumoto
##
## Load plugiin from uri and evaluate it.
## If you omit "name", the last component of the uri will be used as the name of plugin.
##
## - module: plugin_from_uri
##   config:
##     uri: http://some_host/some_path
##     name: super_plugin
##     config:
##       ** configuration for the plugin **

require 'open-uri'
require 'uri'

def plugin_from_uri(config, data)
  uri = URI(config["uri"])
  name = config["name"] || uri.path.split("/").last.gsub(/\..*$/,'')
  
  body = open(uri.to_s) {|io| io.read}
  
  plugin = Class.new(Plugin)
  plugin.class_eval {
    def initialize()
    end
  }
  plugin.class_eval(body, uri.to_s, 1)
  
  plugin.new().send(name, config["config"], data)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yapra-0.2.2 legacy_plugins/plugin_from_uri.rb
yapra-0.2.0 legacy_plugins/plugin_from_uri.rb
yapra-0.1.3 legacy_plugins/plugin_from_uri.rb
yapra-0.1.0 legacy_plugins/plugin_from_uri.rb
yapra-0.1.1 legacy_plugins/plugin_from_uri.rb
yapra-0.1.2 legacy_plugins/plugin_from_uri.rb