knjrbfw 0.0.110 → 0.0.114

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +0 -14
  3. data/lib/knj/autoload.rb +1 -2
  4. data/lib/knj/gtk2_window.rb +7 -7
  5. data/lib/knj/image.rb +60 -51
  6. data/lib/knj/scripts/php_to_rb_helper.rb +13 -20
  7. data/lib/knj/unix_proc.rb +35 -35
  8. data/lib/knj/web.rb +135 -136
  9. metadata +32 -85
  10. data/.document +0 -5
  11. data/.rspec +0 -1
  12. data/Gemfile +0 -22
  13. data/Gemfile.lock +0 -90
  14. data/VERSION +0 -1
  15. data/knjrbfw.gemspec +0 -318
  16. data/lib/knj/.gitignore +0 -1
  17. data/lib/knj/datarow.rb +0 -873
  18. data/lib/knj/datarow_custom.rb +0 -153
  19. data/lib/knj/db.rb +0 -1
  20. data/lib/knj/knjdb/dbtime.rb +0 -35
  21. data/lib/knj/knjdb/drivers/mysql/knjdb_mysql.rb +0 -604
  22. data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_columns.rb +0 -155
  23. data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb +0 -69
  24. data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_sqlspecs.rb +0 -5
  25. data/lib/knj/knjdb/drivers/mysql/knjdb_mysql_tables.rb +0 -443
  26. data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3.rb +0 -184
  27. data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_columns.rb +0 -177
  28. data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_indexes.rb +0 -29
  29. data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_sqlspecs.rb +0 -5
  30. data/lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_tables.rb +0 -449
  31. data/lib/knj/knjdb/dump.rb +0 -122
  32. data/lib/knj/knjdb/idquery.rb +0 -109
  33. data/lib/knj/knjdb/libknjdb.rb +0 -797
  34. data/lib/knj/knjdb/libknjdb_java_sqlite3.rb +0 -83
  35. data/lib/knj/knjdb/libknjdb_row.rb +0 -153
  36. data/lib/knj/knjdb/libknjdb_sqlite3_ironruby.rb +0 -69
  37. data/lib/knj/knjdb/query_buffer.rb +0 -87
  38. data/lib/knj/knjdb/revision.rb +0 -342
  39. data/lib/knj/knjdb/sqlspecs.rb +0 -5
  40. data/lib/knj/objects.rb +0 -957
  41. data/lib/knj/process.rb +0 -480
  42. data/lib/knj/process_meta.rb +0 -569
  43. data/lib/knj/scripts/process_meta_exec.rb +0 -144
  44. data/lib/knj/sshrobot/sshrobot.rb +0 -135
  45. data/lib/knj/sshrobot.rb +0 -1
  46. data/lib/knj/translations.rb +0 -133
  47. data/spec/amixer_spec.rb +0 -32
  48. data/spec/arrayext_spec.rb +0 -42
  49. data/spec/autoload_spec.rb +0 -7
  50. data/spec/cmd_parser_spec.rb +0 -25
  51. data/spec/db_spec.rb +0 -282
  52. data/spec/db_spec_encoding_test_file.txt +0 -1
  53. data/spec/knjrbfw_spec.rb +0 -109
  54. data/spec/locales_spec.rb +0 -9
  55. data/spec/objects_spec.rb +0 -394
  56. data/spec/process_meta_spec.rb +0 -172
  57. data/spec/process_spec.rb +0 -115
  58. data/spec/spec_helper.rb +0 -12
  59. data/spec/strings_spec.rb +0 -65
  60. data/spec/web_spec.rb +0 -77
  61. data/testfiles/image.jpg +0 -0
@@ -1,135 +0,0 @@
1
- class Knj::SSHRobot
2
- def initialize(args)
3
- require "net/ssh"
4
-
5
- @forwards = []
6
- @args = Knj::ArrayExt.hash_sym(args)
7
- @args[:port] = 22 if !@args.key?(:port)
8
-
9
- if block_given?
10
- begin
11
- yield(self)
12
- ensure
13
- self.close
14
- end
15
- end
16
- end
17
-
18
- #Spawns a session if it hasnt already been spawned and returns it.
19
- def session
20
- @session = self.session_spawn if !@session
21
- return @session
22
- end
23
-
24
- #Spawns a new net-ssh-instance.
25
- def session_spawn
26
- return Net::SSH.start(@args[:host], @args[:user], :password => @args[:passwd], :port => @args[:port].to_i)
27
- end
28
-
29
- #Returns the a shell-session.
30
- def shell
31
- return self.session.shell.sync
32
- end
33
-
34
- def sftp
35
- @sftp = Net::SFTP.start(@args[:host], @args[:user], @args[:passwd], :port => @args[:port].to_i)
36
- end
37
-
38
- #Executes a command.
39
- def exec(command, &block)
40
- if block
41
- return self.session.exec!(command) do |channel, stream, line|
42
- block.call(:channel => channel, :stream => stream, :line => line)
43
- end
44
- else
45
- return self.session.exec!(command)
46
- end
47
- end
48
-
49
- #Executes a command as "root" via "sudo". Accepts the "sudo"-password and a command.
50
- def sudo_exec(sudo_passwd, command)
51
- result = ""
52
-
53
- self.session.open_channel do |ch|
54
- ch.request_pty
55
-
56
- ch.exec("sudo #{command}") do |ch, success|
57
- ch.on_data do |ch, data|
58
- if data =~ /^\[sudo\] password for (.+):\s*$/
59
- ch.send_data("#{sudo_passwd}\n")
60
- else
61
- result << data
62
- end
63
- end
64
- end
65
- end
66
-
67
- self.session.loop
68
- return result
69
- end
70
-
71
- def fileExists(filepath)
72
- result = self.exec("ls #{Strings.UnixSafe(filepath)}").strip
73
- return true if result == filepath
74
- return false
75
- end
76
-
77
- def forward(args)
78
- Knj::ArrayExt.hash_sym(args)
79
- args[:type] = "local" if !args[:type]
80
- args[:session] = self.session_spawn if !args[:session]
81
- args[:host_local] = "0.0.0.0" if !args[:host_local]
82
- return SSHRobot::Forward.new(args)
83
- end
84
-
85
- alias getShell shell
86
- alias getSFTP sftp
87
- alias shellCMD exec
88
-
89
- def close
90
- @session.close if @session
91
- @session = nil
92
- end
93
- end
94
-
95
- class Knj::SSHRobot::Forward
96
- attr_reader :open
97
-
98
- def initialize(args)
99
- @open = true
100
- @args = args
101
- @thread = Knj::Thread.new do
102
- begin
103
- #args[:session].logger.sev_threshold = Logger::Severity::DEBUG
104
- if args[:type] == "local"
105
- @args[:session].forward.local(@args[:host_local], @args[:port_local].to_i, @args[:host], @args[:port_remote].to_i)
106
- elsif args[:type] == "remote"
107
- @args[:session].forward.remote_to(@args[:port_local], @args[:host], @args[:port_remote], @args[:host_local])
108
- else
109
- raise "No valid type given."
110
- end
111
-
112
- @args[:session].loop do
113
- true
114
- end
115
- rescue => e
116
- puts e.inspect
117
- puts e.backtrace
118
-
119
- @open = false
120
- end
121
- end
122
- end
123
-
124
- def close
125
- if !@args
126
- return nil
127
- end
128
-
129
- @args[:session].close
130
- @open = false
131
- @thread.exit
132
- @args = nil
133
- @thread = nil
134
- end
135
- end
data/lib/knj/sshrobot.rb DELETED
@@ -1 +0,0 @@
1
- require "#{$knjpath}sshrobot/sshrobot"
@@ -1,133 +0,0 @@
1
- class Knj::Translations
2
- attr_accessor :args, :db, :ob, :cache
3
-
4
- def initialize(args)
5
- @args = args
6
-
7
- raise "No DB given." if !@args[:db]
8
- @db = @args[:db]
9
-
10
- @ob = Knj::Objects.new(
11
- :db => @args[:db],
12
- :extra_args => [self],
13
- :class_path => File.dirname(__FILE__),
14
- :module => Knj::Translations,
15
- :require => false,
16
- :datarow => true
17
- )
18
- end
19
-
20
- #Returns the translated value for an object by the given key.
21
- def get(obj, key, args = {})
22
- return "" if !obj
23
-
24
- if args[:locale]
25
- locale = args[:locale].to_sym
26
- else
27
- locale = @args[:locale].to_sym
28
- end
29
-
30
- #Force to symbol to save memory when caching.
31
- key = key.to_sym
32
-
33
- #Set-get the cache-hash for the object.
34
- if !obj.instance_variable_defined?("@knj_translations_cache")
35
- obj.instance_variable_set("@knj_translations_cache", {})
36
- end
37
-
38
- cache = obj.instance_variable_get("@knj_translations_cache")
39
-
40
- #Return from cache if set.
41
- if cache.key?(key) and cache[key].key?(locale)
42
- return cache[key][locale]
43
- end
44
-
45
- trans = @ob.list(:Translation, {
46
- "object_class" => obj.class.name,
47
- "object_id" => obj.id,
48
- "key" => key,
49
- "locale" => locale
50
- })
51
-
52
- if trans.empty?
53
- print "Nothing found - returning empty string.\n" if @args[:debug] or args[:debug]
54
- return ""
55
- end
56
-
57
- trans.each do |tran|
58
- if !cache[key]
59
- cache[key] = {
60
- locale => tran[:value]
61
- }
62
- elsif !cache[key][locale]
63
- cache[key][locale] = tran[:value]
64
- end
65
- end
66
-
67
- return cache[key][locale]
68
- end
69
-
70
- #Sets translations for an object by the given hash-keys and hash-values.
71
- def set(obj, values, args = {})
72
- #Reset cache to reflect the updates when read next time.
73
- obj.instance_variable_set("@knj_translations_cache", {})
74
-
75
- if args[:locale]
76
- locale = args[:locale]
77
- else
78
- locale = @args[:locale]
79
- end
80
-
81
- values.each do |key, val|
82
- trans = @ob.get_by(:Translation, {
83
- "object_id" => obj.id,
84
- "object_class" => obj.class.name,
85
- "key" => key,
86
- "locale" => locale
87
- })
88
-
89
- if trans
90
- trans.update(:value => val)
91
- else
92
- @ob.add(:Translation, {
93
- :object => obj,
94
- :key => key,
95
- :locale => locale,
96
- :value => val
97
- })
98
- end
99
- end
100
- end
101
-
102
- #Deletes all translations for a given object.
103
- def delete(obj)
104
- classn = obj.class.name
105
- objid = obj.id.to_s
106
-
107
- if obj.instance_variable_defined?("@knj_translations_cache")
108
- cache = obj.instance_variable_get("@knj_translations_cache")
109
- end
110
-
111
- trans = @ob.list(:Translation, {
112
- "object_id" => obj.id,
113
- "object_class" => obj.class.name
114
- })
115
- trans.each do |tran|
116
- #Delete the cache if defined on the object.
117
- cache.delete(tran[:key].to_sym) if cache and cache.key?(tran[:key].to_sym)
118
-
119
- #Delete the translation object.
120
- @ob.delete(tran)
121
- end
122
- end
123
- end
124
-
125
- class Knj::Translations::Translation < Knj::Datarow
126
- def self.add(d)
127
- if d.data[:object]
128
- d.data[:object_class] = d.data[:object].class.name
129
- d.data[:object_id] = d.data[:object].id
130
- d.data.delete(:object)
131
- end
132
- end
133
- end
data/spec/amixer_spec.rb DELETED
@@ -1,32 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Amixer" do
4
- it "should load by using autoload" do
5
- if Knj::Os.os == "linux"
6
- require "knjrbfw"
7
- $amixer = Knj::Amixer.new
8
- end
9
- end
10
-
11
- it "should register various devices" do
12
- if Knj::Os.os == "linux"
13
- $devices = $amixer.devices
14
- end
15
- end
16
-
17
- it "should register various mixers and do various operations on them" do
18
- if Knj::Os.os == "linux"
19
- $devices.each do |name, device|
20
- mixers = device.mixers
21
-
22
- if device.active?(:stream => "PLAYBACK")
23
- mixers.each do |name, mixer|
24
- next if !mixer.volume?
25
- mixer.vol_add -5
26
- mixer.vol_add 3
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,42 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "ArrayExt" do
4
- it "should be able to do powersets" do
5
- ps = Knj::ArrayExt.powerset(:arr => [1, 2, 3, 4]).to_a
6
- raise "Expected length of 16 but it wasnt: #{ps.length}" if ps.length != 16
7
-
8
- ite = 0
9
- Knj::ArrayExt.powerset(:arr => [1, 2, 3, 4]) do |arr|
10
- ite += 1
11
- end
12
-
13
- raise "Expected block to be executed 16 times but it wasnt: #{ite}" if ite != 16
14
- end
15
-
16
- it "should be able to divide arrays" do
17
- arr = [1, 2, 3, 4, 6, 7, 8, 9, 15, 16, 17, 18]
18
- res = Knj::ArrayExt.divide(:arr => arr) do |a, b|
19
- if (b - a) > 1
20
- false
21
- else
22
- true
23
- end
24
- end
25
-
26
- raise "Expected length of 3 but it wasnt: #{res.length}" if res.length != 3
27
- raise "Expected length of 4 but it wasnt: #{res[0].length}" if res[0].length != 4
28
- raise "Expected length of 3 but it wasnt: #{res[1].length}" if res[1].length != 3
29
- raise "Expected length of 3 but it wasnt: #{res[2].length}" if res[2].length != 3
30
- end
31
-
32
- it "should be able to make ago-strings" do
33
- arr = [1, 2]
34
- Knj::ArrayExt.force_no_cols(:arr => arr, :no => 1)
35
- raise "Expected length of 1 but got: #{arr.length}" if arr.length != 1
36
- raise "Expected element to be 1 but it wasnt: #{arr[0]}" if arr[0] != 1
37
-
38
- Knj::ArrayExt.force_no_cols(:arr => arr, :no => 3, :empty => "test")
39
- raise "Expected length of 3 but got: #{arr.lengtj}" if arr.length != 3
40
- raise "Expected element 2 to be 'test' but it wasnt: #{arr[2]}" if arr[2] != "test"
41
- end
42
- end
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Autoload" do
4
- it "Wref" do
5
- require "#{File.dirname(__FILE__)}/../lib/knj/autoload/wref.rb"
6
- end
7
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Cmd_parser" do
4
- it "should be able to parse various strings" do
5
- require "knjrbfw"
6
- require "knj/cmd_parser"
7
- require "php4r" if !Kernel.const_defined?(:Php4r)
8
-
9
- strs = [
10
- "-rw-r--r-- 1 admin administ 186.3M Aug 30 18:09 b4u_synoptik_2011_08_30_17_57_32.sql.gz\n",
11
- "-rw-r--r-- 1 admin administ 2 Nov 21 18:12 test\n",
12
- "-rw-r--r-- 1 kaspernj kaspernj 279943393 2011-07-27 09:28 dbdump_2011_07_27_03_07_36.sql\n",
13
- "-rw-rw-r-- 1 kaspernj kaspernj 58648 2011-10-28 18:33 2011-11-28 - Programmerings aften hos Anders - mad - 600 kr.pdf\n",
14
- "-rw-r--r-- 1 www-data www-data 4,0K 2011-05-16 23:21 dbbackup_2011_05_16-23:21:10.sql.gz\n"
15
- ]
16
-
17
- strs.each do |str|
18
- res = Knj::Cmd_parser.lsl(str)
19
-
20
- res.each do |file|
21
- raise "Byte was not numeric in: '#{str}'." if !(Float(file[:size]) rescue false)
22
- end
23
- end
24
- end
25
- end
data/spec/db_spec.rb DELETED
@@ -1,282 +0,0 @@
1
- #encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
-
5
- describe "Db" do
6
- it "should be able to handle various encodings" do
7
- #I never got this test to actually fail... :-(
8
-
9
- require "knj/db"
10
- require "knj/os"
11
- require "rubygems"
12
- require "sqlite3" if !Kernel.const_defined?("SQLite3") and RUBY_ENGINE != "jruby"
13
-
14
- db_path = "#{Knj::Os.tmpdir}/knjrbfw_test_sqlite3.sqlite3"
15
- File.unlink(db_path) if File.exists?(db_path)
16
-
17
- db = Knj::Db.new(
18
- :type => "sqlite3",
19
- :path => db_path,
20
- :return_keys => "symbols",
21
- :index_append_table_name => true
22
- )
23
-
24
- db.tables.create("test", {
25
- "columns" => [
26
- {"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
27
- {"name" => "text", "type" => "varchar"}
28
- ]
29
- })
30
-
31
-
32
-
33
- #Get a list of tables and check the list for errors.
34
- list = db.tables.list
35
- raise "Table not found: 'test'." if !list.key?("test")
36
- raise "Table-name expected to be 'test' but wasnt: '#{list["test"].name}'." if list["test"].name != "test"
37
-
38
-
39
- #Test revision to create tables, indexes and insert rows.
40
- schema = {
41
- "tables" => {
42
- "test_table" => {
43
- "columns" => [
44
- {"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
45
- {"name" => "name", "type" => "varchar"},
46
- {"name" => "age", "type" => "int"},
47
- {"name" => "nickname", "type" => "varchar"}
48
- ],
49
- "indexes" => [
50
- "name"
51
- ],
52
- "rows" => [
53
- {
54
- "find_by" => {"id" => 1},
55
- "data" => {"id" => 1, "name" => "trala"}
56
- }
57
- ]
58
- }
59
- }
60
- }
61
-
62
- rev = Knj::Db::Revision.new
63
- rev.init_db("schema" => schema, "db" => db)
64
-
65
-
66
- #Test wrong encoding.
67
- cont = File.read("#{File.dirname(__FILE__)}/db_spec_encoding_test_file.txt")
68
- cont.force_encoding("ASCII-8BIT")
69
-
70
- db.insert("test", {
71
- "text" => cont
72
- })
73
-
74
-
75
- #Throw out invalid encoding because it will make dumping fail.
76
- db.tables[:test].truncate
77
-
78
-
79
-
80
- #Test IDQueries.
81
- rows_count = 1250
82
- db.transaction do
83
- 0.upto(rows_count) do |count|
84
- db.insert(:test_table, {:name => "User #{count}"})
85
- end
86
- end
87
-
88
- block_ran = 0
89
- idq = Knj::Db::Idquery.new(:db => db, :debug => false, :table => :test_table, :query => "SELECT id FROM test_table") do |data|
90
- block_ran += 1
91
- end
92
-
93
- raise "Block with should have ran too little: #{block_ran}." if block_ran < rows_count
94
-
95
- block_ran = 0
96
- db.select(:test_table, {}, {:idquery => true}) do |data|
97
- block_ran += 1
98
- end
99
-
100
- raise "Block with should have ran too little: #{block_ran}." if block_ran < rows_count
101
-
102
-
103
- #Test upserting.
104
- data = {:name => "Kasper Johansen"}
105
- sel = {:nickname => "kaspernj"}
106
-
107
- table = db.tables[:test_table]
108
- table.reload
109
- rows_count = table.rows_count
110
-
111
- db.upsert(:test_table, sel, data)
112
-
113
- table.reload
114
- table.rows_count.should eql(rows_count + 1)
115
-
116
- db.upsert(:test_table, sel, data)
117
-
118
- table.reload
119
- table.rows_count.should eql(rows_count + 1)
120
-
121
-
122
- #Test dumping.
123
- dump = Knj::Db::Dump.new(:db => db, :debug => false)
124
- str_io = StringIO.new
125
- dump.dump(str_io)
126
- str_io.rewind
127
-
128
-
129
- #Remember some numbers for validation.
130
- tables_count = db.tables.list.length
131
-
132
-
133
- #Remove everything in the db.
134
- db.tables.list do |table|
135
- table.drop unless table.native?
136
- end
137
-
138
-
139
- #Run the exported SQL.
140
- db.transaction do
141
- str_io.each_line do |sql|
142
- db.q(sql)
143
- end
144
- end
145
-
146
-
147
- #Vaildate import.
148
- raise "Not same amount of tables: #{tables_count}, #{db.tables.list.length}" if tables_count != db.tables.list.length
149
-
150
-
151
-
152
- #Test revision table renaming.
153
- Knj::Db::Revision.new.init_db("db" => db, "schema" => {
154
- "tables" => {
155
- "new_test_table" => {
156
- "renames" => ["test_table"]
157
- }
158
- }
159
- })
160
- tables = db.tables.list
161
- raise "Didnt expect table 'test_table' to exist but it did." if tables.key?("test_table")
162
- raise "Expected 'new_test_table' to exist but it didnt." if !tables.key?("new_test_table")
163
-
164
-
165
- #Test revision for column renaming.
166
- Knj::Db::Revision.new.init_db("db" => db, "schema" => {
167
- "tables" => {
168
- "new_test_table" => {
169
- "columns" => [
170
- {"name" => "new_name", "type" => "varchar", "renames" => ["name"]}
171
- ]
172
- }
173
- }
174
- })
175
- columns = db.tables["new_test_table"].columns
176
- raise "Didnt expect 'name' to exist but it did." if columns.key?("name")
177
- raise "Expected 'new_name'-column to exist but it didnt." if !columns.key?("new_name")
178
-
179
-
180
- #Delete test-database if everything went well.
181
- File.unlink(db_path) if File.exists?(db_path)
182
- end
183
-
184
- it "should generate proper sql" do
185
- require "knj/db"
186
- require "knj/os"
187
- require "rubygems"
188
- require "sqlite3" if !Kernel.const_defined?("SQLite3") and RUBY_ENGINE != "jruby"
189
-
190
- db_path = "#{Knj::Os.tmpdir}/knjrbfw_test_sqlite3.sqlite3"
191
- File.unlink(db_path) if File.exists?(db_path)
192
-
193
- db = Knj::Db.new(
194
- :type => "sqlite3",
195
- :path => db_path,
196
- :return_keys => "symbols",
197
- :index_append_table_name => true
198
- )
199
-
200
- time = Time.new(1985, 6, 17, 10, 30)
201
- db.insert(:test, {:date => time}, :return_sql => true).should eql("INSERT INTO `test` (`date`) VALUES ('1985-06-17 10:30:00')")
202
-
203
- date = Date.new(1985, 6, 17)
204
- db.insert(:test, {:date => date}, :return_sql => true).should eql("INSERT INTO `test` (`date`) VALUES ('1985-06-17')")
205
- end
206
-
207
- it "should copy database structure and data" do
208
- require "knj/db"
209
- require "knj/os"
210
- require "rubygems"
211
- require "sqlite3" if !Kernel.const_defined?("SQLite3") and RUBY_ENGINE != "jruby"
212
-
213
- db_path1 = "#{Knj::Os.tmpdir}/knjrbfw_test_sqlite3_db1.sqlite3"
214
- File.unlink(db_path1) if File.exists?(db_path1)
215
-
216
- db_path2 = "#{Knj::Os.tmpdir}/knjrbfw_test_sqlite3_db2.sqlite3"
217
- File.unlink(db_path2) if File.exists?(db_path2)
218
-
219
- db1 = Knj::Db.new(
220
- :type => "sqlite3",
221
- :path => db_path1,
222
- :return_keys => "symbols",
223
- :index_append_table_name => true
224
- )
225
-
226
- db1.tables.create(:test_table, {
227
- "columns" => [
228
- {"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
229
- {"name" => "testname", "type" => "varchar"}
230
- ],
231
- "indexes" => [
232
- "testname"
233
- ]
234
- })
235
-
236
- table1 = db1.tables["test_table"]
237
- cols1 = table1.columns
238
-
239
- 100.times do |count|
240
- table1.insert(:testname => "TestRow#{count}")
241
- end
242
-
243
- db2 = Knj::Db.new(
244
- :type => "sqlite3",
245
- :path => db_path2,
246
- :return_keys => "symbols",
247
- :index_append_table_name => true
248
- )
249
-
250
- begin
251
- table2 = db2.tables["test_table"]
252
- raise "Expected not-found exception."
253
- rescue Errno::ENOENT
254
- #expected
255
- end
256
-
257
- db1.copy_to(db2)
258
-
259
- table2 = db2.tables["test_table"]
260
-
261
- cols2 = table2.columns
262
- cols2.length.should eql(cols1.length)
263
-
264
- table2.rows_count.should eql(table1.rows_count)
265
-
266
- db1.select(:test_table) do |row1|
267
- found = 0
268
- db2.select(:test_table, row1) do |row2|
269
- found += 1
270
-
271
- row1.each do |key, val|
272
- row2[key].should eql(val)
273
- end
274
- end
275
-
276
- found.should eql(1)
277
- end
278
-
279
- table1.indexes.length.should eql(1)
280
- table2.indexes.length.should eql(table1.indexes.length)
281
- end
282
- end
@@ -1 +0,0 @@
1
- ��pl��p���