Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rVM

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rVM

  • 0.0.17
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= rVM

rVM is the implementation of a VirtualMachine in pure Ruby. To clarify, no virtual machine as in VMWare that lets you virtualize a computer. But rather like ruby 1.9 or JRuby that both implement a virtual machine (written in C or Java) to execute Ruby code. Just that rVM takes it the other way around, it is written in ruby and lets you execute code within ruby.

= So what is so cool about that?

For once, the challenge to pull this off ;P. Then it has on huge advantage. It makes it pretty easy to give ruby programs a interface for scripting.

Now you might think 'wow cool but I could just use ruby!' that is right, and wrong. Imagine just short code snippets to make a query, perhaps you want to implement a SQL based language to let a user query data in your program? Also consider you want your website to allow user side scripts. I would not want to have ruby code executed for random visitors. Then again I might be more tempted to let them execute code within a VM that has no access to anything outside it's VM neither variables nor hardware nor memory.

= Example

The following example implements a pretty easy calculator using the the math language shipped with rVM. Set variables and are not used outside one line

require 'rubygems' require 'rvm' # This loads the rVM gem require 'rvm/languages/math' #This loads the math plugin as well as the math function library s ='' compiler = RVM::Languages[:math].new #Lets get us the compiler while s!= 'QUIT' s=gets.chomp puts compiler.compile(s).execute(compiler.env) # We pass an fresh environment as we don't need an environment. end

Here one example that keeps set variables due to using one environment for all the calls.

require 'rubygems' require 'rvm' # This loads the rVM gem require 'rvm/languages/math' #This loads the math plugin as well as the math function library s ='' compiler = RVM::Languages[:math].new #Lets get us the compiler env = compiler.env while s!= 'QUIT' s=gets.chomp puts compiler.compile(s).execute(env) # We pass an fresh environment as we don't need an environment. end

FAQs

Package last updated on 25 Jul 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc