uu 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.rubocop.local.yml +0 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +0 -0
- data/.travis.yml +3 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +113 -0
- data/Guardfile +66 -0
- data/LICENSE.txt +21 -0
- data/README.md +11 -0
- data/Rakefile +52 -0
- data/lib/drb/http0.rb +80 -0
- data/lib/drb/http0helper.rb +54 -0
- data/lib/drb/http0serv.rb +129 -0
- data/lib/uu.rb +8 -0
- data/lib/uu/remote.rb +28 -0
- data/lib/uu/remote_server.rb +17 -0
- data/lib/uu/version.rb +5 -0
- data/uu.gemspec +39 -0
- metadata +232 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2018ac51f14b6e8c301a24ce67b4bfb75bf1f5625f4dada1135b869e150a7cbc
|
4
|
+
data.tar.gz: 699eed2f70b7a62bc267c0ba86a2049ab5c92023bd94d972f08b405e93b31cf5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 47b6640ca969bb6ab4fb71e6f1b1febd6034d4b2e2049147174c6d55fcbbf8208c4bc027146847adb2d7f0cf64a8640dbe1d43a652928609a45f9c8bbd046eae
|
7
|
+
data.tar.gz: 13b64a78595b1cf963fe0f6dec8f0e98024a360779f06d55e1c857558ddfd1a3c76b4eff8c3c21cda2aec587e1213a1935f2254ebe94cee4b1ac302aa3a90ef2
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.local.yml
ADDED
File without changes
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
File without changes
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
uu (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
coderay (1.1.2)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
ffi (1.9.25)
|
13
|
+
formatador (0.2.5)
|
14
|
+
guard (2.14.2)
|
15
|
+
formatador (>= 0.2.4)
|
16
|
+
listen (>= 2.7, < 4.0)
|
17
|
+
lumberjack (>= 1.0.12, < 2.0)
|
18
|
+
nenv (~> 0.1)
|
19
|
+
notiffany (~> 0.0)
|
20
|
+
pry (>= 0.9.12)
|
21
|
+
shellany (~> 0.0)
|
22
|
+
thor (>= 0.18.1)
|
23
|
+
guard-bundler (2.1.0)
|
24
|
+
bundler (~> 1.0)
|
25
|
+
guard (~> 2.2)
|
26
|
+
guard-compat (~> 1.1)
|
27
|
+
guard-compat (1.2.1)
|
28
|
+
guard-rspec (4.7.3)
|
29
|
+
guard (~> 2.1)
|
30
|
+
guard-compat (~> 1.1)
|
31
|
+
rspec (>= 2.99.0, < 4.0)
|
32
|
+
guard-rubocop (1.3.0)
|
33
|
+
guard (~> 2.0)
|
34
|
+
rubocop (~> 0.20)
|
35
|
+
guard-yard (2.2.1)
|
36
|
+
guard (>= 1.1.0)
|
37
|
+
yard (>= 0.7.0)
|
38
|
+
jaro_winkler (1.5.1)
|
39
|
+
listen (3.1.5)
|
40
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
41
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
42
|
+
ruby_dep (~> 1.2)
|
43
|
+
lumberjack (1.0.13)
|
44
|
+
mbs (0.0.3)
|
45
|
+
thor
|
46
|
+
method_source (0.9.0)
|
47
|
+
nenv (0.3.0)
|
48
|
+
notiffany (0.1.1)
|
49
|
+
nenv (~> 0.1)
|
50
|
+
shellany (~> 0.0)
|
51
|
+
parallel (1.12.1)
|
52
|
+
parser (2.5.1.2)
|
53
|
+
ast (~> 2.4.0)
|
54
|
+
powerpack (0.1.2)
|
55
|
+
pry (0.11.3)
|
56
|
+
coderay (~> 1.1.0)
|
57
|
+
method_source (~> 0.9.0)
|
58
|
+
rainbow (3.0.0)
|
59
|
+
rake (10.5.0)
|
60
|
+
rb-fsevent (0.10.3)
|
61
|
+
rb-inotify (0.9.10)
|
62
|
+
ffi (>= 0.5.0, < 2)
|
63
|
+
rspec (3.8.0)
|
64
|
+
rspec-core (~> 3.8.0)
|
65
|
+
rspec-expectations (~> 3.8.0)
|
66
|
+
rspec-mocks (~> 3.8.0)
|
67
|
+
rspec-core (3.8.0)
|
68
|
+
rspec-support (~> 3.8.0)
|
69
|
+
rspec-expectations (3.8.1)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.8.0)
|
72
|
+
rspec-its (1.2.0)
|
73
|
+
rspec-core (>= 3.0.0)
|
74
|
+
rspec-expectations (>= 3.0.0)
|
75
|
+
rspec-mocks (3.8.0)
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
+
rspec-support (~> 3.8.0)
|
78
|
+
rspec-support (3.8.0)
|
79
|
+
rubocop (0.58.2)
|
80
|
+
jaro_winkler (~> 1.5.1)
|
81
|
+
parallel (~> 1.10)
|
82
|
+
parser (>= 2.5, != 2.5.1.1)
|
83
|
+
powerpack (~> 0.1)
|
84
|
+
rainbow (>= 2.2.2, < 4.0)
|
85
|
+
ruby-progressbar (~> 1.7)
|
86
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
87
|
+
ruby-progressbar (1.10.0)
|
88
|
+
ruby_dep (1.5.0)
|
89
|
+
shellany (0.0.1)
|
90
|
+
thor (0.20.0)
|
91
|
+
unicode-display_width (1.4.0)
|
92
|
+
yard (0.9.15)
|
93
|
+
|
94
|
+
PLATFORMS
|
95
|
+
ruby
|
96
|
+
|
97
|
+
DEPENDENCIES
|
98
|
+
bundler
|
99
|
+
guard
|
100
|
+
guard-bundler
|
101
|
+
guard-rspec
|
102
|
+
guard-rubocop
|
103
|
+
guard-yard
|
104
|
+
mbs
|
105
|
+
rake
|
106
|
+
rspec
|
107
|
+
rspec-its
|
108
|
+
rubocop
|
109
|
+
uu!
|
110
|
+
yard
|
111
|
+
|
112
|
+
BUNDLED WITH
|
113
|
+
1.16.3
|
data/Guardfile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
7
|
+
# directories %w(app lib config test spec features) \
|
8
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
9
|
+
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
13
|
+
#
|
14
|
+
# $ mkdir config
|
15
|
+
# $ mv Guardfile config/
|
16
|
+
# $ ln -s config/Guardfile .
|
17
|
+
#
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
|
+
|
20
|
+
guard :bundler do
|
21
|
+
require 'guard/bundler'
|
22
|
+
require 'guard/bundler/verify'
|
23
|
+
helper = Guard::Bundler::Verify.new
|
24
|
+
|
25
|
+
files = ['Gemfile']
|
26
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
27
|
+
|
28
|
+
# Assume files are symlinked from somewhere
|
29
|
+
files.each { |file| watch(helper.real_path(file)) }
|
30
|
+
end
|
31
|
+
|
32
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
33
|
+
# rspec may be run, below are examples of the most common uses.
|
34
|
+
# * bundler: 'bundle exec rspec'
|
35
|
+
# * bundler binstubs: 'bin/rspec'
|
36
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
37
|
+
# installed the spring binstubs per the docs)
|
38
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
39
|
+
# * 'just' rspec: 'rspec'
|
40
|
+
|
41
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
42
|
+
require 'guard/rspec/dsl'
|
43
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
44
|
+
|
45
|
+
# Feel free to open issues for suggestions and improvements
|
46
|
+
|
47
|
+
# RSpec files
|
48
|
+
rspec = dsl.rspec
|
49
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
50
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
51
|
+
watch(rspec.spec_files)
|
52
|
+
|
53
|
+
# Ruby files
|
54
|
+
ruby = dsl.ruby
|
55
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
56
|
+
end
|
57
|
+
|
58
|
+
guard :yard do
|
59
|
+
watch(%r{lib\/.+\.rb})
|
60
|
+
watch(%r{ext\/.+\.c})
|
61
|
+
end
|
62
|
+
|
63
|
+
guard :rubocop do
|
64
|
+
watch(/.+\.rb$/)
|
65
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
66
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Minwoo Lee
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Uu
|
2
|
+
|
3
|
+
Useful Utilities
|
4
|
+
|
5
|
+
## Contributing
|
6
|
+
|
7
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ermaker/uu.
|
8
|
+
|
9
|
+
## License
|
10
|
+
|
11
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'dotenv/load'
|
5
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
6
|
+
end
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'bundler/gem_tasks'
|
10
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'rspec/core/rake_task'
|
15
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
16
|
+
spec.rspec_opts = '--tag ~remote'
|
17
|
+
end
|
18
|
+
namespace :spec do
|
19
|
+
RSpec::Core::RakeTask.new(:all)
|
20
|
+
end
|
21
|
+
task(:default).prerequisites << task(:spec)
|
22
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'yard'
|
27
|
+
require 'yard/rake/yardoc_task'
|
28
|
+
YARD::Rake::YardocTask.new
|
29
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
require 'rubocop/rake_task'
|
34
|
+
RuboCop::RakeTask.new
|
35
|
+
namespace :rubocop do
|
36
|
+
desc "Run 'rubocop --auto-gen-config'"
|
37
|
+
task :todo do
|
38
|
+
sh 'rubocop --auto-gen-config'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
task(:default).prerequisites << task(:rubocop)
|
42
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
43
|
+
end
|
44
|
+
|
45
|
+
begin
|
46
|
+
require 'rubycritic/rake_task'
|
47
|
+
RubyCritic::RakeTask.new do |task|
|
48
|
+
task.paths = FileList['**/*.rb'] - FileList['spec/**/*_spec.rb']
|
49
|
+
task.options = '--no-browser' + (ENV['CI'] ? ' --format console' : '')
|
50
|
+
end
|
51
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
52
|
+
end
|
data/lib/drb/http0.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# rubocop:disable all
|
2
|
+
|
3
|
+
require 'drb'
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
module DRb
|
8
|
+
module HTTP0
|
9
|
+
class StrStream
|
10
|
+
def initialize(str='')
|
11
|
+
@buf = str
|
12
|
+
end
|
13
|
+
attr_reader :buf
|
14
|
+
|
15
|
+
def read(n)
|
16
|
+
begin
|
17
|
+
return @buf[0,n]
|
18
|
+
ensure
|
19
|
+
@buf[0,n] = ''
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def write(s)
|
24
|
+
@buf.concat s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.uri_option(uri, config)
|
29
|
+
return uri, nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.open(uri, config)
|
33
|
+
unless /^http:/ =~ uri
|
34
|
+
raise(DRbBadScheme, uri) unless uri =~ /^http:/
|
35
|
+
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
36
|
+
end
|
37
|
+
ClientSide.new(uri, config)
|
38
|
+
end
|
39
|
+
|
40
|
+
class ClientSide
|
41
|
+
def initialize(uri, config)
|
42
|
+
@uri = uri
|
43
|
+
@res = nil
|
44
|
+
@config = config
|
45
|
+
@msg = DRbMessage.new(config)
|
46
|
+
@proxy = ENV['HTTP_PROXY']
|
47
|
+
end
|
48
|
+
|
49
|
+
def close; end
|
50
|
+
def alive?; false; end
|
51
|
+
|
52
|
+
def send_request(ref, msg_id, *arg, &b)
|
53
|
+
stream = StrStream.new
|
54
|
+
@msg.send_request(stream, ref, msg_id, *arg, &b)
|
55
|
+
@reply_stream = StrStream.new
|
56
|
+
post(@uri, stream.buf)
|
57
|
+
end
|
58
|
+
|
59
|
+
def recv_reply
|
60
|
+
@msg.recv_reply(@reply_stream)
|
61
|
+
end
|
62
|
+
|
63
|
+
def post(url, data)
|
64
|
+
it = URI.parse(url)
|
65
|
+
path = [(it.path=='' ? '/' : it.path), it.query].compact.join('?')
|
66
|
+
http = Net::HTTP.new(it.host, it.port)
|
67
|
+
sio = StrStream.new
|
68
|
+
http.post(path, data, {'Content-Type'=>'application/octetstream;'}) do |str|
|
69
|
+
sio.write(str)
|
70
|
+
if @config[:load_limit] < sio.buf.size
|
71
|
+
raise TypeError, 'too large packet'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
@reply_stream = sio
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
DRbProtocol.add_protocol(HTTP0)
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'drb'
|
4
|
+
|
5
|
+
Class.include DRb::DRbUndumped
|
6
|
+
|
7
|
+
module DRb
|
8
|
+
class DRbObject
|
9
|
+
alias __orig_method_missing method_missing
|
10
|
+
def method_missing(*args, &blk) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
11
|
+
__orig_method_missing(*args, &blk)
|
12
|
+
rescue DRb::DRbConnError, Errno::ECONNREFUSED
|
13
|
+
sleep 0.1
|
14
|
+
retry
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module UU
|
20
|
+
class RemoteHelper
|
21
|
+
def initialize
|
22
|
+
@mutex = Mutex.new
|
23
|
+
@count = 0
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :count
|
27
|
+
|
28
|
+
def disable
|
29
|
+
@mutex.synchronize do
|
30
|
+
GC.disable
|
31
|
+
@count += 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def enable
|
36
|
+
@mutex.synchronize do
|
37
|
+
@count -= 1
|
38
|
+
break unless @count <= 0
|
39
|
+
GC.enable
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def reset
|
44
|
+
@mutex.synchronize do
|
45
|
+
@count = 0
|
46
|
+
GC.enable
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def eval_(code)
|
51
|
+
instance_eval(code)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# rubocop:disable all
|
2
|
+
|
3
|
+
require 'webrick'
|
4
|
+
require 'drb'
|
5
|
+
require 'drb/http0'
|
6
|
+
|
7
|
+
module DRb
|
8
|
+
module HTTP0
|
9
|
+
|
10
|
+
def self.open_server(uri, config)
|
11
|
+
unless /^http:/ =~ uri
|
12
|
+
raise(DRbBadScheme, uri) unless uri =~ /^http:/
|
13
|
+
raise(DRbBadURI, 'can\'t parse uri:' + uri)
|
14
|
+
end
|
15
|
+
Server.new(uri, config)
|
16
|
+
end
|
17
|
+
|
18
|
+
class Callback < WEBrick::HTTPServlet::AbstractServlet
|
19
|
+
def initialize(config, drb)
|
20
|
+
@config = config
|
21
|
+
@drb = drb
|
22
|
+
@queue = Thread::Queue.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def do_POST(req, res)
|
26
|
+
@req = req
|
27
|
+
@res = res
|
28
|
+
@drb.push(self)
|
29
|
+
@res.body = @queue.pop
|
30
|
+
@res['content-type'] = 'application/octet-stream;'
|
31
|
+
end
|
32
|
+
|
33
|
+
def uri
|
34
|
+
@req.request_uri.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
def req_body
|
38
|
+
@req.body
|
39
|
+
end
|
40
|
+
|
41
|
+
def reply(body)
|
42
|
+
@queue.push(body)
|
43
|
+
end
|
44
|
+
|
45
|
+
def close
|
46
|
+
@queue.push('')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Server
|
51
|
+
attr_reader :uri
|
52
|
+
|
53
|
+
def initialize(uri, config)
|
54
|
+
@uri = uri
|
55
|
+
@config = config
|
56
|
+
@queue = Thread::Queue.new
|
57
|
+
setup_webrick(uri)
|
58
|
+
end
|
59
|
+
|
60
|
+
def close
|
61
|
+
@server.shutdown if @server
|
62
|
+
@server = nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def push(callback)
|
66
|
+
@queue.push(callback)
|
67
|
+
end
|
68
|
+
|
69
|
+
def accept
|
70
|
+
client = @queue.pop
|
71
|
+
ServerSide.new(client, @config)
|
72
|
+
end
|
73
|
+
|
74
|
+
def setup_webrick(uri)
|
75
|
+
logger = WEBrick::Log::new($stderr, WEBrick::Log::FATAL)
|
76
|
+
u = URI.parse(uri)
|
77
|
+
s = WEBrick::HTTPServer.new(:Port => u.port,
|
78
|
+
:AddressFamily => Socket::AF_INET,
|
79
|
+
:BindAddress => u.host,
|
80
|
+
:Logger => logger,
|
81
|
+
:ServerType => Thread)
|
82
|
+
s.mount(u.path, Callback, self)
|
83
|
+
@server = s
|
84
|
+
s.start
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class ServerSide
|
89
|
+
attr_reader :uri
|
90
|
+
|
91
|
+
def initialize(callback, config)
|
92
|
+
@callback = callback
|
93
|
+
@config = config
|
94
|
+
@msg = DRbMessage.new(@config)
|
95
|
+
@req_stream = StrStream.new(@callback.req_body)
|
96
|
+
@uri = @callback.uri
|
97
|
+
end
|
98
|
+
|
99
|
+
def close
|
100
|
+
@callback.close if @callback
|
101
|
+
@callback = nil
|
102
|
+
end
|
103
|
+
|
104
|
+
def alive?; false; end
|
105
|
+
|
106
|
+
def recv_request
|
107
|
+
begin
|
108
|
+
@msg.recv_request(@req_stream)
|
109
|
+
rescue
|
110
|
+
close
|
111
|
+
raise $!
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def send_reply(succ, result)
|
116
|
+
begin
|
117
|
+
return unless @callback
|
118
|
+
stream = StrStream.new
|
119
|
+
@msg.send_reply(stream, succ, result)
|
120
|
+
@callback.reply(stream.buf)
|
121
|
+
rescue
|
122
|
+
close
|
123
|
+
raise $!
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
data/lib/uu.rb
ADDED
data/lib/uu/remote.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'drb'
|
4
|
+
require 'drb/http0'
|
5
|
+
require 'drb/http0helper'
|
6
|
+
|
7
|
+
module UU
|
8
|
+
class Remote
|
9
|
+
def self.start_service
|
10
|
+
DRb.start_service
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.stop_service
|
14
|
+
DRb.stop_service
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(uri)
|
18
|
+
@remote = DRbObject.new_with_uri(uri)
|
19
|
+
end
|
20
|
+
|
21
|
+
def run(klass = nil)
|
22
|
+
@remote.disable
|
23
|
+
yield (klass ? @remote.eval_(klass.to_s) : klass)
|
24
|
+
ensure
|
25
|
+
@remote.enable
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'drb'
|
4
|
+
require 'drb/http0serv'
|
5
|
+
require 'drb/http0helper'
|
6
|
+
|
7
|
+
module UU
|
8
|
+
class RemoteServer
|
9
|
+
def initialize(uri)
|
10
|
+
DRb.start_service(uri, UU::RemoteHelper.new)
|
11
|
+
end
|
12
|
+
|
13
|
+
def join
|
14
|
+
DRb.thread.join
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/uu/version.rb
ADDED
data/uu.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'uu/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
8
|
+
spec.name = 'uu'
|
9
|
+
spec.version = UU::VERSION
|
10
|
+
spec.authors = ['Minwoo Lee']
|
11
|
+
spec.email = ['ermaker@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'UU'
|
14
|
+
spec.description = 'UU'
|
15
|
+
spec.homepage = 'https://github.com/ermaker/uu'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency 'guard'
|
29
|
+
spec.add_development_dependency 'guard-bundler'
|
30
|
+
spec.add_development_dependency 'guard-rspec'
|
31
|
+
spec.add_development_dependency 'guard-rubocop'
|
32
|
+
spec.add_development_dependency 'guard-yard'
|
33
|
+
spec.add_development_dependency 'mbs'
|
34
|
+
spec.add_development_dependency 'rake'
|
35
|
+
spec.add_development_dependency 'rspec'
|
36
|
+
spec.add_development_dependency 'rspec-its'
|
37
|
+
spec.add_development_dependency 'rubocop'
|
38
|
+
spec.add_development_dependency 'yard'
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Minwoo Lee
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard-bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mbs
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-its
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: UU
|
182
|
+
email:
|
183
|
+
- ermaker@gmail.com
|
184
|
+
executables: []
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- ".gitignore"
|
189
|
+
- ".rspec"
|
190
|
+
- ".rubocop.local.yml"
|
191
|
+
- ".rubocop.yml"
|
192
|
+
- ".rubocop_todo.yml"
|
193
|
+
- ".travis.yml"
|
194
|
+
- Gemfile
|
195
|
+
- Gemfile.lock
|
196
|
+
- Guardfile
|
197
|
+
- LICENSE.txt
|
198
|
+
- README.md
|
199
|
+
- Rakefile
|
200
|
+
- lib/drb/http0.rb
|
201
|
+
- lib/drb/http0helper.rb
|
202
|
+
- lib/drb/http0serv.rb
|
203
|
+
- lib/uu.rb
|
204
|
+
- lib/uu/remote.rb
|
205
|
+
- lib/uu/remote_server.rb
|
206
|
+
- lib/uu/version.rb
|
207
|
+
- uu.gemspec
|
208
|
+
homepage: https://github.com/ermaker/uu
|
209
|
+
licenses:
|
210
|
+
- MIT
|
211
|
+
metadata: {}
|
212
|
+
post_install_message:
|
213
|
+
rdoc_options: []
|
214
|
+
require_paths:
|
215
|
+
- lib
|
216
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '0'
|
221
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - ">="
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
requirements: []
|
227
|
+
rubyforge_project:
|
228
|
+
rubygems_version: 2.7.6
|
229
|
+
signing_key:
|
230
|
+
specification_version: 4
|
231
|
+
summary: UU
|
232
|
+
test_files: []
|