简体   繁体   中英

Read ruby syntax in java

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:


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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM