do_mysql 0.9.12-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/LICENSE +20 -0
- data/Manifest.txt +32 -0
- data/README.txt +3 -0
- data/Rakefile +16 -0
- data/lib/do_mysql.rb +44 -0
- data/lib/do_mysql/transaction.rb +44 -0
- data/lib/do_mysql/version.rb +5 -0
- data/lib/do_mysql_ext.jar +0 -0
- data/spec/command_spec.rb +9 -0
- data/spec/connection_spec.rb +19 -0
- data/spec/encoding_spec.rb +8 -0
- data/spec/lib/rspec_immediate_feedback_formatter.rb +3 -0
- data/spec/reader_spec.rb +8 -0
- data/spec/result_spec.rb +9 -0
- data/spec/spec_helper.rb +132 -0
- data/spec/typecast/array_spec.rb +8 -0
- data/spec/typecast/bigdecimal_spec.rb +9 -0
- data/spec/typecast/boolean_spec.rb +9 -0
- data/spec/typecast/byte_array_spec.rb +8 -0
- data/spec/typecast/class_spec.rb +8 -0
- data/spec/typecast/date_spec.rb +9 -0
- data/spec/typecast/datetime_spec.rb +9 -0
- data/spec/typecast/float_spec.rb +9 -0
- data/spec/typecast/integer_spec.rb +8 -0
- data/spec/typecast/nil_spec.rb +10 -0
- data/spec/typecast/range_spec.rb +8 -0
- data/spec/typecast/string_spec.rb +8 -0
- data/spec/typecast/time_spec.rb +8 -0
- data/tasks/gem.rake +60 -0
- data/tasks/install.rake +15 -0
- data/tasks/native.rake +31 -0
- data/tasks/release.rake +75 -0
- data/tasks/retrieve.rake +67 -0
- data/tasks/spec.rake +18 -0
- metadata +148 -0
data/History.txt
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007, 2008, 2009 Yehuda Katz, Dirkjan Bussink
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
.gitignore
|
2
|
+
History.txt
|
3
|
+
LICENSE
|
4
|
+
Manifest.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
buildfile
|
8
|
+
ext-java/src/main/java/DoMysqlExtService.java
|
9
|
+
ext-java/src/main/java/do_mysql/MySqlDriverDefinition.java
|
10
|
+
ext/.gitignore
|
11
|
+
ext/do_mysql_ext/do_mysql_ext.c
|
12
|
+
ext/do_mysql_ext/extconf.rb
|
13
|
+
lib/do_mysql.rb
|
14
|
+
lib/do_mysql/transaction.rb
|
15
|
+
lib/do_mysql/version.rb
|
16
|
+
spec/command_spec.rb
|
17
|
+
spec/connection_spec.rb
|
18
|
+
spec/reader_spec.rb
|
19
|
+
spec/result_spec.rb
|
20
|
+
spec/spec.opts
|
21
|
+
spec/spec_helper.rb
|
22
|
+
spec/typecast/bigdecimal_spec.rb
|
23
|
+
spec/typecast/boolean_spec.rb
|
24
|
+
spec/typecast/byte_array_spec.rb
|
25
|
+
spec/typecast/class_spec.rb
|
26
|
+
spec/typecast/date_spec.rb
|
27
|
+
spec/typecast/datetime_spec.rb
|
28
|
+
spec/typecast/float_spec.rb
|
29
|
+
spec/typecast/integer_spec.rb
|
30
|
+
spec/typecast/nil_spec.rb
|
31
|
+
spec/typecast/string_spec.rb
|
32
|
+
spec/typecast/time_spec.rb
|
data/README.txt
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
|
5
|
+
require 'pathname'
|
6
|
+
require 'lib/do_mysql/version'
|
7
|
+
|
8
|
+
ROOT = Pathname(__FILE__).dirname.expand_path
|
9
|
+
JRUBY = RUBY_PLATFORM =~ /java/
|
10
|
+
WINDOWS = Gem.win_platform?
|
11
|
+
SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
|
12
|
+
BINARY_VERSION = '5.0.77'
|
13
|
+
|
14
|
+
Dir['tasks/*.rake'].each { |f| import f }
|
15
|
+
|
16
|
+
CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_mysql_ext/Makefile ext-java/target ])
|
data/lib/do_mysql.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'data_objects'
|
3
|
+
if RUBY_PLATFORM =~ /java/
|
4
|
+
require 'do_jdbc'
|
5
|
+
require 'java'
|
6
|
+
gem 'jdbc-mysql'
|
7
|
+
require 'jdbc/mysql' # the JDBC driver, packaged as a gem
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'do_mysql_ext'
|
11
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'do_mysql', 'version'))
|
12
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'do_mysql', 'transaction'))
|
13
|
+
|
14
|
+
if RUBY_PLATFORM =~ /java/
|
15
|
+
# Another way of loading the JDBC Class. This seems to be more reliable
|
16
|
+
# than Class.forName() within the data_objects.Connection Java class,
|
17
|
+
# which is currently not working as expected.
|
18
|
+
import 'com.mysql.jdbc.Driver'
|
19
|
+
|
20
|
+
module DataObjects
|
21
|
+
module Mysql
|
22
|
+
class Connection
|
23
|
+
def self.pool_size
|
24
|
+
20
|
25
|
+
end
|
26
|
+
|
27
|
+
def using_socket?
|
28
|
+
@using_socket
|
29
|
+
end
|
30
|
+
|
31
|
+
def character_set
|
32
|
+
# JDBC API does not provide an easy way to get the current character set
|
33
|
+
reader = self.create_command("SHOW VARIABLES LIKE 'character_set_client'").execute_reader
|
34
|
+
reader.next!
|
35
|
+
char_set = reader.values[1]
|
36
|
+
reader.close
|
37
|
+
char_set.downcase
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
module DataObjects
|
3
|
+
|
4
|
+
module Mysql
|
5
|
+
|
6
|
+
class Transaction < DataObjects::Transaction
|
7
|
+
|
8
|
+
def finalize_transaction
|
9
|
+
cmd = "XA END '#{id}'"
|
10
|
+
connection.create_command(cmd).execute_non_query
|
11
|
+
end
|
12
|
+
|
13
|
+
def begin
|
14
|
+
cmd = "XA START '#{id}'"
|
15
|
+
connection.create_command(cmd).execute_non_query
|
16
|
+
end
|
17
|
+
|
18
|
+
def commit
|
19
|
+
cmd = "XA COMMIT '#{id}'"
|
20
|
+
connection.create_command(cmd).execute_non_query
|
21
|
+
end
|
22
|
+
|
23
|
+
def rollback
|
24
|
+
finalize_transaction
|
25
|
+
cmd = "XA ROLLBACK '#{id}'"
|
26
|
+
connection.create_command(cmd).execute_non_query
|
27
|
+
end
|
28
|
+
|
29
|
+
def rollback_prepared
|
30
|
+
cmd = "XA ROLLBACK '#{id}'"
|
31
|
+
connection.create_command(cmd).execute_non_query
|
32
|
+
end
|
33
|
+
|
34
|
+
def prepare
|
35
|
+
finalize_transaction
|
36
|
+
cmd = "XA PREPARE '#{id}'"
|
37
|
+
connection.create_command(cmd).execute_non_query
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
+
require 'data_objects/spec/command_spec'
|
5
|
+
|
6
|
+
describe DataObjects::Mysql::Command do
|
7
|
+
it_should_behave_like 'a Command'
|
8
|
+
it_should_behave_like 'a Command with async'
|
9
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
+
require 'data_objects/spec/connection_spec'
|
5
|
+
|
6
|
+
describe DataObjects::Mysql::Connection do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@driver = CONFIG.scheme
|
10
|
+
@user = CONFIG.user
|
11
|
+
@password = CONFIG.pass
|
12
|
+
@host = CONFIG.host
|
13
|
+
@port = CONFIG.port
|
14
|
+
@database = CONFIG.database
|
15
|
+
end
|
16
|
+
|
17
|
+
it_should_behave_like 'a Connection'
|
18
|
+
#it_should_behave_like 'a Connection with authentication support'
|
19
|
+
end
|
data/spec/reader_spec.rb
ADDED
data/spec/result_spec.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
+
require 'data_objects/spec/result_spec'
|
5
|
+
|
6
|
+
describe DataObjects::Mysql::Result do
|
7
|
+
it_should_behave_like 'a Result'
|
8
|
+
it_should_behave_like 'a Result which returns inserted keys'
|
9
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
$TESTING=true
|
2
|
+
JRUBY = RUBY_PLATFORM =~ /java/
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
gem 'rspec', '>1.1.12'
|
7
|
+
require 'spec'
|
8
|
+
|
9
|
+
require 'date'
|
10
|
+
require 'ostruct'
|
11
|
+
require 'pathname'
|
12
|
+
require 'fileutils'
|
13
|
+
|
14
|
+
# put data_objects from repository in the load path
|
15
|
+
# DO NOT USE installed gem of data_objects!
|
16
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data_objects', 'lib'))
|
17
|
+
require 'data_objects'
|
18
|
+
|
19
|
+
DATAOBJECTS_SPEC_ROOT = Pathname(__FILE__).dirname.parent.parent + 'data_objects' + 'spec'
|
20
|
+
Pathname.glob((DATAOBJECTS_SPEC_ROOT + 'lib/**/*.rb').to_s).each { |f| require f }
|
21
|
+
|
22
|
+
if JRUBY
|
23
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
|
24
|
+
require 'do_jdbc'
|
25
|
+
end
|
26
|
+
|
27
|
+
# put the pre-compiled extension in the path to be found
|
28
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
29
|
+
require 'do_mysql'
|
30
|
+
|
31
|
+
log_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'log', 'do.log'))
|
32
|
+
FileUtils.mkdir_p(File.dirname(log_path))
|
33
|
+
|
34
|
+
DataObjects::Mysql.logger = DataObjects::Logger.new(log_path, :debug)
|
35
|
+
|
36
|
+
at_exit { DataObjects.logger.flush }
|
37
|
+
|
38
|
+
Spec::Runner.configure do |config|
|
39
|
+
config.include(DataObjects::Spec::PendingHelpers)
|
40
|
+
end
|
41
|
+
|
42
|
+
CONFIG = OpenStruct.new
|
43
|
+
CONFIG.scheme = 'mysql'
|
44
|
+
CONFIG.user = ENV['DO_MYSQL_USER'] || 'root'
|
45
|
+
CONFIG.pass = ENV['DO_MYSQL_PASS'] || ''
|
46
|
+
CONFIG.host = ENV['DO_MYSQL_HOST'] || 'localhost'
|
47
|
+
CONFIG.port = ENV['DO_MYSQL_PORT'] || '3306'
|
48
|
+
CONFIG.database = ENV['DO_MYSQL_DATABASE'] || '/do_test'
|
49
|
+
|
50
|
+
CONFIG.uri = ENV["DO_MYSQL_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
|
51
|
+
CONFIG.sleep = "SELECT sleep(1)"
|
52
|
+
|
53
|
+
module DataObjectsSpecHelpers
|
54
|
+
|
55
|
+
def setup_test_environment
|
56
|
+
conn = DataObjects::Connection.new(CONFIG.uri)
|
57
|
+
|
58
|
+
conn.create_command(<<-EOF).execute_non_query
|
59
|
+
DROP TABLE IF EXISTS `invoices`
|
60
|
+
EOF
|
61
|
+
|
62
|
+
conn.create_command(<<-EOF).execute_non_query
|
63
|
+
DROP TABLE IF EXISTS `users`
|
64
|
+
EOF
|
65
|
+
|
66
|
+
conn.create_command(<<-EOF).execute_non_query
|
67
|
+
DROP TABLE IF EXISTS `widgets`
|
68
|
+
EOF
|
69
|
+
|
70
|
+
conn.create_command(<<-EOF).execute_non_query
|
71
|
+
CREATE TABLE `users` (
|
72
|
+
`id` int(11) NOT NULL auto_increment,
|
73
|
+
`name` varchar(200) default 'Billy' NULL,
|
74
|
+
`fired_at` timestamp,
|
75
|
+
PRIMARY KEY (`id`)
|
76
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
77
|
+
EOF
|
78
|
+
|
79
|
+
conn.create_command(<<-EOF).execute_non_query
|
80
|
+
CREATE TABLE `invoices` (
|
81
|
+
`id` int(11) NOT NULL auto_increment,
|
82
|
+
`invoice_number` varchar(50) NOT NULL,
|
83
|
+
PRIMARY KEY (`id`)
|
84
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
85
|
+
EOF
|
86
|
+
|
87
|
+
conn.create_command(<<-EOF).execute_non_query
|
88
|
+
CREATE TABLE `widgets` (
|
89
|
+
`id` int(11) NOT NULL auto_increment,
|
90
|
+
`code` char(8) default 'A14' NULL,
|
91
|
+
`name` varchar(200) default 'Super Widget' NULL,
|
92
|
+
`shelf_location` tinytext NULL,
|
93
|
+
`description` text NULL,
|
94
|
+
`image_data` blob NULL,
|
95
|
+
`ad_description` mediumtext NULL,
|
96
|
+
`ad_image` mediumblob NULL,
|
97
|
+
`whitepaper_text` longtext NULL,
|
98
|
+
`cad_drawing` longblob NULL,
|
99
|
+
`flags` tinyint(1) default 0,
|
100
|
+
`number_in_stock` smallint default 500,
|
101
|
+
`number_sold` mediumint default 0,
|
102
|
+
`super_number` bigint default 9223372036854775807,
|
103
|
+
`weight` float default 1.23,
|
104
|
+
`cost1` double default 10.23,
|
105
|
+
`cost2` decimal(8,2) default 50.23,
|
106
|
+
`release_date` date default '2008-02-14',
|
107
|
+
`release_datetime` datetime default '2008-02-14 00:31:12',
|
108
|
+
`release_timestamp` timestamp default '2008-02-14 00:31:31',
|
109
|
+
`status` enum('active','out of stock') NOT NULL default 'active',
|
110
|
+
PRIMARY KEY (`id`)
|
111
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
112
|
+
EOF
|
113
|
+
|
114
|
+
1.upto(16) do |n|
|
115
|
+
conn.create_command(<<-EOF).execute_non_query
|
116
|
+
insert into widgets(code, name, shelf_location, description, image_data, ad_description, ad_image, whitepaper_text, cad_drawing, super_number, weight) VALUES ('W#{n.to_s.rjust(7,"0")}', 'Widget #{n}', 'A14', 'This is a description', 'IMAGE DATA', 'Buy this product now!', 'AD IMAGE DATA', 'String', 'CAD \001 \000 DRAWING', 1234, 13.4);
|
117
|
+
EOF
|
118
|
+
end
|
119
|
+
|
120
|
+
conn.create_command(<<-EOF).execute_non_query
|
121
|
+
update widgets set flags = 1 where id = 2
|
122
|
+
EOF
|
123
|
+
|
124
|
+
conn.create_command(<<-EOF).execute_non_query
|
125
|
+
update widgets set ad_description = NULL where id = 3
|
126
|
+
EOF
|
127
|
+
|
128
|
+
conn.close
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/bigdecimal_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Mysql with BigDecimal' do
|
7
|
+
it_should_behave_like 'supporting BigDecimal'
|
8
|
+
it_should_behave_like 'supporting BigDecimal autocasting'
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/boolean_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Mysql with Boolean' do
|
7
|
+
it_should_behave_like 'supporting Boolean'
|
8
|
+
it_should_behave_like 'supporting Boolean autocasting'
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/date_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Mysql with Date' do
|
7
|
+
it_should_behave_like 'supporting Date'
|
8
|
+
it_should_behave_like 'supporting Date autocasting'
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/datetime_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Mysql with DateTime' do
|
7
|
+
it_should_behave_like 'supporting DateTime'
|
8
|
+
it_should_behave_like 'supporting DateTime autocasting'
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/float_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Mysql with Float' do
|
7
|
+
it_should_behave_like 'supporting Float'
|
8
|
+
it_should_behave_like 'supporting Float autocasting'
|
9
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/nil_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Mysql with Nil' do
|
7
|
+
it_should_behave_like 'supporting Nil'
|
8
|
+
it_should_behave_like 'supporting writing an Nil'
|
9
|
+
it_should_behave_like 'supporting Nil autocasting'
|
10
|
+
end
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rubygems/package_task'
|
2
|
+
|
3
|
+
GEM_SPEC = Gem::Specification.new do |s|
|
4
|
+
# basic information
|
5
|
+
s.name = "do_mysql"
|
6
|
+
s.version = DataObjects::Mysql::VERSION
|
7
|
+
|
8
|
+
# description and details
|
9
|
+
s.summary = 'DataObjects MySQL Driver'
|
10
|
+
s.description = "Implements the DataObjects API for MySQL"
|
11
|
+
|
12
|
+
# dependencies
|
13
|
+
s.add_dependency "addressable", "~>2.0.0"
|
14
|
+
s.add_dependency "extlib", "~>0.9.12"
|
15
|
+
s.add_dependency "data_objects", DataObjects::Mysql::VERSION
|
16
|
+
|
17
|
+
if JRUBY
|
18
|
+
s.add_dependency "jdbc-mysql", ">=5.0.4"
|
19
|
+
s.add_dependency "do_jdbc", DataObjects::Mysql::VERSION
|
20
|
+
s.platform = "java"
|
21
|
+
# components, files and paths
|
22
|
+
s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake",
|
23
|
+
"LICENSE", "Rakefile", "*.{rdoc,txt,yml}", "lib/*.jar"]
|
24
|
+
else
|
25
|
+
s.platform = Gem::Platform::RUBY
|
26
|
+
s.extensions << 'ext/do_mysql_ext/extconf.rb'
|
27
|
+
s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake", "ext/**/*.{rb,c}",
|
28
|
+
"LICENSE", "Rakefile", "*.{rdoc,txt,yml}"]
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# development dependencies
|
33
|
+
s.add_development_dependency 'rspec', '~>1.2.0'
|
34
|
+
|
35
|
+
s.require_path = 'lib'
|
36
|
+
|
37
|
+
# documentation
|
38
|
+
s.has_rdoc = false
|
39
|
+
|
40
|
+
# project information
|
41
|
+
s.homepage = 'http://github.com/datamapper/do'
|
42
|
+
s.rubyforge_project = 'dorb'
|
43
|
+
|
44
|
+
# author and contributors
|
45
|
+
s.author = 'Dirkjan Bussink'
|
46
|
+
s.email = 'd.bussink@gmail.com'
|
47
|
+
end
|
48
|
+
|
49
|
+
gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
|
50
|
+
pkg.need_tar = false
|
51
|
+
pkg.need_zip = false
|
52
|
+
end
|
53
|
+
|
54
|
+
file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
|
55
|
+
puts "Generating #{t.name}"
|
56
|
+
File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Generate or update the standalone gemspec file for the project"
|
60
|
+
task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
|
data/tasks/install.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
def sudo_gem(cmd)
|
2
|
+
sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
|
3
|
+
end
|
4
|
+
|
5
|
+
# Installation
|
6
|
+
|
7
|
+
desc "Install #{GEM_SPEC.name} #{GEM_SPEC.version}"
|
8
|
+
task :install => [ :package ] do
|
9
|
+
sudo_gem "install pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version} --no-update-sources"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Uninstall #{GEM_SPEC.name} #{GEM_SPEC.version}"
|
13
|
+
task :uninstall => [ :clean ] do
|
14
|
+
sudo_gem "uninstall #{GEM_SPEC.name} -v#{GEM_SPEC.version} -I -x"
|
15
|
+
end
|
data/tasks/native.rake
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
begin
|
2
|
+
gem('rake-compiler')
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
|
5
|
+
Rake::ExtensionTask.new('do_mysql_ext', GEM_SPEC) do |ext|
|
6
|
+
|
7
|
+
mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{BINARY_VERSION}-win32"))
|
8
|
+
|
9
|
+
# automatically add build options to avoid need of manual input
|
10
|
+
if RUBY_PLATFORM =~ /mswin|mingw/ then
|
11
|
+
ext.config_options << "--with-mysql-include=#{mysql_lib}/include"
|
12
|
+
ext.config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
|
13
|
+
else
|
14
|
+
ext.cross_compile = true
|
15
|
+
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
|
16
|
+
ext.cross_config_options << "--with-mysql-include=#{mysql_lib}/include"
|
17
|
+
ext.cross_config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
warn "To cross-compile, install rake-compiler (gem install rake-compiler)"
|
23
|
+
|
24
|
+
if (tasks_dir = ROOT.parent + 'tasks').directory?
|
25
|
+
require tasks_dir + 'ext_helper'
|
26
|
+
require tasks_dir + 'ext_helper_java'
|
27
|
+
|
28
|
+
setup_c_extension("#{GEM_SPEC.name}_ext", GEM_SPEC)
|
29
|
+
setup_java_extension("#{GEM_SPEC.name}_ext", GEM_SPEC)
|
30
|
+
end
|
31
|
+
end
|
data/tasks/release.rake
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
begin
|
2
|
+
gem 'rubyforge', '~> 1.0.1'
|
3
|
+
require 'rubyforge'
|
4
|
+
rescue Exception
|
5
|
+
nil
|
6
|
+
end
|
7
|
+
|
8
|
+
if defined?(RubyForge) then
|
9
|
+
if defined?(GEM_SPEC) then
|
10
|
+
desc 'Package and upload to RubyForge'
|
11
|
+
task :release => [:package] do |t|
|
12
|
+
ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
|
13
|
+
|
14
|
+
# compare versions to avoid mistakes
|
15
|
+
unless ver == GEM_SPEC.version.to_s then
|
16
|
+
fail "Version mismatch (supplied and specification versions differ)."
|
17
|
+
end
|
18
|
+
|
19
|
+
# no rubyforge project? no release for you!
|
20
|
+
if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
|
21
|
+
fail "Must define rubyforge_project in your gem specification."
|
22
|
+
end
|
23
|
+
|
24
|
+
# instantiate a RubyForge object
|
25
|
+
rf = RubyForge.new
|
26
|
+
|
27
|
+
# read project info and overview
|
28
|
+
notes = begin
|
29
|
+
r = File.read("README.rdoc")
|
30
|
+
r.split(/^(=+ .*)/)[1..4].join.strip
|
31
|
+
rescue
|
32
|
+
warn "Missing README.rdoc"
|
33
|
+
''
|
34
|
+
end
|
35
|
+
|
36
|
+
# read changes
|
37
|
+
changes = begin
|
38
|
+
h = File.read("History.txt")
|
39
|
+
h.split(/^(==+ .*)/)[1..2].join.strip
|
40
|
+
rescue
|
41
|
+
warn "Missing History.txt"
|
42
|
+
''
|
43
|
+
end
|
44
|
+
|
45
|
+
# build the configuration for the release
|
46
|
+
config = Hash.new
|
47
|
+
config["release_notes"] = notes
|
48
|
+
config["release_changes"] = changes
|
49
|
+
config["preformatted"] = true
|
50
|
+
|
51
|
+
# prepare configuration
|
52
|
+
rf.configure config
|
53
|
+
|
54
|
+
files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
|
55
|
+
fail "No files found for the release." if files.empty?
|
56
|
+
|
57
|
+
puts "Logging in RubyForge..."
|
58
|
+
rf.login
|
59
|
+
|
60
|
+
puts "Files to upload:"
|
61
|
+
files.each do |f|
|
62
|
+
puts " * #{f}"
|
63
|
+
end
|
64
|
+
|
65
|
+
puts "Releasing #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
|
66
|
+
rf.add_release GEM_SPEC.rubyforge_project, GEM_SPEC.name, GEM_SPEC.version, *files
|
67
|
+
puts "Done."
|
68
|
+
end
|
69
|
+
#Rake::Task['release'].prerequisites.unshift('clean', 'cross', 'native')
|
70
|
+
else
|
71
|
+
warn "no GEM_SPEC is found or defined. 'release' task cannot work without it."
|
72
|
+
end
|
73
|
+
else
|
74
|
+
warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
|
75
|
+
end
|
data/tasks/retrieve.rake
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
begin
|
2
|
+
gem('rake-compiler')
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/extensioncompiler'
|
5
|
+
|
6
|
+
# download mysql library and headers
|
7
|
+
directory "vendor"
|
8
|
+
|
9
|
+
# only on Windows or cross platform compilation
|
10
|
+
def dlltool(dllname, deffile, libfile)
|
11
|
+
# define if we are using GCC or not
|
12
|
+
if Rake::ExtensionCompiler.mingw_gcc_executable then
|
13
|
+
dir = File.dirname(Rake::ExtensionCompiler.mingw_gcc_executable)
|
14
|
+
tool = case RUBY_PLATFORM
|
15
|
+
when /mingw/
|
16
|
+
File.join(dir, 'dlltool.exe')
|
17
|
+
when /linux|darwin/
|
18
|
+
File.join(dir, "#{Rake::ExtensionCompiler.mingw_host}-dlltool")
|
19
|
+
end
|
20
|
+
return "#{tool} --dllname #{dllname} --def #{deffile} --output-lib #{libfile}"
|
21
|
+
else
|
22
|
+
if RUBY_PLATFORM =~ /mswin/ then
|
23
|
+
tool = 'lib.exe'
|
24
|
+
else
|
25
|
+
fail "Unsupported platform for cross-compilation (please, contribute some patches)."
|
26
|
+
end
|
27
|
+
return "#{tool} /DEF:#{deffile} /OUT:#{libfile}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
file "vendor/mysql-noinstall-#{BINARY_VERSION}-win32.zip" => ['vendor'] do |t|
|
32
|
+
base_version = BINARY_VERSION.gsub(/\.[0-9]+$/, '')
|
33
|
+
url = "http://mysql.proserve.nl/Downloads/MySQL-#{base_version}/#{File.basename(t.name)}"
|
34
|
+
when_writing "downloading #{t.name}" do
|
35
|
+
cd File.dirname(t.name) do
|
36
|
+
sh "wget -c #{url} || curl -C - -O #{url}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
file "vendor/mysql-#{BINARY_VERSION}-win32/include/mysql.h" => ["vendor/mysql-noinstall-#{BINARY_VERSION}-win32.zip"] do |t|
|
42
|
+
full_file = File.expand_path(t.prerequisites.last)
|
43
|
+
when_writing "creating #{t.name}" do
|
44
|
+
cd "vendor" do
|
45
|
+
sh "unzip #{full_file} mysql-#{BINARY_VERSION}-win32/bin/** mysql-#{BINARY_VERSION}-win32/include/** mysql-#{BINARY_VERSION}-win32/lib/**"
|
46
|
+
end
|
47
|
+
# update file timestamp to avoid Rake perform this extraction again.
|
48
|
+
touch t.name
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# clobber vendored packages
|
53
|
+
CLOBBER.include('vendor')
|
54
|
+
|
55
|
+
# vendor:mysql
|
56
|
+
task 'vendor:mysql' => ["vendor/mysql-#{BINARY_VERSION}-win32/include/mysql.h"]
|
57
|
+
|
58
|
+
# hook into cross compilation vendored mysql dependency
|
59
|
+
if RUBY_PLATFORM =~ /mingw|mswin/ then
|
60
|
+
Rake::Task['compile'].prerequisites.unshift 'vendor:mysql'
|
61
|
+
else
|
62
|
+
if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
|
63
|
+
Rake::Task['cross'].prerequisites.unshift 'vendor:mysql'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
rescue LoadError
|
67
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Specs
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc 'Run specifications'
|
5
|
+
Spec::Rake::SpecTask.new(:spec => [ :clean, :compile ]) do |t|
|
6
|
+
t.spec_opts << '--options' << ROOT + 'spec/spec.opts'
|
7
|
+
t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
|
8
|
+
|
9
|
+
begin
|
10
|
+
# RCov is run by default, except on the JRuby platform
|
11
|
+
t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
|
12
|
+
t.rcov_opts << '--exclude' << 'spec'
|
13
|
+
t.rcov_opts << '--text-summary'
|
14
|
+
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
15
|
+
rescue Exception
|
16
|
+
# rcov not installed
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
3
|
+
requirements:
|
4
|
+
- - '>='
|
5
|
+
- !ruby/object:Gem::Version
|
6
|
+
version: "0"
|
7
|
+
version:
|
8
|
+
email: d.bussink@gmail.com
|
9
|
+
cert_chain: []
|
10
|
+
|
11
|
+
summary: DataObjects MySQL Driver
|
12
|
+
post_install_message:
|
13
|
+
extra_rdoc_files: []
|
14
|
+
|
15
|
+
homepage: http://github.com/datamapper/do
|
16
|
+
signing_key:
|
17
|
+
name: do_mysql
|
18
|
+
rdoc_options: []
|
19
|
+
|
20
|
+
rubyforge_project: dorb
|
21
|
+
autorequire:
|
22
|
+
licenses: []
|
23
|
+
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
description: Implements the DataObjects API for MySQL
|
27
|
+
specification_version: 3
|
28
|
+
default_executable:
|
29
|
+
files:
|
30
|
+
- lib/do_mysql.rb
|
31
|
+
- lib/do_mysql/transaction.rb
|
32
|
+
- lib/do_mysql/version.rb
|
33
|
+
- spec/command_spec.rb
|
34
|
+
- spec/connection_spec.rb
|
35
|
+
- spec/encoding_spec.rb
|
36
|
+
- spec/reader_spec.rb
|
37
|
+
- spec/result_spec.rb
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
- spec/lib/rspec_immediate_feedback_formatter.rb
|
40
|
+
- spec/typecast/array_spec.rb
|
41
|
+
- spec/typecast/bigdecimal_spec.rb
|
42
|
+
- spec/typecast/boolean_spec.rb
|
43
|
+
- spec/typecast/byte_array_spec.rb
|
44
|
+
- spec/typecast/class_spec.rb
|
45
|
+
- spec/typecast/date_spec.rb
|
46
|
+
- spec/typecast/datetime_spec.rb
|
47
|
+
- spec/typecast/float_spec.rb
|
48
|
+
- spec/typecast/integer_spec.rb
|
49
|
+
- spec/typecast/nil_spec.rb
|
50
|
+
- spec/typecast/range_spec.rb
|
51
|
+
- spec/typecast/string_spec.rb
|
52
|
+
- spec/typecast/time_spec.rb
|
53
|
+
- tasks/gem.rake
|
54
|
+
- tasks/install.rake
|
55
|
+
- tasks/native.rake
|
56
|
+
- tasks/release.rake
|
57
|
+
- tasks/retrieve.rake
|
58
|
+
- tasks/spec.rake
|
59
|
+
- LICENSE
|
60
|
+
- Rakefile
|
61
|
+
- History.txt
|
62
|
+
- Manifest.txt
|
63
|
+
- README.txt
|
64
|
+
- lib/do_mysql_ext.jar
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
rubygems_version: 1.3.2
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
authors:
|
77
|
+
- Dirkjan Bussink
|
78
|
+
date: 2009-05-16 22:00:00 +00:00
|
79
|
+
platform: java
|
80
|
+
test_files: []
|
81
|
+
|
82
|
+
version: !ruby/object:Gem::Version
|
83
|
+
version: 0.9.12
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
dependencies:
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.0.0
|
93
|
+
version:
|
94
|
+
type: :runtime
|
95
|
+
version_requirement:
|
96
|
+
name: addressable
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.9.12
|
103
|
+
version:
|
104
|
+
type: :runtime
|
105
|
+
version_requirement:
|
106
|
+
name: extlib
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 0.9.12
|
113
|
+
version:
|
114
|
+
type: :runtime
|
115
|
+
version_requirement:
|
116
|
+
name: data_objects
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 5.0.4
|
123
|
+
version:
|
124
|
+
type: :runtime
|
125
|
+
version_requirement:
|
126
|
+
name: jdbc-mysql
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 0.9.12
|
133
|
+
version:
|
134
|
+
type: :runtime
|
135
|
+
version_requirement:
|
136
|
+
name: do_jdbc
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ~>
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 1.2.0
|
143
|
+
version:
|
144
|
+
type: :development
|
145
|
+
version_requirement:
|
146
|
+
name: rspec
|
147
|
+
bindir: bin
|
148
|
+
has_rdoc: false
|