lib/apidragon/api.rb in apidragon-1.4.0 vs lib/apidragon/api.rb in apidragon-1.4.1

- old
+ new

@@ -3,28 +3,29 @@ require 'rest-client' require 'yaml' require_relative 'macro' require_relative 'argbucket' -CONFIG = '/tmp/apidragonconf.yaml' +DEFAULT_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. - def initialize(macro_name, config=CONFIG) + def initialize(macro_name, config) `mkdir #{PLUGINS}` unless Dir.exist? PLUGINS @arg_bucket = {} @config = load_config config import @config['vars'] @macro = @config['macros'][macro_name] if @macro.nil? then fail "Command: '#{macro_name}' is not defined." end end def load_config(config) + if config.nil? then config = DEFAULT_CONFIG end YAML.load_file config end def go @macro.each_pair do |_key, value|