How to start developing a new port (Ruby)

5 views
Skip to first unread message

Steve Jorgensen

unread,
May 12, 2009, 2:02:19 AM5/12/09
to JSON Template
Hi all,

I'm interested in working on a Ruby port of JSON Template. First -
perhaps, I'm blind, but I'm having trouble figuring out where to get
the code for the existing implementations, so perhaps one of you can
point me in the right direction.

The strategy I'd like to follow for the Ruby port is to first
implement a similar testing environment in Ruby to what you have in
Python, then start translating tests one at a time and making them
pass.

Andy Chu

unread,
May 12, 2009, 3:00:06 AM5/12/09
to json-t...@googlegroups.com
Great, the code is here:

http://code.google.com/p/json-template/source/checkout

Just check it out with svn. Basically:

1) Make sure you can run the tests ('python jsontemplate_test.py',
will require simplejson). This runs just the Python tests.

2) Try running at least one other set of tests to get a feel for how
it works, e.g. with the --javascript, --java, or --php flags (they
require different interpreters, as Ruby will obviously).

Look at the verifier.py shim in each language directory. This is the
key to making the Python tests work against other languages. It's
basically a bridge so you can serialize the test case over the process
boundary between Python and Ruby interpreters. This means we have one
authoritative set of tests instead of many, and also conveniently
relieves you of having to write detailed tests (although
language-specific tests are welcome and may help you develop the
smaller units).

3) Write the verifier.py shim. You have to fill in 3 methods --
Expansion, CompilationError, EvaluationError. This should be pretty
easy. The Python, JavaScript, and Java ones are slightly different so
copy the one you like and make it work for Ruby.

You'll need some Ruby code to call into your Ruby implementation from
the test too.

4) The -t and -m regex filters on jsontemplate_test.py will help
isolate test runs. It should be pretty gratifying to see it go from 0
passing to 38 passing or however many tests we have now. : )

Since Ruby is similar to Python in so many ways, it will probably work
very well to just port it line-by-line, using the tests as a guide.
The JavaScript version was a line-by-line port, with some idiom
adjustments, and it works quite well.

Let us know if you have any other questions.

thanks,
Andy

Steve Jorgensen

unread,
May 12, 2009, 10:10:31 PM5/12/09
to JSON Template
Thanks for the instructions. I'll hopefully get started on this in
the next few days.

I don't exactly have the worlds biggest supply of spare time, but I'm
pretty efficient with Ruby, so hopefully, I can deliver some useful
work soonish.

Andy Chu

unread,
May 13, 2009, 3:42:50 AM5/13/09
to json-t...@googlegroups.com
OK, let me know if you want svn access to work in the repository.

I just cleaned up the tests a bit, grouping them more logically (for
use with -t), and cleaning up the indentation with the magic BlockStr
function.

Andy
Reply all
Reply to author
Forward
0 new messages