Installing and getting started with ultraviolet

CodeSponge — billychamp

Here is how I got the ultraviolet gem installed.

Install to heroku

Getting ultraviolet working on heroku is a snap. The required dependencies are in the default gemset.

All you have to do to get ultraviolet installed for your heroku app is to add a line ultraviolet to the .gems file at the root of your project. (You may have to create the file.)

Install at Home

The ultraviolet gem requires the textpow gem which in turn requires the oniguruma library and gem. Instalition often isn’t as easy as for the majority of gems but it isn’t too bad. This article should get you going.

The solutions described on this page were done on OS X 10.5.8 using rvm for rubies. I assume you are using a newer version of rubygems. (If you are using rvm then you should be all set.) If you still have an old version you should probably update rubygems.

A Quick Note About RVM

Ruby Version Manager (RVM) lets you install multiple versions of ruby and smoothly switch between them, complete with gemsets. I really like rvm: it does handy things like

rvm gem install gemname
which installs gemname for all versions of ruby that you have installed, or
rvm tests
to run your test suite against multiple versions of ruby. The former example doesn’t work with ultraviolet however as we need to use a different gem for 1.9 …more on that later. You definetly don’t need rvm to install ultraviolet, but I do recommend giving it a try.

Regardless of what ruby version we are using we still need the oniguruma library, so lets get that installed…

Installing oniguruma

Run these commands in your shell. If you find that there is a newer version you can probably replace the version numbers.


cd ~/Downloads
curl "http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.2.tar.gz" > onig-5.9.2.tar.gz
tar xzvf onig-5.9.2.tar.gz
cd onig-5.9.2
./configure && make && sudo make install

The library should be installed! Now we should be able to install ultraviolet.

Installing ultraviolet

For 1.8.6 & 1.8.7

gem install ultraviolet
Depending on your system, you may need to do:
sudo gem install ultraviolet

for 1.9.1

gem install spox-ultraviolet
or
sudo gem install spox-ultraviolet

The command line executible ‘uv’ for 1.9.1 was a bit noisy for me (spits out lots of warnings) but still performs.

Fixing the name error for YAML in theme2xhtmlrender

The theme2xhtmlrender command that comes with ultraviolet didn’t work out of the box for me. It was failing with a name error for YAML. Hopefully this will get fixed in the next version as the following monkey patch will probably get overwritten if you update the gem.

To fix the name error for YAML you can edit the theme2xhtmlrender file in the gems bin directory. If you are using multiple rubies (rvm) then you have to do this for each version to which you installed ultraviolet.

The locations for me are:

(1.8) => $GEM_HOME/gems/spox-ultraviolet-0.10.4/bin/theme2xhtmlrender
(1.9) => $GEM_HOME/gems/ultraviolet-0.10.2/bin/theme2xhtmlrender

Change the part that looks like this:

language: 'ruby'
begin
   require 'plist'
rescue LoadError
   require 'rubygems'
   require 'plist'
end

to look something like this:
language: 'ruby'
begin
   require 'plist'
   require 'yaml'
rescue LoadError
   require 'rubygems'
   require 'plist'
   require 'yaml'
end

Adding a Custom TextMate Theme

If you have edited a TextMate theme or created one from scratch you probably want to add that to the list of available themes in ultraviolet. By default (on my system anyway) TextMate stores the themes you edit or create in ~/Library/Application\ Support/TextMate/Themes.

The theme I use the most is named cobaltCS which I based on the preloaded cobalt theme. So to add my theme I run the following shell command:

theme2xhtmlrender ~/Library/Application\ Support/TextMate/Themes/cobaltCS

(You will need to pick the name of a theme that is in that directory on your system to try this out.)

We can check if the theme is now available.

uv --list themes

If the theme is in that list then it is installed in the gems folder. If you want to use it in multiple versions of ruby then you have to repeat for each version.

Adding a Custom Language

I have not yet added a custom language. I will update this if it takes any tinkering.


Articles List

Comments? ...

blog comments powered by Disqus