-
Notifications
You must be signed in to change notification settings - Fork 334
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
Add support for CSV format to RABL #262
Conversation
I see a couple formatting tweaks and I'll let @nesquena look over it as well. Question, what happens if someone nests multiple levels of values such as a node within a child? Also FasterCSV is now in standard lib, so CSV in Ruby 1.9 is actually FasterCSV: https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L14 |
Hi, Thanks for your reply! Actually, I don't really like what happen when I use nested multiple levels of values. It just convert the content to string. Regarding to FasterCSV, I heard it but I couldn't really understand. So does this mean I do support FasterCSV and do not CSV? Great! (As I said before, I'm a ruby newbie!) Please let me know if you guys have any suggestions. I would be happy to make it better! |
can be good to have this format. |
I'm going to close out this request. It's a neat idea to add more flexibility to RABL but I think it goes against its primary purpose since the conversion to CSV will lose so much of the nesting that JSON and XML use. In the case of others that need an API for CSV, I recommend https://github.com/tatey/conformist |
I agree, I think CSV is inherently too limited for use as a rabl serialization option. Good idea though, do love to support as many formats that make sense for complex data. |
No problem man! I really understand your point and completely agree with you. For sure CSV does not fit well for complex cases, anyway it worked for my simple structure! :) Thanks for your attention! |
You could pull this into a geml 'rabl-csv'. |
Definitely, I would encourage that. I was thinking of doing that at some point for many of the other formats as well (i.e Plist). Perhaps make RABL easily pluggable to new formats in the future. |
Yeah. I realize that CSV is not a complex/nested format but I was mostly interested in it to move the CSV generation out of models and into .rabl views. |
Nice to hear from you about this old pull request. I'm still using it and I agree it is a great idea to have a rabl-csv gem. I'm going to study about how to do it and soon we are going to have it. P.S.: Feel free to point me any direction on how to achieve this. |
@gvieira anything ever come of the gem? |
I know CSV is not a proper tree structure as JSON, XML and PList, anyway I needed to export data to CSV in a project that was already using RABL and I thought it would be great to use the same engine.
It uses the ruby's built-in CSV engine but it can also use FasterCSV and any other engine that provides a generate method.
I have also added a csv_options that accepts a hash and passes it to generate method, so people can set their own column and row separators, as much as other many options (see http://www.ruby-doc.org/stdlib-1.9.3/libdoc/csv/rdoc/CSV.html#method-c-new).
(Based on #153)