Module: RVM

Defined in:
lib/rvm.rb,
lib/rvm/plugin.rb,
lib/rvm/classes.rb,
lib/rvm/library.rb,
lib/rvm/functions.rb,
lib/rvm/languages.rb,
lib/rvm/interpreter.rb,
lib/rvm/classes/list.rb,
lib/rvm/classes/block.rb,
lib/rvm/classes/class.rb,
lib/rvm/classes/error.rb,
lib/rvm/classes/number.rb,
lib/rvm/classes/object.rb,
lib/rvm/classes/string.rb,
lib/rvm/languages/ecma.rb,
lib/rvm/languages/math.rb,
lib/rvm/classes/boolean.rb,
lib/rvm/functions/array/at.rb,
lib/rvm/functions/io/print.rb,
lib/rvm/functions/list/map.rb,
lib/rvm/functions/logic/or.rb,
lib/rvm/functions/math/add.rb,
lib/rvm/functions/math/div.rb,
lib/rvm/functions/math/mul.rb,
lib/rvm/functions/math/neg.rb,
lib/rvm/functions/math/sub.rb,
lib/rvm/classes/association.rb,
lib/rvm/functions/list/join.rb,
lib/rvm/functions/logic/and.rb,
lib/rvm/functions/logic/not.rb,
lib/rvm/languages/brainfuck.rb,
lib/rvm/languages/math/tree.rb,
lib/rvm/functions/general/eq.rb,
lib/rvm/functions/general/gt.rb,
lib/rvm/functions/general/lt.rb,
lib/rvm/functions/list/align.rb,
lib/rvm/functions/list/split.rb,
lib/rvm/functions/math/power.rb,
lib/rvm/functions/string/chr.rb,
lib/rvm/functions/general/cmp.rb,
lib/rvm/functions/general/gte.rb,
lib/rvm/functions/general/lte.rb,
lib/rvm/functions/general/neq.rb,
lib/rvm/functions/string/ansi.rb,
lib/rvm/functions/array/append.rb,
lib/rvm/functions/array/set_at.rb,
lib/rvm/functions/objects/send.rb,
lib/rvm/functions/string/ljust.rb,
lib/rvm/functions/string/rjust.rb,
lib/rvm/functions/string/capstr.rb,
lib/rvm/functions/string/center.rb,
lib/rvm/languages/math/compiler.rb,
lib/rvm/functions/collection/get.rb,
lib/rvm/functions/collection/set.rb,
lib/rvm/languages/math/tokenizer.rb,
lib/rvm/functions/collection/size.rb,
lib/rvm/functions/string/regmatch.rb,
lib/rvm/functions/association/assoc_get.rb,
lib/rvm/functions/association/assoc_set.rb

Overview

This is the rVM library. Including it loads the very basic functionalites rVM offers.

It however does not yet load any functions or languages for security propose. This will have to be done by hand for the reason that it will force the user to concider which functions he wants to offer and which not.

You may very well load your own functions and languages with rVM in the same way you can load shipped languages.

It also contains some usefull functions that wil allow to make the usuage easyer.

Defined Under Namespace

Modules: ActsAsRVMType, Classes, Functions, Interpreter, Languages, Plugin, PluginHost Classes: Library, Safety

Constant Summary collapse

@@strict =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.compile(language, code) ⇒ Object

Compils a code the given language. A new compiler is created for that and discarded afterwards.

Using compiler_for and calling compile for it yourself is more performant if you plan on doing thise more then once.



75
76
77
# File 'lib/rvm.rb', line 75

def compile language, code
  compiler_for(language).compile(code)
end

.compiler_for(language) ⇒ Object

Creates you a compiler object for the given language. If no language is given a error is raised.



81
82
83
84
85
86
87
# File 'lib/rvm.rb', line 81

def compiler_for language
  if (l = RVM::Languages[language])
    l.new
  else
    raise "RVM Error: Unknown Language #{language}"
  end
end

.debug(text) ⇒ Object

A utility function to give debug output based on weather $DEBUG is set or not



90
91
92
# File 'lib/rvm.rb', line 90

def debug text
  puts text if $DEBUG
end

.strictObject

This getter returns if rVM handles types strict.

Calling a method with wrong types will raise a error if this is true. If false rVM will try to typecast accordingly.



60
61
62
# File 'lib/rvm.rb', line 60

def strict
  @@strict
end

.strict=(v) ⇒ Object

Sets if variables are strictly typed or casted for function calls. This allows to make a language either more secure or more flexible.



66
67
68
# File 'lib/rvm.rb', line 66

def strict= v
  @@strict = v
end

Instance Method Details

#require_plugin(path) ⇒ Object

Convenience method for plugin loading. The syntax used is:

require_plugin '<Host ID>/<Plugin ID>'

Returns the loaded plugin.



266
267
268
269
270
271
272
# File 'lib/rvm/plugin.rb', line 266

def require_plugin path
  host_id, plugin_id = path.split '/', 2
  host = PluginHost.host_by_id(host_id)
  raise PluginHost::HostNotFound,
  "No host for #{host_id.inspect} found." unless host
  host.load plugin_id
end