knjrbfw 0.0.110 → 0.0.114
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Rakefile +0 -14
- data/lib/knj/autoload.rb +1 -2
- data/lib/knj/gtk2_window.rb +7 -7
- data/lib/knj/image.rb +60 -51
- data/lib/knj/scripts/php_to_rb_helper.rb +13 -20
- data/lib/knj/unix_proc.rb +35 -35
- data/lib/knj/web.rb +135 -136
- metadata +32 -85
- data/.document +0 -5
- data/.rspec +0 -1
- data/Gemfile +0 -22
- data/Gemfile.lock +0 -90
- data/VERSION +0 -1
- data/knjrbfw.gemspec +0 -318
- data/lib/knj/.gitignore +0 -1
- data/lib/knj/datarow.rb +0 -873
- data/lib/knj/datarow_custom.rb +0 -153
- 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/lib/knj/scripts/process_meta_exec.rb +0 -144
- data/lib/knj/sshrobot/sshrobot.rb +0 -135
- data/lib/knj/sshrobot.rb +0 -1
- data/lib/knj/translations.rb +0 -133
- data/spec/amixer_spec.rb +0 -32
- data/spec/arrayext_spec.rb +0 -42
- data/spec/autoload_spec.rb +0 -7
- data/spec/cmd_parser_spec.rb +0 -25
- data/spec/db_spec.rb +0 -282
- data/spec/db_spec_encoding_test_file.txt +0 -1
- data/spec/knjrbfw_spec.rb +0 -109
- data/spec/locales_spec.rb +0 -9
- data/spec/objects_spec.rb +0 -394
- data/spec/process_meta_spec.rb +0 -172
- data/spec/process_spec.rb +0 -115
- data/spec/spec_helper.rb +0 -12
- data/spec/strings_spec.rb +0 -65
- data/spec/web_spec.rb +0 -77
- data/testfiles/image.jpg +0 -0
@@ -1,83 +0,0 @@
|
|
1
|
-
class KnjDB_java_sqlite3
|
2
|
-
def escape_table
|
3
|
-
return "`"
|
4
|
-
end
|
5
|
-
|
6
|
-
def escape_col
|
7
|
-
return "`"
|
8
|
-
end
|
9
|
-
|
10
|
-
def escape_val
|
11
|
-
return "'"
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(knjdb_ob)
|
15
|
-
@knjdb = knjdb_ob
|
16
|
-
|
17
|
-
if @knjdb.opts[:sqlite_driver]
|
18
|
-
require @knjdb.opts[:sqlite_driver]
|
19
|
-
else
|
20
|
-
require File.dirname(__FILE__) + "/sqlitejdbc-v056.jar"
|
21
|
-
end
|
22
|
-
|
23
|
-
require "java"
|
24
|
-
import "org.sqlite.JDBC"
|
25
|
-
@conn = java.sql.DriverManager::getConnection("jdbc:sqlite:" + @knjdb.opts[:path])
|
26
|
-
@stat = @conn.createStatement
|
27
|
-
end
|
28
|
-
|
29
|
-
def query(string)
|
30
|
-
begin
|
31
|
-
return KnjDB_java_sqlite3_result.new(@stat.executeQuery(string))
|
32
|
-
rescue java.sql.SQLException => e
|
33
|
-
if e.message == "java.sql.SQLException: query does not return ResultSet"
|
34
|
-
#ignore it.
|
35
|
-
else
|
36
|
-
raise e
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def fetch(result)
|
42
|
-
return result.fetch
|
43
|
-
end
|
44
|
-
|
45
|
-
def escape(string)
|
46
|
-
if (!string)
|
47
|
-
return ""
|
48
|
-
end
|
49
|
-
|
50
|
-
string = string.gsub("'", "\\'")
|
51
|
-
return string
|
52
|
-
end
|
53
|
-
|
54
|
-
def lastID
|
55
|
-
return @conn.last_insert_row_id
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class KnjDB_java_sqlite3_result
|
60
|
-
def initialize(rs)
|
61
|
-
@rs = rs
|
62
|
-
@index = 0
|
63
|
-
|
64
|
-
if rs
|
65
|
-
@metadata = rs.getMetaData
|
66
|
-
@columns_count = @metadata.getColumnCount
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def fetch
|
71
|
-
if !@rs.next
|
72
|
-
return false
|
73
|
-
end
|
74
|
-
|
75
|
-
tha_return = {}
|
76
|
-
for i in (1..@columns_count)
|
77
|
-
col_name = @metadata.getColumnName(i)
|
78
|
-
tha_return.store(col_name, @rs.getString(i))
|
79
|
-
end
|
80
|
-
|
81
|
-
return tha_return
|
82
|
-
end
|
83
|
-
end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
class Knj::Db_row
|
2
|
-
attr_reader :args, :data
|
3
|
-
|
4
|
-
def is_knj?; return true; end
|
5
|
-
|
6
|
-
def initialize(args)
|
7
|
-
@args = {}
|
8
|
-
args.each do |key, value|
|
9
|
-
@args[key.to_sym] = value
|
10
|
-
end
|
11
|
-
|
12
|
-
@args[:db] = $db if !@args[:db] and $db and $db.class.to_s == "Knj::Db"
|
13
|
-
@args[:objects] = $objects if !@args[:objects] and $objects and $objects.is_a?(Knj::Objects)
|
14
|
-
@args[:col_id] = :id if !@args[:col_id]
|
15
|
-
raise "No table given." if !@args[:table]
|
16
|
-
|
17
|
-
if @args[:data] and (@args[:data].is_a?(Integer) or @args[:data].is_a?(Fixnum) or @args[:data].is_a?(String))
|
18
|
-
@data = {@args[:col_id].to_sym => @args[:data].to_s}
|
19
|
-
self.reload
|
20
|
-
elsif @args[:data] and @args[:data].is_a?(Hash)
|
21
|
-
@data = {}
|
22
|
-
@args[:data].each do |key, value|
|
23
|
-
@data[key.to_sym] = value
|
24
|
-
end
|
25
|
-
elsif @args[:id]
|
26
|
-
@data = {}
|
27
|
-
@data[@args[:col_id].to_sym] = @args[:id]
|
28
|
-
self.reload
|
29
|
-
else
|
30
|
-
raise ArgumentError.new("Invalid data: #{@args[:data].to_s} (#{@args[:data].class.to_s})")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def db
|
35
|
-
if !@args[:force_selfdb]
|
36
|
-
curthread = Thread.current
|
37
|
-
if curthread.is_a?(Knj::Thread) and curthread[:knjappserver] and curthread[:knjappserver][:db]
|
38
|
-
return curthread[:knjappserver][:db]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
return @args[:db]
|
43
|
-
end
|
44
|
-
|
45
|
-
def ob
|
46
|
-
return @args[:objects] if @args.key?(:objects)
|
47
|
-
return $ob if $ob and $ob.is_a?(Knj::Objects)
|
48
|
-
return false
|
49
|
-
end
|
50
|
-
|
51
|
-
alias :objects :ob
|
52
|
-
|
53
|
-
def reload
|
54
|
-
last_id = self.id
|
55
|
-
data = self.db.single(@args[:table], {@args[:col_id] => self.id})
|
56
|
-
if !data
|
57
|
-
raise Errno::ENOENT.new("Could not find any data for the object with ID: '#{last_id}' in the table '#{@args[:table].to_s}'.")
|
58
|
-
end
|
59
|
-
|
60
|
-
@data = {}
|
61
|
-
data.each do |key, value|
|
62
|
-
@data[key.to_sym] = value
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def update(newdata)
|
67
|
-
self.db.update(@args[:table], newdata, {@args[:col_id] => self.id})
|
68
|
-
self.reload
|
69
|
-
|
70
|
-
if self.ob
|
71
|
-
self.ob.call("object" => self, "signal" => "update")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def delete
|
76
|
-
self.db.delete(@args[:table], {@args[:col_id] => self.id})
|
77
|
-
self.destroy
|
78
|
-
end
|
79
|
-
|
80
|
-
def destroy
|
81
|
-
@args = nil
|
82
|
-
@data = nil
|
83
|
-
end
|
84
|
-
|
85
|
-
def has_key?(key)
|
86
|
-
return @data.key?(key.to_sym)
|
87
|
-
end
|
88
|
-
|
89
|
-
def [](key)
|
90
|
-
raise "No valid key given." if !key
|
91
|
-
raise "No data was loaded on the object? Maybe you are trying to call a deleted object?" if !@data
|
92
|
-
|
93
|
-
if @data.key?(key)
|
94
|
-
return @data[key]
|
95
|
-
elsif @data.key?(key.to_sym)
|
96
|
-
return @data[key.to_sym]
|
97
|
-
elsif @data.key?(key.to_s)
|
98
|
-
return @data[key.to_s]
|
99
|
-
end
|
100
|
-
|
101
|
-
raise "No such key: #{key.to_s}."
|
102
|
-
end
|
103
|
-
|
104
|
-
def []=(key, value)
|
105
|
-
self.update(key.to_sym => value)
|
106
|
-
self.reload
|
107
|
-
end
|
108
|
-
|
109
|
-
def id
|
110
|
-
return @data[@args[:col_id]]
|
111
|
-
end
|
112
|
-
|
113
|
-
def title
|
114
|
-
if @args[:col_title]
|
115
|
-
return @data[@args[:col_title].to_sym]
|
116
|
-
end
|
117
|
-
|
118
|
-
if @data.key?(:title)
|
119
|
-
return @data[:title]
|
120
|
-
elsif @data.key?(:name)
|
121
|
-
return @data[:name]
|
122
|
-
end
|
123
|
-
|
124
|
-
raise "'col_title' has not been set for the class: '#{self.class.to_s}'."
|
125
|
-
end
|
126
|
-
|
127
|
-
alias :name :title
|
128
|
-
|
129
|
-
def each(&args)
|
130
|
-
return @data.each(&args)
|
131
|
-
end
|
132
|
-
|
133
|
-
def to_hash
|
134
|
-
return @data.clone
|
135
|
-
end
|
136
|
-
|
137
|
-
def esc(str)
|
138
|
-
return self.db.escape(str)
|
139
|
-
end
|
140
|
-
|
141
|
-
def method_missing(*args)
|
142
|
-
func_name = args[0].to_s
|
143
|
-
if match = func_name.match(/^(\S+)\?$/) and @data.key?(match[1].to_sym)
|
144
|
-
if @data[match[1].to_sym] == "1" or @data[match[1].to_sym] == "yes"
|
145
|
-
return true
|
146
|
-
elsif @data[match[1].to_sym] == "0" or @data[match[1].to_sym] == "no"
|
147
|
-
return false
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
raise sprintf("No such method: %s", func_name)
|
152
|
-
end
|
153
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require "Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"
|
2
|
-
require "Mono.Data.SqliteClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"
|
3
|
-
|
4
|
-
class KnjDB_sqlite3_ironruby
|
5
|
-
def escape_table
|
6
|
-
return "`"
|
7
|
-
end
|
8
|
-
|
9
|
-
def escape_col
|
10
|
-
return "`"
|
11
|
-
end
|
12
|
-
|
13
|
-
def escape_val
|
14
|
-
return "'"
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(knjdb_ob)
|
18
|
-
@knjdb = knjdb_ob
|
19
|
-
@conn = Mono::Data::SqliteClient::SqliteConnection.new("URI=file:" + @knjdb.opts[:path] + ",version=3")
|
20
|
-
@conn.Open
|
21
|
-
end
|
22
|
-
|
23
|
-
def query(string)
|
24
|
-
dbcmd = @conn.CreateCommand
|
25
|
-
dbcmd.CommandText = string
|
26
|
-
reader = dbcmd.ExecuteReader
|
27
|
-
return KnjDB_sqlite3_ironruby_result.new(reader)
|
28
|
-
end
|
29
|
-
|
30
|
-
def escape(string)
|
31
|
-
if (!string)
|
32
|
-
return ""
|
33
|
-
end
|
34
|
-
|
35
|
-
string = string.gsub("'", "\\'")
|
36
|
-
return string
|
37
|
-
end
|
38
|
-
|
39
|
-
def lastID
|
40
|
-
return @conn.last_insert_row_id
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class KnjDB_sqlite3_ironruby_result
|
45
|
-
def initialize(reader)
|
46
|
-
@reader = reader
|
47
|
-
end
|
48
|
-
|
49
|
-
def fetch
|
50
|
-
if !@reader.Read
|
51
|
-
return false
|
52
|
-
end
|
53
|
-
|
54
|
-
ret = {}
|
55
|
-
|
56
|
-
count = 0
|
57
|
-
while true
|
58
|
-
begin
|
59
|
-
ret[@reader.get_name(count)] = @reader.get_string(count)
|
60
|
-
rescue IndexError => e
|
61
|
-
break
|
62
|
-
end
|
63
|
-
|
64
|
-
count += 1
|
65
|
-
end
|
66
|
-
|
67
|
-
return ret
|
68
|
-
end
|
69
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
#This class buffers a lot of queries and flushes them out via transactions.
|
2
|
-
class Knj::Db::Query_buffer
|
3
|
-
#Constructor. Takes arguments to be used and a block.
|
4
|
-
def initialize(args)
|
5
|
-
@args = args
|
6
|
-
@queries = []
|
7
|
-
@inserts = {}
|
8
|
-
@queries_count = 0
|
9
|
-
@debug = @args[:debug]
|
10
|
-
@lock = Mutex.new
|
11
|
-
|
12
|
-
STDOUT.puts "Query buffer started." if @debug
|
13
|
-
|
14
|
-
if block_given?
|
15
|
-
begin
|
16
|
-
yield(self)
|
17
|
-
ensure
|
18
|
-
self.flush
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
#Adds a query to the buffer.
|
24
|
-
def query(str)
|
25
|
-
@lock.synchronize do
|
26
|
-
STDOUT.print "Adding to buffer: #{str}\n" if @debug
|
27
|
-
@queries << str
|
28
|
-
@queries_count += 1
|
29
|
-
end
|
30
|
-
|
31
|
-
self.flush if @queries_count >= 1000
|
32
|
-
return nil
|
33
|
-
end
|
34
|
-
|
35
|
-
#Delete as on a normal Knj::Db.
|
36
|
-
#===Examples
|
37
|
-
# db.q_buffer do |buffer|
|
38
|
-
# buffer.delete(:users, {:id => 5})
|
39
|
-
# end
|
40
|
-
def delete(table, where)
|
41
|
-
STDOUT.puts "Delete called on table #{table} with arguments: '#{where}'." if @debug
|
42
|
-
self.query(@args[:db].delete(table, where, :return_sql => true))
|
43
|
-
return nil
|
44
|
-
end
|
45
|
-
|
46
|
-
#Plans to inset a hash into a table. It will only be inserted when flush is called.
|
47
|
-
#===Examples
|
48
|
-
# db.q_buffer do |buffer|
|
49
|
-
# buffer.insert(:users, {:name => "John Doe"})
|
50
|
-
# end
|
51
|
-
def insert(table, data)
|
52
|
-
@lock.synchronize do
|
53
|
-
@inserts[table] = [] if !@inserts.key?(table)
|
54
|
-
@inserts[table] << data
|
55
|
-
@queries_count += 1
|
56
|
-
end
|
57
|
-
|
58
|
-
self.flush if @queries_count >= 1000
|
59
|
-
return nil
|
60
|
-
end
|
61
|
-
|
62
|
-
#Flushes all queries out in a transaction. This will automatically be called for every 1000 queries.
|
63
|
-
def flush
|
64
|
-
return nil if @queries_count <= 0
|
65
|
-
|
66
|
-
@lock.synchronize do
|
67
|
-
@args[:db].transaction do
|
68
|
-
@queries.shift(1000).each do |str|
|
69
|
-
STDOUT.print "Executing via buffer: #{str}\n" if @debug
|
70
|
-
@args[:db].q(str)
|
71
|
-
end
|
72
|
-
|
73
|
-
@inserts.each do |table, datas_arr|
|
74
|
-
while !datas_arr.empty?
|
75
|
-
datas_chunk_arr = datas_arr.shift(1000)
|
76
|
-
@args[:db].insert_multi(table, datas_chunk_arr)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
@inserts.clear
|
82
|
-
@queries_count = 0
|
83
|
-
end
|
84
|
-
|
85
|
-
return nil
|
86
|
-
end
|
87
|
-
end
|