Permalink
Browse files

connect to server

  • Loading branch information...
1 parent b15d66c commit 6a70dcad9fcd28e8ce3ae8a334a54c9489eec6d9 @igrigorik committed Jan 10, 2011
Showing with 64 additions and 3 deletions.
  1. 0 .rspec
  2. +27 −0 Gemfile.lock
  3. +3 −0 em-handlersocket.gemspec
  4. +8 −3 lib/em-handlersocket.rb
  5. +8 −0 lib/em-handlersocket/client.rb
  6. +14 −0 spec/client_spec.rb
  7. +4 −0 spec/helper.rb
View
0 .rspec
No changes.
View
27 Gemfile.lock
@@ -0,0 +1,27 @@
+PATH
+ remote: .
+ specs:
+ em-handlersocket (0.0.1)
+ eventmachine
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.2)
+ eventmachine (0.12.11)
+ rspec (2.4.0)
+ rspec-core (~> 2.4.0)
+ rspec-expectations (~> 2.4.0)
+ rspec-mocks (~> 2.4.0)
+ rspec-core (2.4.0)
+ rspec-expectations (2.4.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.4.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ em-handlersocket!
+ eventmachine
+ rspec
View
3 em-handlersocket.gemspec
@@ -14,6 +14,9 @@ Gem::Specification.new do |s|
s.rubyforge_project = "em-handlersocket"
+ s.add_dependency "eventmachine"
+ s.add_development_dependency "rspec"
+
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
View
11 lib/em-handlersocket.rb
@@ -1,5 +1,10 @@
-module Em
- module Handlersocket
- # Your code goes here...
+require 'eventmachine'
+require 'em-handlersocket/client'
+
+module EventMachine
+ module HandlerSocket
+ def self.new(opt = {})
+ EventMachine.connect(opt[:host], opt[:port], EventMachine::HandlerSocket::Client)
+ end
end
end
View
8 lib/em-handlersocket/client.rb
@@ -0,0 +1,8 @@
+module EventMachine
+ module HandlerSocket
+ class Client < EventMachine::Connection
+
+
+ end
+ end
+end
View
14 spec/client_spec.rb
@@ -0,0 +1,14 @@
+require 'helper'
+
+describe EventMachine::HandlerSocket do
+
+ it "should connect to HandlerSocket server" do
+ EM.run {
+ c = EM::HandlerSocket.new(:host => '127.0.0.1', :port => '9998')
+ c.class.should == EventMachine::HandlerSocket::Client
+
+ EM.stop
+ }
+ end
+
+end
View
4 spec/helper.rb
@@ -0,0 +1,4 @@
+require 'bundler'
+Bundler.setup
+
+require 'lib/em-handlersocket'

0 comments on commit 6a70dca

Please sign in to comment.