Module: Hglib::Extension
Defined Under Namespace
Class Method Summary collapse
-
.load_all ⇒ Object
Load all of the extensions.
Instance Method Summary collapse
-
#global_commands(&block) ⇒ Object
Define one or more commands that should be attached to the Hglib module.
-
#repo_commands(&block) ⇒ Object
Define one or more commands that should be attached to Repo objects.
Class Method Details
.load_all ⇒ Object
Load all of the extensions.
18 19 20 21 22 23 24 25 |
# File 'lib/hglib/extension.rb', line 18 def self::load_all # :TODO: Allow gem extensions? extdir = Pathname( __FILE__ ).dirname + 'extension' Pathname.glob( extdir + '*.rb' ).each do |extpath| self.log.debug "Loading extensions from %s" % [ extpath ] require( extpath ) end end |
Instance Method Details
#global_commands(&block) ⇒ Object
Define one or more commands that should be attached to the Hglib module.
40 41 42 43 44 45 46 47 |
# File 'lib/hglib/extension.rb', line 40 def global_commands( &block ) raise LocalJumpError, "no block given" unless block mod = Module.new mod.class_eval( &block ) Hglib.extend( mod ) end |
#repo_commands(&block) ⇒ Object
Define one or more commands that should be attached to Repo objects.
29 30 31 32 33 34 35 36 |
# File 'lib/hglib/extension.rb', line 29 def repo_commands( &block ) raise LocalJumpError, "no block given" unless block mod = Module.new mod.class_eval( &block ) Hglib::Repo.include( mod ) end |