lib/apidragon/api.rb in apidragon-1.3.0 vs lib/apidragon/api.rb in apidragon-1.4.0
- old
+ new
@@ -12,20 +12,20 @@
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)
+ def initialize(macro_name, config=CONFIG)
`mkdir #{PLUGINS}` unless Dir.exist? PLUGINS
@arg_bucket = {}
- @config = load_config
+ @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
- YAML.load_file CONFIG
+ def load_config(config)
+ YAML.load_file config
end
def go
@macro.each_pair do |_key, value|
call = Call.new(value, @arg_bucket)