Module: Kernel
- Defined in:
- lib/n/std.rb,
lib/n/parts.rb,
lib/n/macros.rb
Instance Method Summary collapse
- #old_require ⇒ Object
-
#pp_exception(ex) ⇒ Object
pretty prints an exception/error object usefull for helpfull debug messages.
-
#register_part(part_class) ⇒ Object
Register a part.
- #require(path) ⇒ Object
-
#require_part(path) ⇒ Object
Special require for part definitions.
Instance Method Details
#old_require ⇒ Object
16 |
# File 'lib/n/macros.rb', line 16 alias_method :old_require, :require |
#pp_exception(ex) ⇒ Object
pretty prints an exception/error object usefull for helpfull debug messages
Input: The Exception/StandardError object
Output: the pretty printed string
52 53 54 |
# File 'lib/n/std.rb', line 52 def pp_exception(ex) return %{#{ex.}\n\tBACKTRACE:\n\t#{ex.backtrace.join("\n\t")}\n\tLOGGED FROM:\n\t#{caller[0]}} end |
#register_part(part_class) ⇒ Object
Register a part
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/n/parts.rb', line 38 def register_part(part_class) part = part_class.instance() $parts[part.name] = part # gmosx: DOESNT work yet, we have to manage # the require order, perhaps DI/Copland can help # here? # auto require the parts this one depends # on. # #for dep_part in part.dependencies # require_part(dep_part) #end part.start() end |
#require(path) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/n/macros.rb', line 17 def require(path) return if $__required__[path] source = File.read(path) # parse macro source.gsub!(/defmacro\s*\/(.*?)\/\s(.*?)endmacro/m) { $__macros__[Regexp.new($1)] = $2 ; "" } # expand macros $__macros__.each { |match, replace| source.gsub!(match, replace) } $__required__[path] = true eval(source) end |
#require_part(path) ⇒ Object
Special require for part definitions.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/n/parts.rb', line 24 def require_part(path) require("p/#{path}/part") for lc in $lc_use begin require("p/#{path}/#{lc}") rescue LoadError => e # Drink it! # $log.debug "No localization files for part '#{path}'" if $DBG end end end |