ruby-proxy 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/atu/sikuli.rb +2 -6
- data/lib/ext/drb_ext.rb +6 -0
- data/lib/ruby_proxy/client.rb +23 -3
- data/lib/ruby_proxy/proxy.rb +1 -1
- data/lib/ruby_proxy/proxy_load.rb +1 -1
- data/lib/ruby_proxy/server.rb +2 -0
- data/lib/ruby_proxy/version.rb +1 -1
- data/unittests/support/atu/hello.rb +18 -0
- data/unittests/test_drb_proxy.rb +15 -1
- metadata +27 -12
data/lib/atu/sikuli.rb
CHANGED
@@ -4,12 +4,8 @@ require 'java'
|
|
4
4
|
#This is key to making it work under ruby. The path above is the default
|
5
5
|
#installation location on the Mac which contains all of the
|
6
6
|
#relevant sikuli jar files.
|
7
|
-
require "sikuli-script.jar"
|
7
|
+
require "atu/sikuli-script.jar"
|
8
8
|
|
9
|
-
module B
|
10
|
-
class C
|
11
|
-
end
|
12
|
-
end
|
13
9
|
|
14
10
|
|
15
11
|
#~ include Java
|
@@ -18,10 +14,10 @@ module ATU
|
|
18
14
|
java_import 'org.sikuli.script.Region'
|
19
15
|
java_import 'org.sikuli.script.Screen'
|
20
16
|
java_import 'org.sikuli.script.Settings'
|
17
|
+
java_import 'org.sikuli.script.Pattern'
|
21
18
|
java_import 'org.sikuli.script.SikuliEvent'
|
22
19
|
java_import 'org.sikuli.script.SikuliScript'
|
23
20
|
include Java::OrgSikuliScript
|
24
|
-
include B
|
25
21
|
end
|
26
22
|
#Sikuli = Java::OrgSikuliScript
|
27
23
|
end
|
data/lib/ext/drb_ext.rb
ADDED
data/lib/ruby_proxy/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'drb'
|
2
|
+
require 'ext/drb_ext'
|
2
3
|
require 'timeout'
|
3
4
|
require 'socket'
|
4
5
|
require 'logger'
|
@@ -12,7 +13,7 @@ module ATU
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.make_kclass(name,type)
|
15
|
-
puts "make_kclass: #{name}, #{type}"
|
16
|
+
#puts "make_kclass: #{name}, #{type}"
|
16
17
|
case type
|
17
18
|
when "Class"
|
18
19
|
RubyProxy::KlassFactory.make_class(name) do |klass|
|
@@ -20,7 +21,21 @@ module ATU
|
|
20
21
|
def initialize(*arg)
|
21
22
|
#puts self.class.to_s
|
22
23
|
@proxy = RubyProxy::DRbClient.client.proxy(self.class.to_s,"new",*arg)
|
24
|
+
# undef type method
|
25
|
+
# I think all methods should be proxyed by remote
|
26
|
+
#~ class << @proxy
|
27
|
+
#~ undef :type
|
28
|
+
#~ end
|
23
29
|
end
|
30
|
+
undef :type
|
31
|
+
undef :to_s
|
32
|
+
undef :to_a if respond_to?(:to_a)
|
33
|
+
undef :methods
|
34
|
+
|
35
|
+
def __proxy
|
36
|
+
@proxy
|
37
|
+
end
|
38
|
+
|
24
39
|
def method_missing(name,*arg)
|
25
40
|
#return if @proxy.nil?
|
26
41
|
#puts "#{@proxy.methods(false)}"
|
@@ -158,8 +173,13 @@ module RubyProxy
|
|
158
173
|
@@logger.info "start jruby proxy server..."
|
159
174
|
org_path = Dir.pwd
|
160
175
|
Dir.chdir(File.join(File.dirname(__FILE__),'..')) do
|
161
|
-
|
162
|
-
|
176
|
+
# we can start jruby proxy or ruby
|
177
|
+
# just change here command
|
178
|
+
temp = ENV["RUBYOPT"]
|
179
|
+
ENV["RUBYOPT"] = "-rubygems"
|
180
|
+
system("start /I /B jruby ruby_proxy/server.rb #{@ip} #{@port} \"#{org_path}\" ")#> #{@start_service_log_path} 2>&1")
|
181
|
+
ENV["RUBYOPT"] = temp
|
182
|
+
end
|
163
183
|
end
|
164
184
|
wait_until_server_start_time(t)
|
165
185
|
end
|
data/lib/ruby_proxy/proxy.rb
CHANGED
@@ -8,7 +8,7 @@ module RubyProxy
|
|
8
8
|
# you can use Proxy.load_path << "" to add load path
|
9
9
|
ProxyLoad.load
|
10
10
|
@@logger = Logger.new(STDOUT)
|
11
|
-
@@logger.level = Logger::
|
11
|
+
@@logger.level = Logger::INFO
|
12
12
|
|
13
13
|
def self.proxy(klass_name,method=nil,*arg)
|
14
14
|
@@logger.debug "klass_name= #{klass_name}"
|
data/lib/ruby_proxy/server.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'drb'
|
2
2
|
require 'ruby_proxy/proxy'
|
3
|
+
require 'drb/timeridconv'
|
3
4
|
module RubyProxy
|
4
5
|
class DRbServer
|
5
6
|
@ip = "127.0.0.1"
|
@@ -8,6 +9,7 @@ module RubyProxy
|
|
8
9
|
attr_writer :ip,:port
|
9
10
|
end
|
10
11
|
def self.start_service
|
12
|
+
DRb.install_id_conv(DRb::TimerIdConv.new)
|
11
13
|
DRb.start_service("druby://#{@ip}:#{@port}",Proxy)
|
12
14
|
DRb.thread.join
|
13
15
|
end
|
data/lib/ruby_proxy/version.rb
CHANGED
@@ -88,6 +88,24 @@ module ATU
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
class Hello7
|
92
|
+
def to_a
|
93
|
+
puts "call to_a"
|
94
|
+
[1,2,3]
|
95
|
+
end
|
96
|
+
def type(a)
|
97
|
+
puts "call type"
|
98
|
+
"a"
|
99
|
+
end
|
100
|
+
def to_s
|
101
|
+
puts "call to_s"
|
102
|
+
return "b"
|
103
|
+
end
|
104
|
+
def normal
|
105
|
+
"normal"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
91
109
|
end
|
92
110
|
|
93
111
|
end
|
data/unittests/test_drb_proxy.rb
CHANGED
@@ -21,7 +21,7 @@ class TestDrbProxy < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
def test_atu_ok
|
23
23
|
a = ATU::Hello.new
|
24
|
-
puts "aaa= #{a}"
|
24
|
+
#~ puts "aaa= #{a}"
|
25
25
|
assert_equal(1,a.return_1)
|
26
26
|
assert_equal("1",a.return_str_1)
|
27
27
|
end
|
@@ -115,7 +115,10 @@ class TestDrbProxy < Test::Unit::TestCase
|
|
115
115
|
assert([1,"1"],ATU::M1::Hello6.a(1,"1"))
|
116
116
|
assert("m",ATU::M1::m)
|
117
117
|
end
|
118
|
+
|
118
119
|
# failed, fix me
|
120
|
+
# I have not seen druby's block call. That not be supported to call block.
|
121
|
+
# I will do fixing it later.
|
119
122
|
def test_block_ok
|
120
123
|
a = ATU::M1::Hello6.new
|
121
124
|
assert_equal(1,a.a() {|i| i})
|
@@ -127,4 +130,15 @@ class TestDrbProxy < Test::Unit::TestCase
|
|
127
130
|
assert_equal(true,ATU::M1::Hello6.file_exist?(path))
|
128
131
|
end
|
129
132
|
|
133
|
+
#now pass it
|
134
|
+
# it seems sometimes druby in jruby has some bugs like concurrent problem.
|
135
|
+
# other time, I will fix it.
|
136
|
+
def test_specify_method_support
|
137
|
+
hello7 = ATU::M1::Hello7.new
|
138
|
+
assert_equal([1,2,3],hello7.to_a)
|
139
|
+
assert_equal("a",hello7.type("b"))
|
140
|
+
assert_equal("b",hello7.to_s)
|
141
|
+
assert_equal("normal",hello7.normal)
|
142
|
+
end
|
143
|
+
|
130
144
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- yafei Li
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2011-08-
|
17
|
+
date: 2011-08-26 00:00:00 +08:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -22,50 +27,60 @@ extensions: []
|
|
22
27
|
extra_rdoc_files: []
|
23
28
|
|
24
29
|
files:
|
25
|
-
- lib/atu
|
26
30
|
- lib/atu/key.rb
|
27
31
|
- lib/atu/sikuli-script.jar
|
28
32
|
- lib/atu/sikuli.rb
|
29
|
-
- lib/
|
33
|
+
- lib/ext/drb_ext.rb
|
30
34
|
- lib/ruby_proxy/client.rb
|
31
35
|
- lib/ruby_proxy/proxy.rb
|
32
36
|
- lib/ruby_proxy/proxy_load.rb
|
33
37
|
- lib/ruby_proxy/server.rb
|
34
38
|
- lib/ruby_proxy/version.rb
|
35
39
|
- lib/ruby_proxy.rb
|
36
|
-
|
40
|
+
- unittests/all_tests.rb
|
41
|
+
- unittests/setup.rb
|
42
|
+
- unittests/support/atu/hello.rb
|
43
|
+
- unittests/support/image/search.png
|
44
|
+
- unittests/support/image/start.png
|
45
|
+
- unittests/test_drb_proxy.rb
|
46
|
+
- unittests/test_sikuli_api.rb
|
47
|
+
- unittests/your_jruby_sikuli_config_ok.rb
|
48
|
+
has_rdoc: true
|
37
49
|
homepage: https://github.com/windy/ruby_proxy
|
50
|
+
licenses: []
|
51
|
+
|
38
52
|
post_install_message:
|
39
53
|
rdoc_options: []
|
40
54
|
|
41
55
|
require_paths:
|
42
56
|
- lib
|
43
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
44
59
|
requirements:
|
45
60
|
- - ">="
|
46
61
|
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
47
64
|
version: "0"
|
48
|
-
version:
|
49
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
50
67
|
requirements:
|
51
68
|
- - ">="
|
52
69
|
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
53
72
|
version: "0"
|
54
|
-
version:
|
55
73
|
requirements: []
|
56
74
|
|
57
75
|
rubyforge_project: ruby-proxy
|
58
|
-
rubygems_version: 1.3.
|
76
|
+
rubygems_version: 1.3.7
|
59
77
|
signing_key:
|
60
|
-
specification_version:
|
78
|
+
specification_version: 3
|
61
79
|
summary: Ruby Proxy for Jruby.
|
62
80
|
test_files:
|
63
81
|
- unittests/all_tests.rb
|
64
82
|
- unittests/setup.rb
|
65
|
-
- unittests/support
|
66
|
-
- unittests/support/atu
|
67
83
|
- unittests/support/atu/hello.rb
|
68
|
-
- unittests/support/image
|
69
84
|
- unittests/support/image/search.png
|
70
85
|
- unittests/support/image/start.png
|
71
86
|
- unittests/test_drb_proxy.rb
|