Module: Hglib::Extension

Extended by:
Loggability
Included in:
GPG, Topic
Defined in:
lib/hglib/extension.rb

Defined Under Namespace

Modules: GPG, Topic

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load_allObject

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.

Raises:

  • (LocalJumpError)


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.

Raises:

  • (LocalJumpError)


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