Saturday, October 24, 2009

Thinning down Aptana's RadRails to use with Eclipse

I believe that Eclipse is the best damn IDE ever developed. The modular design (OSGI) coupled with its open plugin development environment and reasonable publication coverage makes it an ideal development environment. Companies have built development solutions on Eclipse technology and one such company is Aptana, the developer of RadRails, the development solution for web developers/Ruby on Rails developers.

A while ago, there was an Eclipse plugin called RDT (Ruby Development Toolkit) that provided "simple" Ruby support (a nice editor, some code completion etc.). Development of this plugin was discontinued and instead rolled into Aptana's large RadRails suite since RDT's developer was hired by Aptana. This obviously was great news for him but sad for me because I didn't want the heavy RadRails environment with its hundreds of plugin jars doing everything from HTML to Cloud Computing deployment. Given Eclipse's pluggable nature, I figured that I should be able to take a RadRails install and only extract the portions I wanted to give me my basic RDT back except now it's the latest and greatest.

Below is a directory listing showing the directories and jars to extract from the RadRails install to make your eclipse have Ruby development capabilities. I found this through trial and error and they seem to work just fine but if you find errors, post comments for others to see.

./eclipse/features
./eclipse/features/org.rubypeople.rdt_1.4.0.1254334821-7H7X7c7jrMElGv94Q
./eclipse/plugins
./eclipse/plugins/com.aptana.rdt.libraries.win32_1.0.1.jar
./eclipse/plugins/com.aptana.rdt.libraries_1.0.7.jar
./eclipse/plugins/com.aptana.rdt.rake_1.3.2.1254241359.jar
./eclipse/plugins/com.aptana.rdt.ui_1.3.2.1254332735.jar
./eclipse/plugins/com.aptana.rdt_1.3.1.1254334821.jar
./eclipse/plugins/org.epic.regexp_rdt_0.1.6.1252597203.jar
./eclipse/plugins/org.jruby_1.2.0.9419p2
./eclipse/plugins/org.kxml2_2.1.5.jar
./eclipse/plugins/org.rubypeople.rdt.branding_1.3.0.1254241359.jar
./eclipse/plugins/org.rubypeople.rdt.core_1.3.2.1254332672.jar
./eclipse/plugins/org.rubypeople.rdt.debug.core_1.3.2.1254241359.jar
./eclipse/plugins/org.rubypeople.rdt.debug.ui_1.3.2.1254334821.jar
./eclipse/plugins/org.rubypeople.rdt.launching_1.3.0.1254241359.jar
./eclipse/plugins/org.rubypeople.rdt.refactoring_1.2.2.1252686004.jar
./eclipse/plugins/org.rubypeople.rdt.testunit_1.2.4.1254241359.jar
./eclipse/plugins/org.rubypeople.rdt.ui_1.2.4.1254254467.jar

I highly recommend creating a separate extension location to store these plugins so future upgrades become easier since you know the features and plugins in this extension location are solely dedicated to RDT.

I am not a serious web developer requiring me to install the full Aptana suite, which significantly slowed down my other development in Eclipse, so this little trick has worked well for me. Now I have my RDT back without all the unnecessary plugins!

Wednesday, August 5, 2009

JRuby + Merb + Google AppEngine MemCache

Searching far and wide for a cheap Java based web hosting provider, I became interested in learning about Google's AppEngine, which offers free space for web applications within reasonable access limits. I also thought that this would be a good opportunity to learn some Ruby (JRuby) to write a web application. In short, this post is about how to configure MERB running on JRuby/Google AppEngine to use Google's MemCache store to store session data via memcache instead of cookies.

I wanted to do this because I didn't want my web application data stored in a browser's cookie and so either I could use MemCache or the DataStore and I chose memcache. I assume that you have an AppEngine project setup with MERB as your web framework of choice.

All the changes described are located in /war/WEB-INF/config/init.rb
  1. Load the APIs (place these near the top of init.rb)
    # Load the apis
    ENV['APPLICATION_ROOT'] = File.join(File.dirname(__FILE__), '..')
    require 'appengine-apis/local_boot'
  2. Change the session store from cookie to memcache
    c[:session_store] = 'memcache'
  3. Add the following to the Merb::BootLoader.after_app_loads section # This will get executed after your app's classes have been loaded.
    Merb::MemcacheSession.store = AppEngine::Memcache.new
    module AppEngine
    # For the memcache-client gem.
    class Memcache
    include Merb::MemcacheStore
    end
    end
The first two and a good portion of the third step are standard Merb as far as I understand (although it took me some digging through the Merb code to find this). The second part of the third step is what I discovered when looking at the source code to see how the standard Memcache gem is integrated into the memcache store. Once I added this mixin AppEngine module, I had session data stored in memcache! Post comments if this works or doesn't work for you and/or if you have any other suggestions, please post so that others can find it!