classroom 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/classroom.gemspec +1 -1
- data/examples/demo_client.rb +1 -1
- data/examples/demo_client2.rb +1 -1
- data/examples/demo_client3.rb +1 -1
- data/examples/demo_client4.rb +2 -2
- data/examples/demo_client5.rb +1 -1
- data/examples/test_modules.rb +1 -1
- data/examples/test_modules2.rb +1 -1
- data/examples/test_modules3.rb +1 -1
- data/lib/classroom.rb +8 -9
- data/test/classroom_test.rb +1 -4
- metadata +1 -1
data/classroom.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = 'classroom'
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.2"
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.summary = "ClassRoom is a 'class server' based on DRb"
|
8
8
|
s.files = Dir.glob("**/**/**").delete_if {|item| item.include?(".svn")}
|
data/examples/demo_client.rb
CHANGED
@@ -17,7 +17,7 @@ klass = %q{
|
|
17
17
|
# Here's the magic..
|
18
18
|
class_server = ClassRoom::Client.new(ARGV.first || 'classroom://:2001')
|
19
19
|
class_server.add_class(klass)
|
20
|
-
class_server.load_class(
|
20
|
+
class_server.load_class(:all)
|
21
21
|
|
22
22
|
# Create and use objects as you would normally, but remember
|
23
23
|
# 'BasicQueue' actually exists on the ClassRoom server and,
|
data/examples/demo_client2.rb
CHANGED
@@ -9,7 +9,7 @@ require 'rubygems'
|
|
9
9
|
require 'classroom'
|
10
10
|
|
11
11
|
class_server = ClassRoom::Client.new(ARGV.first || 'classroom://:2001')
|
12
|
-
class_server.load_class(
|
12
|
+
class_server.load_class(:BasicQueue)
|
13
13
|
|
14
14
|
q = BasicQueue.new(5)
|
15
15
|
10.times { |i| q.push("test #{i}") }
|
data/examples/demo_client3.rb
CHANGED
@@ -19,7 +19,7 @@ class_server.add_class(klass)
|
|
19
19
|
|
20
20
|
# Load local references to all the classes on the ClassRoom server,
|
21
21
|
# including BasicDataClass
|
22
|
-
class_server.load_class(
|
22
|
+
class_server.load_class(:all)
|
23
23
|
|
24
24
|
# Create and use objects as you would normally, but remember
|
25
25
|
# 'BasicDataClass' actually exists on the ClassRoom server
|
data/examples/demo_client4.rb
CHANGED
@@ -37,8 +37,8 @@ klass = %q{
|
|
37
37
|
# Here's the magic..
|
38
38
|
class_server = ClassRoom::Client.new(ARGV.first || 'druby://coop-pb:2001')
|
39
39
|
class_server.add_class(klass)
|
40
|
-
class_server.load_class(
|
41
|
-
#class_server.load_non_present_classes(
|
40
|
+
class_server.load_class(:all)
|
41
|
+
#class_server.load_non_present_classes()
|
42
42
|
|
43
43
|
puts BasicParent.give_child.x
|
44
44
|
puts BasicParent.x
|
data/examples/demo_client5.rb
CHANGED
data/examples/test_modules.rb
CHANGED
@@ -36,7 +36,7 @@ klass = %q{
|
|
36
36
|
# Here's the magic..
|
37
37
|
class_server = ClassRoom::Client.new(ARGV.first || 'druby://coop-pb:2001')
|
38
38
|
class_server.add_class(klass)
|
39
|
-
class_server.load_non_present_classes
|
39
|
+
class_server.load_non_present_classes
|
40
40
|
|
41
41
|
puts class_server.classes.inspect
|
42
42
|
puts TestModule::BasicParent.give_child.x
|
data/examples/test_modules2.rb
CHANGED
@@ -26,7 +26,7 @@ klass2 = %q{
|
|
26
26
|
class_server = ClassRoom::Client.new(ARGV.first || 'druby://coop-pb:2001')
|
27
27
|
class_server.add_class(klass)
|
28
28
|
class_server.add_class(klass2)
|
29
|
-
class_server.load_class(
|
29
|
+
class_server.load_class(:all)
|
30
30
|
|
31
31
|
x = Something.new(10)
|
32
32
|
puts x.blah
|
data/examples/test_modules3.rb
CHANGED
data/lib/classroom.rb
CHANGED
@@ -162,23 +162,22 @@ module ClassRoom
|
|
162
162
|
|
163
163
|
# Load a class (or all classes, if :all is specified) from the
|
164
164
|
# ClassRoom server to be used locally
|
165
|
-
def load_class(
|
166
|
-
return nil unless classes
|
165
|
+
def load_class(*classes)
|
166
|
+
return nil unless classes
|
167
167
|
classes = self.classes if classes.first == :all
|
168
168
|
classes.each do |class_name|
|
169
|
-
eval
|
169
|
+
eval(%Q{
|
170
170
|
class #{class_name} < ClassRoom::Client::ProxyObject
|
171
171
|
end
|
172
172
|
#{class_name}.class_name = :\"#{class_name}\"
|
173
173
|
#{class_name}.drb = ClassRoom::Client::get_drb('#{@drb_url}')
|
174
|
-
},
|
174
|
+
}, TOPLEVEL_BINDING)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
178
|
# Load all classes on the ClassRoom server that do not already
|
179
179
|
# exist locally (not fully tested yet!)
|
180
|
-
def load_non_present_classes
|
181
|
-
return nil unless b
|
180
|
+
def load_non_present_classes
|
182
181
|
classes = self.classes
|
183
182
|
classes.each do |class_name|
|
184
183
|
eval %Q{
|
@@ -186,19 +185,19 @@ module ClassRoom
|
|
186
185
|
class #{class_name} < ClassRoom::Client::ProxyObject
|
187
186
|
end
|
188
187
|
end
|
189
|
-
},
|
188
|
+
}, TOPLEVEL_BINDING
|
190
189
|
eval %Q{
|
191
190
|
begin
|
192
191
|
#{class_name}.drb = @drb
|
193
192
|
rescue
|
194
193
|
end
|
195
|
-
}
|
194
|
+
}, TOPLEVEL_BINDING
|
196
195
|
eval %Q{
|
197
196
|
begin
|
198
197
|
#{class_name}.class_name = :\"#{class_name}\"
|
199
198
|
rescue
|
200
199
|
end
|
201
|
-
}
|
200
|
+
}, TOPLEVEL_BINDING
|
202
201
|
end
|
203
202
|
end
|
204
203
|
|
data/test/classroom_test.rb
CHANGED
@@ -2,9 +2,6 @@ require 'test/unit'
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'classroom'
|
4
4
|
|
5
|
-
# Get a binding for the top level
|
6
|
-
$top_level_binding = binding
|
7
|
-
|
8
5
|
class ClassRoomTest < Test::Unit::TestCase
|
9
6
|
|
10
7
|
def setup
|
@@ -35,7 +32,7 @@ class ClassRoomTest < Test::Unit::TestCase
|
|
35
32
|
end
|
36
33
|
|
37
34
|
def test_e_can_import_classes
|
38
|
-
assert $class_server.load_class(
|
35
|
+
assert $class_server.load_class(:all)
|
39
36
|
end
|
40
37
|
|
41
38
|
def test_f_can_use_imported_classes
|