| Total Complexity | 2 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| 1 | module Carrasco |
||
| 2 | class CommandBuilder |
||
| 3 | def from_config(config) |
||
| 4 | klass = Class.new(Thor) |
||
| 5 | |||
| 6 | config['commands'].each do |method, options| |
||
| 7 | command = Command.new(method, options) |
||
| 8 | inject_command_into_class(command, klass) |
||
| 9 | end |
||
| 10 | |||
| 11 | klass |
||
| 12 | end |
||
| 13 | |||
| 14 | def inject_command_into_class(command, klass) |
||
| 15 | klass.desc(command.help, command.description) |
||
| 16 | klass.class_eval do |
||
| 17 | define_method(command.command_name) do |
||
| 18 | execute_command(command) |
||
| 19 | end |
||
| 20 | end |
||
| 21 | end |
||
| 22 | end |
||
| 24 |