Module: Kernel
- Defined in:
- lib/framework/rho/rho.rb,
lib/framework/builtinME.rb,
lib/framework/rhoframework.rb,
lib/extensions/mspec/mspec/pp.rb,
lib/extensions/uri/uri/common.rb,
lib/extensions/rhospec/rhospec.rb,
lib/extensions/json/json/common.rb,
lib/extensions/mspec/mspec/helpers/const_lookup.rb
Class Method Summary collapse
-
.pp(*objs) ⇒ Object
prints arguments in pretty form.
-
.URI(uri_str) ⇒ Object
alias for URI.parse.
Instance Method Summary collapse
- #=~(x) ⇒ Object
- #const_lookup(c) ⇒ Object
- #eval_compiled_file(fname, bind) ⇒ Object
- #fork ⇒ Object
-
#j(*objs) ⇒ Object
Outputs objs to STDOUT as JSON strings in the shortest form, that is in one line.
-
#jj(*objs) ⇒ Object
Ouputs objs to STDOUT as JSON strings in a pretty format, with indentation and over many lines.
-
#JSON(object, opts = {}) ⇒ Object
If object is string-like parse the string and return the parsed result as a Ruby data structure.
-
#load(file_name) ⇒ Object
private.
- #nil? ⇒ Boolean
-
#pretty_inspect ⇒ Object
returns a pretty printed object as a string.
-
#require(file_name) ⇒ Object
private.
- #require_model(name) ⇒ Object
- #require_source(name) ⇒ Object
- #singleton_method_added(symbol) ⇒ Object
- #singleton_method_removed(symbol) ⇒ Object
- #singleton_method_undefined(symbol) ⇒ Object
Class Method Details
.pp(*objs) ⇒ Object
prints arguments in pretty form.
pp returns nil.
434 435 436 437 438 439 |
# File 'lib/extensions/mspec/mspec/pp.rb', line 434 def pp(*objs) # :doc: objs.each {|obj| PP.pp(obj) } nil end |
.URI(uri_str) ⇒ Object
alias for URI.parse.
This method is introduced at 1.8.2.
853 854 855 |
# File 'lib/extensions/uri/uri/common.rb', line 853 def URI(uri_str) # :doc: URI.parse(uri_str) end |
Instance Method Details
#=~(x) ⇒ Object
45 46 47 |
# File 'lib/framework/builtinME.rb', line 45 def =~ x false end |
#const_lookup(c) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/extensions/mspec/mspec/helpers/const_lookup.rb', line 2 def const_lookup(c) names = c.split '::' names.shift if names.first.empty? names.inject(Object) do |m, n| defined = RUBY_VERSION =~ /^1.9/ ? m.const_defined?(n, false) : m.const_defined?(n) defined ? m.const_get(n) : m.const_missing(n) end end |
#eval_compiled_file(fname, bind) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/framework/rhoframework.rb', line 33 def eval_compiled_file(fname, bind) require 'erb' rhosim_platform = Rho::RhoConfig.rhosim_platform if rhosim_platform && rhosim_platform.length() > 0 dot = fname.rindex('.') if dot fname1 = fname.dup fname1.insert(dot, "." + rhosim_platform ) else fname1 = fname + "." + rhosim_platform end fname = fname1 if File.exist?(fname1) end puts "eval_compiled_file : #{fname}" strFile = IO.read(fname) code = ERB.new(strFile).src eval(code, bind) end |
#fork ⇒ Object
89 90 91 |
# File 'lib/framework/builtinME.rb', line 89 def fork raise NotImplementedError, "the fork() function is unimplemented on this machine" end |
#j(*objs) ⇒ Object
Outputs objs to STDOUT as JSON strings in the shortest form, that is in one line.
319 320 321 322 323 324 |
# File 'lib/extensions/json/json/common.rb', line 319 def j(*objs) objs.each do |obj| puts JSON::generate(obj, :allow_nan => true, :max_nesting => false) end nil end |
#jj(*objs) ⇒ Object
Ouputs objs to STDOUT as JSON strings in a pretty format, with indentation and over many lines.
328 329 330 331 332 333 |
# File 'lib/extensions/json/json/common.rb', line 328 def jj(*objs) objs.each do |obj| puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false) end nil end |
#JSON(object, opts = {}) ⇒ Object
If object is string-like parse the string and return the parsed result as a Ruby data structure. Otherwise generate a JSON text from the Ruby data structure object and return it.
The opts argument is passed through to generate/parse respectively, see generate and parse for their documentation.
341 342 343 344 345 346 347 |
# File 'lib/extensions/json/json/common.rb', line 341 def JSON(object, opts = {}) if object.respond_to? :to_str JSON.parse(object.to_str, opts) else JSON.generate(object, opts) end end |
#load(file_name) ⇒ Object
private
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/framework/builtinME.rb', line 72 def load(file_name) if __load_with_reflection__(file_name) return true end # $:.each do |path| # return true if load_rb_file(path, file_name) # end raise LoadError, "no such file to load -- " + file_name end |
#nil? ⇒ Boolean
41 42 43 |
# File 'lib/framework/builtinME.rb', line 41 def nil? false end |
#pretty_inspect ⇒ Object
returns a pretty printed object as a string.
426 427 428 |
# File 'lib/extensions/mspec/mspec/pp.rb', line 426 def pretty_inspect PP.pp(self, '') end |
#require(file_name) ⇒ Object
private
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/framework/builtinME.rb', line 59 def require(file_name) return false if ($".include?(file_name) || $".include?(file_name + ".rb")) nExt = file_name.index('.rb') if nExt file_name1 = file_name[0,nExt] #puts "require test: #{file_name1}" return false if ($".include?(file_name1)) end load(file_name); end |
#require_model(name) ⇒ Object
1244 1245 1246 |
# File 'lib/framework/rho/rho.rb', line 1244 def require_model(name) Rho::RHO.get_instance().load_model(name.to_s) end |
#require_source(name) ⇒ Object
1241 1242 1243 |
# File 'lib/framework/rho/rho.rb', line 1241 def require_source(name) Rho::RHO.get_instance().load_model(name.to_s) end |
#singleton_method_added(symbol) ⇒ Object
49 50 |
# File 'lib/framework/builtinME.rb', line 49 def singleton_method_added symbol end |
#singleton_method_removed(symbol) ⇒ Object
52 53 |
# File 'lib/framework/builtinME.rb', line 52 def singleton_method_removed symbol end |
#singleton_method_undefined(symbol) ⇒ Object
55 56 |
# File 'lib/framework/builtinME.rb', line 55 def singleton_method_undefined symbol end |