_ = require 'lodash'

module.exports = (conf, appkey, debug) ->
  if debug
    console.log JSON.stringify conf, null, 4
  config = _.find conf, (c) ->
    c.app_key is appkey
  pkg = require config.plugin
  new pkg config, debug