amalgalite 0.4.2-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/HISTORY +81 -0
  2. data/LICENSE +29 -0
  3. data/README +40 -0
  4. data/bin/amalgalite-pack-into-db +155 -0
  5. data/examples/a.rb +9 -0
  6. data/examples/blob.rb +105 -0
  7. data/examples/bootstrap.rb +36 -0
  8. data/examples/gem-db.rb +94 -0
  9. data/examples/requires.rb +54 -0
  10. data/examples/schema-info.rb +34 -0
  11. data/ext/amalgalite3.c +201 -0
  12. data/ext/amalgalite3.h +121 -0
  13. data/ext/amalgalite3_blob.c +241 -0
  14. data/ext/amalgalite3_constants.c +221 -0
  15. data/ext/amalgalite3_database.c +550 -0
  16. data/ext/amalgalite3_requires_bootstrap.c +210 -0
  17. data/ext/amalgalite3_statement.c +628 -0
  18. data/ext/extconf.rb +19 -0
  19. data/ext/gen_constants.rb +130 -0
  20. data/ext/rbconfig-mingw.rb +178 -0
  21. data/ext/sqlite3.c +97092 -0
  22. data/ext/sqlite3.h +6364 -0
  23. data/ext/sqlite3_options.h +4 -0
  24. data/ext/sqlite3ext.h +372 -0
  25. data/gemspec.rb +55 -0
  26. data/lib/amalgalite.rb +33 -0
  27. data/lib/amalgalite/blob.rb +186 -0
  28. data/lib/amalgalite/boolean.rb +42 -0
  29. data/lib/amalgalite/column.rb +86 -0
  30. data/lib/amalgalite/core_ext/kernel/require.rb +14 -0
  31. data/lib/amalgalite/database.rb +514 -0
  32. data/lib/amalgalite/index.rb +43 -0
  33. data/lib/amalgalite/paths.rb +70 -0
  34. data/lib/amalgalite/profile_tap.rb +130 -0
  35. data/lib/amalgalite/requires.rb +112 -0
  36. data/lib/amalgalite/schema.rb +115 -0
  37. data/lib/amalgalite/sqlite3.rb +6 -0
  38. data/lib/amalgalite/sqlite3/constants.rb +82 -0
  39. data/lib/amalgalite/sqlite3/database/status.rb +69 -0
  40. data/lib/amalgalite/sqlite3/status.rb +61 -0
  41. data/lib/amalgalite/sqlite3/version.rb +38 -0
  42. data/lib/amalgalite/statement.rb +394 -0
  43. data/lib/amalgalite/table.rb +36 -0
  44. data/lib/amalgalite/taps.rb +2 -0
  45. data/lib/amalgalite/taps/console.rb +27 -0
  46. data/lib/amalgalite/taps/io.rb +71 -0
  47. data/lib/amalgalite/trace_tap.rb +35 -0
  48. data/lib/amalgalite/type_map.rb +63 -0
  49. data/lib/amalgalite/type_maps/default_map.rb +167 -0
  50. data/lib/amalgalite/type_maps/storage_map.rb +41 -0
  51. data/lib/amalgalite/type_maps/text_map.rb +23 -0
  52. data/lib/amalgalite/version.rb +37 -0
  53. data/lib/amalgalite/view.rb +26 -0
  54. data/lib/amalgalite3.so +0 -0
  55. data/spec/amalgalite_spec.rb +4 -0
  56. data/spec/blob_spec.rb +81 -0
  57. data/spec/boolean_spec.rb +23 -0
  58. data/spec/database_spec.rb +238 -0
  59. data/spec/default_map_spec.rb +87 -0
  60. data/spec/integeration_spec.rb +111 -0
  61. data/spec/paths_spec.rb +28 -0
  62. data/spec/schema_spec.rb +60 -0
  63. data/spec/spec_helper.rb +25 -0
  64. data/spec/sqlite3/constants_spec.rb +65 -0
  65. data/spec/sqlite3/database_status_spec.rb +36 -0
  66. data/spec/sqlite3/status_spec.rb +18 -0
  67. data/spec/sqlite3/version_spec.rb +14 -0
  68. data/spec/sqlite3_spec.rb +23 -0
  69. data/spec/statement_spec.rb +134 -0
  70. data/spec/storage_map_spec.rb +41 -0
  71. data/spec/tap_spec.rb +59 -0
  72. data/spec/text_map_spec.rb +23 -0
  73. data/spec/type_map_spec.rb +17 -0
  74. data/spec/version_spec.rb +9 -0
  75. data/tasks/announce.rake +39 -0
  76. data/tasks/config.rb +110 -0
  77. data/tasks/distribution.rake +53 -0
  78. data/tasks/documentation.rake +33 -0
  79. data/tasks/extension.rake +100 -0
  80. data/tasks/rspec.rake +32 -0
  81. data/tasks/rubyforge.rake +59 -0
  82. data/tasks/utils.rb +80 -0
  83. metadata +192 -0
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
+ require 'amalgalite/type_maps/storage_map'
6
+
7
+ describe Amalgalite::TypeMaps::StorageMap do
8
+ before(:each) do
9
+ @map = Amalgalite::TypeMaps::StorageMap.new
10
+ end
11
+
12
+ describe "#bind_type_of" do
13
+
14
+ it "Float is bound to DataType::FLOAT" do
15
+ @map.bind_type_of( 3.14 ).should == ::Amalgalite::SQLite3::Constants::DataType::FLOAT
16
+ end
17
+
18
+ it "Fixnum is bound to DataType::INTGER" do
19
+ @map.bind_type_of( 42 ).should == ::Amalgalite::SQLite3::Constants::DataType::INTEGER
20
+ end
21
+
22
+ it "nil is bound to DataType::NULL" do
23
+ @map.bind_type_of( nil ).should == ::Amalgalite::SQLite3::Constants::DataType::NULL
24
+ end
25
+
26
+ it "::Amalgalite::Blob is bound to DataType::BLOB" do
27
+ @map.bind_type_of( ::Amalgalite::Blob.new( :string => "testing mapping", :column => true ) ).should == ::Amalgalite::SQLite3::Constants::DataType::BLOB
28
+ end
29
+
30
+ it "everything else is bound to DataType::TEXT" do
31
+ @map.bind_type_of( "everything else" ).should == ::Amalgalite::SQLite3::Constants::DataType::TEXT
32
+ end
33
+
34
+ end
35
+
36
+ describe "#result_value_of" do
37
+ it "returns the original object for everything passed in" do
38
+ @map.result_value_of( "doesn't matter", 42 ).should == 42
39
+ end
40
+ end
41
+ end
data/spec/tap_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
+ require 'amalgalite'
6
+ require 'amalgalite/trace_tap'
7
+ require 'amalgalite/profile_tap'
8
+ require 'amalgalite/taps/console'
9
+ require 'stringio'
10
+
11
+ describe Amalgalite::TraceTap do
12
+ it "wraps up an object and delegates the 'trace' method to a method on that object" do
13
+ s = StringIO.new
14
+ tt = ::Amalgalite::TraceTap.new( s, 'puts' )
15
+ tt.trace('test trace')
16
+ s.string.should == "test trace\n"
17
+ end
18
+
19
+ it "raises an error if an the wrapped object does not respond to the indicated method" do
20
+ lambda{ ::Amalgalite::TraceTap.new( Object.new ) }.should raise_error( Amalgalite::Error )
21
+ end
22
+ end
23
+
24
+ describe Amalgalite::ProfileTap do
25
+ it "raises an error if an the wrapped object does not respond to the indicated method" do
26
+ lambda{ ::Amalgalite::ProfileTap.new( Object.new ) }.should raise_error( Amalgalite::Error )
27
+ end
28
+ end
29
+
30
+ describe Amalgalite::Taps::StringIO do
31
+ it "dumps profile information" do
32
+ s = ::Amalgalite::Taps::StringIO.new
33
+ s.profile( 'test', 42 )
34
+ s.dump_profile
35
+ s.string.should == "42 : test\ntest[test] => sum: 42, sumsq: 1764, n: 1, mean: 42.000000, stddev: 0.000000, min: 42, max: 42\n"
36
+ end
37
+
38
+ it "has a stdout tap" do
39
+ s = ::Amalgalite::Taps::Stdout.new
40
+ end
41
+
42
+ it "has a stderr tap" do
43
+ s = ::Amalgalite::Taps::Stderr.new
44
+ end
45
+ end
46
+
47
+ describe Amalgalite::ProfileSampler do
48
+ it "aggregates samples" do
49
+ s = Amalgalite::ProfileSampler.new( 'test1' )
50
+ s.sample( 42 )
51
+ s.sample( 84 )
52
+ s.sample( 21 )
53
+ h = s.to_h
54
+ h['min'].should == 21
55
+ h['max'].should == 84
56
+ h['mean'].should == 49
57
+ h['n'].should == 3
58
+ end
59
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
+ require 'amalgalite/type_maps/text_map'
6
+
7
+ describe Amalgalite::TypeMaps::TextMap do
8
+ before(:each) do
9
+ @map = Amalgalite::TypeMaps::TextMap.new
10
+ end
11
+
12
+ describe "#bind_type_of" do
13
+ it "returnes text for everything" do
14
+ @map.bind_type_of( 3.14 ).should == ::Amalgalite::SQLite3::Constants::DataType::TEXT
15
+ end
16
+ end
17
+
18
+ describe "#result_value_of" do
19
+ it "returns the string value of the object for everything passed in" do
20
+ @map.result_value_of( "doesn't matter", 42 ).should == "42"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
+ require 'amalgalite/type_map'
6
+
7
+ describe Amalgalite::TypeMap do
8
+ it "#bind_type_of raises NotImplemented error" do
9
+ tm = Amalgalite::TypeMap.new
10
+ lambda { tm.bind_type_of( Object.new ) }.should raise_error( NotImplementedError )
11
+ end
12
+
13
+ it "#result_value_of raises NotImplemented error" do
14
+ tm = Amalgalite::TypeMap.new
15
+ lambda { tm.result_value_of( "foo", Object.new ) }.should raise_error( NotImplementedError )
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
2
+ require 'amalgalite/version'
3
+
4
+ describe "Amalgalite::Version" do
5
+ it "should have a version string" do
6
+ Amalgalite::Version.to_s.should =~ /\d+\.\d+\.\d+/
7
+ Amalgalite::VERSION.should =~ /\d+\.\d+\.\d+/
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ require 'tasks/config'
2
+ #-------------------------------------------------------------------------------
3
+ # announcement methods
4
+ #-------------------------------------------------------------------------------
5
+
6
+ proj_config = Configuration.for('project')
7
+ namespace :announce do
8
+ desc "create email for ruby-talk"
9
+ task :email do
10
+ info = Utils.announcement
11
+
12
+ File.open("email.txt", "w") do |mail|
13
+ mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
14
+ mail.puts "To: ruby-talk@ruby-lang.org"
15
+ mail.puts "Date: #{Time.now.rfc2822}"
16
+ mail.puts "Subject: [ANN] #{info[:subject]}"
17
+ mail.puts
18
+ mail.puts info[:title]
19
+ mail.puts
20
+ mail.puts " gem install #{Amalgalite::GEM_SPEC.name}"
21
+ mail.puts
22
+ mail.puts info[:urls]
23
+ mail.puts
24
+ mail.puts info[:description]
25
+ mail.puts
26
+ mail.puts "{{ Release notes for Version #{Amalgalite::VERSION} }}"
27
+ mail.puts
28
+ mail.puts info[:release_notes]
29
+ mail.puts
30
+ end
31
+ puts "Created the following as email.txt:"
32
+ puts "-" * 72
33
+ puts File.read("email.txt")
34
+ puts "-" * 72
35
+ end
36
+
37
+ CLOBBER << "email.txt"
38
+ end
39
+
data/tasks/config.rb ADDED
@@ -0,0 +1,110 @@
1
+ require 'configuration'
2
+
3
+ require 'rake'
4
+ require 'tasks/utils'
5
+
6
+ #-----------------------------------------------------------------------
7
+ # General project configuration
8
+ #-----------------------------------------------------------------------
9
+ Configuration.for('project') {
10
+ name "amalgalite"
11
+ version Amalgalite::Version.to_s
12
+ author "Jeremy Hinegardner"
13
+ email "jeremy at copiousfreetime dot org"
14
+ homepage "http://copiousfreetime.rubyforge.org/amalgalite/"
15
+ description Utils.section_of("README", "description")
16
+ summary description.split(".").first
17
+ history "HISTORY"
18
+ license FileList["LICENSE"]
19
+ readme "README"
20
+ }
21
+
22
+ #-----------------------------------------------------------------------
23
+ # Packaging
24
+ #-----------------------------------------------------------------------
25
+ Configuration.for('packaging') {
26
+ # files in the project
27
+ proj_conf = Configuration.for('project')
28
+ files {
29
+ bin FileList["bin/*"]
30
+ ext FileList["ext/*.{c,h,rb}"]
31
+ examples FileList["examples/*"]
32
+ lib FileList["lib/**/*.rb"]
33
+ test FileList["spec/**/*.rb", "test/**/*.rb"]
34
+ data FileList["data/**/*"]
35
+ tasks FileList["tasks/**/*.r{ake,b}"]
36
+ rdoc FileList[proj_conf.readme, proj_conf.history,
37
+ proj_conf.license] + lib + FileList["ext/amalgalite3*.c"]
38
+ all bin + ext + examples + lib + test + data + rdoc + tasks
39
+ }
40
+
41
+ puts "ext files = #{files.ext}"
42
+
43
+ # ways to package the results
44
+ formats {
45
+ tgz true
46
+ zip true
47
+ gem Configuration::Table.has_key?('gem')
48
+ }
49
+ }
50
+
51
+ #-----------------------------------------------------------------------
52
+ # Gem packaging
53
+ #-----------------------------------------------------------------------
54
+ Configuration.for("gem") {
55
+ spec "gemspec.rb"
56
+ Configuration.for('packaging').files.all << spec
57
+ }
58
+
59
+ #-----------------------------------------------------------------------
60
+ # Testing
61
+ # - change mode to 'testunit' to use unit testing
62
+ #-----------------------------------------------------------------------
63
+ Configuration.for('test') {
64
+ mode "spec"
65
+ files Configuration.for("packaging").files.test
66
+ options %w[ --format specdoc --color ]
67
+ ruby_opts %w[ ]
68
+ }
69
+
70
+ #-----------------------------------------------------------------------
71
+ # Rcov
72
+ #-----------------------------------------------------------------------
73
+ Configuration.for('rcov') {
74
+ output_dir "coverage"
75
+ libs %w[ lib ]
76
+ rcov_opts %w[ --html ]
77
+ ruby_opts %w[ ]
78
+ test_files Configuration.for('packaging').files.test
79
+ }
80
+
81
+ #-----------------------------------------------------------------------
82
+ # Rdoc
83
+ #-----------------------------------------------------------------------
84
+ Configuration.for('rdoc') {
85
+ files Configuration.for('packaging').files.rdoc
86
+ main_page files.first
87
+ title Configuration.for('project').name
88
+ options %w[ --line-numbers --inline-source ] #-f darkfish ]
89
+ output_dir "doc"
90
+ }
91
+
92
+ #-----------------------------------------------------------------------
93
+ # Extensions
94
+ #-----------------------------------------------------------------------
95
+ Configuration.for('extension') {
96
+ #configs Configuration.for('packaging').files.ext.find_all { |x| %w[ mkrf_conf.rb extconf.rb ].include?(File.basename(x)) }
97
+ configs Configuration.for('packaging').files.ext.find_all { |x| %w[ extconf.rb ].include?(File.basename(x)) }
98
+ }
99
+
100
+ #-----------------------------------------------------------------------
101
+ # Rubyforge
102
+ #-----------------------------------------------------------------------
103
+ Configuration.for('rubyforge') {
104
+ project "copiousfreetime"
105
+ user "jjh"
106
+ host "rubyforge.org"
107
+ rdoc_location "#{user}@#{host}:/var/www/gforge-projects/#{project}/amalgalite/"
108
+ }
109
+
110
+
@@ -0,0 +1,53 @@
1
+ require 'tasks/config'
2
+
3
+ #-------------------------------------------------------------------------------
4
+ # Distribution and Packaging
5
+ #-------------------------------------------------------------------------------
6
+ if pkg_config = Configuration.for_if_exist?("packaging") then
7
+
8
+ require 'gemspec'
9
+ require 'rake/gempackagetask'
10
+ require 'rake/contrib/sshpublisher'
11
+
12
+ namespace :dist do
13
+
14
+ Rake::GemPackageTask.new(Amalgalite::GEM_SPEC) do |pkg|
15
+ pkg.need_tar = pkg_config.formats.tgz
16
+ pkg.need_zip = pkg_config.formats.zip
17
+ end
18
+
19
+ desc "Install as a gem"
20
+ task :install => [:clobber, :package] do
21
+ sh "sudo gem install --local pkg/#{Amalgalite::GEM_SPEC.full_name}.gem"
22
+ end
23
+
24
+ desc "Uninstall gem"
25
+ task :uninstall do
26
+ sh "sudo gem uninstall -i #{Amalgalite::GEM_SPEC.name} -x"
27
+ end
28
+
29
+ desc "dump gemspec"
30
+ task :gemspec do
31
+ puts Amalgalite::GEM_SPEC.to_ruby
32
+ end
33
+
34
+ desc "reinstall gem"
35
+ task :reinstall => [:uninstall, :repackage, :install]
36
+
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
41
+ mv Dir["*.gem"].first, "pkg"
42
+ end
43
+
44
+ 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',
48
+ '/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
49
+ 'pkg', *gems).upload
50
+ sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,33 @@
1
+ require 'tasks/config'
2
+
3
+ #-----------------------------------------------------------------------
4
+ # Documentation
5
+ #-----------------------------------------------------------------------
6
+
7
+ if rdoc_config = Configuration.for_if_exist?('rdoc') then
8
+
9
+ namespace :doc do
10
+
11
+ require 'rake/rdoctask'
12
+ #gem 'darkfish-rdoc'
13
+ #require 'darkfish-rdoc'
14
+
15
+ # generating documentation locally
16
+ Rake::RDocTask.new do |rdoc|
17
+ rdoc.rdoc_dir = rdoc_config.output_dir
18
+ rdoc.options = rdoc_config.options
19
+ rdoc.rdoc_files = rdoc_config.files
20
+ rdoc.title = rdoc_config.title
21
+ rdoc.main = rdoc_config.main_page
22
+ end
23
+
24
+ if rubyforge_config = Configuration.for_if_exist?('rubyforge') then
25
+ desc "Deploy the RDoc documentation to #{rubyforge_config.rdoc_location}"
26
+ task :deploy => :rerdoc do
27
+ sh "rsync -zav --delete #{rdoc_config.output_dir}/ #{rubyforge_config.rdoc_location}"
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,100 @@
1
+ require 'tasks/config'
2
+ require 'pathname'
3
+ require 'zlib'
4
+ require 'archive/tar/minitar'
5
+
6
+ #-----------------------------------------------------------------------
7
+ # Extensions
8
+ #-----------------------------------------------------------------------
9
+
10
+ if ext_config = Configuration.for_if_exist?('extension') then
11
+ namespace :ext do
12
+ desc "Build the extension(s)"
13
+ task :build do
14
+ ext_config.configs.each do |extension|
15
+ path = Pathname.new(extension)
16
+ parts = path.split
17
+ conf = parts.last
18
+ Dir.chdir(path.dirname) do |d|
19
+ ruby conf.to_s
20
+ #sh "rake default"
21
+ sh "make"
22
+ end
23
+ end
24
+ end
25
+
26
+ desc "Build the extensions for windows"
27
+ task :build_win => :clobber do
28
+ ext_config.configs.each do |extension|
29
+ path = Pathname.new( extension )
30
+ parts = path.split
31
+ conf = parts.last
32
+ Dir.chdir( path.dirname ) do |d|
33
+ cp "rbconfig-mingw.rb", "rbconfig.rb"
34
+ sh "ruby -I. extconf.rb"
35
+ sh "make"
36
+ rm_f "rbconfig.rb"
37
+ end
38
+ end
39
+ end
40
+
41
+ task :clean do
42
+ ext_config.configs.each do |extension|
43
+ path = Pathname.new(extension)
44
+ parts = path.split
45
+ conf = parts.last
46
+ Dir.chdir(path.dirname) do |d|
47
+ #sh "rake clean"
48
+ sh "make clean"
49
+ rm_f "rbconfig.rb"
50
+ end
51
+ end
52
+ end
53
+
54
+ task :clobber do
55
+ ext_config.configs.each do |extension|
56
+ path = Pathname.new(extension)
57
+ parts = path.split
58
+ conf = parts.last
59
+ Dir.chdir(path.dirname) do |d|
60
+ #sh "rake clobber"
61
+ if File.exist?( "Makefile") then
62
+ sh "make distclean"
63
+ end
64
+ rm_f "rbconfig.rb"
65
+ end
66
+ end
67
+ end
68
+
69
+ desc "Download and integrate the next version of sqlite"
70
+ task :update_sqlite do
71
+ next_version = ENV['VERSION']
72
+ puts "downloading ..."
73
+ url = URI.parse("http://sqlite.org/sqlite-amalgamation-#{next_version}.tar.gz")
74
+ file = "tmp/#{File.basename( url.path ) }"
75
+ File.open( file, "wb+") do |f|
76
+ res = Net::HTTP.get_response( url )
77
+ f.write( res.body )
78
+ end
79
+
80
+ puts "extracting..."
81
+ upstream_files = %w[ sqlite3.h sqlite3.c sqlite3ext.h ]
82
+ Zlib::GzipReader.open( file ) do |tgz|
83
+ Archive::Tar::Minitar::Reader.open( tgz ) do |tar|
84
+ tar.each_entry do |entry|
85
+ bname = File.basename( entry.full_name )
86
+ if upstream_files.include?( bname ) then
87
+ dest_file = File.join( "ext", bname )
88
+ puts "updating #{ dest_file }"
89
+ File.open( dest_file, "wb" ) do |df|
90
+ while bytes = entry.read do
91
+ df.write bytes
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end