I have a tool backed by Velocity templates which statically creates a file (Ruby like syntax) after capturing inputs from Web App for use with some other tool (Vagrant - built in Ruby). However, now I wish to support the reverse of what is being done till now so that I can browse a previously created Vagrant file in my tool and have the settings defined there-in populate my Java Beans and end up at the Web App's UI.
Is there any way to interpret the Ruby Syntax like:
config.vm.define :firstMachine do |master|
master.vm.hostname = "boxupp.test.first"
master.vm.box = "Ubuntu"
master.vm.box_url = "http://www.google.com"
master.vm.provider "virtualbox" do |prov|
prov.customize ["modifyvm", :id, "--memory", "384"]
end
end
and populate the corresponding values in the Java Beans.
I stumbled across JRuby but it looks like another Scripting platform.
Thanks for your time !!
If you just want to read / parse the syntax, then you would need to write (or find) a Ruby parser written in Java.
If you mean interpret ... as in execute / run ... Ruby code in Java, then you either need:
a Ruby interpreter that you can call from Java; see https://github.com/jruby/jruby/wiki/JRubyAndJavaCodeExamples
or a way to turn Ruby code into a real Java method; see https://github.com/jruby/jruby/wiki/GeneratingJavaClasses
I stumbled across JRuby but it looks like another Scripting platform.
Ermm ... it is an implementation of the Ruby language.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.