UNPKG

697 Btext/coffeescriptView Raw
1Operation = require "./Operation"
2
3class Plugin
4 constructor: (plug) ->
5 @_meta = plug.meta
6 @_operations = {}
7 for k,v of plug when typeof v is "function" and k isnt "meta"
8 if k is "_default"
9 @_default = v
10 else
11 @_operations[k] = new Operation k,v
12 return
13
14 operations: -> (op.details() for name, op of @_operations)
15 operation: (name) ->
16 return op if op = @_operations[name]
17 return new Operation name, op if op = @_default? name
18
19 details: ->
20 out =
21 name: @_meta.name
22 author: @_meta.author
23 version: @_meta.version
24 description: @_meta.description
25 operations: @operations()
26 return out
27
28module.exports = Plugin
\No newline at end of file