I am interested in using a ruby script (https://github.com/zmoazeni/csscss) withing an ASPNET MVC site. I have no previous experience with ruby so my question could be naive.
Is it possible to import the ironruby nuget package and execute the ruby scripts?
My goal would be to put a .net wrapper around the ruby script(s) and put the output out as HTML.
So far I have tried Googling getting started with ironruby but have not found much that I understand and could get working, (yes that sound vague, but I don't know ruby or ironruby and couldn't find any good simple guides on getting started).
I've realized a simple proof of concept at https://github.com/edymtt/csscss-from-ironruby that shows in a console application how to use IronRuby to run the source code of csscss
to analyze a CSS loaded from a file. To achieve this result I've started from this SO question -- you can find the additional resources I've used in the comments of the program. I haven't tried this code in a ASP.net MVC site -- anyway this sample should be a good starting point.
This solution is a bit cumbersome to maintain, since you have to manually put the sources for the csscss
and its dependent libraries in the solution. An alternative solution is to install Ruby on the machine, install csscss
using gem
(so it download the dependencies automatically) and to invoke the program from .NET -- I'll also show this approach in the sample. Note that this solution requires that you could install Ruby on the web server.
UPDATE 2013-09-02 18:15 UTC Following the suggestion from Zach Moazeni I've been able to semplify the approach that used IronRuby to run csscss
and I've updated accordingly the proof of concept. In a nutshell:
csscss
and json
(and dependent gems) to a local folder of the project;bundler
(by finding the gems
folder and then including for each subfolder the lib
folder, this algoritm was inspired by this SO thread);csscss
.This approach should conjugate the ability to use only .NET to run the program with the ease of the update given by gem
and bundler
.
I'm the author of csscss and I built the JSON output for this reason.
csscss -j file.css
It's not a perfect solution, but instead of outputting human readable text, it will output JSON that you can parse from whatever language/runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With