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 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]
@@ -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
- create_makefile('amalgalite/amalgalite3')
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::GEM_SPEC_WIN = Amalgalite::GEM_SPEC.clone
53
- Amalgalite::GEM_SPEC_WIN.platform = ::Gem::Platform.new( "i386-mswin32_60" )
54
- Amalgalite::GEM_SPEC_WIN.extensions = []
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::SPECS = [ Amalgalite::GEM_SPEC, Amalgalite::GEM_SPEC_WIN ]
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
- # support for fat binaries on windows
20
- if RUBY_PLATFORM =~ /(mswin|mingw)/i then
21
- require "amalgalite/#{RUBY_VERSION.sub(/\.\d$/,'')}/amalgalite3"
22
- else
23
- require "amalgalite/amalgalite3"
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'
@@ -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 daabase
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:
@@ -9,7 +9,7 @@ module Amalgalite
9
9
 
10
10
  MAJOR = 0
11
11
  MINOR = 10
12
- BUILD = 0
12
+ BUILD = 1
13
13
 
14
14
  #
15
15
  # return the Version as an array of MAJOR, MINOR, BUILD
@@ -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
@@ -2,7 +2,6 @@ require 'rubygems'
2
2
  require 'spec'
3
3
 
4
4
  $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
- $: << File.expand_path(File.join(File.dirname(__FILE__),"..","ext"))
6
5
 
7
6
  require 'amalgalite'
8
7
 
@@ -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::GEM_SPEC_WIN.to_ruby
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::GEM_SPEC_WIN.files += FileList["lib/amalgalite/{1.8,1.9}/**.{dll,so}"]
53
- Gem::Builder.new( Amalgalite::GEM_SPEC_WIN ).build
54
- mkdir "pkg" unless File.directory?( 'pkg' )
55
- mv Dir["*.gem"].first, "pkg"
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?( "Makfeile" ) then
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.0
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-06-28 00:00:00 -06:00
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