amalgalite 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/HISTORY +10 -1
  2. data/bin/amalgalite-pack +1 -1
  3. data/examples/bootstrap.rb +1 -1
  4. data/ext/{amalgalite3.c → amalgalite/amalgalite3.c} +0 -0
  5. data/ext/{amalgalite3.h → amalgalite/amalgalite3.h} +0 -0
  6. data/ext/{amalgalite3_blob.c → amalgalite/amalgalite3_blob.c} +0 -0
  7. data/ext/{amalgalite3_constants.c → amalgalite/amalgalite3_constants.c} +0 -0
  8. data/ext/{amalgalite3_database.c → amalgalite/amalgalite3_database.c} +28 -2
  9. data/ext/{amalgalite3_requires_bootstrap.c → amalgalite/amalgalite3_requires_bootstrap.c} +0 -0
  10. data/ext/{amalgalite3_statement.c → amalgalite/amalgalite3_statement.c} +0 -0
  11. data/ext/amalgalite/extconf.rb +36 -0
  12. data/ext/{gen_constants.rb → amalgalite/gen_constants.rb} +0 -0
  13. data/ext/{sqlite3.c → amalgalite/sqlite3.c} +9529 -7297
  14. data/ext/{sqlite3.h → amalgalite/sqlite3.h} +305 -166
  15. data/ext/{sqlite3_options.h → amalgalite/sqlite3_options.h} +0 -0
  16. data/ext/{sqlite3ext.h → amalgalite/sqlite3ext.h} +0 -0
  17. data/gemspec.rb +1 -1
  18. data/lib/amalgalite.rb +6 -0
  19. data/lib/amalgalite/database.rb +0 -1
  20. data/lib/amalgalite/sqlite3.rb +0 -1
  21. data/lib/amalgalite/sqlite3/constants.rb +0 -2
  22. data/lib/amalgalite/sqlite3/database/status.rb +0 -1
  23. data/lib/amalgalite/sqlite3/status.rb +0 -1
  24. data/lib/amalgalite/sqlite3/version.rb +0 -1
  25. data/lib/amalgalite/statement.rb +0 -1
  26. data/lib/amalgalite/type_maps/default_map.rb +0 -1
  27. data/lib/amalgalite/type_maps/storage_map.rb +0 -1
  28. data/lib/amalgalite/type_maps/text_map.rb +0 -1
  29. data/lib/amalgalite/version.rb +1 -1
  30. data/spec/aggregate_spec.rb +1 -1
  31. data/spec/function_spec.rb +8 -0
  32. data/spec/sqlite3/version_spec.rb +2 -2
  33. data/tasks/announce.rake +10 -6
  34. data/tasks/config.rb +2 -2
  35. data/tasks/distribution.rake +30 -9
  36. data/tasks/extension.rake +30 -25
  37. metadata +26 -22
  38. data/ext/extconf.rb +0 -23
data/gemspec.rb CHANGED
@@ -25,6 +25,7 @@ Amalgalite::GEM_SPEC = Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency("rake", "~> 0.8.4")
26
26
  spec.add_development_dependency("configuration", "~> 0.0.5")
27
27
  spec.add_development_dependency("rspec", "~> 1.2.2")
28
+ spec.add_development_dependency("rake-compiler", "~> 0.5.0")
28
29
 
29
30
  if ext_conf = Configuration.for_if_exist?("extension") then
30
31
  spec.extensions << ext_conf.configs
@@ -51,6 +52,5 @@ end
51
52
  Amalgalite::GEM_SPEC_WIN = Amalgalite::GEM_SPEC.clone
52
53
  Amalgalite::GEM_SPEC_WIN.platform = ::Gem::Platform.new( "i386-mswin32_60" )
53
54
  Amalgalite::GEM_SPEC_WIN.extensions = []
54
- Amalgalite::GEM_SPEC_WIN.files += ["lib/amalgalite3.so"]
55
55
 
56
56
  Amalgalite::SPECS = [ Amalgalite::GEM_SPEC, Amalgalite::GEM_SPEC_WIN ]
@@ -16,6 +16,12 @@ 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
25
  require 'amalgalite/aggregate'
20
26
  require 'amalgalite/blob'
21
27
  require 'amalgalite/boolean'
@@ -2,7 +2,6 @@
2
2
  # Copyright (c) 2008 Jeremy Hinegardner
3
3
  # All rights reserved. See LICENSE and/or COPYING for details.
4
4
  #++
5
- require 'amalgalite3'
6
5
  require 'amalgalite/statement'
7
6
  require 'amalgalite/trace_tap'
8
7
  require 'amalgalite/profile_tap'
@@ -1,4 +1,3 @@
1
- require 'amalgalite3'
2
1
  require 'amalgalite/version'
3
2
  require 'amalgalite/sqlite3/version'
4
3
  require 'amalgalite/sqlite3/constants'
@@ -2,8 +2,6 @@
2
2
  # Copyright (c) 2008 Jeremy Hinegardner
3
3
  # All rights reserved. See LICENSE and/or COPYING for details.
4
4
  #++
5
-
6
- require 'amalgalite3'
7
5
  module Amalgalite::SQLite3
8
6
  module Constants
9
7
  module Helpers
@@ -1,4 +1,3 @@
1
- require 'amalgalite3'
2
1
  require 'amalgalite/sqlite3/constants'
3
2
  module Amalgalite::SQLite3
4
3
  class Database
@@ -1,4 +1,3 @@
1
- require 'amalgalite3'
2
1
  require 'amalgalite/sqlite3/constants'
3
2
  module Amalgalite::SQLite3
4
3
 
@@ -2,7 +2,6 @@
2
2
  # Copyright (c) 2008 Jeremy Hinegardner
3
3
  # All rights reserved. See LICENSE and/or COPYING for details.
4
4
  #++
5
- require 'amalgalite3'
6
5
  module Amalgalite
7
6
  module SQLite3
8
7
  module Version
@@ -3,7 +3,6 @@
3
3
  # All rights reserved. See LICENSE and/or COPYING for details.
4
4
  #++
5
5
  #
6
- require 'amalgalite3'
7
6
  require 'date'
8
7
  require 'arrayfields'
9
8
  require 'ostruct'
@@ -4,7 +4,6 @@
4
4
  #++
5
5
 
6
6
  require 'amalgalite/type_map'
7
- require 'amalgalite3'
8
7
  require 'time'
9
8
  require 'date'
10
9
 
@@ -4,7 +4,6 @@
4
4
  #++
5
5
 
6
6
  require 'amalgalite/type_map'
7
- require 'amalgalite3'
8
7
 
9
8
  module Amalgalite::TypeMaps
10
9
  ##
@@ -4,7 +4,6 @@
4
4
  #++
5
5
  #
6
6
  require 'amalgalite/type_map'
7
- require 'amalgalite3'
8
7
 
9
8
  module Amalgalite::TypeMaps
10
9
  ##
@@ -8,7 +8,7 @@ module Amalgalite
8
8
  module Version
9
9
 
10
10
  MAJOR = 0
11
- MINOR = 9
11
+ MINOR = 10
12
12
  BUILD = 0
13
13
 
14
14
  #
@@ -101,7 +101,7 @@ describe "Aggregate SQL Functions" do
101
101
  def name() "atest3"; end
102
102
  def arity() 128; end
103
103
  end
104
- lambda { @iso_db.define_aggregate("atest3", AggregateTest3 ) }.should raise_error( ::Amalgalite::SQLite3::Error, /SQLITE_ERROR .* bad parameters/ )
104
+ lambda { @iso_db.define_aggregate("atest3", AggregateTest3 ) }.should raise_error( ::Amalgalite::SQLite3::Error, /SQLITE_ERROR .* Library used incorrectly/ )
105
105
  end
106
106
 
107
107
  it "does not allow registering a function which does not match the defined name " do
@@ -65,6 +65,14 @@ describe "Scalar SQL Functions" do
65
65
  end
66
66
  end
67
67
 
68
+ it "does not allow outrageous arity" do
69
+ class FunctionTest3 < ::Amalgalite::Function
70
+ def name() "ftest3"; end
71
+ def arity() 128; end
72
+ end
73
+ lambda { @iso_db.define_aggregate("ftest3", FunctionTest3) }.should raise_error( ::Amalgalite::SQLite3::Error, /SQLITE_ERROR .* Library used incorrectly/ )
74
+ end
75
+
68
76
  it "raises an error if the function returns a complex Ruby object" do
69
77
  l = lambda { Hash.new }
70
78
  @iso_db.define_function("htest", l)
@@ -5,10 +5,10 @@ describe "Amalgalite::SQLite3::Version" do
5
5
  it "should have the sqlite3 version" do
6
6
  Amalgalite::SQLite3::VERSION.should =~ /\d\.\d\.\d/
7
7
  Amalgalite::SQLite3::Version.to_s.should =~ /\d\.\d\.\d/
8
- Amalgalite::SQLite3::Version.to_i.should eql(3006012)
8
+ Amalgalite::SQLite3::Version.to_i.should eql(3006016)
9
9
  Amalgalite::SQLite3::Version::MAJOR.should eql(3)
10
10
  Amalgalite::SQLite3::Version::MINOR.should eql(6)
11
- Amalgalite::SQLite3::Version::RELEASE.should eql(12)
11
+ Amalgalite::SQLite3::Version::RELEASE.should eql(16)
12
12
  Amalgalite::SQLite3::Version.to_a.should have(3).items
13
13
  end
14
14
  end
@@ -17,16 +17,20 @@ namespace :announce do
17
17
  mail.puts
18
18
  mail.puts info[:title]
19
19
  mail.puts
20
- mail.puts " gem install #{Amalgalite::GEM_SPEC.name}"
20
+ mail.puts "{{ Release notes for Version #{Amalgalite::VERSION} }}"
21
21
  mail.puts
22
- mail.puts info[:urls]
23
- mail.puts
24
- mail.puts info[:description]
22
+ mail.puts info[:release_notes]
25
23
  mail.puts
26
- mail.puts "{{ Release notes for Version #{Amalgalite::VERSION} }}"
24
+ mail.puts " #{info[:urls]}"
25
+ mail.puts
26
+ mail.puts "=== Installation"
27
+ mail.puts
28
+ mail.puts " gem install #{Amalgalite::GEM_SPEC.name}"
27
29
  mail.puts
28
- mail.puts info[:release_notes]
30
+ mail.puts "=== Description"
29
31
  mail.puts
32
+ mail.puts info[:description]
33
+ mail.puts
30
34
  end
31
35
  puts "Created the following as email.txt:"
32
36
  puts "-" * 72
@@ -27,7 +27,7 @@ Configuration.for('packaging') {
27
27
  proj_conf = Configuration.for('project')
28
28
  files {
29
29
  bin FileList["bin/*"]
30
- ext FileList["ext/*.{c,h,rb}"]
30
+ ext FileList["ext/amalgalite/*.{c,h,rb}"]
31
31
  examples FileList["examples/*"]
32
32
  lib FileList["lib/**/*.rb"]
33
33
  test FileList["spec/**/*.rb", "test/**/*.rb"]
@@ -91,8 +91,8 @@ Configuration.for('rdoc') {
91
91
  # Extensions
92
92
  #-----------------------------------------------------------------------
93
93
  Configuration.for('extension') {
94
- #configs Configuration.for('packaging').files.ext.find_all { |x| %w[ mkrf_conf.rb extconf.rb ].include?(File.basename(x)) }
95
94
  configs Configuration.for('packaging').files.ext.find_all { |x| %w[ extconf.rb ].include?(File.basename(x)) }
95
+ cross_rbconfig YAML.load_file( File.expand_path("~/.rake-compiler/config.yml"))
96
96
  }
97
97
 
98
98
  #-----------------------------------------------------------------------
@@ -31,23 +31,44 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
31
31
  puts Amalgalite::GEM_SPEC.to_ruby
32
32
  end
33
33
 
34
+ desc "dump gemspec for win"
35
+ task :gemspec_win do
36
+ puts Amalgalite::GEM_SPEC_WIN.to_ruby
37
+ end
38
+
34
39
  desc "reinstall gem"
35
40
  task :reinstall => [:uninstall, :repackage, :install]
36
41
 
37
- desc "package the windows gem"
38
- task :package_win => "ext:build_win" do
39
- cp "ext/amalgalite3.so", "lib", :verbose => true
40
- Gem::Builder.new( Amalgalite::GEM_SPEC_WIN ).build
42
+ desc "package up a windows gem"
43
+ task :package_win => :clean do
44
+ Configuration.for("extension").cross_rbconfig.keys.each do |rbconfig|
45
+ v = rbconfig.split("-").last
46
+ s = v.sub(/\.\d$/,'')
47
+ sh "rake ext:build_win-#{v}"
48
+ mkdir_p "lib/amalgalite/#{s}", :verbose => true
49
+ cp "ext/amalgalite/amalgalite3.so", "lib/amalgalite/#{s}/", :verbose => true
50
+ end
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' )
41
55
  mv Dir["*.gem"].first, "pkg"
42
56
  end
43
57
 
58
+ task :clobber do
59
+ rm_rf 'lib/amalgalite/1.8'
60
+ rm_rf 'lib/amalgalite/1.9'
61
+ end
62
+
63
+ task :prep => [:clobber, :package, :package_win ]
64
+
44
65
  desc "distribute copiously"
45
- task :copious => [:package, :package_win] do
46
- gems = Amalgalite::SPECS.collect { |s| "#{s.full_name}.gem" }
47
- Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
66
+ task :copious => :prep do
67
+ gems = Amalgalite::SPECS.collect { |s| "#{s.full_name}.gem" }
68
+ Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
48
69
  '/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
49
70
  'pkg', *gems).upload
50
- sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
71
+ sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
51
72
  end
52
- end
73
+ end
53
74
  end
@@ -24,7 +24,7 @@ if ext_config = Configuration.for_if_exist?('extension') then
24
24
  end
25
25
 
26
26
  desc "Build the SQLite extension version #{current_sqlite_version}"
27
- task :build do
27
+ task :build => :clean do
28
28
  ext_config.configs.each do |extension|
29
29
  path = Pathname.new(extension)
30
30
  parts = path.split
@@ -36,33 +36,38 @@ if ext_config = Configuration.for_if_exist?('extension') then
36
36
  end
37
37
  end
38
38
 
39
- desc "Build the extensions for windows"
40
- task :build_win => :clobber do
41
- ext_config.configs.each do |extension|
42
- path = Pathname.new( extension )
39
+ def build_win( version = "1.8.6" )
40
+ ext_config = Configuration.for("extension")
41
+ rbconfig = ext_config.cross_rbconfig["rbconfig-#{version}"]
42
+ raise ArgumentError, "No cross compiler for version #{version}, we have #{ext_config.cross_rbconfig.keys.join(",")}" unless rbconfig
43
+ ruby_exe = if version =~ /1\.8/ then
44
+ "ruby"
45
+ else
46
+ "ruby1.9"
47
+ end
48
+ Amalgalite::GEM_SPEC.extensions.each do |extension|
49
+ path = Pathname.new(extension)
43
50
  parts = path.split
44
51
  conf = parts.last
45
- mingw_rbconfig = path.dirname.parent.realpath + "rbconfig-mingw.rb"
46
- Dir.chdir( path.dirname ) do |d|
47
- cp mingw_rbconfig, "rbconfig.rb"
48
- sh "ruby -I. extconf.rb"
52
+ Dir.chdir(path.dirname) do |d|
53
+ if File.exist?( "Makefile" ) then
54
+ sh "make clean distclean"
55
+ end
56
+ cp "#{rbconfig}", "rbconfig.rb"
57
+ sh "#{ruby_exe} -I. extconf.rb"
49
58
  sh "make"
50
- rm_f "rbconfig.rb"
51
59
  end
52
60
  end
53
61
  end
54
62
 
55
- desc "Build the extension for ruby1.9"
56
- task :build19 => :clobber do
57
- ext_config.configs.each do |extension|
58
- path = Pathname.new( extension )
59
- parts = path.split
60
- conf = parts.last
61
- Dir.chdir( path.dirname ) do |d|
62
- sh "ruby1.9 -I. extconf.rb"
63
- sh "make"
64
- end
65
-
63
+ win_builds = []
64
+ ext_config.cross_rbconfig.keys.each do |v|
65
+ s = v.split("-").last
66
+ desc "Build the extension for windows version #{s}"
67
+ win_bname = "build_win-#{s}"
68
+ win_builds << win_bname
69
+ task win_bname => :clean do
70
+ build_win( s )
66
71
  end
67
72
  end
68
73
 
@@ -72,8 +77,9 @@ if ext_config = Configuration.for_if_exist?('extension') then
72
77
  parts = path.split
73
78
  conf = parts.last
74
79
  Dir.chdir(path.dirname) do |d|
75
- #sh "rake clean"
76
- sh "make clean"
80
+ if File.exist?( "Makfeile" ) then
81
+ sh "make clean"
82
+ end
77
83
  rm_f "rbconfig.rb"
78
84
  end
79
85
  end
@@ -85,7 +91,6 @@ if ext_config = Configuration.for_if_exist?('extension') then
85
91
  parts = path.split
86
92
  conf = parts.last
87
93
  Dir.chdir(path.dirname) do |d|
88
- #sh "rake clobber"
89
94
  if File.exist?( "Makefile") then
90
95
  sh "make distclean"
91
96
  end
@@ -114,7 +119,7 @@ if ext_config = Configuration.for_if_exist?('extension') then
114
119
  tar.each_entry do |entry|
115
120
  bname = File.basename( entry.full_name )
116
121
  if upstream_files.include?( bname ) then
117
- dest_file = File.join( "ext", bname )
122
+ dest_file = File.join( "ext", "amalgalite", bname )
118
123
  puts "updating #{ dest_file }"
119
124
  File.open( dest_file, "wb" ) do |df|
120
125
  while bytes = entry.read do
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.9.0
4
+ version: 0.10.0
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-04-05 00:00:00 -06:00
12
+ date: 2009-06-28 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,12 +52,22 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: 1.2.2
54
54
  version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: 0.5.0
64
+ version:
55
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.
56
66
  email: jeremy@hinegardner.org
57
67
  executables:
58
68
  - amalgalite-pack
59
69
  extensions:
60
- - ext/extconf.rb
70
+ - ext/amalgalite/extconf.rb
61
71
  extra_rdoc_files:
62
72
  - README
63
73
  - HISTORY
@@ -96,27 +106,21 @@ extra_rdoc_files:
96
106
  - lib/amalgalite/version.rb
97
107
  - lib/amalgalite/view.rb
98
108
  - lib/amalgalite.rb
99
- - ext/amalgalite3.c
100
- - ext/amalgalite3_blob.c
101
- - ext/amalgalite3_constants.c
102
- - ext/amalgalite3_database.c
103
- - ext/amalgalite3_requires_bootstrap.c
104
- - ext/amalgalite3_statement.c
105
109
  files:
106
110
  - bin/amalgalite-pack
107
- - ext/amalgalite3.c
108
- - ext/amalgalite3_blob.c
109
- - ext/amalgalite3_constants.c
110
- - ext/amalgalite3_database.c
111
- - ext/amalgalite3_requires_bootstrap.c
112
- - ext/amalgalite3_statement.c
113
- - ext/sqlite3.c
114
- - ext/amalgalite3.h
115
- - ext/sqlite3.h
116
- - ext/sqlite3_options.h
117
- - ext/sqlite3ext.h
118
- - ext/extconf.rb
119
- - ext/gen_constants.rb
111
+ - ext/amalgalite/amalgalite3.c
112
+ - ext/amalgalite/amalgalite3_blob.c
113
+ - ext/amalgalite/amalgalite3_constants.c
114
+ - ext/amalgalite/amalgalite3_database.c
115
+ - ext/amalgalite/amalgalite3_requires_bootstrap.c
116
+ - ext/amalgalite/amalgalite3_statement.c
117
+ - ext/amalgalite/sqlite3.c
118
+ - ext/amalgalite/amalgalite3.h
119
+ - ext/amalgalite/sqlite3.h
120
+ - ext/amalgalite/sqlite3_options.h
121
+ - ext/amalgalite/sqlite3ext.h
122
+ - ext/amalgalite/extconf.rb
123
+ - ext/amalgalite/gen_constants.rb
120
124
  - examples/a.rb
121
125
  - examples/blob.rb
122
126
  - examples/bootstrap.rb
@@ -1,23 +0,0 @@
1
- require 'mkmf'
2
- require 'rbconfig'
3
-
4
- # make available table and column meta data api
5
- $CFLAGS += " -DSQLITE_ENABLE_COLUMN_METADATA=1"
6
- $CFLAGS += " -DSQLITE_ENABLE_RTREE=1"
7
- $CFLAGS += " -DSQLITE_OMIT_BUILTIN_TEST=1"
8
-
9
- # we compile sqlite the same way that the installation of ruby is compiled.
10
- if Config::CONFIG['configure_args'].include?( "--enable-pthread" ) then
11
- $CFLAGS += " -DSQLITE_THREADSAFE=1"
12
- else
13
- $CFLAGS += " -DSQLITE_THREADSAFE=0"
14
- end
15
-
16
- # remove the -g if it exists
17
- $CFLAGS = $CFLAGS.gsub(/-g/,'')
18
-
19
- # remove -Wall if it exists
20
- $CFLAGS = $CFLAGS.gsub(/-Wall/,'')
21
- #$CFLAGS += " -Wall"
22
-
23
- create_makefile('amalgalite3')