We don’t live in a perfect world, and unfortunately we have to often endure Microsoft technologies even though we’d rather play with Ruby. I digress…
I have created a gem called ElDap which makes it easy to search and authenticate against an Active Directory.
Why make this?
The need for this gem arose out of a business requirement for all user authentication to be done against Active Directory. Our users were tired of having to remember multiple usernames and passwords, and asked if they could simply use their network credentials to log into our applications. This gem passes off their username and password to an Active Directory server for authentication.
Additionally, users are also able to search the Active Directory.
If this sounds like something you need, check out El Dap on Github for more information.
Bundler makes it very easy to create and distribute gems. You still have to write the gem’s code yourself (Bundler is clever, but not that clever!) but everything else is done for you.
Here’s a summary of the steps you’ll need to follow to create and release your gem:
bundle gem new_magik_gem
This creates the project directory and the skeletal .gemspec file. Open your new .gemspec file and fill in the blanks with the appropriate details. Here is a good post on doing just that.
Also make sure that your ./lib/new_magik_gem/version.rb file exists – this is where the gem version is read from. You could also just hard code the gemspec file with the version.
Write tests. Write code. You are writing tests aren’t you? Good lad. Commit everything to Github. When you’re done, install the gem locally.
All good? Then release the gem and you’ll see your name in light on the RubyGems front page.
Make sure you have a RubyGems account setup, otherwise the release step will probably fail (or hang).
For more information about this, see this post.
The setup for Ubuntu 10.10 is a little different to the 10.04 setup. I seem to have to manually install quite a few more packages to get things moving. But as usual it’s easy enough once you’ve done it once…or a few times.
First, install the necessary packages and a system Ruby (1.8.7). RVM will ignore the system installed Ruby, but in my experience you will save yourself a lot of hassle by having a system-installed Ruby.
sudo apt-get install ri ruby ruby1.8 ruby-dev rake libruby1.8 zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev build-essential curl git-core git-gui gitk libxml2 libxml2-dev libxslt1-dev bison autoconf
Then install RVM (see the RVM website for the latest installation instructions).
bash < <(curl -B http://rvm.beginrescueend.com/install/rvm)
Then run the following command, and… READ THE NOTES!
Make sure you read the RVM post-installation notes. You will get an updated list of OS dependencies and instructions on how to modify your .bash file. If you don’t do this you will probably drive yourself crazy trying to get RVM to work. You will fail.
Finally, install whatever rubies you want:
rvm install 1.8.7-head rvm install 1.9.2-head
Then install MySQL (and the MySQL GUI tools)…
sudo apt-get install mysql-server libmysqlclient-dev libmysql-ruby mysql-admin