Permalink
Browse files

Various directory organization.

  • Loading branch information...
1 parent 7b99c21 commit 5160e25caaeeac489498d56ada7e3b2b5ea94267 @steveWang steveWang committed Aug 6, 2011
Showing with 22 additions and 11 deletions.
  1. +10 −0 README.md
  2. +10 −0 examples/simple/simple.rb
  3. +1 −10 lib/ruby-now.rb
  4. +1 −1 lib/util.rb
View
10 README.md
@@ -0,0 +1,10 @@
+RubyNow
+=======
+
+This is meant to be a Ruby client for NowJS. It's not quite as
+feature-rich as the Node library itself, but it permits for RPC with
+an arbitrary chain of callbacks, which we figured was the main reason
+folks use Now. Have fun!
+
+You'll need to `gem build ruby-now.gemspec` before `gem install`, by
+the way.
View
10 examples/simple/simple.rb
@@ -0,0 +1,10 @@
+require 'ruby-now'
+
+EventMachine::run {
+ EventMachine::start_server "127.0.0.1", 8081, RubyNow
+ RubyNow.registerFunction('aFunctionObject', lambda{|*a|
+ puts a.join(' ')})
+ RubyNow.registerFunction('otherFunc', lambda{|cb, *a|
+ cb.call(a.join(' '))})
+ puts 'Running TCP server on port 8081. Awaiting orders.'
+}
View
11 lib/ruby-now.rb
@@ -5,7 +5,7 @@
require 'util'
require 'namedblock'
-module BidirectionalJsonRadio
+module RubyNow
@@conn = []
def self.conn
@@conn
@@ -26,12 +26,3 @@ def unbind
@@conn.delete self
end
end
-
-EventMachine::run {
- EventMachine::start_server "127.0.0.1", 8081, BidirectionalJsonRadio
- BidirectionalJsonRadio.registerFunction('aFunctionObject', lambda{|*a|
- puts a.join(' ')})
- BidirectionalJsonRadio.registerFunction('otherFunc', lambda{|cb, *a|
- cb.call(a.join(' '))})
- puts 'running json radio of happiness on port 8081 of your microwave'
-}
View
2 lib/util.rb
@@ -38,6 +38,6 @@ def self.callFunc func, args
})
end
def self.send_data str
- BidirectionalJsonRadio.conn[0].send_data str
+ RubyNow.conn[0].send_data str
end
end

0 comments on commit 5160e25

Please sign in to comment.