Switch web framework from Cuba to Roda#260
Open
jeremyevans wants to merge 1 commit intotabulapdf:masterfrom
Open
Switch web framework from Cuba to Roda#260jeremyevans wants to merge 1 commit intotabulapdf:masterfrom
jeremyevans wants to merge 1 commit intotabulapdf:masterfrom
Conversation
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.
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! |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roda is a fork of Cuba. Here are the advantages I see to this change:
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.
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:
require 'tilt/erb' explicitly. This avoids some warnings printed
by tilt, which should be the case for both Roda and Cuba.
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.