Module: Antrapol::ToolRack::ArgUtils
- Includes:
- ConditionUtils
- Defined in:
- lib/toolrack/arg_utils.rb
Defined Under Namespace
Modules: ClassMethods Classes: ArgParsingException, DuplicatedField, InvalidKey, RequiredFieldEmpty
Class Method Summary collapse
-
.included(klass) ⇒ Object
module ClassMethods.
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
module ClassMethods
110 111 112 |
# File 'lib/toolrack/arg_utils.rb', line 110 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#parse_argv(argv, &block) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/toolrack/arg_utils.rb', line 114 def parse_argv(argv, &block) cb = self.class.callbacks[:pre_processing] if not_empty?(cb) and cb[:cb] #logger.debug "Calling pre-processing for class #{self}" @parse_argv_block = block # here will engage the DSL method of the included class update_argv, val = instance_exec(argv, &cb[:cb]) #logger.debug "Preprocessing return update flag : #{update_argv} and list #{val} for class #{self}" argv = val if update_argv end # split the key and value if given # > app -n:john if self.class.value_separator == " " and argv.length > 0 parse_argv_space(argv) else parse_argv_key_value_mixed(argv) end cbp = self.class.callbacks[:post_processing] if not_empty?(cbp) and cbp[:cb] #logger.debug "Post processing got #{argv}" instance_exec(argv, &cbp[:cb]) end end |