do_sqlite3 0.9.11-x86-mswin32-60 → 0.9.12-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/LICENSE +1 -1
  2. data/Manifest.txt +15 -4
  3. data/Rakefile +7 -207
  4. data/ext/do_sqlite3_ext/do_sqlite3_ext.c +187 -71
  5. data/ext/do_sqlite3_ext/extconf.rb +2 -0
  6. data/lib/do_sqlite3/version.rb +1 -1
  7. data/lib/do_sqlite3_ext.so +0 -0
  8. data/spec/command_spec.rb +8 -0
  9. data/spec/connection_spec.rb +18 -0
  10. data/spec/lib/rspec_immediate_feedback_formatter.rb +3 -0
  11. data/spec/reader_spec.rb +8 -0
  12. data/spec/result_spec.rb +9 -0
  13. data/spec/spec_helper.rb +88 -17
  14. data/spec/typecast/array_spec.rb +8 -0
  15. data/spec/typecast/bigdecimal_spec.rb +8 -0
  16. data/spec/typecast/boolean_spec.rb +8 -0
  17. data/spec/typecast/byte_array_spec.rb +9 -0
  18. data/spec/typecast/class_spec.rb +8 -0
  19. data/spec/typecast/date_spec.rb +8 -0
  20. data/spec/typecast/datetime_spec.rb +8 -0
  21. data/spec/typecast/float_spec.rb +8 -0
  22. data/spec/typecast/integer_spec.rb +8 -0
  23. data/spec/typecast/nil_spec.rb +10 -0
  24. data/spec/typecast/range_spec.rb +8 -0
  25. data/spec/typecast/string_spec.rb +8 -0
  26. data/spec/typecast/time_spec.rb +8 -0
  27. data/tasks/gem.rake +61 -0
  28. data/tasks/install.rake +15 -0
  29. data/tasks/native.rake +35 -0
  30. data/tasks/release.rake +75 -0
  31. data/tasks/retrieve.rake +104 -0
  32. data/tasks/spec.rake +18 -0
  33. metadata +73 -41
  34. data/.gitignore +0 -3
  35. data/buildfile +0 -27
  36. data/ext-java/src/main/java/DoSqlite3ExtService.java +0 -23
  37. data/ext-java/src/main/java/do_sqlite3/Sqlite3DriverDefinition.java +0 -26
  38. data/spec/integration/do_sqlite3_spec.rb +0 -278
  39. data/spec/integration/logging_spec.rb +0 -53
  40. data/spec/integration/quoting_spec.rb +0 -23
  41. data/spec/spec.opts +0 -2
  42. data/spec/unit/transaction_spec.rb +0 -34
@@ -36,5 +36,7 @@ end
36
36
  # create_makefile(extension_name)
37
37
  if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
38
38
  have_func("sqlite3_prepare_v2")
39
+ have_func("sqlite3_open_v2")
40
+
39
41
  create_makefile(extension_name)
40
42
  end
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Sqlite3
3
- VERSION = "0.9.11"
3
+ VERSION = "0.9.12"
4
4
  end
5
5
  end
Binary file
@@ -0,0 +1,8 @@
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::Sqlite3::Command do
7
+ it_should_behave_like 'a Command'
8
+ end
@@ -0,0 +1,18 @@
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::Sqlite3::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
+ end
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'data_objects', 'spec', 'lib', 'rspec_immediate_feedback_formatter'))
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
+ require 'data_objects/spec/reader_spec'
5
+
6
+ describe DataObjects::Sqlite3::Reader do
7
+ it_should_behave_like 'a Reader'
8
+ 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/result_spec'
5
+
6
+ describe DataObjects::Sqlite3::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 CHANGED
@@ -2,15 +2,23 @@ $TESTING=true
2
2
  JRUBY = RUBY_PLATFORM =~ /java/
3
3
 
4
4
  require 'rubygems'
5
+
6
+ gem 'rspec', '>1.1.12'
5
7
  require 'spec'
8
+
6
9
  require 'date'
10
+ require 'ostruct'
7
11
  require 'pathname'
12
+ require 'fileutils'
8
13
 
9
14
  # put data_objects from repository in the load path
10
15
  # DO NOT USE installed gem of data_objects!
11
16
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data_objects', 'lib'))
12
17
  require 'data_objects'
13
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
+
14
22
  if JRUBY
15
23
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
16
24
  require 'do_jdbc'
@@ -27,27 +35,90 @@ DataObjects::Sqlite3.logger = DataObjects::Logger.new(log_path, :debug)
27
35
 
28
36
  at_exit { DataObjects.logger.flush }
29
37
 
30
- module Sqlite3SpecHelpers
38
+ Spec::Runner.configure do |config|
39
+ config.include(DataObjects::Spec::PendingHelpers)
40
+ end
31
41
 
32
- def insert(query, *args)
33
- result = @connection.create_command(query).execute_non_query(*args)
34
- result.insert_id
35
- end
42
+ CONFIG = OpenStruct.new
43
+ CONFIG.scheme = 'sqlite3'
44
+ CONFIG.database = ENV['DO_SQLITE3_DATABASE'] || "#{File.expand_path(File.dirname(__FILE__))}/test.db"
36
45
 
37
- def exec(query, *args)
38
- @connection.create_command(query).execute_non_query(*args)
39
- end
46
+ CONFIG.uri = ENV["DO_SQLITE3_SPEC_URI"] || "#{CONFIG.scheme}://#{CONFIG.database}"
47
+
48
+ module DataObjectsSpecHelpers
49
+
50
+ def setup_test_environment
51
+ conn = DataObjects::Connection.new(CONFIG.uri)
52
+
53
+ conn.create_command(<<-EOF).execute_non_query
54
+ DROP TABLE IF EXISTS "invoices"
55
+ EOF
40
56
 
41
- def select(query, types = nil, *args)
42
- begin
43
- command = @connection.create_command(query)
44
- command.set_types types unless types.nil?
45
- reader = command.execute_reader(*args)
46
- reader.next!
47
- yield reader
48
- ensure
49
- reader.close if reader
57
+ conn.create_command(<<-EOF).execute_non_query
58
+ DROP TABLE IF EXISTS "users"
59
+ EOF
60
+
61
+ conn.create_command(<<-EOF).execute_non_query
62
+ DROP TABLE IF EXISTS "widgets"
63
+ EOF
64
+
65
+ conn.create_command(<<-EOF).execute_non_query
66
+ CREATE TABLE "users" (
67
+ "id" SERIAL,
68
+ "name" VARCHAR(200) default 'Billy' NULL,
69
+ "fired_at" timestamp,
70
+ PRIMARY KEY ("id")
71
+ );
72
+ EOF
73
+
74
+ conn.create_command(<<-EOF).execute_non_query
75
+ CREATE TABLE "invoices" (
76
+ "id" SERIAL,
77
+ "invoice_number" varchar(50) NOT NULL,
78
+ PRIMARY KEY ("id")
79
+ );
80
+ EOF
81
+
82
+ conn.create_command(<<-EOF).execute_non_query
83
+ CREATE TABLE "widgets" (
84
+ "id" INTEGER PRIMARY KEY AUTOINCREMENT,
85
+ "code" char(8) default 'A14' NULL,
86
+ "name" varchar(200) default 'Super Widget' NULL,
87
+ "shelf_location" text NULL,
88
+ "description" text NULL,
89
+ "image_data" blob NULL,
90
+ "ad_description" text NULL,
91
+ "ad_image" blob NULL,
92
+ "whitepaper_text" text NULL,
93
+ "cad_drawing" blob,
94
+ "flags" char default 'f',
95
+ "number_in_stock" smallint default 500,
96
+ "number_sold" integer default 0,
97
+ "super_number" bigint default 9223372036854775807,
98
+ "weight" float default 1.23,
99
+ "cost1" double precision default 10.23,
100
+ "cost2" decimal(8,2) default 50.23,
101
+ "release_date" date default '2008-02-14',
102
+ "release_datetime" timestamp default '2008-02-14T00:31:12+00:00',
103
+ "release_timestamp" timestamp with time zone default '2008-02-14 00:31:31'
104
+ );
105
+ EOF
106
+
107
+ 1.upto(16) do |n|
108
+ conn.create_command(<<-EOF).execute_non_query
109
+ 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 DRAWING', 1234, 13.4);
110
+ EOF
50
111
  end
112
+
113
+ conn.create_command(<<-EOF).execute_non_query
114
+ update widgets set flags = 't' where id = 2
115
+ EOF
116
+
117
+ conn.create_command(<<-EOF).execute_non_query
118
+ update widgets set ad_description = NULL where id = 3
119
+ EOF
120
+
121
+ conn.close
51
122
  end
52
123
 
53
124
  end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/array_spec'
5
+
6
+ describe 'DataObjects::Sqlite3 with Array' do
7
+ it_should_behave_like 'supporting Array'
8
+ end
@@ -0,0 +1,8 @@
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::Sqlite3 with BigDecimal' do
7
+ it_should_behave_like 'supporting BigDecimal'
8
+ end
@@ -0,0 +1,8 @@
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::Sqlite3 with Boolean' do
7
+ it_should_behave_like 'supporting Boolean'
8
+ 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/byte_array_spec'
5
+
6
+ describe 'DataObjects::Sqlite3 with ByteArray' do
7
+ # We need to switch to using parameter binding for this to work with Sqlite3
8
+ # it_should_behave_like 'supporting ByteArray'
9
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/class_spec'
5
+
6
+ describe 'DataObjects::Sqlite3 with Class' do
7
+ it_should_behave_like 'supporting Class'
8
+ end
@@ -0,0 +1,8 @@
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::Sqlite3 with Date' do
7
+ it_should_behave_like 'supporting Date'
8
+ end
@@ -0,0 +1,8 @@
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::Sqlite3 with DateTime' do
7
+ it_should_behave_like 'supporting DateTime'
8
+ end
@@ -0,0 +1,8 @@
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::Sqlite3 with Float' do
7
+ it_should_behave_like 'supporting Float'
8
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/integer_spec'
5
+
6
+ describe 'DataObjects::Sqlite3 with Integer' do
7
+ it_should_behave_like 'supporting Integer'
8
+ 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::Sqlite3 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
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/range_spec'
5
+
6
+ describe 'DataObjects::Sqlite3 with Range' do
7
+ it_should_behave_like 'supporting Range'
8
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/string_spec'
5
+
6
+ describe 'DataObjects::Sqlite3 with String' do
7
+ it_should_behave_like 'supporting String'
8
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/time_spec'
5
+
6
+ describe 'DataObjects::Sqlite3 with Time' do
7
+ it_should_behave_like 'supporting Time'
8
+ end
data/tasks/gem.rake ADDED
@@ -0,0 +1,61 @@
1
+ require 'rubygems/package_task'
2
+
3
+ GEM_SPEC = Gem::Specification.new do |s|
4
+ # basic information
5
+ s.name = "do_sqlite3"
6
+ s.version = DataObjects::Sqlite3::VERSION
7
+
8
+ # description and details
9
+ s.summary = 'DataObjects Sqlite3 Driver'
10
+ s.description = "Implements the DataObjects API for Sqlite3"
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::Sqlite3::VERSION
16
+
17
+ if JRUBY
18
+ s.add_dependency "jdbc-sqlite3", ">=3.5.8"
19
+ s.add_dependency "do_jdbc", DataObjects::Sqlite3::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_sqlite3_ext/extconf.rb'
27
+ # components, files and paths
28
+ s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake", "ext/**/*.{rb,c}",
29
+ "LICENSE", "Rakefile", "*.{rdoc,txt,yml}"]
30
+ end
31
+
32
+ # development dependencies
33
+ s.add_development_dependency 'rspec', '~>1.2.0'
34
+
35
+
36
+ s.require_path = 'lib'
37
+
38
+ # documentation
39
+ s.has_rdoc = false
40
+
41
+ # project information
42
+ s.homepage = 'http://github.com/datamapper/do'
43
+ s.rubyforge_project = 'dorb'
44
+
45
+ # author and contributors
46
+ s.author = 'Dirkjan Bussink'
47
+ s.email = 'd.bussink@gmail.com'
48
+ end
49
+
50
+ gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
51
+ pkg.need_tar = false
52
+ pkg.need_zip = false
53
+ end
54
+
55
+ file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
56
+ puts "Generating #{t.name}"
57
+ File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
58
+ end
59
+
60
+ desc "Generate or update the standalone gemspec file for the project"
61
+ task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
@@ -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,35 @@
1
+ begin
2
+ gem('rake-compiler')
3
+ require 'rake/extensiontask'
4
+
5
+ # compile the extension
6
+ if JRUBY
7
+ # XXX: is it necessary to run this everytime?
8
+ Rake::Task['compile:jruby'].invoke
9
+ end
10
+
11
+ Rake::ExtensionTask.new('do_sqlite3_ext', GEM_SPEC) do |ext|
12
+
13
+ sqlite3_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'sqlite3'))
14
+
15
+ ext.cross_compile = true
16
+ ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
17
+ ext.cross_config_options << "--with-sqlite3-dir=#{sqlite3_lib}"
18
+
19
+ # automatically add build options to avoid need of manual input
20
+ if RUBY_PLATFORM =~ /mswin|mingw/ then
21
+ ext.config_options << "--with-sqlite3-dir=#{sqlite3_lib}"
22
+ end
23
+
24
+ end
25
+ rescue LoadError
26
+ warn "To cross-compile, install rake-compiler (gem install rake-compiler)"
27
+
28
+ if (tasks_dir = ROOT.parent + 'tasks').directory?
29
+ require tasks_dir + 'ext_helper'
30
+ require tasks_dir + 'ext_helper_java'
31
+
32
+ setup_c_extension("#{GEM_SPEC.name}_ext", GEM_SPEC)
33
+ setup_java_extension("#{GEM_SPEC.name}_ext", GEM_SPEC)
34
+ end
35
+ end