amalgalite 0.10.0 → 0.10.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.
- data/HISTORY +8 -0
- data/README +4 -0
- data/ext/amalgalite/extconf.rb +2 -2
- data/gemspec.rb +8 -4
- data/lib/amalgalite.rb +5 -6
- data/lib/amalgalite/database.rb +7 -2
- data/lib/amalgalite/version.rb +1 -1
- data/spec/rtree_spec.rb +71 -0
- data/spec/spec_helper.rb +0 -1
- data/tasks/distribution.rake +8 -5
- data/tasks/extension.rake +7 -1
- metadata +4 -3
data/HISTORY
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
= Amalgalite Changelog
|
2
|
+
== Version 0.10.1 - 2009-08-01
|
3
|
+
|
4
|
+
* Add version subdirectory for extension on all platforms for building locally
|
5
|
+
on gem install.
|
6
|
+
* Small documentation change for Amalgalite::Database#new
|
7
|
+
* Add gem for x86-ming32 platform
|
8
|
+
* Add specs to validate the R*Tree index is compiled correctly
|
9
|
+
|
2
10
|
== Version 0.10.0 - 2009-06-28
|
3
11
|
|
4
12
|
=== Enhancements
|
data/README
CHANGED
@@ -30,6 +30,10 @@ Look in the examples/ directory to see
|
|
30
30
|
Also Scroll through Amalgalite::Database for a quick example, and a general
|
31
31
|
overview of the API.
|
32
32
|
|
33
|
+
Amalgalite adds in the following additional non-default SQLite extension(s):
|
34
|
+
|
35
|
+
* {R*Tree index extension}[http://sqlite.org/rtree.html]
|
36
|
+
|
33
37
|
== CREDITS
|
34
38
|
|
35
39
|
* Jamis Buck for the first {ruby sqlite implementation}[http://www.rubyforge.org/projects/sqlite-ruby]
|
data/ext/amalgalite/extconf.rb
CHANGED
@@ -4,7 +4,6 @@ require 'rbconfig'
|
|
4
4
|
# make available table and column meta data api
|
5
5
|
$CFLAGS += " -DSQLITE_ENABLE_COLUMN_METADATA=1"
|
6
6
|
$CFLAGS += " -DSQLITE_ENABLE_RTREE=1"
|
7
|
-
$CFLAGS += " -DSQLITE_OMIT_BUILTIN_TEST=1"
|
8
7
|
|
9
8
|
# we compile sqlite the same way that the installation of ruby is compiled.
|
10
9
|
if Config::CONFIG['configure_args'].include?( "--enable-pthread" ) then
|
@@ -33,4 +32,5 @@ if CONFIG['arch'] =~ /(mswin|mingw)/i then
|
|
33
32
|
CONFIG['debugflags'] = CONFIG['debugflags'].gsub(/-g/,'') if CONFIG['debugflags']
|
34
33
|
CONFIG['warnflags'] = CONFIG['warnflags'].gsub(/-Wall/,'') if CONFIG['warnflags']
|
35
34
|
end
|
36
|
-
|
35
|
+
subdir = RUBY_VERSION.sub(/\.\d$/,'')
|
36
|
+
create_makefile("amalgalite/#{subdir}/amalgalite3")
|
data/gemspec.rb
CHANGED
@@ -49,8 +49,12 @@ Amalgalite::GEM_SPEC = Gem::Specification.new do |spec|
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
Amalgalite::
|
53
|
-
Amalgalite::
|
54
|
-
Amalgalite::
|
52
|
+
Amalgalite::GEM_SPEC_MSWIN32 = Amalgalite::GEM_SPEC.clone
|
53
|
+
Amalgalite::GEM_SPEC_MSWIN32.platform = ::Gem::Platform.new( "i386-mswin32" )
|
54
|
+
Amalgalite::GEM_SPEC_MSWIN32.extensions = []
|
55
55
|
|
56
|
-
Amalgalite::
|
56
|
+
Amalgalite::GEM_SPEC_MINGW32= Amalgalite::GEM_SPEC.clone
|
57
|
+
Amalgalite::GEM_SPEC_MINGW32.platform = ::Gem::Platform.new( "i386-mingw32" )
|
58
|
+
Amalgalite::GEM_SPEC_MINGW32.extensions = []
|
59
|
+
|
60
|
+
Amalgalite::SPECS = [ Amalgalite::GEM_SPEC, Amalgalite::GEM_SPEC_MSWIN32, Amalgalite::GEM_SPEC_MINGW32 ]
|
data/lib/amalgalite.rb
CHANGED
@@ -16,12 +16,11 @@ module Amalgalite
|
|
16
16
|
class Error < ::StandardError; end
|
17
17
|
end
|
18
18
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
19
|
+
# use a version subdirectory for extensions, initially to support windows, but
|
20
|
+
# why make a special case, it doesn't hurt anyone to have an extra subdir
|
21
|
+
# someplace
|
22
|
+
require "amalgalite/#{RUBY_VERSION.sub(/\.\d$/,'')}/amalgalite3"
|
23
|
+
|
25
24
|
require 'amalgalite/aggregate'
|
26
25
|
require 'amalgalite/blob'
|
27
26
|
require 'amalgalite/boolean'
|
data/lib/amalgalite/database.rb
CHANGED
@@ -15,7 +15,7 @@ module Amalgalite
|
|
15
15
|
#
|
16
16
|
# The encapsulation of a connection to an SQLite3 database.
|
17
17
|
#
|
18
|
-
# Example opening and possibly creating a new
|
18
|
+
# Example opening and possibly creating a new database
|
19
19
|
#
|
20
20
|
# db = Amalgalite::Database.new( "mydb.db" )
|
21
21
|
# db.execute( "SELECT * FROM table" ) do |row|
|
@@ -28,6 +28,9 @@ module Amalgalite
|
|
28
28
|
#
|
29
29
|
# db = Amalgalite::Database.new( "mydb.db", "r" )
|
30
30
|
#
|
31
|
+
# Open an in-memory database:
|
32
|
+
#
|
33
|
+
# db = Amalgalite::Database.new( ":memory:" )
|
31
34
|
#
|
32
35
|
class Database
|
33
36
|
|
@@ -108,7 +111,9 @@ module Amalgalite
|
|
108
111
|
# :call-seq:
|
109
112
|
# Amalgalite::Database.new( filename, "w+", opts = {}) -> Database
|
110
113
|
#
|
111
|
-
# The first parameter is the filename of the sqlite database.
|
114
|
+
# The first parameter is the filename of the sqlite database. Specifying
|
115
|
+
# ":memory:" as the filename creates an in-memory database.
|
116
|
+
#
|
112
117
|
# The second parameter is the standard file modes of how to open a file.
|
113
118
|
#
|
114
119
|
# The modes are:
|
data/lib/amalgalite/version.rb
CHANGED
data/spec/rtree_spec.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require File.expand_path( File.join( File.dirname(__FILE__), 'spec_helper'))
|
4
|
+
|
5
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
|
6
|
+
require 'amalgalite'
|
7
|
+
require 'amalgalite/database'
|
8
|
+
|
9
|
+
# Example from http://sqlite.org/rtree.html
|
10
|
+
#
|
11
|
+
describe "SQLite3 R*Tree extension" do
|
12
|
+
before( :each ) do
|
13
|
+
@db = Amalgalite::Database.new( ":memory:" )
|
14
|
+
x = @db.execute_batch <<-sql
|
15
|
+
CREATE VIRTUAL TABLE demo_index USING rtree(
|
16
|
+
id, -- Integer primary key
|
17
|
+
minX, maxX, -- Minimum and maximum X coordinate
|
18
|
+
minY, maxY -- Minimum and maximum Y coordinate
|
19
|
+
);
|
20
|
+
--
|
21
|
+
INSERT INTO demo_index VALUES(
|
22
|
+
1, -- Primary key
|
23
|
+
-80.7749, -80.7747, -- Longitude range
|
24
|
+
30.3776, 30.3778 -- Latitude range
|
25
|
+
);
|
26
|
+
INSERT INTO demo_index VALUES(
|
27
|
+
2,
|
28
|
+
-81.0, -79.6,
|
29
|
+
35.0, 36.2
|
30
|
+
);
|
31
|
+
sql
|
32
|
+
x.should == 3
|
33
|
+
end
|
34
|
+
|
35
|
+
after( :each ) do
|
36
|
+
@db.close
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has 2 rows" do
|
40
|
+
r = @db.first_value_from( "SELECT count(*) FROM demo_index")
|
41
|
+
r.should == 2
|
42
|
+
end
|
43
|
+
|
44
|
+
it "queries normally" do
|
45
|
+
r = @db.execute "SELECT * FROM demo_index WHERE id=1;"
|
46
|
+
r.size.should == 1
|
47
|
+
row = r.first
|
48
|
+
row['id'].should == 1
|
49
|
+
end
|
50
|
+
|
51
|
+
it "does a 'contained within' query" do
|
52
|
+
r = @db.execute <<-sql
|
53
|
+
SELECT id FROM demo_index
|
54
|
+
WHERE minX>=-81.08 AND maxX<=-80.58
|
55
|
+
AND minY>=30.00 AND maxY<=30.44;
|
56
|
+
sql
|
57
|
+
|
58
|
+
r.size.should == 1
|
59
|
+
r.first['id'].should == 1
|
60
|
+
end
|
61
|
+
|
62
|
+
it "does an 'overlapping' query" do
|
63
|
+
r = @db.execute <<-sql
|
64
|
+
SELECT id FROM demo_index
|
65
|
+
WHERE maxX>=-81.08 AND minX<=-80.58
|
66
|
+
AND maxY>=30.00 AND minY<=35.44;
|
67
|
+
sql
|
68
|
+
r.size.should == 2
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
data/spec/spec_helper.rb
CHANGED
data/tasks/distribution.rake
CHANGED
@@ -33,7 +33,7 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
|
|
33
33
|
|
34
34
|
desc "dump gemspec for win"
|
35
35
|
task :gemspec_win do
|
36
|
-
puts Amalgalite::
|
36
|
+
puts Amalgalite::GEM_SPEC_MINGW32.to_ruby
|
37
37
|
end
|
38
38
|
|
39
39
|
desc "reinstall gem"
|
@@ -49,10 +49,13 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
|
|
49
49
|
cp "ext/amalgalite/amalgalite3.so", "lib/amalgalite/#{s}/", :verbose => true
|
50
50
|
end
|
51
51
|
|
52
|
-
Amalgalite::
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
Amalgalite::SPECS.each do |spec|
|
53
|
+
next if spec.platform == "ruby"
|
54
|
+
spec.files += FileList["lib/amalgalite/{1.8,1.9}/**.{dll,so}"]
|
55
|
+
Gem::Builder.new( spec ).build
|
56
|
+
mkdir "pkg" unless File.directory?( 'pkg' )
|
57
|
+
mv Dir["*.gem"].first, "pkg"
|
58
|
+
end
|
56
59
|
end
|
57
60
|
|
58
61
|
task :clobber do
|
data/tasks/extension.rake
CHANGED
@@ -32,6 +32,12 @@ if ext_config = Configuration.for_if_exist?('extension') then
|
|
32
32
|
Dir.chdir(path.dirname) do |d|
|
33
33
|
ruby conf.to_s
|
34
34
|
sh "make"
|
35
|
+
|
36
|
+
# install into requireable location so specs will run
|
37
|
+
subdir = "amalgalite/#{RUBY_VERSION.sub(/\.\d$/,'')}"
|
38
|
+
dest_dir = Amalgalite::Paths.lib_path( subdir )
|
39
|
+
mkdir_p dest_dir, :verbose => true
|
40
|
+
cp "amalgalite3.#{Config::CONFIG['DLEXT']}", dest_dir, :verbose => true
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
@@ -77,7 +83,7 @@ if ext_config = Configuration.for_if_exist?('extension') then
|
|
77
83
|
parts = path.split
|
78
84
|
conf = parts.last
|
79
85
|
Dir.chdir(path.dirname) do |d|
|
80
|
-
if File.exist?( "
|
86
|
+
if File.exist?( "Makefile" ) then
|
81
87
|
sh "make clean"
|
82
88
|
end
|
83
89
|
rm_f "rbconfig.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amalgalite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Hinegardner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-01 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: 0.5.0
|
64
64
|
version:
|
65
|
-
description: Amalgalite embeds the SQLite database engine in a ruby extension. There is no need to install SQLite separately. Look in the examples/ directory to see * general usage * blob io * schema information * custom functions * custom aggregates * requiring ruby code from a database Also Scroll through Amalgalite::Database for a quick example, and a general overview of the API.
|
65
|
+
description: "Amalgalite embeds the SQLite database engine in a ruby extension. There is no need to install SQLite separately. Look in the examples/ directory to see * general usage * blob io * schema information * custom functions * custom aggregates * requiring ruby code from a database Also Scroll through Amalgalite::Database for a quick example, and a general overview of the API. Amalgalite adds in the following additional non-default SQLite extension(s): * {R*Tree index extension}[http://sqlite.org/rtree.html]"
|
66
66
|
email: jeremy@hinegardner.org
|
67
67
|
executables:
|
68
68
|
- amalgalite-pack
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- spec/paths_spec.rb
|
179
179
|
- spec/progress_handler_spec.rb
|
180
180
|
- spec/requires_spec.rb
|
181
|
+
- spec/rtree_spec.rb
|
181
182
|
- spec/schema_spec.rb
|
182
183
|
- spec/spec_helper.rb
|
183
184
|
- spec/sqlite3/constants_spec.rb
|