knjrbfw 0.0.110 → 0.0.111
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/knjrbfw.gemspec +8 -36
- data/lib/knj/autoload.rb +1 -2
- data/lib/knj/gtk2_window.rb +7 -7
- data/lib/knj/unix_proc.rb +35 -35
- metadata +33 -62
- data/lib/knj/db.rb +0 -1
- data/lib/knj/knjdb/dbtime.rb +0 -35
- data/lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb +0 -604
- data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_columns.rb +0 -155
- data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb +0 -69
- data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_sqlspecs.rb +0 -5
- data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_tables.rb +0 -443
- data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3.rb +0 -184
- data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_columns.rb +0 -177
- data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_indexes.rb +0 -29
- data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_sqlspecs.rb +0 -5
- data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_tables.rb +0 -449
- data/lib/knj/knjdb/dump.rb +0 -122
- data/lib/knj/knjdb/idquery.rb +0 -109
- data/lib/knj/knjdb/libknjdb.rb +0 -797
- data/lib/knj/knjdb/libknjdb_java_sqlite3.rb +0 -83
- data/lib/knj/knjdb/libknjdb_row.rb +0 -153
- data/lib/knj/knjdb/libknjdb_sqlite3_ironruby.rb +0 -69
- data/lib/knj/knjdb/query_buffer.rb +0 -87
- data/lib/knj/knjdb/revision.rb +0 -342
- data/lib/knj/knjdb/sqlspecs.rb +0 -5
- data/lib/knj/objects.rb +0 -957
- data/lib/knj/process.rb +0 -480
- data/lib/knj/process_meta.rb +0 -569
- data/spec/db_spec.rb +0 -282
- data/spec/db_spec_encoding_test_file.txt +0 -1
- data/spec/objects_spec.rb +0 -394
- data/spec/process_meta_spec.rb +0 -172
- data/spec/process_spec.rb +0 -115
data/spec/process_meta_spec.rb
DELETED
@@ -1,172 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Process_meta" do
|
4
|
-
it "should be able to start a server and a client" do
|
5
|
-
require "knj/process_meta"
|
6
|
-
require "timeout"
|
7
|
-
|
8
|
-
#Start the activity.
|
9
|
-
$process_meta = Knj::Process_meta.new("debug" => true, "debug_err" => true, "id" => "process_meta_spec")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should be able to do simple blocks" do
|
13
|
-
block_ran = false
|
14
|
-
fpath = "#{Knj::Os.tmpdir}/process_meta_file_open"
|
15
|
-
|
16
|
-
Timeout.timeout(4) do
|
17
|
-
$process_meta.static(:File, :open, fpath, "w") do |fp|
|
18
|
-
block_ran = true
|
19
|
-
fp.write("Test!")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
raise "Block didnt run!" if !block_ran
|
24
|
-
raise "Unexpected file-content." if File.read(fpath) != "Test!"
|
25
|
-
File.unlink(fpath) if File.exists?(fpath)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should be able to do various operations" do
|
29
|
-
#Test that breaking a block wont continue to run in the process.
|
30
|
-
$process_meta.str_eval("
|
31
|
-
class Testclass
|
32
|
-
attr_reader :last_num
|
33
|
-
|
34
|
-
def initialize
|
35
|
-
@num = 0
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_block
|
39
|
-
@num.upto(10) do |i|
|
40
|
-
@last_num = i
|
41
|
-
yield(i)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
")
|
46
|
-
|
47
|
-
proxy_obj = $process_meta.new(:Testclass)
|
48
|
-
proxy_obj2 = $process_meta.new(:Testclass)
|
49
|
-
proxy_obj3 = $process_meta.new(:Testclass)
|
50
|
-
|
51
|
-
$ids = []
|
52
|
-
$ids << proxy_obj.__id__
|
53
|
-
$ids << proxy_obj2.__id__
|
54
|
-
$ids << proxy_obj3.__id__
|
55
|
-
|
56
|
-
proxy_obj.test_block do |i|
|
57
|
-
break if i == 5
|
58
|
-
end
|
59
|
-
|
60
|
-
last_num = proxy_obj.last_num
|
61
|
-
raise "Expected last num to be 5 but it wasnt: '#{last_num}'." if last_num != 5
|
62
|
-
|
63
|
-
#Somehow define_finalizer is always one behind, so we have to do another funny one here.
|
64
|
-
ObjectSpace.define_finalizer(self, $process_meta.method(:proxy_finalizer))
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should be able to do more" do
|
68
|
-
GC.start
|
69
|
-
|
70
|
-
#Its difficult to test this on JRuby.
|
71
|
-
if RUBY_ENGINE != "jruby"
|
72
|
-
count = 0
|
73
|
-
$ids.each do |id|
|
74
|
-
count += 1
|
75
|
-
raise "The object should no longer exist but it does: #{count}." if $process_meta.proxy_has?(id)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
#Spawn a test-object - a string - with a variable-name.
|
81
|
-
proxy_obj = $process_meta.spawn_object(:String, "my_test_var", "Kasper")
|
82
|
-
raise "to_s should return 'Kasper' but didnt: '#{proxy_obj.to_s}'." if proxy_obj.to_s != "Kasper"
|
83
|
-
|
84
|
-
#Stress it a little by doing 500 calls.
|
85
|
-
0.upto(500) do
|
86
|
-
res = proxy_obj.slice(0, 3)
|
87
|
-
raise "Expected output was: 'Kas' but wasnt: '#{res}'." if res != "Kas"
|
88
|
-
end
|
89
|
-
|
90
|
-
#Do a lot of calls at the same time to test thread-safety.
|
91
|
-
threads = []
|
92
|
-
0.upto(10) do |thread_i|
|
93
|
-
should_return = "Kasper".slice(0, thread_i)
|
94
|
-
thread = Knj::Thread.new do
|
95
|
-
0.upto(500) do |num_i|
|
96
|
-
res = proxy_obj.slice(0, thread_i)
|
97
|
-
raise "Should return: '#{should_return}' but didnt: '#{res}'." if res != should_return
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
threads << thread
|
102
|
-
end
|
103
|
-
|
104
|
-
threads.each do |thread|
|
105
|
-
thread.join
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
#Try to define an integer and run upto with a block.
|
111
|
-
proxy_int = $process_meta.spawn_object(:Integer, nil, 5)
|
112
|
-
expect = 5
|
113
|
-
proxy_int.upto(1000) do |i|
|
114
|
-
raise "Expected '#{expect}' but got: '#{i}'." if i != expect
|
115
|
-
expect += 1
|
116
|
-
end
|
117
|
-
|
118
|
-
#Ensure the expected has actually been increased by running the block.
|
119
|
-
raise "Expected end-result of 1001 but got: '#{expect}'." if expect != 1001
|
120
|
-
|
121
|
-
|
122
|
-
proxy_int = $process_meta.spawn_object(:Integer, nil, 5)
|
123
|
-
proxy_int._process_meta_block_buffer_use = true
|
124
|
-
expect = 5
|
125
|
-
|
126
|
-
#If this takes more than 10 secs - something is wrong (JRuby can take a long time)...
|
127
|
-
Timeout.timeout(10) do
|
128
|
-
proxy_int.upto(10000) do |i|
|
129
|
-
raise "Expected '#{expect}' but got: '#{i}'." if i != expect
|
130
|
-
expect += 1
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
|
-
#Ensure the expected has actually been increased by running the block.
|
136
|
-
raise "Expected end-result of 10001 but got: '#{expect}'." if expect != 10001
|
137
|
-
|
138
|
-
#Try to unset an object.
|
139
|
-
proxy_obj._process_meta_unset
|
140
|
-
proxy_int._process_meta_unset
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should be able to do slow block-results in JRuby." do
|
144
|
-
$process_meta.str_eval("
|
145
|
-
class Kaspertest
|
146
|
-
def self.kaspertest
|
147
|
-
8.upto(12) do |i|
|
148
|
-
yield(i)
|
149
|
-
sleep 0.5
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
nil
|
155
|
-
")
|
156
|
-
|
157
|
-
Timeout.timeout(10) do
|
158
|
-
expect = 8
|
159
|
-
$process_meta.static("Kaspertest", "kaspertest") do |count|
|
160
|
-
raise "Expected '#{expect}' but got: '#{count}'." if expect != count
|
161
|
-
expect += 1
|
162
|
-
end
|
163
|
-
|
164
|
-
raise "Expected '13' but got: '#{expect}'." if expect != 13
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should be able to be destroyed." do
|
169
|
-
#Destroy the process-meta which should stop the process.
|
170
|
-
$process_meta.destroy
|
171
|
-
end
|
172
|
-
end
|
data/spec/process_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
require "socket"
|
4
|
-
|
5
|
-
describe "Process" do
|
6
|
-
it "should be able to start a server and a client" do
|
7
|
-
require "timeout"
|
8
|
-
|
9
|
-
tcp_server = TCPServer.new("0.0.0.0", 15678)
|
10
|
-
conn_client = TCPSocket.new("localhost", 15678)
|
11
|
-
conn_server = tcp_server.accept
|
12
|
-
|
13
|
-
answers = {}
|
14
|
-
|
15
|
-
$process_server = Knj::Process.new(
|
16
|
-
:in => conn_server,
|
17
|
-
:out => conn_server,
|
18
|
-
:debug => false,
|
19
|
-
:listen => true,
|
20
|
-
:on_rec => proc{|d|
|
21
|
-
if d.obj == "hello server"
|
22
|
-
d.answer("hello back client")
|
23
|
-
elsif match = d.obj.match(/^test (\d+)$/)
|
24
|
-
d.answer("testanswer #{match[1]}")
|
25
|
-
else
|
26
|
-
raise "Received unknown object: '#{d.obj}'."
|
27
|
-
end
|
28
|
-
}
|
29
|
-
)
|
30
|
-
|
31
|
-
$process_client = Knj::Process.new(
|
32
|
-
:in => conn_client,
|
33
|
-
:out => conn_client,
|
34
|
-
:debug => false,
|
35
|
-
:listen => true,
|
36
|
-
:on_rec => proc{|d, &block|
|
37
|
-
if d.obj == "hello client"
|
38
|
-
d.answer("hello back server")
|
39
|
-
elsif d.obj == "test_block"
|
40
|
-
raise "No block was given." if !block
|
41
|
-
0.upto(100) do |i|
|
42
|
-
#$stderr.print "Calling block with: #{i}\n"
|
43
|
-
block.call(i)
|
44
|
-
end
|
45
|
-
|
46
|
-
d.answer("ok")
|
47
|
-
else
|
48
|
-
raise "Received unknown object: '#{d.obj}'."
|
49
|
-
end
|
50
|
-
}
|
51
|
-
)
|
52
|
-
|
53
|
-
Timeout.timeout(1) do
|
54
|
-
answer = $process_server.send("hello client")
|
55
|
-
raise "Unexpected answer: '#{answer}'." if answer != "hello back server"
|
56
|
-
end
|
57
|
-
|
58
|
-
Timeout.timeout(1) do
|
59
|
-
answer = $process_client.send("hello server")
|
60
|
-
raise "Unexpected answer: '#{answer}'." if answer != "hello back client"
|
61
|
-
end
|
62
|
-
|
63
|
-
#Stress it by doing 1000 requests.
|
64
|
-
if RUBY_ENGINE == "jruby"
|
65
|
-
tout = 7
|
66
|
-
else
|
67
|
-
tout = 2
|
68
|
-
end
|
69
|
-
|
70
|
-
Timeout.timeout(tout) do
|
71
|
-
0.upto(1000) do |count|
|
72
|
-
#$stderr.print "Testing #{count}\n"
|
73
|
-
answer = $process_client.send("test #{count}")
|
74
|
-
match = answer.match(/^testanswer (\d+)$/)
|
75
|
-
raise "Unexpected answer: '#{answer}'." if !match
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
#Run a test block.
|
81
|
-
expect = 0
|
82
|
-
$process_server.send("test_block") do |ele|
|
83
|
-
#$stderr.print "test_block: #{ele}\n"
|
84
|
-
raise "Expected '#{expect}' but got: '#{ele}'." if ele != expect
|
85
|
-
expect += 1
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
#Run several test blocks at the same time.
|
90
|
-
threads = []
|
91
|
-
results = {} #this can be used for debugging.
|
92
|
-
|
93
|
-
0.upto(10) do |thread_id|
|
94
|
-
threads << Knj::Thread.new do
|
95
|
-
myres = []
|
96
|
-
expect_thread = 0
|
97
|
-
$process_server.send("test_block") do |ele|
|
98
|
-
#$stderr.print "test_block: #{ele}\n"
|
99
|
-
myres << [ele, expect_thread]
|
100
|
-
raise "Expected '#{expect_thread}' but got: '#{ele}'." if ele != expect_thread
|
101
|
-
expect_thread += 1
|
102
|
-
end
|
103
|
-
|
104
|
-
results[thread_id] = myres
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
threads.each do |thread|
|
109
|
-
thread.join
|
110
|
-
end
|
111
|
-
|
112
|
-
#this can be used for debugging.
|
113
|
-
#Php4r.print_r(results)
|
114
|
-
end
|
115
|
-
end
|