The ironruby nuget package can be installed, which is then used in the vanilla VS2012

I am interested in using a ruby ​​script ( https://github.com/zmoazeni/csscss ) with an ASPNET MVC site. I have no previous experience with ruby, so my question may be naive.

Is it possible to import the nuget ironruby package and execute ruby ​​scripts?

My goal is to place the .net wrapper around ruby ​​script (s) and output the output as HTML.


So far I have been trying to get started with Google, but I haven’t found much that I understood and could work (yes, that sounds vague, but I don’t know ruby ​​or iron and I can’t find any good simple guides at startup).

+6
source share
2 answers

I understood a simple proof of concept in https://github.com/edymtt/csscss-from-ironruby , which shows in a console application how to use IronRuby to run a source csscss code to parse CSS loaded from a file. To achieve this result, I started with this SO> question - you can find additional resources that I used in the comments to the program. I have not tried this code on ASP.net MVC - in any case, this sample should be a good starting point.

This solution is a bit cumbersome to maintain as you need to manually place sources for csscss and dependent libraries in the solution. An alternative solution is to install Ruby on the machine, install csscss using gem (so that it automatically downloads the dependencies), and call the program from .NET. I will also show this approach in an example. Please note that this solution requires that you can install Ruby on a web server.

UPDATE 2013-09-02 18:15 UTC Following Zach Moazeni's suggestion, I was able to come to terms with the approach IronRuby used to run csscss , and I updated the proof of concept accordingly. In a nutshell:

  • outside of a .NET program. I used bundler to load csscss and json (and dependent stones) into the local project folder;
  • in the .NET program, I wrote a function to detect all library paths in the gem folder created by bundler (by searching for the gems folder and then for each subfolder for the lib folder, this algorithm was inspired by this SO thread );
  • I passed this list of paths to the IronRuby interpreter before running csscss .

This approach should combine the ability to use only .NET to run the program with the ease of updating given by gem and bundler .

+3
source

I am the author of csscss, and for this reason I built JSON output.

 csscss -j file.css 

This is not an ideal solution, but instead of outputting human-readable text, it outputs JSON, which you can parse from any language / runtime.

+2
source

All Articles