ibruby 0.5.5-i686-darwin8.9.1

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.
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'TestSetup'
4
+ require 'test/unit'
5
+ #require 'rubygems'
6
+ require 'ibruby'
7
+
8
+ include IBRuby
9
+
10
+ class TransactionTest < Test::Unit::TestCase
11
+ CURDIR = "#{Dir.getwd}"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}tx_unit_test.ib"
13
+
14
+ def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
16
+ if File::exist?(DB_FILE)
17
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
18
+ end
19
+
20
+ @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
21
+ @connections = []
22
+ @transactions = []
23
+
24
+ @connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
25
+ @connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
26
+ @connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
27
+ end
28
+
29
+ def teardown
30
+ @transactions.each do |tx|
31
+ tx.rollback if tx.active?
32
+ end
33
+ @transactions.clear
34
+ @connections.each do |cxn|
35
+ cxn.close if cxn.open?
36
+ end
37
+ if File::exist?(DB_FILE)
38
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
39
+ end
40
+ puts "#{self.class.name} finished." if TEST_LOGGING
41
+ end
42
+
43
+ def test01
44
+ @transactions.push(@connections[0].start_transaction)
45
+ assert(@transactions[0].active?)
46
+
47
+ @transactions.push(Transaction.new(@connections[1]))
48
+ assert(@transactions[1].active?)
49
+
50
+ assert(@transactions[0].connections == [@connections[0]])
51
+ assert(@transactions[1].connections == [@connections[1]])
52
+
53
+ assert(@transactions[0].for_connection?(@connections[1]) == false)
54
+ assert(@transactions[1].for_connection?(@connections[0]) == false)
55
+ assert(@transactions[0].for_connection?(@connections[0]))
56
+ assert(@transactions[1].for_connection?(@connections[1]))
57
+
58
+ @transactions[0].commit
59
+ assert(@transactions[0].active? == false)
60
+ assert(@transactions[0].connections == [])
61
+ assert(@transactions[0].for_connection?(@connections[0]) == false)
62
+ assert(@transactions[0].for_connection?(@connections[1]) == false)
63
+
64
+ @transactions[1].rollback
65
+ assert(@transactions[1].active? == false)
66
+ assert(@transactions[1].connections == [])
67
+ assert(@transactions[1].for_connection?(@connections[0]) == false)
68
+ assert(@transactions[1].for_connection?(@connections[1]) == false)
69
+
70
+ @transactions[0] = Transaction.new([@connections[0], @connections[1]])
71
+ assert(@transactions[0].active? == true)
72
+ assert(@transactions[0].for_connection?(@connections[0]))
73
+ assert(@transactions[0].for_connection?(@connections[1]))
74
+ assert(@transactions[0].for_connection?(@connections[2]) == false)
75
+
76
+ @transactions[0].commit
77
+ assert(@transactions[0].active? == false)
78
+ assert(@transactions[0].connections == [])
79
+ assert(@transactions[0].for_connection?(@connections[0]) == false)
80
+ assert(@transactions[0].for_connection?(@connections[1]) == false)
81
+ assert(@transactions[0].for_connection?(@connections[2]) == false)
82
+
83
+ @transactions[0] = Transaction.new([@connections[0], @connections[2]])
84
+ assert(@transactions[0].active?)
85
+ @transactions[0].rollback
86
+ assert(@transactions[0].active? == false)
87
+ assert(@transactions[0].connections == [])
88
+ assert(@transactions[0].for_connection?(@connections[0]) == false)
89
+ assert(@transactions[0].for_connection?(@connections[1]) == false)
90
+ assert(@transactions[0].for_connection?(@connections[2]) == false)
91
+ end
92
+
93
+ def test02
94
+ sql = []
95
+ sql.push("UPDATE RDB$EXCEPTIONS SET RDB$MESSAGE = 'WoooHooo'"\
96
+ "WHERE RDB$EXCEPTION_NAME = 'Lalala'")
97
+ sql.push("SELECT RDB$FIELD_NAME FROM RDB$FIELDS")
98
+ @transactions.push(Transaction.new(@connections[0]))
99
+
100
+ assert(@transactions[0].execute(sql[0]) == 0)
101
+ r = @transactions[0].execute(sql[1])
102
+ assert(r != nil)
103
+ assert(r.class == ResultSet)
104
+ r.close
105
+
106
+ total = 0
107
+ @transactions[0].execute(sql[1]) do |row|
108
+ total += 1
109
+ end
110
+ assert(total == 113)
111
+ end
112
+ end
data/test/TypeTest.rb ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'TestSetup'
4
+ require 'test/unit'
5
+ #require 'rubygems'
6
+ require 'ibruby'
7
+ require 'date'
8
+
9
+ include IBRuby
10
+
11
+ class TypeTest < Test::Unit::TestCase
12
+ CURDIR = "#{Dir.getwd}"
13
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}types_unit_test.ib"
14
+
15
+ def setup
16
+ puts "#{self.class.name} started." if TEST_LOGGING
17
+ if File.exist?(DB_FILE)
18
+ db = Database.new(DB_FILE)
19
+ db.drop(DB_USER_NAME, DB_PASSWORD)
20
+ end
21
+ @db = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
22
+ cxn = @db.connect(DB_USER_NAME, DB_PASSWORD)
23
+ cxn.start_transaction do |tx|
24
+ tx.execute("create table types_table (COL01 integer, "\
25
+ "COL02 float, COL03 decimal(10,2), "\
26
+ "COL04 numeric(5,3), COL05 date, COL06 timestamp, "\
27
+ "COL07 char(10), COL08 time, COL09 varchar(30))")
28
+ end
29
+
30
+ cxn.start_transaction do |tx|
31
+ stmt = Statement.new(cxn, tx, "insert into types_table values "\
32
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?)", 3)
33
+ stmt.execute_for([10, 100.2, 2378.65, 192.345,
34
+ Date.new(2005, 10, 21), Time.new, 'La la la',
35
+ Time.new, "Oobly Joobly"])
36
+ stmt.close
37
+ end
38
+ cxn.close
39
+ end
40
+
41
+ def teardown
42
+ if File::exist?(DB_FILE)
43
+ @db.drop(DB_USER_NAME, DB_PASSWORD)
44
+ end
45
+ puts "#{self.class.name} finished." if TEST_LOGGING
46
+ end
47
+
48
+ def test01
49
+ rows = cxn = nil
50
+ begin
51
+ cxn = @db.connect(DB_USER_NAME, DB_PASSWORD)
52
+ rows = cxn.execute_immediate('select * from types_table')
53
+ row = rows.fetch
54
+ assert(row[0].kind_of?(Integer))
55
+ assert(row[1].instance_of?(Float))
56
+ assert(row[2].kind_of?(Numeric))
57
+ assert(row[3].kind_of?(Numeric))
58
+ assert(row[4].instance_of?(Date))
59
+ assert(row[5].instance_of?(Time))
60
+ assert(row[6].instance_of?(String))
61
+ assert(row[7].instance_of?(Time))
62
+ assert(row[8].instance_of?(String))
63
+ ensure
64
+ rows.close if rows != nil
65
+ cxn.close if cxn != nil
66
+ end
67
+ end
68
+
69
+ def test02
70
+ $IBRubySettings[:DATE_AS_DATE] = false
71
+ rows = cxn = nil
72
+ begin
73
+ cxn = @db.connect(DB_USER_NAME, DB_PASSWORD)
74
+ rows = cxn.execute_immediate('select * from types_table')
75
+ row = rows.fetch
76
+ assert(row[0].kind_of?(Integer))
77
+ assert(row[1].instance_of?(Float))
78
+ assert(row[2].kind_of?(Numeric))
79
+ assert(row[3].kind_of?(Numeric))
80
+ assert(row[4].instance_of?(Time))
81
+ assert(row[5].instance_of?(Time))
82
+ assert(row[6].instance_of?(String))
83
+ assert(row[7].instance_of?(Time))
84
+ assert(row[8].instance_of?(String))
85
+ rows.close
86
+ ensure
87
+ rows.close if rows != nil
88
+ cxn.close if cxn != nil
89
+ end
90
+ $IBRubySettings[:DATE_AS_DATE] = true
91
+ end
92
+ end
@@ -0,0 +1,38 @@
1
+ ***************
2
+ *** 53,60 ****
3
+ row = rows.fetch
4
+ assert(row[0].kind_of?(Integer))
5
+ assert(row[1].instance_of?(Float))
6
+ - assert(row[2].instance_of?(Float))
7
+ - assert(row[3].instance_of?(Float))
8
+ assert(row[4].instance_of?(Date))
9
+ assert(row[5].instance_of?(Time))
10
+ assert(row[6].instance_of?(String))
11
+ --- 53,60 ----
12
+ row = rows.fetch
13
+ assert(row[0].kind_of?(Integer))
14
+ assert(row[1].instance_of?(Float))
15
+ + assert(row[2].kind_of?(Numeric))
16
+ + assert(row[3].kind_of?(Numeric))
17
+ assert(row[4].instance_of?(Date))
18
+ assert(row[5].instance_of?(Time))
19
+ assert(row[6].instance_of?(String))
20
+ ***************
21
+ *** 75,82 ****
22
+ row = rows.fetch
23
+ assert(row[0].kind_of?(Integer))
24
+ assert(row[1].instance_of?(Float))
25
+ - assert(row[2].instance_of?(Float))
26
+ - assert(row[3].instance_of?(Float))
27
+ assert(row[4].instance_of?(Time))
28
+ assert(row[5].instance_of?(Time))
29
+ assert(row[6].instance_of?(String))
30
+ --- 75,82 ----
31
+ row = rows.fetch
32
+ assert(row[0].kind_of?(Integer))
33
+ assert(row[1].instance_of?(Float))
34
+ + assert(row[2].kind_of?(Numeric))
35
+ + assert(row[3].kind_of?(Numeric))
36
+ assert(row[4].instance_of?(Time))
37
+ assert(row[5].instance_of?(Time))
38
+ assert(row[6].instance_of?(String))
data/test/UnitTest.rb ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #-------------------------------------------------------------------------------
4
+ # Old Unit Test Suite
5
+ #
6
+ # This code has been dropped for two reasons. First, adding new tests requires
7
+ # that this code be updated. Second, running the tests in a single Ruby
8
+ # interpreter seems to cause issues as the tests create, use and drop a lot of
9
+ # database files and this seems to cause intermittent problems with one or more
10
+ # of the test scripts that doesn't occur when the script is run on its own.
11
+ # Changing the number of scripts run also seemed to cause the problems to go
12
+ # away. It didn't seem to matter which scripts where left out which leads me
13
+ # to believe that the problem is related to timing issues.
14
+ #
15
+ # The new unit test suite, below, searches the directory for unit test files
16
+ # and executes each in their own interpreter. I have left this code here for
17
+ # reference purposes.
18
+ #-------------------------------------------------------------------------------
19
+ #require 'DatabaseTest'
20
+ #require 'ConnectionTest'
21
+ #require 'TransactionTest'
22
+ #require 'StatementTest'
23
+ #require 'ResultSetTest'
24
+ #require 'RowCountTest'
25
+ #require 'RowTest'
26
+ #require 'GeneratorTest'
27
+ #require 'DDLTest'
28
+ #require 'SQLTest'
29
+ #require 'ServiceManagerTest'
30
+ #require 'CharacterSetTest'
31
+ #require 'KeyTest'
32
+ #require 'TypeTest'
33
+ #require 'SQLTypeTest'
34
+ #if PLATFORM.include?('powerpc-darwin') == false
35
+ #require 'BackupRestoreTest'
36
+ #require 'AddRemoveUserTest'
37
+ #end
38
+ #-------------------------------------------------------------------------------
39
+ SPECIALS = ['AddRemoveUserTest',
40
+ 'BackupRestoreTest',
41
+ 'ServiceManagerTest']
42
+ begin
43
+ files = Dir.entries(".")
44
+ files.reject! do |name|
45
+ ['.', '..', 'UnitTest.rb'].include?(name) or
46
+ name[-7,7] != 'Test.rb'
47
+ end
48
+ files.each do |name|
49
+ execute = true
50
+ if SPECIALS.include?(name)
51
+ execute = !(PLATFORM.include?('powerpc-darwin'))
52
+ end
53
+
54
+ if execute
55
+ system("ruby #{name}")
56
+
57
+ if $? != 0
58
+ raise StandardError.new("Error executing '#{name}'. Testing terminated.")
59
+ end
60
+ end
61
+ end
62
+ rescue => error
63
+ puts "\n\nERROR: #{error.message}"
64
+ end
@@ -0,0 +1,19 @@
1
+ ***************
2
+ *** 32,39 ****
3
+ #require 'TypeTest'
4
+ #require 'SQLTypeTest'
5
+ #if PLATFORM.include?('powerpc-darwin') == false
6
+ - # require 'BackupRestoreTest'
7
+ - # require 'AddRemoveUserTest'
8
+ #end
9
+ #-------------------------------------------------------------------------------
10
+ SPECIALS = ['AddRemoveUserTest',
11
+ --- 32,39 ----
12
+ #require 'TypeTest'
13
+ #require 'SQLTypeTest'
14
+ #if PLATFORM.include?('powerpc-darwin') == false
15
+ + #require 'BackupRestoreTest'
16
+ + #require 'AddRemoveUserTest'
17
+ #end
18
+ #-------------------------------------------------------------------------------
19
+ SPECIALS = ['AddRemoveUserTest',
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: ibruby
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.5.5
7
+ date: 2007-09-07 00:00:00 -07:00
8
+ summary: Ruby interface library for the InterBase database.
9
+ require_paths:
10
+ - lib
11
+ email: paw220470@yahoo.ie, richard@developers-inc.co.nz
12
+ homepage: http://rubyforge.org/projects/ibruby/
13
+ rubyforge_project:
14
+ description: IBRuby is an extension to the Ruby programming language that provides access to the InterBase RDBMS. IBRuby is based in the InterBase C API and has no additional dependencies. The IBRuby library wraps the API calls in a Ruby OO interface.
15
+ autorequire: ibruby
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: i686-darwin8.9.1
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Peter Wood, Richard Vowles
31
+ files:
32
+ - lib/ib_lib.bundle
33
+ - lib/ibmeta.rb
34
+ - lib/ibruby.rb
35
+ - lib/mkdoc
36
+ - lib/src.rb
37
+ - test/AddRemoveUserTest.rb
38
+ - test/BackupRestoreTest.rb
39
+ - test/BooleanTest.rb
40
+ - test/CharacterSetTest.rb
41
+ - test/ConnectionTest.rb
42
+ - test/DatabaseTest.rb
43
+ - test/DDLTest.rb
44
+ - test/GeneratorTest.rb
45
+ - test/GeneratorTest.rb.rej
46
+ - test/KeyTest.rb
47
+ - test/KeyTest.rb.rej
48
+ - test/MetaTest.rb
49
+ - test/ResultSetTest.rb
50
+ - test/RoleTest.rb
51
+ - test/RowCountTest.rb
52
+ - test/RowTest.rb
53
+ - test/ServiceManagerTest.rb
54
+ - test/SQLTest.rb
55
+ - test/SQLTypeTest.rb
56
+ - test/SQLTypeTest.rb.rej
57
+ - test/StatementTest.rb
58
+ - test/StatementTest.rb.rej
59
+ - test/TestSetup.rb
60
+ - test/TransactionTest.rb
61
+ - test/TypeTest.rb
62
+ - test/TypeTest.rb.rej
63
+ - test/UnitTest.rb
64
+ - test/UnitTest.rb.rej
65
+ - doc/classes
66
+ - doc/files
67
+ - doc/license.txt
68
+ - doc/README
69
+ - examples/example01.rb
70
+ test_files:
71
+ - test/UnitTest.rb
72
+ rdoc_options:
73
+ - --main
74
+ - doc/README
75
+ extra_rdoc_files:
76
+ - doc/README
77
+ executables: []
78
+
79
+ extensions: []
80
+
81
+ requirements: []
82
+
83
+ dependencies: []
84
+