rubarb 0.2.0 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,12 +62,8 @@ end
62
62
 
63
63
  describe Rubarb::Server do
64
64
 
65
- before(:each) do
66
- @reactor_thread = nil
67
- end
68
-
69
65
  after(:each) do
70
- stop_reactor(@reactor_thread) if @reactor_thread
66
+ sync_stop(@server)
71
67
  end
72
68
 
73
69
  it "has an instance of Rubarb::Id" do
@@ -96,15 +92,15 @@ describe Rubarb::Server do
96
92
  end
97
93
 
98
94
  def connect
99
- @reactor_thread = start_reactor
100
95
  connected = false
101
96
  @server = Rubarb::Server.new("127.0.0.1", 9441, mock("server"))
102
97
  @connection = Rubarb::Connection.new("127.0.0.1", 9441, mock("client"))
103
98
  EM.schedule do
104
99
  @server.start { |client| @client = client }
105
- @connection.start { connected = true }
100
+ EM.next_tick {@connection.start { connected = true } }
106
101
  end
107
- wait_for { connected }
102
+ wait_for { connected && @client}
103
+ connected.should == true
108
104
  end
109
105
 
110
106
  it "sets instance of Rubarb::Id to each connection for connection ids" do
@@ -137,7 +133,6 @@ describe Rubarb::Server do
137
133
  end
138
134
 
139
135
  it "makes two overlapping calls" do
140
- @reactor_thread = start_reactor
141
136
  connected = false
142
137
 
143
138
  @server = Rubarb::Server.new("127.0.0.1", 9441, TestApi.new)
@@ -173,7 +168,6 @@ describe Rubarb::Server do
173
168
  it "should catch exceptions in starting server" do
174
169
  EventMachine.stub!(:start_server).and_raise("EMReactor Exception")
175
170
 
176
- @reactor_thread = start_reactor
177
171
  done = false
178
172
 
179
173
  @server = Rubarb::Server.new("127.0.0.1", 9441, TestApi.new)
data/spec/spec_helper.rb CHANGED
@@ -5,21 +5,28 @@ require 'timeout'
5
5
  require 'eventmachine'
6
6
 
7
7
  def start_reactor
8
- t = Thread.current
9
- reactor = Thread.new do
10
- EM.run do
11
- t.wakeup
8
+ main_thread = Thread.current
9
+ em_thread = Thread.new do
10
+ EventMachine::run do
11
+ main_thread.wakeup
12
12
  end
13
13
  end
14
- sleep(4)
15
- reactor
14
+ while !(em_thread.alive? && em_thread.status != "sleep")
15
+ sleep(0.2)
16
+ end
17
+ return em_thread
16
18
  end
17
19
 
20
+
18
21
  def stop_reactor(reactor)
19
- EM::schedule {EM.stop}
22
+ return unless EM::reactor_running?
23
+ EM.stop
20
24
  reactor.join
25
+ rescue Exception => e
26
+
21
27
  end
22
28
 
29
+
23
30
  def wait_for
24
31
  Timeout::timeout(5) do
25
32
  while !yield
@@ -29,4 +36,18 @@ def wait_for
29
36
  rescue Timeout::Error => e
30
37
  end
31
38
 
39
+ def sync_stop(server)
40
+ return unless server
41
+ stopped = false
42
+ server.stop { stopped = true }
43
+ wait_for { stopped }
44
+ end
45
+
46
+
47
+ Spec::Runner.configure do |config|
48
+ config.before(:suite) {$reactor_thread = start_reactor}
49
+ config.after(:suite) {stop_reactor($reactor_thread)}
50
+ end
51
+
52
+
32
53
  #$DEBUG = true
metadata CHANGED
@@ -1,55 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubarb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
6
+ - 0
7
+ - 2
8
+ - 11
9
+ version: 0.2.11
11
10
  platform: ruby
12
11
  authors:
13
- - doug bradbury
12
+ - doug bradbury
14
13
  autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-11-12 00:00:00 -06:00
17
+ date: 2011-02-09 00:00:00 -06:00
19
18
  default_executable:
20
19
  dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 27
30
- segments:
31
- - 1
32
- - 3
33
- - 0
34
- version: 1.3.0
35
- type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: eventmachine
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 57
46
- segments:
47
- - 0
48
- - 12
49
- - 11
50
- version: 0.12.11
51
- type: :runtime
52
- version_requirements: *id002
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 3
30
+ - 0
31
+ version: 1.3.0
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: eventmachine
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 0
44
+ - 0
45
+ - beta
46
+ - 2
47
+ version: 1.0.0.beta.2
48
+ type: :runtime
49
+ version_requirements: *id002
53
50
  description: |-
54
51
  This library uses two socket connections between a client and a server. One is used for request / replies from the
55
52
  client to the server. The other is used for remote calls made from the server to the client.
@@ -63,84 +60,64 @@ executables: []
63
60
  extensions: []
64
61
 
65
62
  extra_rdoc_files:
66
- - README
63
+ - README.md
67
64
  files:
68
- - .gitignore
69
- - README
70
- - Rakefile
71
- - VERSION
72
- - examples/client.rb
73
- - examples/server.rb
74
- - lib/dkbrpc.rb
75
- - lib/rubarb.rb
76
- - lib/rubarb/connection.rb
77
- - lib/rubarb/connection_error.rb
78
- - lib/rubarb/connection_id.rb
79
- - lib/rubarb/default.rb
80
- - lib/rubarb/fast_message_protocol.rb
81
- - lib/rubarb/id.rb
82
- - lib/rubarb/incoming_connection.rb
83
- - lib/rubarb/insecure_method_call_error.rb
84
- - lib/rubarb/outgoing_connection.rb
85
- - lib/rubarb/remote_call.rb
86
- - lib/rubarb/responder.rb
87
- - lib/rubarb/server.rb
88
- - spec/rubarb/connection_failure_spec.rb
89
- - spec/rubarb/connection_spec.rb
90
- - spec/rubarb/id_spec.rb
91
- - spec/rubarb/incoming_connection_spec.rb
92
- - spec/rubarb/integration_spec.rb
93
- - spec/rubarb/outgoing_connection_spec.rb
94
- - spec/rubarb/remote_call_spec.rb
95
- - spec/rubarb/responder_spec.rb
96
- - spec/rubarb/server_failure_spec.rb
97
- - spec/rubarb/server_spec.rb
98
- - spec/spec_helper.rb
65
+ - lib/dkbrpc.rb
66
+ - lib/rubarb.rb
67
+ - lib/rubarb/connection.rb
68
+ - lib/rubarb/connection_error.rb
69
+ - lib/rubarb/connection_id.rb
70
+ - lib/rubarb/default.rb
71
+ - lib/rubarb/fast_message_protocol.rb
72
+ - lib/rubarb/id.rb
73
+ - lib/rubarb/incoming_connection.rb
74
+ - lib/rubarb/insecure_method_call_error.rb
75
+ - lib/rubarb/outgoing_connection.rb
76
+ - lib/rubarb/remote_call.rb
77
+ - lib/rubarb/responder.rb
78
+ - lib/rubarb/server.rb
79
+ - README.md
99
80
  has_rdoc: true
100
81
  homepage: http://github.com/dougbradbury/rubarb
101
82
  licenses: []
102
83
 
103
84
  post_install_message:
104
- rdoc_options:
105
- - --charset=UTF-8
85
+ rdoc_options: []
86
+
106
87
  require_paths:
107
- - lib
88
+ - lib
108
89
  required_ruby_version: !ruby/object:Gem::Requirement
109
- none: false
110
90
  requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ version: "0"
117
96
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
97
  requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ segments:
101
+ - 0
102
+ version: "0"
126
103
  requirements: []
127
104
 
128
105
  rubyforge_project:
129
- rubygems_version: 1.3.7
106
+ rubygems_version: 1.3.6
130
107
  signing_key:
131
108
  specification_version: 3
132
109
  summary: A Bidirectional Event Machine Based Remote Procedure Call Library for Ruby
133
110
  test_files:
134
- - spec/rubarb/connection_failure_spec.rb
135
- - spec/rubarb/connection_spec.rb
136
- - spec/rubarb/id_spec.rb
137
- - spec/rubarb/incoming_connection_spec.rb
138
- - spec/rubarb/integration_spec.rb
139
- - spec/rubarb/outgoing_connection_spec.rb
140
- - spec/rubarb/remote_call_spec.rb
141
- - spec/rubarb/responder_spec.rb
142
- - spec/rubarb/server_failure_spec.rb
143
- - spec/rubarb/server_spec.rb
144
- - spec/spec_helper.rb
145
- - examples/client.rb
146
- - examples/server.rb
111
+ - examples/client.rb
112
+ - examples/server.rb
113
+ - spec/rubarb/connection_failure_spec.rb
114
+ - spec/rubarb/connection_spec.rb
115
+ - spec/rubarb/id_spec.rb
116
+ - spec/rubarb/incoming_connection_spec.rb
117
+ - spec/rubarb/integration_spec.rb
118
+ - spec/rubarb/outgoing_connection_spec.rb
119
+ - spec/rubarb/remote_call_spec.rb
120
+ - spec/rubarb/responder_spec.rb
121
+ - spec/rubarb/server_failure_spec.rb
122
+ - spec/rubarb/server_spec.rb
123
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- dkbrpc.i*
2
- rubarb.i*
3
- pkg
4
- .idea
5
- *.iml
6
- .rakeTasks
7
- *.gemspec
data/README DELETED
@@ -1,77 +0,0 @@
1
- rubaRb
2
- A Bidirectional Event Machine Based Remote Procedure Call Library for Ruby
3
-
4
- This library uses two socket connections between a client and a server.
5
- One is used for request / replies from the client to the server.
6
- The other is used for remote calls made from the server to the client.
7
-
8
- Each end publishes a single object on which methods can be called by the remote end.
9
- All calls to the remote objects are asyncronous. Do not make any blocking calls in
10
- the published object. Responses are return by calling the "reply method on the responder object.
11
-
12
- Server and Connection object may be created and started outside of EM::run,
13
- but the Eventmachine reactor must be started somewhere in your application
14
-
15
- ################################# Server Example #####################################################################
16
-
17
- class ServerApi
18
- def time(responder)
19
- puts "Server received time request"
20
- responder.reply(Time.now)
21
- end
22
- end
23
-
24
- EM.run do
25
- server = Rubarb::Server.new("127.0.0.1", 9441, ServerApi.new)
26
-
27
- connections = {}
28
-
29
- server.start do |client|
30
- puts "Connection Made: #{client}"
31
- client.name do |name|
32
- connections[name] = client
33
- client.errback do
34
- puts "Connection Lost: #{name}"
35
- connections.delete(name)
36
- end
37
-
38
- end
39
-
40
- end
41
-
42
- EventMachine.add_periodic_timer(1) { puts "Connections: #{connections.keys.inspect}" }
43
-
44
- end
45
- ######################################################################################################################
46
-
47
-
48
- ################################# Client Example #####################################################################
49
- class ClientApi
50
- def initialize(name)
51
- @name = name
52
- end
53
- def name(responder)
54
- responder.reply(@name)
55
- end
56
- end
57
-
58
- EM::run do
59
- connection = Rubarb::Connection.new("127.0.0.1", 9441, ClientApi.new(ARGV[0]))
60
- connection.errback do |error|
61
- puts ("Connection Error: #{error}")
62
- end
63
-
64
- connection.start do
65
- connection.time do |response|
66
- puts "Server Said it is: #{response.strftime("%D")}"
67
- end
68
-
69
- EventMachine.add_timer(20) do
70
- puts "stopping"
71
- connection.stop
72
- EM::stop
73
- end
74
- end
75
-
76
- end
77
- ######################################################################################################################
data/Rakefile DELETED
@@ -1,51 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "rubarb"
8
- gem.summary = %Q{A Bidirectional Event Machine Based Remote Procedure Call Library for Ruby}
9
- gem.description = %Q{This library uses two socket connections between a client and a server. One is used for request / replies from the
10
- client to the server. The other is used for remote calls made from the server to the client.
11
-
12
- Each end publishes a single object on which
13
- methods can be called by the remote end. All calls to the remote objects are asyncronous. Do not make any blocking
14
- calls in the published object. Responses are return by calling the "reply method on the responder object.}
15
-
16
- gem.email = "doug@8thlight.com"
17
- gem.homepage = "http://github.com/dougbradbury/rubarb"
18
- gem.authors = ["doug bradbury"]
19
- gem.add_development_dependency "rspec", ">= 1.3.0"
20
- gem.add_dependency "eventmachine", ">= 0.12.11"
21
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
- end
23
- rescue LoadError
24
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
- end
26
-
27
- require 'spec/rake/spectask'
28
- Spec::Rake::SpecTask.new(:spec) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.spec_files = FileList['spec/**/*_spec.rb']
31
- end
32
-
33
- Spec::Rake::SpecTask.new(:rcov) do |spec|
34
- spec.libs << 'lib' << 'spec'
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
37
- end
38
-
39
- task :spec => :check_dependencies
40
-
41
- task :default => :spec
42
-
43
- require 'rake/rdoctask'
44
- Rake::RDocTask.new do |rdoc|
45
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
-
47
- rdoc.rdoc_dir = 'rdoc'
48
- rdoc.title = "rubarb-gem #{version}"
49
- rdoc.rdoc_files.include('README*')
50
- rdoc.rdoc_files.include('lib/**/*.rb')
51
- end