Sha256: e57a912dd8c01dc1aad3d20d9c0135d6098030eb4ab4c362793b97e0ebe53f4a
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
module Quickl class Command class Builder # Adds document tracking information def document(file, line) @file, @line = file, line end # Adds some command class modules def class_modules(*mods) @class_modules ||= [ Command::ClassMethods, Command::Options::ClassMethods, ] @class_modules += mods end alias :class_module class_modules # Adds some command instance modules def instance_modules(*mods) @instance_modules ||= [ Command::InstanceMethods, Command::Robustness, Command::Options::InstanceMethods ] @instance_modules += mods end alias :instance_module instance_modules # Sets the parent of the command currently built def command_parent=(p) @parent = p end # Installs a callback block to execute at # install time def callback(&block) @callbacks ||= [] @callbacks << block end # Installs on a command subclass def run(command) # install class and instance methods class_modules.each{|mod| command.extend(mod) } instance_modules.each{|mod| command.instance_eval{ include mod } } # install documentation if @file and @line command.doc_place = [@file, @line] end # install hierarchy parent = @parent || RubyTools::parent_module(command) if parent && parent.ancestors.include?(Command) command.super_command = parent parent.subcommands << command end # execute callbacks @callbacks.each do |blk| blk.call(command) end if @callbacks command end end # class Builder end # class Command end # module Quickl
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
quickl-0.2.2 | lib/quickl/command/builder.rb |
quickl-0.2.1 | lib/quickl/command/builder.rb |