shoesgem 0.1430.0 → 0.1469.0
Sign up to get free protection for your applications and to get access to all the features.
- data/shoes/VERSION.txt +1 -1
- data/shoes/freetype6.dll +0 -0
- data/shoes/lib/shoes/help.rb +2 -1
- data/shoes/libcairo-2.dll +0 -0
- data/shoes/libeay32.dll +0 -0
- data/shoes/libexpat-1.dll +0 -0
- data/shoes/libfontconfig-1.dll +0 -0
- data/shoes/libgio-2.0-0.dll +0 -0
- data/shoes/libglib-2.0-0.dll +0 -0
- data/shoes/libgmodule-2.0-0.dll +0 -0
- data/shoes/libgobject-2.0-0.dll +0 -0
- data/shoes/libgthread-2.0-0.dll +0 -0
- data/shoes/libiconv2.dll +0 -0
- data/shoes/libjpeg-8.dll +0 -0
- data/shoes/libpango-1.0-0.dll +0 -0
- data/shoes/libpangocairo-1.0-0.dll +0 -0
- data/shoes/libpangoft2-1.0-0.dll +0 -0
- data/shoes/libpangowin32-1.0-0.dll +0 -0
- data/shoes/libpng14-14.dll +0 -0
- data/shoes/libportaudio-2.dll +0 -0
- data/shoes/libshoes.dll +0 -0
- data/shoes/libssl32.dll +0 -0
- data/shoes/libungif4.dll +0 -0
- data/shoes/msvcrt-ruby191.dll +0 -0
- data/shoes/nsis/shoes.nsi +1 -1
- data/shoes/readline5.dll +0 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/fast_xs.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot_scan.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext/generator.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext/parser.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/constants.rb +0 -0
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/database.rb +152 -305
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/errors.rb +0 -24
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/pragmas.rb +16 -7
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/resultset.rb +26 -80
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/statement.rb +22 -107
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/translator.rb +6 -1
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/value.rb +0 -0
- data/shoes/ruby/gems/1.9.1/gems/{sqlite3-ruby-1.2.5-x86-mswin32 → sqlite3-ruby-1.3.0}/lib/sqlite3/version.rb +3 -3
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.0/lib/sqlite3.rb +11 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.0/lib/sqlite3_native.so +0 -0
- data/shoes/ruby/gems/1.9.1/specifications/sqlite3-ruby-1.3.0.gemspec +48 -0
- data/shoes/ruby/lib/ftsearch/suffix_array_reader.rb +4 -2
- data/shoes/ruby/lib/i386-mingw32/bigdecimal.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/binject.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/bloops.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/chipmunk.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/continuation.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/coverage.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/curses.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/bubblebabble.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/md5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/rmd160.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/sha1.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/sha2.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/dl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/big5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/cp949.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/emacs_mule.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/encdb.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_jp.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_kr.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_tw.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gb18030.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gb2312.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gbk.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_1.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_10.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_11.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_13.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_14.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_15.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_16.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_2.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_3.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_4.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_6.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_7.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_8.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_9.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/koi8_r.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/koi8_u.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/shift_jis.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/big5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/chinese.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/escape.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/gb18030.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/gbk.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/iso2022.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese_euc.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese_sjis.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/korean.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/single_byte.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/transdb.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/utf_16_32.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_16be.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_16le.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_32be.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_32le.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/windows_1251.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/etc.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/fcntl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/fiber.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/ftsearchrt.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/gdbm.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/iconv.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/io/wait.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/json/ext/generator.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/json/ext/parser.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/mathn/complex.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/mathn/rational.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/nkf.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/openssl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/racc/cparse.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/readline.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/ripper.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/sdbm.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/socket.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/stringio.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/strscan.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/syck.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/win32ole.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/zlib.so +0 -0
- data/shoes/ruby/lib/rbconfig/datadir.rb +24 -24
- data/shoes/ruby/lib/rubygems/builder.rb +88 -88
- data/shoes/ruby/lib/rubygems/command.rb +406 -406
- data/shoes/ruby/lib/rubygems/command_manager.rb +146 -146
- data/shoes/ruby/lib/rubygems/commands/build_command.rb +53 -53
- data/shoes/ruby/lib/rubygems/commands/cert_command.rb +86 -86
- data/shoes/ruby/lib/rubygems/commands/check_command.rb +75 -75
- data/shoes/ruby/lib/rubygems/commands/cleanup_command.rb +91 -91
- data/shoes/ruby/lib/rubygems/commands/contents_command.rb +74 -74
- data/shoes/ruby/lib/rubygems/commands/dependency_command.rb +188 -188
- data/shoes/ruby/lib/rubygems/commands/environment_command.rb +128 -128
- data/shoes/ruby/lib/rubygems/commands/fetch_command.rb +62 -62
- data/shoes/ruby/lib/rubygems/commands/generate_index_command.rb +57 -57
- data/shoes/ruby/lib/rubygems/commands/help_command.rb +172 -172
- data/shoes/ruby/lib/rubygems/commands/install_command.rb +148 -148
- data/shoes/ruby/lib/rubygems/commands/list_command.rb +35 -35
- data/shoes/ruby/lib/rubygems/commands/lock_command.rb +110 -110
- data/shoes/ruby/lib/rubygems/commands/mirror_command.rb +111 -111
- data/shoes/ruby/lib/rubygems/commands/outdated_command.rb +33 -33
- data/shoes/ruby/lib/rubygems/commands/pristine_command.rb +93 -93
- data/shoes/ruby/lib/rubygems/commands/query_command.rb +233 -233
- data/shoes/ruby/lib/rubygems/commands/rdoc_command.rb +82 -82
- data/shoes/ruby/lib/rubygems/commands/search_command.rb +37 -37
- data/shoes/ruby/lib/rubygems/commands/server_command.rb +48 -48
- data/shoes/ruby/lib/rubygems/commands/sources_command.rb +152 -152
- data/shoes/ruby/lib/rubygems/commands/specification_command.rb +77 -77
- data/shoes/ruby/lib/rubygems/commands/stale_command.rb +27 -27
- data/shoes/ruby/lib/rubygems/commands/uninstall_command.rb +73 -73
- data/shoes/ruby/lib/rubygems/commands/unpack_command.rb +95 -95
- data/shoes/ruby/lib/rubygems/commands/update_command.rb +181 -181
- data/shoes/ruby/lib/rubygems/commands/which_command.rb +87 -87
- data/shoes/ruby/lib/rubygems/config_file.rb +266 -266
- data/shoes/ruby/lib/rubygems/custom_require.rb +46 -46
- data/shoes/ruby/lib/rubygems/defaults.rb +88 -89
- data/shoes/ruby/lib/rubygems/dependency.rb +119 -119
- data/shoes/ruby/lib/rubygems/dependency_installer.rb +258 -258
- data/shoes/ruby/lib/rubygems/dependency_list.rb +165 -165
- data/shoes/ruby/lib/rubygems/digest/digest_adapter.rb +39 -39
- data/shoes/ruby/lib/rubygems/digest/md5.rb +23 -23
- data/shoes/ruby/lib/rubygems/digest/sha1.rb +16 -16
- data/shoes/ruby/lib/rubygems/digest/sha2.rb +17 -17
- data/shoes/ruby/lib/rubygems/doc_manager.rb +214 -214
- data/shoes/ruby/lib/rubygems/exceptions.rb +84 -84
- data/shoes/ruby/lib/rubygems/ext/builder.rb +56 -56
- data/shoes/ruby/lib/rubygems/ext/configure_builder.rb +24 -24
- data/shoes/ruby/lib/rubygems/ext/ext_conf_builder.rb +23 -23
- data/shoes/ruby/lib/rubygems/ext/rake_builder.rb +27 -27
- data/shoes/ruby/lib/rubygems/ext.rb +18 -18
- data/shoes/ruby/lib/rubygems/format.rb +87 -87
- data/shoes/ruby/lib/rubygems/gem_openssl.rb +83 -83
- data/shoes/ruby/lib/rubygems/gem_path_searcher.rb +100 -100
- data/shoes/ruby/lib/rubygems/gem_runner.rb +58 -58
- data/shoes/ruby/lib/rubygems/indexer.rb +370 -370
- data/shoes/ruby/lib/rubygems/install_update_options.rb +113 -113
- data/shoes/ruby/lib/rubygems/installer.rb +575 -578
- data/shoes/ruby/lib/rubygems/local_remote_options.rb +134 -134
- data/shoes/ruby/lib/rubygems/old_format.rb +148 -148
- data/shoes/ruby/lib/rubygems/package/f_sync_dir.rb +24 -24
- data/shoes/ruby/lib/rubygems/package/tar_header.rb +245 -245
- data/shoes/ruby/lib/rubygems/package/tar_input.rb +219 -219
- data/shoes/ruby/lib/rubygems/package/tar_output.rb +143 -143
- data/shoes/ruby/lib/rubygems/package/tar_reader/entry.rb +99 -99
- data/shoes/ruby/lib/rubygems/package/tar_reader.rb +86 -86
- data/shoes/ruby/lib/rubygems/package/tar_writer.rb +180 -180
- data/shoes/ruby/lib/rubygems/package.rb +95 -95
- data/shoes/ruby/lib/rubygems/platform.rb +178 -178
- data/shoes/ruby/lib/rubygems/remote_fetcher.rb +344 -344
- data/shoes/ruby/lib/rubygems/require_paths_builder.rb +14 -14
- data/shoes/ruby/lib/rubygems/requirement.rb +163 -163
- data/shoes/ruby/lib/rubygems/rubygems_version.rb +6 -6
- data/shoes/ruby/lib/rubygems/security.rb +786 -786
- data/shoes/ruby/lib/rubygems/server.rb +629 -629
- data/shoes/ruby/lib/rubygems/source_index.rb +559 -559
- data/shoes/ruby/lib/rubygems/source_info_cache.rb +393 -393
- data/shoes/ruby/lib/rubygems/source_info_cache_entry.rb +56 -56
- data/shoes/ruby/lib/rubygems/spec_fetcher.rb +249 -249
- data/shoes/ruby/lib/rubygems/specification.rb +1264 -1262
- data/shoes/ruby/lib/rubygems/test_utilities.rb +131 -131
- data/shoes/ruby/lib/rubygems/timer.rb +25 -25
- data/shoes/ruby/lib/rubygems/uninstaller.rb +242 -242
- data/shoes/ruby/lib/rubygems/user_interaction.rb +360 -360
- data/shoes/ruby/lib/rubygems/validator.rb +209 -208
- data/shoes/ruby/lib/rubygems/version.rb +167 -167
- data/shoes/ruby/lib/rubygems/version_option.rb +48 -48
- data/shoes/ruby/lib/rubygems.rb +889 -888
- data/shoes/ruby/lib/ubygems.rb +10 -10
- data/shoes/samples/simple-sqlite3.rb +13 -0
- data/shoes/shoes.exe +0 -0
- data/shoes/sqlite3.dll +0 -0
- data/shoes/static/manual-en.txt +1 -1
- data/shoes/zlib.dll +0 -0
- data/shoes/zlib1.dll +0 -0
- metadata +17 -19
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/api.rb +0 -152
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/driver.rb +0 -307
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/native/driver.rb +0 -219
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3.rb +0 -1
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3_api.so +0 -0
- data/shoes/ruby/gems/1.9.1/specifications/sqlite3-ruby-1.2.5-x86-mswin32.gemspec +0 -46
@@ -35,7 +35,7 @@ module SQLite3
|
|
35
35
|
class Database
|
36
36
|
include Pragmas
|
37
37
|
|
38
|
-
class <<self
|
38
|
+
class << self
|
39
39
|
|
40
40
|
alias :open :new
|
41
41
|
|
@@ -48,12 +48,6 @@ module SQLite3
|
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
|
-
# The low-level opaque database handle that this object wraps.
|
52
|
-
attr_reader :handle
|
53
|
-
|
54
|
-
# A reference to the underlying SQLite3 driver used by this database.
|
55
|
-
attr_reader :driver
|
56
|
-
|
57
51
|
# A boolean that indicates whether rows in result sets should be returned
|
58
52
|
# as hashes or not. By default, rows are returned as arrays.
|
59
53
|
attr_accessor :results_as_hash
|
@@ -62,54 +56,6 @@ module SQLite3
|
|
62
56
|
# database.
|
63
57
|
attr_accessor :type_translation
|
64
58
|
|
65
|
-
# Create a new Database object that opens the given file. If utf16
|
66
|
-
# is +true+, the filename is interpreted as a UTF-16 encoded string.
|
67
|
-
#
|
68
|
-
# By default, the new database will return result rows as arrays
|
69
|
-
# (#results_as_hash) and has type translation disabled (#type_translation=).
|
70
|
-
def initialize( file_name, options={} ) # :yields: db
|
71
|
-
utf16 = options.fetch(:utf16, false)
|
72
|
-
load_driver( options[:driver] )
|
73
|
-
|
74
|
-
@statement_factory = options[:statement_factory] || Statement
|
75
|
-
|
76
|
-
result, @handle = @driver.open( file_name, utf16 )
|
77
|
-
Error.check( result, self, "could not open database" )
|
78
|
-
|
79
|
-
@closed = false
|
80
|
-
@results_as_hash = options.fetch(:results_as_hash,false)
|
81
|
-
@type_translation = options.fetch(:type_translation,false)
|
82
|
-
@translator = nil
|
83
|
-
@transaction_active = false
|
84
|
-
|
85
|
-
if block_given?
|
86
|
-
begin
|
87
|
-
yield self
|
88
|
-
ensure
|
89
|
-
self.close
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# Return +true+ if the string is a valid (ie, parsable) SQL statement, and
|
95
|
-
# +false+ otherwise. If +utf16+ is +true+, then the string is a UTF-16
|
96
|
-
# character string.
|
97
|
-
def complete?( string, utf16=false )
|
98
|
-
@driver.complete?( string, utf16 )
|
99
|
-
end
|
100
|
-
|
101
|
-
# Return a string describing the last error to have occurred with this
|
102
|
-
# database.
|
103
|
-
def errmsg( utf16=false )
|
104
|
-
@driver.errmsg( @handle, utf16 )
|
105
|
-
end
|
106
|
-
|
107
|
-
# Return an integer representing the last error to have occurred with this
|
108
|
-
# database.
|
109
|
-
def errcode
|
110
|
-
@driver.errcode( @handle )
|
111
|
-
end
|
112
|
-
|
113
59
|
# Return the type translator employed by this database instance. Each
|
114
60
|
# database instance has its own type translator; this allows for different
|
115
61
|
# type handlers to be installed in each instance without affecting other
|
@@ -120,35 +66,12 @@ module SQLite3
|
|
120
66
|
@translator ||= Translator.new
|
121
67
|
end
|
122
68
|
|
123
|
-
# Closes this database.
|
124
|
-
def close
|
125
|
-
unless @closed
|
126
|
-
result = @driver.close( @handle )
|
127
|
-
Error.check( result, self )
|
128
|
-
end
|
129
|
-
@closed = true
|
130
|
-
end
|
131
|
-
|
132
|
-
# Returns +true+ if this database instance has been closed (see #close).
|
133
|
-
def closed?
|
134
|
-
@closed
|
135
|
-
end
|
136
|
-
|
137
|
-
# Installs (or removes) a block that will be invoked for every SQL
|
138
|
-
# statement executed. The block receives a two parameters: the +data+
|
139
|
-
# argument, and the SQL statement executed. If the block is +nil+,
|
140
|
-
# any existing tracer will be uninstalled.
|
141
|
-
def trace( data=nil, &block )
|
142
|
-
@driver.trace( @handle, data, &block )
|
143
|
-
end
|
144
|
-
|
145
69
|
# Installs (or removes) a block that will be invoked for every access
|
146
70
|
# to the database. If the block returns 0 (or +nil+), the statement
|
147
71
|
# is allowed to proceed. Returning 1 causes an authorization error to
|
148
72
|
# occur, and returning 2 causes the access to be silently denied.
|
149
|
-
def authorizer(
|
150
|
-
|
151
|
-
Error.check( result, self )
|
73
|
+
def authorizer( &block )
|
74
|
+
self.authorizer = block
|
152
75
|
end
|
153
76
|
|
154
77
|
# Returns a Statement object representing the given SQL. This does not
|
@@ -156,16 +79,14 @@ module SQLite3
|
|
156
79
|
#
|
157
80
|
# The Statement can then be executed using Statement#execute.
|
158
81
|
#
|
159
|
-
def prepare
|
160
|
-
stmt =
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
else
|
168
|
-
return stmt
|
82
|
+
def prepare sql
|
83
|
+
stmt = SQLite3::Statement.new( self, sql )
|
84
|
+
return stmt unless block_given?
|
85
|
+
|
86
|
+
begin
|
87
|
+
yield stmt
|
88
|
+
ensure
|
89
|
+
stmt.close
|
169
90
|
end
|
170
91
|
end
|
171
92
|
|
@@ -183,13 +104,55 @@ module SQLite3
|
|
183
104
|
#
|
184
105
|
# See also #execute2, #query, and #execute_batch for additional ways of
|
185
106
|
# executing statements.
|
186
|
-
def execute
|
107
|
+
def execute sql, bind_vars = [], *args, &block
|
108
|
+
# FIXME: This is a terrible hack and should be removed but is required
|
109
|
+
# for older versions of rails
|
110
|
+
hack = Object.const_defined?(:ActiveRecord) && sql =~ /^PRAGMA index_list/
|
111
|
+
|
112
|
+
if bind_vars.nil? || !args.empty?
|
113
|
+
if args.empty?
|
114
|
+
bind_vars = []
|
115
|
+
else
|
116
|
+
bind_vars = [nil] + args
|
117
|
+
end
|
118
|
+
|
119
|
+
warn(<<-eowarn) if $VERBOSE
|
120
|
+
#{caller[0]} is calling SQLite3::Database#execute with nil or multiple bind params
|
121
|
+
without using an array. Please switch to passing bind parameters as an array.
|
122
|
+
eowarn
|
123
|
+
end
|
124
|
+
|
187
125
|
prepare( sql ) do |stmt|
|
188
|
-
|
126
|
+
stmt.bind_params(bind_vars)
|
127
|
+
if type_translation
|
128
|
+
stmt = ResultSet.new(self, stmt).to_a
|
129
|
+
end
|
130
|
+
|
189
131
|
if block_given?
|
190
|
-
|
132
|
+
stmt.each do |row|
|
133
|
+
if @results_as_hash
|
134
|
+
h = Hash[*stmt.columns.zip(row).flatten]
|
135
|
+
row.each_with_index { |r, i| h[i] = r }
|
136
|
+
|
137
|
+
yield h
|
138
|
+
else
|
139
|
+
yield row
|
140
|
+
end
|
141
|
+
end
|
191
142
|
else
|
192
|
-
|
143
|
+
if @results_as_hash
|
144
|
+
stmt.map { |row|
|
145
|
+
h = Hash[*stmt.columns.zip(row).flatten]
|
146
|
+
row.each_with_index { |r, i| h[i] = r }
|
147
|
+
|
148
|
+
# FIXME UGH TERRIBLE HACK!
|
149
|
+
h['unique'] = h['unique'].to_s if hack
|
150
|
+
|
151
|
+
h
|
152
|
+
}
|
153
|
+
else
|
154
|
+
stmt.to_a
|
155
|
+
end
|
193
156
|
end
|
194
157
|
end
|
195
158
|
end
|
@@ -208,10 +171,10 @@ module SQLite3
|
|
208
171
|
prepare( sql ) do |stmt|
|
209
172
|
result = stmt.execute( *bind_vars )
|
210
173
|
if block_given?
|
211
|
-
yield
|
174
|
+
yield stmt.columns
|
212
175
|
result.each { |row| yield row }
|
213
176
|
else
|
214
|
-
return result.inject( [
|
177
|
+
return result.inject( [ stmt.columns ] ) { |arr,row|
|
215
178
|
arr << row; arr }
|
216
179
|
end
|
217
180
|
end
|
@@ -225,11 +188,40 @@ module SQLite3
|
|
225
188
|
#
|
226
189
|
# This always returns +nil+, making it unsuitable for queries that return
|
227
190
|
# rows.
|
228
|
-
def execute_batch( sql,
|
191
|
+
def execute_batch( sql, bind_vars = [], *args )
|
192
|
+
# FIXME: remove this stuff later
|
193
|
+
unless [Array, Hash].include?(bind_vars.class)
|
194
|
+
bind_vars = [bind_vars]
|
195
|
+
warn(<<-eowarn) if $VERBOSE
|
196
|
+
#{caller[0]} is calling SQLite3::Database#execute_batch with bind parameters
|
197
|
+
that are not a list of a hash. Please switch to passing bind parameters as an
|
198
|
+
array or hash.
|
199
|
+
eowarn
|
200
|
+
end
|
201
|
+
|
202
|
+
# FIXME: remove this stuff later
|
203
|
+
if bind_vars.nil? || !args.empty?
|
204
|
+
if args.empty?
|
205
|
+
bind_vars = []
|
206
|
+
else
|
207
|
+
bind_vars = [nil] + args
|
208
|
+
end
|
209
|
+
|
210
|
+
warn(<<-eowarn) if $VERBOSE
|
211
|
+
#{caller[0]} is calling SQLite3::Database#execute_batch with nil or multiple bind params
|
212
|
+
without using an array. Please switch to passing bind parameters as an array.
|
213
|
+
eowarn
|
214
|
+
end
|
215
|
+
|
229
216
|
sql = sql.strip
|
230
217
|
until sql.empty? do
|
231
218
|
prepare( sql ) do |stmt|
|
232
|
-
|
219
|
+
# FIXME: this should probably use sqlite3's api for batch execution
|
220
|
+
# This implementation requires stepping over the results.
|
221
|
+
if bind_vars.length == stmt.bind_parameter_count
|
222
|
+
stmt.bind_params(bind_vars)
|
223
|
+
end
|
224
|
+
stmt.step
|
233
225
|
sql = stmt.remainder.strip
|
234
226
|
end
|
235
227
|
end
|
@@ -247,8 +239,22 @@ module SQLite3
|
|
247
239
|
# returned, or you could have problems with locks on the table. If called
|
248
240
|
# with a block, +close+ will be invoked implicitly when the block
|
249
241
|
# terminates.
|
250
|
-
def query( sql,
|
251
|
-
|
242
|
+
def query( sql, bind_vars = [], *args )
|
243
|
+
|
244
|
+
if bind_vars.nil? || !args.empty?
|
245
|
+
if args.empty?
|
246
|
+
bind_vars = []
|
247
|
+
else
|
248
|
+
bind_vars = [nil] + args
|
249
|
+
end
|
250
|
+
|
251
|
+
warn(<<-eowarn) if $VERBOSE
|
252
|
+
#{caller[0]} is calling SQLite3::Database#query with nil or multiple bind params
|
253
|
+
without using an array. Please switch to passing bind parameters as an array.
|
254
|
+
eowarn
|
255
|
+
end
|
256
|
+
|
257
|
+
result = prepare( sql ).execute( bind_vars )
|
252
258
|
if block_given?
|
253
259
|
begin
|
254
260
|
yield result
|
@@ -279,55 +285,7 @@ module SQLite3
|
|
279
285
|
nil
|
280
286
|
end
|
281
287
|
|
282
|
-
|
283
|
-
# instance.
|
284
|
-
def last_insert_row_id
|
285
|
-
@driver.last_insert_rowid( @handle )
|
286
|
-
end
|
287
|
-
|
288
|
-
# Returns the number of changes made to this database instance by the last
|
289
|
-
# operation performed. Note that a "delete from table" without a where
|
290
|
-
# clause will not affect this value.
|
291
|
-
def changes
|
292
|
-
@driver.changes( @handle )
|
293
|
-
end
|
294
|
-
|
295
|
-
# Returns the total number of changes made to this database instance
|
296
|
-
# since it was opened.
|
297
|
-
def total_changes
|
298
|
-
@driver.total_changes( @handle )
|
299
|
-
end
|
300
|
-
|
301
|
-
# Interrupts the currently executing operation, causing it to abort.
|
302
|
-
def interrupt
|
303
|
-
@driver.interrupt( @handle )
|
304
|
-
end
|
305
|
-
|
306
|
-
# Register a busy handler with this database instance. When a requested
|
307
|
-
# resource is busy, this handler will be invoked. If the handler returns
|
308
|
-
# +false+, the operation will be aborted; otherwise, the resource will
|
309
|
-
# be requested again.
|
310
|
-
#
|
311
|
-
# The handler will be invoked with the name of the resource that was
|
312
|
-
# busy, and the number of times it has been retried.
|
313
|
-
#
|
314
|
-
# See also the mutually exclusive #busy_timeout.
|
315
|
-
def busy_handler( data=nil, &block ) # :yields: data, retries
|
316
|
-
result = @driver.busy_handler( @handle, data, &block )
|
317
|
-
Error.check( result, self )
|
318
|
-
end
|
319
|
-
|
320
|
-
# Indicates that if a request for a resource terminates because that
|
321
|
-
# resource is busy, SQLite should sleep and retry for up to the indicated
|
322
|
-
# number of milliseconds. By default, SQLite does not retry
|
323
|
-
# busy resources. To restore the default behavior, send 0 as the
|
324
|
-
# +ms+ parameter.
|
325
|
-
#
|
326
|
-
# See also the mutually exclusive #busy_handler.
|
327
|
-
def busy_timeout( ms )
|
328
|
-
result = @driver.busy_timeout( @handle, ms )
|
329
|
-
Error.check( result, self )
|
330
|
-
end
|
288
|
+
alias :busy_timeout :busy_timeout=
|
331
289
|
|
332
290
|
# Creates a new function for use in SQL statements. It will be added as
|
333
291
|
# +name+, with the given +arity+. (For variable arity functions, use
|
@@ -352,23 +310,12 @@ module SQLite3
|
|
352
310
|
# end
|
353
311
|
#
|
354
312
|
# puts db.get_first_value( "select maim(name) from table" )
|
355
|
-
def create_function
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
block.call( FunctionProxy.new( @driver, func ),
|
361
|
-
*args.map{|v| Value.new(self,v)} )
|
362
|
-
rescue StandardError, Exception => e
|
363
|
-
@driver.result_error( func,
|
364
|
-
"#{e.message} (#{e.class})", -1 )
|
365
|
-
end
|
313
|
+
def create_function name, arity, text_rep=Constants::TextRep::ANY, &block
|
314
|
+
define_function(name) do |*args|
|
315
|
+
fp = FunctionProxy.new
|
316
|
+
block.call(fp, *args)
|
317
|
+
fp.result
|
366
318
|
end
|
367
|
-
|
368
|
-
result = @driver.create_function( @handle, name, arity, text_rep, nil,
|
369
|
-
callback, nil, nil )
|
370
|
-
Error.check( result, self )
|
371
|
-
|
372
319
|
self
|
373
320
|
end
|
374
321
|
|
@@ -410,47 +357,40 @@ module SQLite3
|
|
410
357
|
# aggregate functions.
|
411
358
|
def create_aggregate( name, arity, step=nil, finalize=nil,
|
412
359
|
text_rep=Constants::TextRep::ANY, &block )
|
413
|
-
# begin
|
414
|
-
if block
|
415
|
-
proxy = AggregateDefinitionProxy.new
|
416
|
-
proxy.instance_eval(&block)
|
417
|
-
step ||= proxy.step_callback
|
418
|
-
finalize ||= proxy.finalize_callback
|
419
|
-
end
|
420
360
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
ctx[:__error] = e
|
429
|
-
end
|
361
|
+
factory = Class.new do
|
362
|
+
def self.step( &block )
|
363
|
+
define_method(:step, &block)
|
364
|
+
end
|
365
|
+
|
366
|
+
def self.finalize( &block )
|
367
|
+
define_method(:finalize, &block)
|
430
368
|
end
|
431
369
|
end
|
432
370
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
@driver.result_error( func,
|
440
|
-
"#{e.message} (#{e.class})", -1 )
|
441
|
-
end
|
442
|
-
else
|
443
|
-
e = ctx[:__error]
|
444
|
-
@driver.result_error( func,
|
445
|
-
"#{e.message} (#{e.class})", -1 )
|
371
|
+
if block_given?
|
372
|
+
factory.instance_eval(&block)
|
373
|
+
else
|
374
|
+
factory.class_eval do
|
375
|
+
define_method(:step, step)
|
376
|
+
define_method(:finalize, finalize)
|
446
377
|
end
|
447
378
|
end
|
448
379
|
|
449
|
-
|
450
|
-
|
451
|
-
|
380
|
+
proxy = factory.new
|
381
|
+
proxy.extend(Module.new {
|
382
|
+
attr_accessor :ctx
|
452
383
|
|
453
|
-
|
384
|
+
def step( *args )
|
385
|
+
super(@ctx, *args)
|
386
|
+
end
|
387
|
+
|
388
|
+
def finalize
|
389
|
+
super(@ctx)
|
390
|
+
end
|
391
|
+
})
|
392
|
+
proxy.ctx = FunctionProxy.new
|
393
|
+
define_aggregator(name, proxy)
|
454
394
|
end
|
455
395
|
|
456
396
|
# This is another approach to creating an aggregate function (see
|
@@ -500,47 +440,22 @@ module SQLite3
|
|
500
440
|
# db.create_aggregate_handler( LengthsAggregateHandler )
|
501
441
|
# puts db.get_first_value( "select lengths(name) from A" )
|
502
442
|
def create_aggregate_handler( handler )
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
text_rep = handler.text_rep if handler.respond_to?(:text_rep)
|
508
|
-
name = handler.name
|
509
|
-
|
510
|
-
step = proc do |func,*args|
|
511
|
-
ctx = @driver.aggregate_context( func )
|
512
|
-
unless ctx[ :__error ]
|
513
|
-
ctx[ :handler ] ||= handler.new
|
514
|
-
begin
|
515
|
-
ctx[ :handler ].step( FunctionProxy.new( @driver, func, ctx ),
|
516
|
-
*args.map{|v| Value.new(self,v)} )
|
517
|
-
rescue Exception, StandardError => e
|
518
|
-
ctx[ :__error ] = e
|
519
|
-
end
|
443
|
+
proxy = Class.new do
|
444
|
+
def initialize handler
|
445
|
+
@handler = handler
|
446
|
+
@fp = FunctionProxy.new
|
520
447
|
end
|
521
|
-
end
|
522
448
|
|
523
|
-
|
524
|
-
|
525
|
-
unless ctx[ :__error ]
|
526
|
-
ctx[ :handler ] ||= handler.new
|
527
|
-
begin
|
528
|
-
ctx[ :handler ].finalize( FunctionProxy.new( @driver, func, ctx ) )
|
529
|
-
rescue Exception => e
|
530
|
-
ctx[ :__error ] = e
|
531
|
-
end
|
449
|
+
def step( *args )
|
450
|
+
@handler.step(@fp, *args)
|
532
451
|
end
|
533
452
|
|
534
|
-
|
535
|
-
|
536
|
-
@
|
453
|
+
def finalize
|
454
|
+
@handler.finalize @fp
|
455
|
+
@fp.result
|
537
456
|
end
|
538
457
|
end
|
539
|
-
|
540
|
-
result = @driver.create_function( @handle, name, arity, text_rep, nil,
|
541
|
-
nil, step, finalize )
|
542
|
-
Error.check( result, self )
|
543
|
-
|
458
|
+
define_aggregator(handler.name, proxy.new(handler.new))
|
544
459
|
self
|
545
460
|
end
|
546
461
|
|
@@ -604,33 +519,6 @@ module SQLite3
|
|
604
519
|
@transaction_active
|
605
520
|
end
|
606
521
|
|
607
|
-
# Loads the corresponding driver, or if it is nil, attempts to locate a
|
608
|
-
# suitable driver.
|
609
|
-
def load_driver( driver )
|
610
|
-
case driver
|
611
|
-
when Class
|
612
|
-
# do nothing--use what was given
|
613
|
-
when Symbol, String
|
614
|
-
require "sqlite3/driver/#{driver.to_s.downcase}/driver"
|
615
|
-
driver = SQLite3::Driver.const_get( driver )::Driver
|
616
|
-
else
|
617
|
-
[ "Native", "DL" ].each do |d|
|
618
|
-
begin
|
619
|
-
require "sqlite3/driver/#{d.downcase}/driver"
|
620
|
-
driver = SQLite3::Driver.const_get( d )::Driver
|
621
|
-
break
|
622
|
-
rescue SyntaxError
|
623
|
-
raise
|
624
|
-
rescue ScriptError, Exception, NameError
|
625
|
-
end
|
626
|
-
end
|
627
|
-
raise "no driver for sqlite3 found" unless driver
|
628
|
-
end
|
629
|
-
|
630
|
-
@driver = driver.new
|
631
|
-
end
|
632
|
-
private :load_driver
|
633
|
-
|
634
522
|
# A helper class for dealing with custom functions (see #create_function,
|
635
523
|
# #create_aggregate, and #create_aggregate_handler). It encapsulates the
|
636
524
|
# opaque function object that represents the current invocation. It also
|
@@ -640,26 +528,15 @@ module SQLite3
|
|
640
528
|
# This class will almost _always_ be instantiated indirectly, by working
|
641
529
|
# with the create methods mentioned above.
|
642
530
|
class FunctionProxy
|
531
|
+
attr_accessor :result
|
643
532
|
|
644
533
|
# Create a new FunctionProxy that encapsulates the given +func+ object.
|
645
534
|
# If context is non-nil, the functions context will be set to that. If
|
646
535
|
# it is non-nil, it must quack like a Hash. If it is nil, then none of
|
647
536
|
# the context functions will be available.
|
648
|
-
def initialize
|
649
|
-
@
|
650
|
-
@
|
651
|
-
@context = context
|
652
|
-
end
|
653
|
-
|
654
|
-
# Calls #set_result to set the result of this function.
|
655
|
-
def result=( result )
|
656
|
-
set_result( result )
|
657
|
-
end
|
658
|
-
|
659
|
-
# Set the result of the function to the given value. The function will
|
660
|
-
# then return this value.
|
661
|
-
def set_result( result, utf16=false )
|
662
|
-
@driver.result_text( @func, result, utf16 )
|
537
|
+
def initialize
|
538
|
+
@result = nil
|
539
|
+
@context = {}
|
663
540
|
end
|
664
541
|
|
665
542
|
# Set the result of the function to the given error message.
|
@@ -672,50 +549,20 @@ module SQLite3
|
|
672
549
|
# that the aggregate has processed so far. This will include the current
|
673
550
|
# row, and so will always return at least 1.
|
674
551
|
def count
|
675
|
-
ensure_aggregate!
|
676
552
|
@driver.aggregate_count( @func )
|
677
553
|
end
|
678
554
|
|
679
555
|
# Returns the value with the given key from the context. This is only
|
680
556
|
# available to aggregate functions.
|
681
557
|
def []( key )
|
682
|
-
ensure_aggregate!
|
683
558
|
@context[ key ]
|
684
559
|
end
|
685
560
|
|
686
561
|
# Sets the value with the given key in the context. This is only
|
687
562
|
# available to aggregate functions.
|
688
563
|
def []=( key, value )
|
689
|
-
ensure_aggregate!
|
690
564
|
@context[ key ] = value
|
691
565
|
end
|
692
|
-
|
693
|
-
# A function for performing a sanity check, to ensure that the function
|
694
|
-
# being invoked is an aggregate function. This is implied by the
|
695
|
-
# existence of the context variable.
|
696
|
-
def ensure_aggregate!
|
697
|
-
unless @context
|
698
|
-
raise MisuseException, "function is not an aggregate"
|
699
|
-
end
|
700
|
-
end
|
701
|
-
private :ensure_aggregate!
|
702
|
-
|
703
566
|
end
|
704
|
-
|
705
|
-
# A proxy used for defining the callbacks to an aggregate function.
|
706
|
-
class AggregateDefinitionProxy # :nodoc:
|
707
|
-
attr_reader :step_callback, :finalize_callback
|
708
|
-
|
709
|
-
def step( &block )
|
710
|
-
@step_callback = block
|
711
|
-
end
|
712
|
-
|
713
|
-
def finalize( &block )
|
714
|
-
@finalize_callback = block
|
715
|
-
end
|
716
|
-
end
|
717
|
-
|
718
567
|
end
|
719
|
-
|
720
568
|
end
|
721
|
-
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'sqlite3/constants'
|
2
2
|
|
3
3
|
module SQLite3
|
4
|
-
|
5
4
|
class Exception < ::StandardError
|
6
5
|
@code = 0
|
7
6
|
|
@@ -42,27 +41,4 @@ module SQLite3
|
|
42
41
|
class FormatException < Exception; end
|
43
42
|
class RangeException < Exception; end
|
44
43
|
class NotADatabaseException < Exception; end
|
45
|
-
|
46
|
-
EXCEPTIONS = [
|
47
|
-
nil,
|
48
|
-
SQLException, InternalException, PermissionException,
|
49
|
-
AbortException, BusyException, LockedException, MemoryException,
|
50
|
-
ReadOnlyException, InterruptException, IOException, CorruptException,
|
51
|
-
NotFoundException, FullException, CantOpenException, ProtocolException,
|
52
|
-
EmptyException, SchemaChangedException, TooBigException,
|
53
|
-
ConstraintException, MismatchException, MisuseException,
|
54
|
-
UnsupportedException, AuthorizationException, FormatException,
|
55
|
-
RangeException, NotADatabaseException
|
56
|
-
].each_with_index { |e,i| e.instance_variable_set( :@code, i ) if e }
|
57
|
-
|
58
|
-
module Error
|
59
|
-
def check( result, db=nil, msg=nil )
|
60
|
-
unless result == Constants::ErrorCode::OK
|
61
|
-
msg = ( msg ? msg + ": " : "" ) + db.errmsg if db
|
62
|
-
raise(( EXCEPTIONS[result] || SQLite3::Exception ), msg)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
module_function :check
|
66
|
-
end
|
67
|
-
|
68
44
|
end
|
@@ -213,16 +213,24 @@ module SQLite3
|
|
213
213
|
get_query_pragma "index_list", table, &block
|
214
214
|
end
|
215
215
|
|
216
|
-
|
217
|
-
|
216
|
+
###
|
217
|
+
# Returns information about +table+. Yields each row of table information
|
218
|
+
# if a block is provided.
|
219
|
+
def table_info table
|
220
|
+
stmt = prepare "PRAGMA table_info(#{table})"
|
221
|
+
columns = stmt.columns
|
218
222
|
|
219
|
-
needs_tweak_default =
|
223
|
+
needs_tweak_default =
|
224
|
+
version_compare(SQLite3.libversion.to_s, "3.3.7") > 0
|
220
225
|
|
221
226
|
result = [] unless block_given?
|
222
|
-
|
223
|
-
new_row =
|
224
|
-
|
225
|
-
|
227
|
+
stmt.each do |row|
|
228
|
+
new_row = Hash[*columns.zip(row).flatten]
|
229
|
+
|
230
|
+
# FIXME: This should be removed but is required for older versions
|
231
|
+
# of rails
|
232
|
+
if(Object.const_defined?(:ActiveRecord))
|
233
|
+
new_row['notnull'] = new_row['notnull'].to_s
|
226
234
|
end
|
227
235
|
|
228
236
|
tweak_default(new_row) if needs_tweak_default
|
@@ -233,6 +241,7 @@ module SQLite3
|
|
233
241
|
result << new_row
|
234
242
|
end
|
235
243
|
end
|
244
|
+
stmt.close
|
236
245
|
|
237
246
|
result
|
238
247
|
end
|