Concurrency With Ruby

I spent some time to explore node.js. I found some interesting ruby project for concurrency. And this article (Debunking the Node.js Gish Gallop) was good to read. wycatz’s talk at railsconf 2012 “Rails: The Next Five Years” was also helpful.

There are other resources out there.

Celluloid is a concurrent object oriented programming framework for Ruby which lets you build multithreaded programs out of concurrent objects just as easily as you build sequential programs out of regular objects

Concurrent programming with Celluloid (MWRC 2012)

Nodetuts in Coffeescript

Use node-inspector with Coffeescript!

Step1

In a new terminal tab, run the node-inspector

node-inspector&

Step2

Complie & watch the source file in another terminal tab

coffee -cw 014_0_tools.coffee

Step3

In a new terminal tab, run the javascript file

node --debug 014_0_tools.js

TDD Lib Ranking (5th July, 2011)

Gibhub (#watchers)

npm registry (#depended on)

NodeCloud Ranking (ranking#)

vows example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
vows= require('vows')
fs= require('fs')
assert= require('assert')

vows
.describe('Division by zero')

.addBatch
 'when dividing a number by zero':
   #topic is function and returns a value
   topic: -> 42 / 0
   # the topic value is used as an argument
   'we get Infinity' : (topic) ->
     assert.equal topic, Infinity

 'but when dividing zero by zero':
   #topic is only run once. Hence the value is different from
   # example value above
   topic: -> 0 / 0
   'we get a value which':
     'is not a number': (topic) ->
       assert.isNaN topic
     #topic has a scope. we use the same 0 / 0 value here.
     'is not equal to itself': (topic) ->
       assert.notEqual topic, topic

Writing asynchronous tests

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
.addBatch
  'A introduction file':
    topic: ->
      # this.callback function is available inside all topics
      # When this.callback is called, it passes on the arguments
      # it received to the test functions, one by one, as if 
      # the values were returned by the topic function itself.
      # this allows us to decouple callback from they async function call
      # topics which do not return anything must take use of 'this.callback'
      fs.stat '000_intro.coffee', this.callback
    'can be accessed': (err, stat) ->
      # we have no err
      assert.isNull err
      # we have a stat object
      assert.isObject stat
    'is not empty': (err, stat) ->
      # the file size is > 0
      assert.isNotZero stat.size

.run()