Question

I have no idea about Ruby :)

The thing is, I need a way to turn all CSS in an HTML e-mail into inline styles. And there's no better way to do that, than use Alex Dunae's Premailer.

But I want to run it on Windows. My goal is to be able to run the script from C#, and fetch the file created by the ruby script in C# and use the HTML for the e-mail.

Anyway, running the ruby script is the hard part for me. I've downloaded and installed the Ruby Installer, and I've also downloaded the Premailer 1.6.2 package.

I try to run it doing this:

C:\Ruby192\bin>ruby.exe C:\Workspace\Premailer\bin\premailer C:\Workspace\index.htm > C:\Workspace\index2.htm

And what it tells me is this:

C:\Ruby192\bin>ruby.exe C:\Workspace\Premailer\bin\premailer C:\Workspace\index.htm > C:\Workspace\index2.htm
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- hpricot (LoadError)
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from C:/Workspace/Premailer/lib/premailer.rb:4:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from C:/Workspace/Premailer/bin/premailer:5:in `<main>'

I probably need some dependencies, or what?

Was it helpful?

Solution

You are missing the Hpricot library, which is an HTML parser.

However, I am not sure why it is missing. It is properly listed as a dependency in Premailer's package specification and it should have been automatically installed when you installed Premailer (unless you explicitly disabled it with the --ignore-dependencies flag).

Also, the Premailer binary should have been installed in C:\Ruby192\bin, not C:\Workspace\Premailer\bin.

Try uninstalling Premailer:

gem uninstall --force premailer

And then try again to install it:

gem install premailer

Note: Hpricot is actually written in C, not in Ruby, so to install it, you need to have the RubyInstaller DevKit installed. (This could be an explanation why it didn't get installed automatically.)

A general tip: if you want to interoperate between the CLI and Ruby, it is much easier to use the IronRuby Ruby implementation instead of YARV, which it appears you are using, because IronRuby actually runs on the CLI (more precisely the DLR) and has a standardized API for calling CLI code from Ruby and vice versa (and that API is fully compatible with C# 4's dynamic). Except in this particular case that won't work because, as I mentioned, Hpricot is written in C, as an extension to YARV, so it simply won't work with IronRuby.

OTHER TIPS

Yeah, "hpricot" is missing. The easiest way to you is probably using rubygems to install:

gem install -r hpricot
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top