ruby_process 0.0.9 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/README.md +98 -0
- data/Rakefile +2 -2
- data/RubyProcess.gemspec +88 -0
- data/VERSION +1 -1
- data/cmds/blocks.rb +18 -18
- data/cmds/marshal.rb +2 -2
- data/cmds/new.rb +13 -13
- data/cmds/numeric.rb +4 -4
- data/cmds/static.rb +10 -10
- data/cmds/str_eval.rb +4 -4
- data/cmds/system.rb +11 -11
- data/examples/example_csv.rb +13 -0
- data/examples/example_file_write.rb +2 -2
- data/examples/example_knj_db_dump.rb +7 -7
- data/examples/example_strscan.rb +3 -3
- data/include/args_handeling.rb +21 -21
- data/lib/ruby_process.rb +111 -105
- data/lib/{ruby_process_cproxy.rb → ruby_process/class_proxy.rb} +35 -35
- data/lib/{ruby_process_proxyobj.rb → ruby_process/proxy_object.rb} +18 -18
- data/ruby_process.gemspec +17 -10
- data/scripts/ruby_process_script.rb +7 -7
- data/shippable.yml +7 -0
- data/spec/class_proxy_spec.rb +95 -0
- data/spec/hard_load_spec.rb +13 -17
- data/spec/leaks_spec.rb +7 -7
- data/spec/ruby_process_spec.rb +75 -77
- data/spec/spec_helper.rb +3 -1
- metadata +60 -60
- data/README.rdoc +0 -19
- data/spec/cproxy_spec.rb +0 -101
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= ruby_process
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to ruby_process
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|
data/spec/cproxy_spec.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "RubyProcess" do
|
4
|
-
it "should be able to do quick in-and-outs without leaking" do
|
5
|
-
ts = []
|
6
|
-
|
7
|
-
1.upto(2) do |tcount|
|
8
|
-
ts << Thread.new do
|
9
|
-
1.upto(10) do
|
10
|
-
Ruby_process::Cproxy.run do |data|
|
11
|
-
sp = data[:subproc]
|
12
|
-
str = sp.new(:String, "Wee")
|
13
|
-
res1 = str.include?("Kasper")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
ts.each do |thread|
|
20
|
-
thread.join
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should be able to do basic stuff" do
|
25
|
-
require "stringio"
|
26
|
-
|
27
|
-
Ruby_process::Cproxy.run do |data|
|
28
|
-
data[:subproc].static(:Object, :require, "rubygems")
|
29
|
-
data[:subproc].static(:Object, :require, "rexml/document")
|
30
|
-
|
31
|
-
doc = Ruby_process::Cproxy::REXML::Document.new
|
32
|
-
doc.add_element("test")
|
33
|
-
|
34
|
-
strio = StringIO.new
|
35
|
-
doc.write(strio)
|
36
|
-
|
37
|
-
raise "Didnt expect REXML to be defined in host process." if Kernel.const_defined?(:REXML)
|
38
|
-
raise "Expected strio to contain '<test/>' but it didnt: '#{strio.string}'." if strio.string != "<test/>"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should be able to do multiple calls at once" do
|
43
|
-
ts = []
|
44
|
-
|
45
|
-
0.upto(9) do |tcount|
|
46
|
-
ts << Thread.new do
|
47
|
-
Ruby_process::Cproxy.run do |data|
|
48
|
-
sp = data[:subproc]
|
49
|
-
sp.new(:String, "Wee")
|
50
|
-
|
51
|
-
1.upto(250) do
|
52
|
-
str = sp.new(:String, "Kasper Johansen")
|
53
|
-
|
54
|
-
res1 = str.include?("Kasper")
|
55
|
-
str << " More"
|
56
|
-
|
57
|
-
res2 = str.include?("Johansen")
|
58
|
-
str << " Even more"
|
59
|
-
|
60
|
-
res3 = str.include?("Christina")
|
61
|
-
str << " Much more"
|
62
|
-
|
63
|
-
raise "Expected res1 to be true but it wasnt: '#{res1}'." if res1 != true
|
64
|
-
raise "Expected res2 to be true but it wasnt: '#{res2}'." if res2 != true
|
65
|
-
raise "Expected res3 to be false but it wasnt: '#{res3}'." if res3 != false
|
66
|
-
|
67
|
-
#print tcount
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
count = 0
|
74
|
-
ts.each do |t|
|
75
|
-
count += 1
|
76
|
-
#puts "Thread #{count}"
|
77
|
-
t.join
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should not leak" do
|
82
|
-
str = "kasper"
|
83
|
-
str = nil
|
84
|
-
sleep 0.1
|
85
|
-
GC.start
|
86
|
-
sleep 0.1
|
87
|
-
|
88
|
-
count_objs = 0
|
89
|
-
ObjectSpace.each_object(Ruby_process) do |obj|
|
90
|
-
count_objs += 1
|
91
|
-
end
|
92
|
-
|
93
|
-
count_proxy_objs = 0
|
94
|
-
ObjectSpace.each_object(Ruby_process::Proxyobj) do |obj|
|
95
|
-
count_proxy_objs += 1
|
96
|
-
end
|
97
|
-
|
98
|
-
raise "Expected 1 or less 'Ruby_process' to be left but it wasnt like that: #{count_objs} (proxy objects: #{count_proxy_objs})" if count_objs > 1
|
99
|
-
raise "Expected 0 constants to be left on cproxy." if !Ruby_process::Cproxy.constants.empty?
|
100
|
-
end
|
101
|
-
end
|