amalgalite 0.10.1-x86-mingw32

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.
Files changed (100) hide show
  1. data/HISTORY +201 -0
  2. data/LICENSE +29 -0
  3. data/README +51 -0
  4. data/bin/amalgalite-pack +126 -0
  5. data/examples/a.rb +9 -0
  6. data/examples/blob.rb +88 -0
  7. data/examples/bootstrap.rb +36 -0
  8. data/examples/define_aggregate.rb +75 -0
  9. data/examples/define_function.rb +104 -0
  10. data/examples/gem-db.rb +94 -0
  11. data/examples/gems.db +0 -0
  12. data/examples/require_me.rb +11 -0
  13. data/examples/requires.rb +42 -0
  14. data/examples/schema-info.rb +34 -0
  15. data/ext/amalgalite/amalgalite3.c +290 -0
  16. data/ext/amalgalite/amalgalite3.h +151 -0
  17. data/ext/amalgalite/amalgalite3_blob.c +240 -0
  18. data/ext/amalgalite/amalgalite3_constants.c +221 -0
  19. data/ext/amalgalite/amalgalite3_database.c +1148 -0
  20. data/ext/amalgalite/amalgalite3_requires_bootstrap.c +210 -0
  21. data/ext/amalgalite/amalgalite3_statement.c +639 -0
  22. data/ext/amalgalite/extconf.rb +36 -0
  23. data/ext/amalgalite/gen_constants.rb +130 -0
  24. data/ext/amalgalite/sqlite3.c +106729 -0
  25. data/ext/amalgalite/sqlite3.h +5626 -0
  26. data/ext/amalgalite/sqlite3_options.h +4 -0
  27. data/ext/amalgalite/sqlite3ext.h +380 -0
  28. data/gemspec.rb +60 -0
  29. data/lib/amalgalite.rb +43 -0
  30. data/lib/amalgalite/1.8/amalgalite3.so +0 -0
  31. data/lib/amalgalite/1.9/amalgalite3.so +0 -0
  32. data/lib/amalgalite/aggregate.rb +67 -0
  33. data/lib/amalgalite/blob.rb +186 -0
  34. data/lib/amalgalite/boolean.rb +42 -0
  35. data/lib/amalgalite/busy_timeout.rb +47 -0
  36. data/lib/amalgalite/column.rb +97 -0
  37. data/lib/amalgalite/core_ext/kernel/require.rb +21 -0
  38. data/lib/amalgalite/database.rb +947 -0
  39. data/lib/amalgalite/function.rb +61 -0
  40. data/lib/amalgalite/index.rb +43 -0
  41. data/lib/amalgalite/packer.rb +226 -0
  42. data/lib/amalgalite/paths.rb +70 -0
  43. data/lib/amalgalite/profile_tap.rb +131 -0
  44. data/lib/amalgalite/progress_handler.rb +21 -0
  45. data/lib/amalgalite/requires.rb +120 -0
  46. data/lib/amalgalite/schema.rb +191 -0
  47. data/lib/amalgalite/sqlite3.rb +6 -0
  48. data/lib/amalgalite/sqlite3/constants.rb +80 -0
  49. data/lib/amalgalite/sqlite3/database/function.rb +48 -0
  50. data/lib/amalgalite/sqlite3/database/status.rb +68 -0
  51. data/lib/amalgalite/sqlite3/status.rb +60 -0
  52. data/lib/amalgalite/sqlite3/version.rb +37 -0
  53. data/lib/amalgalite/statement.rb +414 -0
  54. data/lib/amalgalite/table.rb +90 -0
  55. data/lib/amalgalite/taps.rb +2 -0
  56. data/lib/amalgalite/taps/console.rb +27 -0
  57. data/lib/amalgalite/taps/io.rb +71 -0
  58. data/lib/amalgalite/trace_tap.rb +35 -0
  59. data/lib/amalgalite/type_map.rb +63 -0
  60. data/lib/amalgalite/type_maps/default_map.rb +167 -0
  61. data/lib/amalgalite/type_maps/storage_map.rb +40 -0
  62. data/lib/amalgalite/type_maps/text_map.rb +22 -0
  63. data/lib/amalgalite/version.rb +37 -0
  64. data/lib/amalgalite/view.rb +26 -0
  65. data/spec/aggregate_spec.rb +169 -0
  66. data/spec/amalgalite_spec.rb +4 -0
  67. data/spec/blob_spec.rb +81 -0
  68. data/spec/boolean_spec.rb +23 -0
  69. data/spec/busy_handler.rb +165 -0
  70. data/spec/database_spec.rb +494 -0
  71. data/spec/default_map_spec.rb +87 -0
  72. data/spec/function_spec.rb +94 -0
  73. data/spec/integeration_spec.rb +111 -0
  74. data/spec/packer_spec.rb +60 -0
  75. data/spec/paths_spec.rb +28 -0
  76. data/spec/progress_handler_spec.rb +105 -0
  77. data/spec/requires_spec.rb +23 -0
  78. data/spec/rtree_spec.rb +71 -0
  79. data/spec/schema_spec.rb +120 -0
  80. data/spec/spec_helper.rb +27 -0
  81. data/spec/sqlite3/constants_spec.rb +65 -0
  82. data/spec/sqlite3/database_status_spec.rb +36 -0
  83. data/spec/sqlite3/status_spec.rb +18 -0
  84. data/spec/sqlite3/version_spec.rb +14 -0
  85. data/spec/sqlite3_spec.rb +53 -0
  86. data/spec/statement_spec.rb +161 -0
  87. data/spec/storage_map_spec.rb +41 -0
  88. data/spec/tap_spec.rb +59 -0
  89. data/spec/text_map_spec.rb +23 -0
  90. data/spec/type_map_spec.rb +17 -0
  91. data/spec/version_spec.rb +15 -0
  92. data/tasks/announce.rake +43 -0
  93. data/tasks/config.rb +107 -0
  94. data/tasks/distribution.rake +77 -0
  95. data/tasks/documentation.rake +32 -0
  96. data/tasks/extension.rake +141 -0
  97. data/tasks/rspec.rake +33 -0
  98. data/tasks/rubyforge.rake +59 -0
  99. data/tasks/utils.rb +80 -0
  100. metadata +237 -0
data/HISTORY ADDED
@@ -0,0 +1,201 @@
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
+
10
+ == Version 0.10.0 - 2009-06-28
11
+
12
+ === Enhancements
13
+
14
+ * windows gem is now a fat binary to support installing into ruby 1.8 and 1.9
15
+ from the same gem
16
+ * Update to Sqlite 3.6.16 and fix errors returned by define_aggregate and
17
+ define_function based upon update
18
+
19
+ == Version 0.9.0 - 2009-04-05
20
+
21
+ === Enhancements
22
+
23
+ * Ruby 1.9 compatibility
24
+ * Update to SQLite 3.6.12
25
+ * Added support for the new SQLite Backup API, see Amalgalite::Database#replicate_to
26
+ * Added exclusive/immediate/deferred transaction helpers
27
+
28
+ == Version 0.8.0 - 2009-03-23
29
+
30
+ === Enhancements
31
+
32
+ * Add in support for obtaining limited schema information on temporary tables
33
+ and indexes
34
+ * Add support for returning the primary key columns of a table
35
+ * Other miscellaneous items to support the ActiveRecord adapter
36
+
37
+ == Version 0.7.7 - 2009-03-03
38
+
39
+ === Bug Fixes
40
+
41
+ * roll back to SQLite 3.6.10 because of substr() bug in 3.6.11
42
+
43
+ == Version 0.7.6 - 2009-03-02
44
+
45
+ === Enhancements
46
+
47
+ * Update to SQLite 3.6.11
48
+
49
+ === Bug Fixes
50
+
51
+ * fix issues with the wrong error message appearing in statement closing
52
+ * incorrectly raise an exception if a transaction is started when rescuing an
53
+ exception [reported by James Edwared Gray II]
54
+
55
+ == Version 0.7.5 - 2009-02-12
56
+
57
+ === Bug Fixes
58
+
59
+ * another ruby -w pass to clear up warnings
60
+ * force all tests to run with -w turned on
61
+
62
+ == Version 0.7.4 - 2009-02-08
63
+
64
+ === Bug Fixes
65
+
66
+ * fix Database#first_row_from not behaving the same as Database#execute() when
67
+ there are no results. [reported by James Edward Gray II]
68
+
69
+ == Version 0.7.3 - 2009-02-08
70
+
71
+ === Enhancements
72
+
73
+ * added Database#first_row_from
74
+ * added Database#first_value_from
75
+
76
+ === Bug Fixes
77
+
78
+ * clean up ruby warnings when run with -w
79
+ * fix documenation on Database#execute
80
+
81
+ == Version 0.7.2 - 2009-01-24
82
+ === Enhancements
83
+
84
+ * added quoting and escaping of text support, used for database drivers
85
+ * added ability to access columns of the schame in original definition order
86
+
87
+ == Version 0.7.1 - 2009-01-18
88
+
89
+ === Enhancements
90
+
91
+ * added support for sqlite's nexted transactions which appeared in sqlite
92
+ * update to SQLite version 3.6.10
93
+ * added ability to set the SQLite temporary directory
94
+ * added amalgalite-pack --require-order
95
+
96
+ === Bug Fixes
97
+
98
+ * fix exception when accessing the special 'rowid' column
99
+ * fix internal require order list for use in packing
100
+
101
+ == Version 0.6.0 - 2009-01-10
102
+
103
+ === Enhancements
104
+
105
+ * Added ability to define custom SQL functions implemented in Ruby
106
+ * Added ability to define custom SQL aggregates implemented in Ruby
107
+ * Added support for Ruby busy handlers
108
+ * Added database 'interrupt' support
109
+ * Added support for Ruby progress handlers
110
+ * update to SQLite version 3.6.7
111
+
112
+ == Version 0.5.1 - 2008-11-30
113
+
114
+ === Enhancements
115
+
116
+ * update to SQLite version 3.6.6.2
117
+
118
+ == Version 0.5.0 - 2008-11-16
119
+
120
+ === Enhancements
121
+
122
+ * amalgalite-pack-into-db has been reworked into amalgalite-pack
123
+ * ruby code that is packed into a database for later requiring can now be
124
+ compressed
125
+ * update to SQLite version 3.6.5
126
+
127
+ == Version 0.4.2 - 2008-10-12
128
+
129
+ === Enhancements
130
+
131
+ * release of windows gem
132
+
133
+ == Version 0.4.1 - 2008-09-28
134
+
135
+ === Enhancements
136
+
137
+ * update to SQLite3 version 3.6.3
138
+ * change rdoc template to darkfish
139
+
140
+ == Version 0.4.0 - 2008-09-14
141
+
142
+ === Enhancements
143
+ * update to SQLite3 version 3.6.2 and enable the RTree option by default
144
+ * Amalgalite::Requires module allowing ruby code to be 'required' from columns in an SQLite database
145
+ * Amagalite::Requires::Bootstrap extension module enabling low level boot
146
+ strapping of the pure ruby Amalgalite code from an sqlite database
147
+ * more indepth information about indexes is available via the Index class
148
+ * add support for sqlite3_status and sqlite3_db_status information
149
+
150
+ === Bugfixes
151
+
152
+ * fix nil exception when using a declared_data_type on primary key column that
153
+ has no declared_data_type
154
+ * when Database#transaction is passed a block, the return value is the return
155
+ value of the block
156
+ * nested transactions are 'faked'. Calling Database#transaction while
157
+ Databased#in_transaction? is true does not result in an exception, but
158
+ continues on in the current transaction.
159
+ * raise LoadError if required in the same program as sqlite3-ruby. These
160
+ libraries conflict with each other.
161
+
162
+ == Version 0.2.4 - 2008-07-13
163
+
164
+ === Bugfixes
165
+ * fix compilation when ruby is compiled without pthreads using
166
+
167
+ == Version 0.2.3 - 2008-07-12
168
+
169
+ === Bugfixes
170
+ * make sure file permissions are all read before shipping gem
171
+
172
+ == Version 0.2.2 - 2008-07-12
173
+
174
+ === Bugfixes
175
+ * Database#pragma should accept a block just like Database#execute does
176
+ * convert to using extconf.rb instead of mkrf to enable compilation as a
177
+ direct ruby extension in the ruby source tree
178
+
179
+ == Version 0.2.1 - 2008-07-05
180
+
181
+ === Bugfixes
182
+ * make sure that the pthread support in sqlite3 matches that of ruby
183
+ * fix schema reloading in the example scripts
184
+
185
+ == Version 0.2.0 - 2008-07-04
186
+
187
+ === Enhancements
188
+ * blob support, both incremental access and normal access
189
+ * added examples/gem_db.rb script demonstrating taps and prepared statements
190
+ * added examples/schema-info.rb script demonstrating meta information
191
+ * added examples/blob.rb demonstrating incremental blob IO
192
+ * added access to the SQLite3 errcode and errmsg api
193
+
194
+ === Bugfixes
195
+ * added taps.rb for requiring
196
+ * fixed prepared statement reset
197
+ * caught an error in executing prepared statements earlier in the process so the correct error is reported
198
+
199
+ == Version 0.1.0 - 2008-06-21
200
+
201
+ * Initial public release
data/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2008, Jeremy Hinegardner
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ this list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ * Neither the name of Jeremy Hinegardner nor the names of its contributors
16
+ may be used to endorse or promote products derived from this software without
17
+ specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README ADDED
@@ -0,0 +1,51 @@
1
+ == Amalgalite
2
+
3
+ * Homepage[http://copiousfreetime.rubyforge.org/amalgalite]
4
+ * {Rubyforge Project}[http://rubyforge.org/projects/copiousfreetime/]
5
+ * email jeremy at copiousfreetime dot org
6
+ * git clone url git://github.com/copiousfreetime/amalgalite.git
7
+
8
+ == Articles
9
+
10
+ * {Writing SQL Functions in Ruby}[http://copiousfreetime.org/articles/2009/01/10/writing-sql-functions-in-ruby.html]
11
+
12
+ == INSTALL
13
+
14
+ * gem install amalgalite
15
+
16
+ == DESCRIPTION
17
+
18
+ Amalgalite embeds the SQLite database engine in a ruby extension. There is no
19
+ need to install SQLite separately.
20
+
21
+ Look in the examples/ directory to see
22
+
23
+ * general usage
24
+ * blob io
25
+ * schema information
26
+ * custom functions
27
+ * custom aggregates
28
+ * requiring ruby code from a database
29
+
30
+ Also Scroll through Amalgalite::Database for a quick example, and a general
31
+ overview of the API.
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
+
37
+ == CREDITS
38
+
39
+ * Jamis Buck for the first {ruby sqlite implementation}[http://www.rubyforge.org/projects/sqlite-ruby]
40
+
41
+ == CHANGES
42
+
43
+ Read the HISTORY file.
44
+
45
+ == LICENSE
46
+
47
+ Copyright (c) 2008 Jeremy Hinegardner
48
+
49
+ All rights reserved.
50
+
51
+ See LICENSE and/or COPYING for details.
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'pathname'
4
+ require 'rubygems'
5
+
6
+ #
7
+ # add relative paths to the load path if we are not a gem and calculate what the
8
+ # strip path will be if we decide to pack --self
9
+ #
10
+ this_path = Pathname.new( File.expand_path( __FILE__ ) )
11
+ gem_path = Pathname.new( Gem.dir )
12
+ rel_path = this_path.relative_path_from( gem_path )
13
+ if ".." == rel_path.to_s.split( File::SEPARATOR ).first then
14
+ lib_path = File.join( File.dirname( __FILE__ ), "../lib" )
15
+ $:.unshift lib_path
16
+ $:.unshift File.join( File.dirname( __FILE__ ), "../ext" )
17
+ end
18
+
19
+ #
20
+ # snapshot of what is needed for amalgalite requires, this info may only be used
21
+ # when packing amalgalite itself
22
+ #
23
+ loaded_features_before = $LOADED_FEATURES.dup
24
+ require 'amalgalite/packer'
25
+ loaded_features_after = $LOADED_FEATURES.dup
26
+ amalgalite_needs = loaded_features_after - loaded_features_before
27
+
28
+ #
29
+ # Commandline parser
30
+ #
31
+ options = {}
32
+ begin
33
+ parser = OptionParser.new do |op|
34
+ op.banner = "Usage: #{op.program_name} [options] <files>"
35
+ op.separator ""
36
+
37
+ op.on("--dbfile DB", "The Database file in which to pack files") do |d|
38
+ options[:dbfile] = d
39
+ end
40
+
41
+ op.on("--drop-table", "Drop the table before inserting rows") do |t|
42
+ options[:drop_table] = t
43
+ end
44
+
45
+ op.on("-m", "--merge", "Merge these files into the existing table overwriting rows that conflict") do |m|
46
+ options[:merge] = true
47
+ end
48
+
49
+ op.on("--require-order", "Dump Amalgalite's require order" ) do |m|
50
+ puts amalgalite_needs
51
+ exit 0
52
+ end
53
+
54
+ op.on("--self", "pack amalgalite itself into the database") do |d|
55
+ options[:self] = true
56
+ end
57
+
58
+ op.on("--strip-prefix PREFIX", "strip this path prefix off the front of each file") do |p|
59
+ options[:strip_prefix] = File.expand_path( p )
60
+ end
61
+
62
+ op.on("-t", "--table TABLE", "the table name to pack into") do |t|
63
+ options[:table_name] = t
64
+ end
65
+
66
+ op.on("--verbose", "Be verbose about output") do |v|
67
+ options[:verbose] = v
68
+ end
69
+
70
+ op.on("-z", "--compressed", "compress the file contents on storage") do |z|
71
+ options[:compressed] = true
72
+ end
73
+
74
+ end
75
+
76
+ parser.parse!
77
+ require 'amalgalite/packer'
78
+ file_list = ARGV.dup
79
+
80
+
81
+ if options[:self] then
82
+ options[:table_name] = Amalgalite::Requires::Bootstrap::DEFAULT_BOOTSTRAP_TABLE
83
+ core_libs = (amalgalite_needs - Amalgalite::Packer.amalgalite_require_order).delete_if { |l| l.index(".rb").nil? }
84
+
85
+ #
86
+ # check and make sure nothing is missed
87
+ #
88
+ core_libs.each do |l|
89
+ if l.index("malgalite") then
90
+ STDERR.puts "ERROR! require_order needs an update #{l}"
91
+ exit 2
92
+ end
93
+ end
94
+ file_list = core_libs.concat( Amalgalite::Packer.amalgalite_require_order )
95
+ if options[:compressed] then
96
+ STDERR.puts "Compressing --self is not allowed, reverting to uncompressed"
97
+ options[:compressed] = false
98
+ end
99
+ end
100
+ STDERR.puts parser if file_list.empty?
101
+
102
+ packer = Amalgalite::Packer.new( options )
103
+ packer.pack( file_list )
104
+
105
+ rescue OptionParser::ParseError => pe
106
+ STDERR.puts "ERROR : #{pe}"
107
+ STDERR.puts parser
108
+ exit 1
109
+ end
110
+
111
+ __END__
112
+
113
+ puts <<-text
114
+
115
+ Packing complete. To utilize the bootstrapping in #{dbfile} you must do
116
+ one of the following:
117
+
118
+ * statically compile the amalgalite C extension into your application
119
+ * require 'amalgalite/amalgalite3'
120
+
121
+ Once one of those is working you can boostrap the Amalgalite library with
122
+ this line in your code:
123
+
124
+ Amalgalite::Requries::Boostrap.lift( 'dbfile' => '#{dbfile}' )
125
+
126
+ text
data/examples/a.rb ADDED
@@ -0,0 +1,9 @@
1
+ class A
2
+ def initialize
3
+ puts "Initialized A"
4
+ end
5
+
6
+ def a
7
+ puts "called a"
8
+ end
9
+ end
data/examples/blob.rb ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # An Amalgalite example showing how Blob's can be utilized
5
+ #
6
+ # We'll make a database with one table, that we store files in. We'll use the
7
+ # Blob incremental IO to store the files and retrieve them from the database
8
+ #
9
+ # This little program will store 1 or more files in the sqlite3 database when
10
+ # the 'store' action is given, and cat a file to stdout on 'retrieve'
11
+ #
12
+ # e.g.
13
+ #
14
+ # ruby blob.rb store a.rb b.rb c.rb # => stores a.rb b.rb and c.rb in the db
15
+ #
16
+ # ruby blob.rb retrieve a.rb # => dumps a.rb to stdout
17
+ #
18
+
19
+ require 'rubygems'
20
+ $: << "../lib"
21
+ $: << "../ext"
22
+ require 'amalgalite'
23
+ require 'amalgalite/packer'
24
+ VALID_ACTIONS = %w[ list retrieve store ]
25
+ def usage
26
+ STDERR.puts "Usage: #{File.basename($0)} ( #{VALID_ACTIONS.join(' | ')} ) file(s)"
27
+ exit 1
28
+ end
29
+
30
+ #
31
+ # This does the basic command line parsing
32
+ #
33
+ usage if ARGV.size < 1
34
+ action = ARGV.shift
35
+ usage unless VALID_ACTIONS.include? action
36
+ file_list = ARGV
37
+
38
+ #
39
+ # create the database if it doesn't exist
40
+ #
41
+ db = Amalgalite::Database.new( "filestore.db" )
42
+
43
+ case action
44
+ #
45
+ # list all the files that are stored in the database
46
+ #
47
+ when 'list'
48
+ db.execute("SELECT filename FROM rubylibs") do |row|
49
+ puts row['filename']
50
+ end
51
+
52
+ #
53
+ # if we are doing the store action, then loop over the files and store them in
54
+ # the database. This will use incremental IO to store the files directly from
55
+ # the file names.
56
+ #
57
+ # It is slightly strange in that you have to tell the Blob object what column
58
+ # it is going to, but that is necessary at this point to be able to hook
59
+ # automatically into the lower level incremental blob IO api.
60
+ #
61
+ # This also shows using the $var syntax for binding name sql values in a
62
+ # prepared statement.
63
+ #
64
+ when 'store'
65
+ usage if file_list.empty?
66
+ require 'amalgalite/packer'
67
+
68
+ packer = Amalgalite::Packer.new( :dbfile => 'filestore.db',
69
+ :compressed => false )
70
+ packer.pack( file_list )
71
+
72
+ #
73
+ # dump the file that matches the right path to stdout. This also shows
74
+ # positional sql varible binding using the '?' syntax.
75
+ #
76
+ when 'retrieve'
77
+ usage if file_list.empty?
78
+ db.execute("SELECT id, compressed, filename, contents FROM rubylibs WHERE filename = ?", file_list.first) do |row|
79
+ STDERR.puts "Dumping #{row['filename']} to stdout"
80
+ if row['compressed'] then
81
+ s = row['contents'].to_s
82
+ STDOUT.puts Amalgalite::Packer.gunzip( s )
83
+ else
84
+ row['contents'].write_to_io( STDOUT )
85
+ end
86
+ end
87
+ end
88
+ db.close