Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch web framework from Cuba to Roda #260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeremyevans
Copy link

Roda is a fork of Cuba. Here are the advantages I see to this change:

  1. Uses terminal routes. One of the reasons behind the fork is that
    by default, routes in Cuba are not terminal. So the following
    requests are currently handled the same by Tabula:

POST /upload
POST /upload/with/additional/stuff

Basically, you can stick whatever you want at the end of a path, and
Cuba will just ignore it. Roda has built in support for terminal
routes, so adding stuff at the end of the path will result in a
404, like practically all websites.

  1. Comes with a JSON plugin. This simplifies JSON handling, and makes
    it so you don't have to set the Content-Type to application/json and
    call .to_json manually. You just have the route block return an array
    or hash, and Roda will automatically convert it to json for you.

While I was converting the app from Cuba to Roda, I noticed there were
some parts that could derive more benefit from the routing tree. One
example is TabulaDebug, where I moved a some duplicate code in every
route up to the enclosing branch, so the behavior is shared by all of
the routes under the branch.

Some things get a little more verbose with the switch, such as the
second argument to Roda#view is a general options hash instead of
specific to local variables. In general that could be made simpler by
passing data to the views implicitly using instance variables instead
of local variables.

Some other changes:

  1. require 'tilt/erb' explicitly. This avoids some warnings printed
    by tilt, which should be the case for both Roda and Cuba.

  2. require tabula_debug and tabula_job_progress outside of the
    routing tree, so they aren't required on every request that uses them.

Disclaimer: I'm the author of Roda.

Roda is a fork of Cuba.  Here are the advantages I see to this change:

1) Uses terminal routes.  One of the reasons behind the fork is that
by default, routes in Cuba are not terminal.  So the following
requests are currently handled the same by Tabula:

POST /upload
POST /upload/with/additional/stuff

Basically, you can stick whatever you want at the end of a path, and
Cuba will just ignore it.  Roda has built in support for terminal
routes, so adding stuff at the end of the path will result in a
404, like practically all websites.

2) Comes with a JSON plugin.  This simplifies JSON handling, and makes
it so you don't have to set the Content-Type to application/json and
call .to_json manually.  You just have the route block return an array
or hash, and Roda will automatically convert it to json for you.

While I was converting the app from Cuba to Roda, I noticed there were
some parts that could derive more benefit from the routing tree.  One
example is TabulaDebug, where I moved a some duplicate code in every
route up to the enclosing branch, so the behavior is shared by all of
the routes under the branch.

Some things get a little more verbose with the switch, such as the
second argument to Roda#view is a general options hash instead of
specific to local variables.  In general that could be made simpler by
passing data to the views implicitly using instance variables instead
of local variables.

Some other changes:

1) require 'tilt/erb' explicitly.  This avoids some warnings printed
by tilt, which should be the case for both Roda and Cuba.

2) require tabula_debug and tabula_job_progress outside of the
routing tree, so they aren't required on every request that uses them.
@jeremybmerrill
Copy link
Member

@jeremyevans: This is really interesting. We're a sort of slow-moving project -- nobody's day job, and we're in the middle of rewriting the UI -- but we'll take a look. Thanks!

@jeremyevans
Copy link
Author

That's cool, no rush. Thanks for taking the time to look at this and respond.

BTW, the way I found out about Tabula is that the auditors I work with at my job use it for extracting information from PDFs. I was pleasantly surprised to find out it was built with JRuby and very easy to hack on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants