lib/apidragon/api.rb in apidragon-1.0.0 vs lib/apidragon/api.rb in apidragon-1.1.0
- old
+ new
@@ -4,10 +4,12 @@
require 'yaml'
require_relative 'macro'
require_relative 'argbucket'
CONFIG = '/tmp/apidragonconf.yaml'
+PLUGINS = '/tmp/apidragonplugins/'
+LOG = '/tmp/apidragon.log'
class Api < ArgBucket
# Uses the configuration data in config.yaml to run a sequence of api calls.
# All variables are dumped into a variable bucket (@arg_bucket)
# so that they can be used as parameters for function calls.
@@ -19,30 +21,22 @@
import @config['vars']
@macro = @config['macros'][macro_name]
if @macro.nil? then fail "Command: '#{macro_name}' is not defined." end
end
- def macro_init
- macro = @macro
- @macro = []
- macro.each_pair do |key, value|
- @macro << Call.new(value['input'], value['output'], value['mode'], value['function'], @arg_bucket)
- end
- end
-
def load_config
YAML.load_file CONFIG
end
def go
@macro.each_pair do |key, value|
- call = Call.new(value['input'], value['output'], value['mode'], value['function'], @arg_bucket)
+ call = Call.new(value['input'], value['output'], value['mode'], value['function'], @arg_bucket, value['logging'], value['plugin'])
@arg_bucket = call.run
if !value['record'].nil?
value['record'].each do |var|
add_config_var var, get(var)
end
- end
+ end
end
end
def rest_get_request(url, **params)
RestClient.get url, params: params