Archive for the 'Ruby' Category

Multiple-Application Login

I’m trying to handle an integration between a humongous code-base Java application (doing basic stuff) with a new Rails application (talking about injecting Rails transparently). Handling login (multi-application logins) was my first obstacle, and after talking with Steven and Brenton, I came up with the following implementation:



require 'rubygems'
require 'hpricot'
require 'mechanize'

class WelcomeController < ApplicationController
...

  def login
    agent = WWW::Mechanize.new
    page = agent.get('http://example.com')
    login_form = page.form('loginForm')
    login_form.username = params['username']
    login_form.password = params['password']
    page = agent.submit(login_form, login_form.buttons.first)
    cookie = agent.cookies.first
    cookies["JSESSIONID"] = {:value => pet_cookie.value, :path => ‘/’, :domain => ‘example.com’}
  end

…

end

Of course this is just the basic stuff (no error handling, no response checking, no cookie review, …)

The idea is to use Mechanize to simulate the browser actions from within the controller, log-in to the second application, set up a first-application session cookie with the same name/value pair as that of the returned cookie from the first application. I’m not sure that this covers all the basis but it’s not a bad start. Muhammad has also mentioned the idea of having Rails session cookies written with the same name/value pair as those of the Java application.

Thoughts?

CruiseControl.rb Superfast Setup

This is my timesheet this morning

cruisecontrolrb.jpg

CruiseControl.rb folks lie when they say it’s a 5 minute installation. It only takes 2 :)

Rails after Ruby

Rails 1.2.3 has been released. According to Riding Rails:

“This release irons out the few wrinkles there was between Ruby 1.8.6 and Rails 1.2.2. So now you can enjoy the latest Ruby with the latest Rails.”

Considering that Ruby 1.8.6 has been out for only one day - Rails team seem to be dead serious about what they do (and serious == fun in ruby land).

Congratulations guys, and thanks.

CruiseControl.rb - Continuous Integration, the Ruby way

Once again, Ruby is revealing itself as a delivery tool. This time in the form of CruiseControl.rb - ruby continuous integration tool/application.

CruiseControl.rb was the topic for this month’s Calgary Ruby Users Group (CRUSERS) meeting. Accorindg to core-contributor Alexey Verkhovsky, from Thoughworks (Calgary), it’s an ‘incarnation’ [A carefully chosen word, over 'port'] of Cruise Control (the famous continuous integration tool in Java).

The session was a light-hearted one, probably matching the spirit that lead to CruiseControl.rb.

  • Java Cruise Control:
    • History.
    • Shortcomings (setup, Ruby integration).
    • Other “Basic’ CI tools (Cerberus, CIA or continuous Builder Plugin by DHH).
  • CruiseControl.rb features:
    • Lightweight.
    • Easy Setup (No DB setup even).
    • Email, CCTray, Jabber (plug-in), RSS notifications.
    • Plugin architecture (for the lava lamp enthusiasts).
    • Configurations (if needed), are in Ruby.
  • Setup:
    • Extract the compressed file
      • Dashboard Rails application (for monitoring).
      • Scripts (cruise) for adding/removing project, starting/stopping the daemon (builder) script.
    • Add a project (cruise add <project_name> –url file:///path/to/svn/repo/project)
    • Start the Dashboard rails application.
    • Enjoy.
  • How it works:
    • The builder (deamon) script polls the SVN repo for change.
      When change is found; CruiseControl.rb updates a copy of the project, then invokes the project Rake file tasks. The priority is a ‘cruise’ task, db:test:purge, db:migrate, test or then the ‘default’ task (check cc_build.rake)
  • Custom Configurations:
    • Custom configurations can be done through cruise_config.rb in your project directory.
    • Example:
      Project.configure do|project|
      project.scheduler.polling_interval = 10
      end
  • CruiseControl shortcomings (opinionated features?)
    • SVN only (so far)
    • Can’t detect build results ran from outside the Dashboard (ran from the console).
    • Ruby projects only (but theoretically can be hooked to other projets).
    • SVN externals not handled.
  • Coming Soon:
    • Dependency builds
  • How to contribute:
    • TRY IT OUT!
    • Propose features/bugs/patches/… you know.
  • Cool things to try:
    • You have access (from the dashboard) to the failure/error-causing line (hyperlinked tothe file, with the line highlighted)
    • Text/HTML files placed in CC-BUILD_ARTIFACTS are picked up by CruiseControl.rb and hyperlinked on the specific project dashboard page (check: http://cruisecontrolrb.thoughtworks.com/builds/CruiseControl right side links for test coverage /rcov files)
  • Some ‘hidden’ links:

Quite a nice and light tool that definitely has a market (at least I know I am going to use it).

Dang: Alex was the lucky one winning ‘Rails Cookbook’ ruffle - and yes - he knows Rails enough to pass it to a friend :)

Ruby on Rails - Lunch and Learn

Last Friday was my Ruby on Rails presentation at Commerx Corporation (in Lunch and Learn series). It wasn’t as good as I wanted, but, wasn’t too bad either. Some keys on the laptop were in the on-again-off-again mode, so, I had to rely on an external keyboard and use the touchpad at the same time (not a very recommended setup).

Anyways, I think some of the guys were entrigued enough to, at least, give it a try. Being mainly at a PHP shop, I’m still not qualified to do a full comparison, but, from the little time I spent with PHP (so far), I’m becoming even more attached to the beloved Rails.

I think I’m becoming more of a Rails fanatic - comparing every code and architecture I come across to Rails. I find myself asking, how ‘that’ could be done in Rails. How could ruby shine in such a situation. How elegant would it be to implement that in Rails. How much less lines of code I could reach that same setup.

My next project is a minor refactoring of what seems like a complex Java project (read: reusable components). I’m still exploring the source tree. I can’t help but to wonder about the size of the project, and what it ‘actually’ do :). I’m having a hard time forcing myself ‘NOT’ to think of it as a Rails rewrite opportunity. Hope I can manage :)

DHH talking

Yes! too late for most. But I’ve just came across it (remember, I was in the washing machine for a while). DHH is a definite talker [InfoQ Interview], you can’t help but to listen to every word and … enjoy it. The same as with working with Rails.

Starter Toolkit for DB2 on Rails

Finally, a progress in the DB2 - Rails front. the Starter Toolkit for DB2 on Rails has just been released.

Although, we're on a DB2 iSeries, the work required for a DB2/400 - Rails combination is doable and there's a good chance I can sell Rails to the people here.

Ruby on Rails Presentation

Yesterday I presented Ruby on Rails for the first “real” time to a group of developers and interested minds. I think it went well. It was an introduction that covered a step-by-step for developing a simple issue tracking application (we traded off many of the application features to exploring the capabilities of Ruby and Ruby on Rails). The intelligent audience, albeit somewhat small, was so engaged and encouraging. You can view the slides here.

The opportunity was given by OpenCraft in their great “Technical Seminar” series. OpenCraft has been reaching out to and engaging in the FOSS community in Egypt and are taking on responsibilities in raising the level of collaboration, networking among entities, increasing awareness of FOSS, and improving the skills of IT personnel and users in various fields. That's not to mention their awesome new space and idea factory (stupid me, I haven?t taken pictures :-( !!). Kudos to OC.

Perhaps just one more word for Egyptian developers about Ruby on Rails.

Ruby != ruby

Keeping Busy (2/3) - Schoolata school reviews

I started a while back to gather info about different schools as I'll be applying to my 3 year-old for school this year. After the numerous opinions I've received, I decided to put up a website to collect reviews of Egyptian schools. Introducing Schoolata with 100% Ruby on Rails. It's still in its infancy (pre-alpha that's to say), and I have yet to see whether it will grow and If I'll be spending more time on implementing features. I'm using the free hosting service donated by Pratik at typo.in to host the website for the time being.

The local market lack such implementations (customer reviews of anything) which can be attributed to the dominant internet culture that doesn't foster using the internet as a collaboration media (I'd probably dedicate a separate post to the issue).

For such local applications to succeed (assuming good capabilities, features, interface) I guess few things have to occurr:

  • Marketing the service - heavily - “way outside” the internet (brochures, hardcopy banners, word of mouth)
  • Adding features according to user requirements (who doesn't do that), but would encourage the sense of ownership, creating passionate users (I can already see that in the inital phase)
  • Changing the prevailing internet culture of using the internet for leisure and news (I always wanted to do something that would change the world, I guess it would be easier to change the world)

I was able to convince (force? :-)) some friends into writing their reviews into Schoolata (talk about driving traffic). So, if you're reading this, and know someone who'd be interested or want to share your opinion about Egyptian schools, Schoolata is the place.

Rails 1.0

Rails 1.0 is out. A similarly great project should be at a 2.0 release with such features. But Rails folks seem down to earth. Thanks guys.

The release celebrations included launching a remake of ruby on rails website inspired by 37 Signals.

« Previous PageNext Page »