DTD

Ruby EventMachine: a short introduction

Introduction

Before answering what is EventMachine, first I will try to explain the problem that EventMachine solves.

A network server like http server or chat server usually works in a threaded model. What it means is that on a particular port, a process is listening for connections. When a client makes a connection then this process spawns a new thread and that thread is handed over the task of responding to that client. If server is getting too much traffic then the number of threads created by the main process goes up very quickly.

Testing JavaScript with blue-ridge, Screw.Unit, env.js and Rhino in a rails application

Following code is tested with Rails 2.3 .

Testing Javascript without browser is not easy. However, others have a done a lot of hard work which makes it possible to test JavaScript using command line.

Seeing is believing

First let’s see some JavaScript testing in action.

Post-Javascript DOM with Aptana Jaxer

It is hard to imagine the web as we know it today without AJAX. Within just a couple of years, it has transformed how we think about web applications, how we build them, and the technology stack underneath.

Javascript in Haml

One thing that is not obvious with HAML is how to add javascript. In the past, haml didn’t really like javascript that much but the latest version of haml on github makes it very simple. It’s done using the :javascript filter. Here’s an example:

Syndicate content