exceptionz

Thoughts on Technology, Methodology and Programming.

Archive for March, 2008

Run gem install behind a firewall in Windows

Posted by Marcus Wyatt on 18 March 2008

I’m contracting at a client running a Novell network and wanted to create some small little ruby scripts to automate some tasks for me. But I ran into problems using gem install behind their firewall. I’m getting the following error:

ERROR: While executing gem … (Gem::RemoteSourceException) HTTP Response 407

Here is the steps I followed to get gem install working on my windows xp machine in painstaking detail: 🙂

Firstly we need to set the HTTP_PROXY environment variable. I’ve played around with different options, using uid and pwd and other suggestions, but all I needed was the following:

  1. On the desktop right click the ‘My Computer’ icon and select properties.
  2. Now you can either add the HTTP_PROXY variable to the ‘User’ or the ‘System’ variables by clicking the ‘New’ button.
  3. Within the new system variable dialog, specify ’HTTP_PROXY’ as the variable name and in the value area a url in the following format – http://%5Bproxy_ip%5D:%5Bproxy_port%5D – i.e. http://127.168.1.3:5865

Next we install the Ruby Win32 SSPI which gives ruby the ability to authenticate with ISA natively. We need this library because as far as I understand, it patches the Open-uri library because of some incompatibilities with windows. Anyways, follow the following steps to get it working:

  1. Download rubysspi from the Ruby Win32 SSPI project page(also available as gem install rubysspi but that doesn’t help much, does it?)
  2. Install the gem locally using the following command: gem install [local_path_to_gem]\rubysspi-1.2.3.gem i.e. C:\gems\rubysspi-1.2.3.gem
  3. Now copy the spa.rb file from the gem install directory and paste it in the site-ruby directory. i.e. If ruby is installed in C:\ruby, then the paths should be:
    • origin path – C:\ruby\lib\ruby\gems\1.8\gems\rubysspi-1.2.3\spa.rb
    • destination path – C:\ruby\lib\ruby\site_ruby\spa.rb
  4. Find gem.bat in your ruby bin directory (C:\ruby\bin) and replace the last line (i.e. "%~d0%~p0ruby" -x "%~f0" %*) with the following line – @"ruby" -rspa "c:\ruby\bin\gem" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. Test you can access the remote ruby gems by executing the following command: gem list rails -r
  6. You should see similar output as shown above.

Now we can work again without any issues when trying to install or update gems.

Enjoy!!!

Technorati Tags: , ,

Posted in Development, Rails, Ruby, Software, Tools, XP | 36 Comments »

TextMate command to annotate your current ActiveRecord Model with the DB Schema

Posted by Marcus Wyatt on 18 March 2008

Edit: If you can’t wait until the end, here is the download link.

Who hasn’t used the Annotate Models plugin written by Dave Thomas, of Rails Pragmatic Studio fame? If you haven’t don’t fret… The plugin basically adds a comment block to the top of all of your model classes documenting the current database schema for the given model. I like to have the info in my model files to make it a little easier to work with models.

Annotated Models Plugin

The rails bundle within TextMate gives you a ‘Show DB Schema for current class’ command you can press to show a tool tip with the database schema (Control + Shift + Command + S). This works great, but I find the command sequence to long and the slight wait to see the schema info breaks my rhythm.

Show DB Schema for Current Class

To solve the problem I made a copy of the source files used by the command and modified it slightly to output the info as comments at the top of the file. Now I have nicely annotated model files. This is a real time saver.

Annotated Models Bundles

The bundle also contain the the Beautify command. This command adds automatic code formatting capability for your ruby code. I found the beautify command from Tim Burks. Cheers Tim…

You can download the bundle here.

Technorati Tags: , , , ,

Blogged from TextMate

Posted in Mac, OS X, Rails, Ruby, Software, TextMate | Leave a Comment »

Quick note: Ubuntu(gutsy) C compiler install and setup (glibc-devel)

Posted by Marcus Wyatt on 11 March 2008

UPDATE: Tim Haines notified me that you can install all the necessary tools with one command:

apt-get install build-essential

Thanks Tim, I’ve tried it on a clean VPS and it works a charm…

If you are busy setting up a new Ubuntu Linux server and you get the following error:

configure: error: no acceptable C compiler found in $PATH

when trying to run ./configure, then you need to install the gcc compiler (Yeah, I know… this is like a no brainer for you *nix guru’s).

Here is the command to install the gcc compiler on Ubuntu:

sudo apt-get install gcc

But now you get the following error:

error: checking for C compiler default output file name

Most results on on google search point you glibc-devel as the solution. But, alas… apt-get will report the following message when you try to install glibc-devel:

Couldn’t find package glibc-devel

So what to do? The correct Ubuntu package that is similar to the glibc-devel is libc6-dev. Below is the command to install the Ubuntu package:

sudo apt-get install libc6-dev

Happy compiling and installing…

Technorati Tags:

Posted in Software, Tools, Ubuntu | 1 Comment »

You can now build the source code in either VS2k5 or VS2k8

Posted by Marcus Wyatt on 11 March 2008

I’ve updated the source code to include some conditional compilation directives to support different Visual Studio IDE versions. So if you are still stuck in VS2005 land, you can now build the source and be able to take advantage of the new features that Owen Evans added.

These include the new attributes (Context, BeforeAll, BeforeEach, AfterAll, AfterEach) and new functionality like Collection.Contains#WithProperty. If you lucky to be using VS2008 you’ll have new functionality that allows you to pass lambda’s. For more information look at http://bgeek.net/2008/02/14/nspecify-rspec-well-closer-anyway/

Owen also added a new library called NSpecify.Framework.Extensions. This gives you some extension methods that you can use to specify your expectations directly on the object under test.

i.e. newDeveloper.Surname.Must().Equal(“Evans”);

Nice hey!

Posted in BDD, Development, OO, Software, TDD, Tools | Tagged: , , | Leave a Comment »