lib/apidragon/api.rb in apidragon-1.2.0 vs lib/apidragon/api.rb in apidragon-1.2.1
- old
+ new
@@ -13,10 +13,11 @@
# 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.
def initialize(macro_name)
+ `mkdir #{PLUGINS}` unless Dir.exist? PLUGINS
@arg_bucket = {}
@config = load_config
import @config['vars']
@macro = @config['macros'][macro_name]
if @macro.nil? then fail "Command: '#{macro_name}' is not defined." end
@@ -25,22 +26,18 @@
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, value['logging'], value['plugin'])
+ @macro.each_pair do |_key, value|
+ call = Call.new(value, @arg_bucket)
@arg_bucket = call.run
if !value['record'].nil?
value['record'].each do |var|
add_config_var var, get(var)
end
end
end
- end
-
- def rest_get_request(url, **params)
- RestClient.get url, params: params
end
def import(args)
args.each_pair do |key, value|
set key, value