sqlite3 1.4.2 → 1.7.2

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/{API_CHANGES.rdoc → API_CHANGES.md} +3 -4
  3. data/CHANGELOG.md +641 -0
  4. data/CONTRIBUTING.md +34 -0
  5. data/FAQ.md +431 -0
  6. data/Gemfile +7 -14
  7. data/INSTALLATION.md +259 -0
  8. data/LICENSE-DEPENDENCIES +20 -0
  9. data/README.md +110 -0
  10. data/dependencies.yml +14 -0
  11. data/ext/sqlite3/aggregator.c +10 -10
  12. data/ext/sqlite3/backup.c +26 -13
  13. data/ext/sqlite3/database.c +89 -38
  14. data/ext/sqlite3/database.h +2 -0
  15. data/ext/sqlite3/extconf.rb +269 -84
  16. data/ext/sqlite3/sqlite3.c +5 -2
  17. data/ext/sqlite3/sqlite3_ruby.h +5 -2
  18. data/ext/sqlite3/statement.c +37 -28
  19. data/lib/sqlite3/constants.rb +1 -1
  20. data/lib/sqlite3/database.rb +55 -30
  21. data/lib/sqlite3/pragmas.rb +13 -6
  22. data/lib/sqlite3/resultset.rb +4 -12
  23. data/lib/sqlite3/statement.rb +2 -1
  24. data/lib/sqlite3/translator.rb +2 -3
  25. data/lib/sqlite3/version.rb +3 -5
  26. data/ports/archives/sqlite-autoconf-3450100.tar.gz +0 -0
  27. data/test/helper.rb +9 -0
  28. data/test/test_database.rb +182 -17
  29. data/test/test_deprecated.rb +10 -5
  30. data/test/test_encoding.rb +10 -0
  31. data/test/test_integration_resultset.rb +2 -2
  32. data/test/test_integration_statement.rb +2 -2
  33. data/test/test_pragmas.rb +22 -0
  34. data/test/test_result_set.rb +18 -8
  35. data/test/test_sqlite3.rb +9 -0
  36. data/test/test_statement.rb +28 -1
  37. data/test/test_statement_execute.rb +4 -0
  38. metadata +36 -144
  39. data/.travis.yml +0 -33
  40. data/CHANGELOG.rdoc +0 -318
  41. data/Manifest.txt +0 -60
  42. data/README.rdoc +0 -118
  43. data/Rakefile +0 -8
  44. data/appveyor.yml +0 -36
  45. data/faq/faq.rb +0 -145
  46. data/faq/faq.yml +0 -426
  47. data/rakelib/faq.rake +0 -9
  48. data/rakelib/gem.rake +0 -40
  49. data/rakelib/native.rake +0 -56
  50. data/rakelib/vendor_sqlite3.rake +0 -97
  51. data/setup.rb +0 -1333
data/CHANGELOG.rdoc DELETED
@@ -1,318 +0,0 @@
1
- === 1.4.2
2
-
3
- * Travis: Drop unused setting "sudo: false"
4
- * The taint mechanism will be deprecated in Ruby 2.7
5
- * Fix Ruby 2.7 rb_check_safe_obj warnings
6
- * Update travis config
7
-
8
- === 1.4.1
9
-
10
- * Don't mandate dl functions for the extention build
11
- * bumping version
12
-
13
- === 1.4.0
14
-
15
- * Enhancements
16
- * Better aggregator support
17
-
18
- * Bugfixes
19
- * Various
20
-
21
- === 1.3.13
22
-
23
- * Enancements
24
- * Support SQLite flags when defining functions
25
- * Add definition for SQLITE_DETERMINISTIC flag
26
-
27
- === 1.3.12
28
-
29
- * Bugfixes:
30
- * OS X install will default to homebrew if available. Fixes #195
31
-
32
- === 1.3.11 / 2015-10-10
33
-
34
- * Enhancements:
35
- * Windows: build against SQLite 3.8.11.1
36
-
37
- * Internal:
38
- * Use rake-compiler-dock to build Windows binaries. Pull #159 [larskanis]
39
- * Expand Ruby versions being tested for Travis and AppVeyor
40
-
41
- === 1.3.10 / 2014-10-30
42
-
43
- * Enhancements:
44
- * Windows: build against SQLite 3.8.6. Closes #135 [Hubro]
45
-
46
- === 1.3.9 / 2014-02-25
47
-
48
- * Bugfixes:
49
- * Reset exception message. Closes #80
50
- * Reduce warnings due unused pointers. Closes #89
51
- * Add BSD-3 license reference to gemspec. Refs #99 and #106
52
-
53
- === 1.3.8 / 2013-08-17
54
-
55
- * Enhancements:
56
- * Windows: build against SQLite 3.7.17
57
-
58
- * Bugfixes:
59
- * Reset exception message. Closes #80
60
- * Correctly convert BLOB values to Ruby. Closes #65
61
- * Add MIT license reference to gemspec. Closes #99
62
- * Remove unused pointer. Closes #89
63
-
64
- * Internal:
65
- * Backport improvements in cross compilation for Windows
66
- * Use of Minitest for internal tests
67
- * Use Gemfile (generated by Hoe) to deal with dependencies
68
- * Cleanup Travis CI
69
-
70
- === 1.3.7 / 2013-01-11
71
-
72
- * Bugfixes
73
- * Closing a bad statement twice will not segv.
74
- * Aggregate handlers are initialized on each query. Closes #44
75
-
76
- * Internal
77
- * Unset environment variables that could affect cross compilation.
78
-
79
- === 1.3.6 / 2012-04-16
80
-
81
- * Enhancements
82
- * Windows: build against SQLite 3.7.11
83
- * Added SQLite3::ResultSet#each_hash for fetching each row as a hash.
84
- * Added SQLite3::ResultSet#next_hash for fetching one row as a hash.
85
-
86
- * Bugfixes
87
- * Support both UTF-16LE and UTF-16BE encoding modes on PPC. Closes #63
88
- * Protect parameters to custom functions from being garbage collected too
89
- soon. Fixes #60. Thanks hirataya!
90
- * Fix backwards compatibility with 1.2.5 with bind vars and `query` method.
91
- Fixes #35.
92
- * Fix double definition error caused by defining sqlite3_int64/uint64.
93
- * Fix suspicious version regexp.
94
-
95
- * Deprecations
96
- * ArrayWithTypesAndFields#types is deprecated and the class will be removed
97
- in version 2.0.0. Please use the `types` method on the ResultSet class
98
- that created this object.
99
- * ArrayWithTypesAndFields#fields is deprecated and the class will be removed
100
- in version 2.0.0. Please use the `columns` method on the ResultSet class
101
- that created this object.
102
- * The ArrayWithTypesAndFields class will be removed in 2.0.0
103
- * The ArrayWithTypes class will be removed in 2.0.0
104
- * HashWithTypesAndFields#types is deprecated and the class will be removed
105
- in version 2.0.0. Please use the `types` method on the ResultSet class
106
- that created this object.
107
- * HashWithTypesAndFields#fields is deprecated and the class will be removed
108
- in version 2.0.0. Please use the `columns` method on the ResultSet class
109
- that created this object.
110
-
111
- === 1.3.5 / 2011-12-03 - ZOMG Holidays are here Edition!
112
-
113
- * Enhancements
114
- * Windows: build against SQLite 3.7.9
115
- * Static: enable SQLITE_ENABLE_COLUMN_METADATA
116
- * Added Statement#clear_bindings! to set bindings back to nil
117
-
118
- * Bugfixes
119
- * Fixed a segv on Database.new. Fixes #34 (thanks nobu!)
120
- * Database error is not reset, so don't check it in Statement#reset!
121
- * Remove conditional around Bignum statement bindings.
122
- Fixes #52. Fixes #56. Thank you Evgeny Myasishchev.
123
-
124
- * Internal
125
- * Use proper endianness when testing database connection with UTF-16.
126
- Fixes #40. Fixes #51
127
- * Use -fPIC for static compilation when host is x86_64.
128
-
129
- === 1.3.4 / 2011-07-25
130
-
131
- * Enhancements:
132
- * Windows: build against SQLite 3.7.7.1
133
- * Windows: build static binaries that do not depend on sqlite3.dll be
134
- installed anymore
135
-
136
- * Bugfixes
137
- * Backup API is conditionaly required so that older libsqlite3 can be used.
138
- Thanks Hongli Lai.
139
- * Fixed segmentation fault when nil is passed to SQLite3::Statement.new
140
- * Fix extconf's hardcoded path that affected installation on certain systems.
141
-
142
- === 1.3.3 / 2010-01-16
143
-
144
- * Bugfixes
145
- * Abort on installation if sqlite3_backup_init is missing. Fixes #19
146
- * Gem has been renamed to 'sqlite3'. Please use `gem install sqlite3`
147
-
148
- === 1.3.2 / 2010-10-30 / RubyConf Uruguay Edition!
149
-
150
- * Enhancements:
151
- * Windows: build against 3.7.3 version of SQLite3
152
- * SQLite3::Database can now be open as readonly
153
-
154
- db = SQLite3::Database.new('my.db', :readonly => true)
155
-
156
- * Added SQLite3::SQLITE_VERSION and SQLite3::SQLITE_VERSION_NUMBER [nurse]
157
-
158
- * Bugfixes
159
- * type_translation= works along with Database#execute and a block
160
- * defined functions are kept in a hash to prevent GC. #7
161
- * Removed GCC specific flags from extconf.
162
-
163
- * DEPRECATIONS
164
- * SQLite3::Database#type_translation= will be deprecated in the future with
165
- no replacement.
166
- * SQlite3::Version will be deprecated in 2.0.0 with SQLite3::VERSION as the
167
- replacement.
168
-
169
- === 1.3.1 / 2010-07-09
170
-
171
- * Enhancements
172
- * Custom collations may be defined using SQLite3::Database#collation
173
-
174
- * Bugfixes
175
- * Statements returning 0 columns are automatically stepped. [RF #28308]
176
- * SQLite3::Database#encoding works on 1.8 and 1.9
177
-
178
- === 1.3.0 / 2010-06-06
179
-
180
- * Enhancements
181
- * Complete rewrite of C-based adapter from SWIG to hand-crafted one [tenderlove]
182
- See API_CHANGES document for details.
183
- This closes: Bug #27300, Bug #27241, Patch #16020
184
- * Improved UTF, Unicode, M17N, all that handling and proper BLOB handling [tenderlove, nurse]
185
- * Added support for type translations [tenderlove]
186
-
187
- @db.translator.add_translator('sometime') do |type, thing|
188
- 'output' # this will be returned as value for that column
189
- end
190
-
191
- * Experimental
192
- * Added API to access and load extensions. [kashif]
193
- These functions maps directly into SQLite3 own enable_load_extension()
194
- and load_extension() C-API functions. See SQLite3::Database API documentation for details.
195
- This closes: Patches #9178
196
-
197
- * Bugfixes
198
- * Corrected gem dependencies (runtime and development)
199
- * Fixed threaded tests [Alexey Borzenkov]
200
- * Removed GitHub gemspec
201
- * Fixed "No definition for" warnings from RDoc
202
- * Generate zip and tgz files for releases
203
- * Added Luis Lavena as gem Author (maintainer)
204
- * Prevent mkmf interfere with Mighty Snow Leopard
205
- * Allow extension compilation search for common lib paths [kashif]
206
- (lookup /usr/local, /opt/local and /usr)
207
- * Corrected extension compilation under MSVC [romuloceccon]
208
- * Define load_extension functionality based on availability [tenderlove]
209
- * Deprecation notices for Database#query. Fixes RF #28192
210
-
211
- === 1.3.0.beta.2 / 2010-05-15
212
-
213
- * Enhancements
214
- * Added support for type translations [tenderlove]
215
-
216
- @db.translator.add_translator('sometime') do |type, thing|
217
- 'output' # this will be returned as value for that column
218
- end
219
-
220
- * Bugfixes
221
- * Allow extension compilation search for common lib paths [kashif]
222
- (lookup /usr/local, /opt/local and /usr)
223
- * Corrected extension compilation under MSVC [romuloceccon]
224
- * Define load_extension functionality based on availability [tenderlove]
225
- * Deprecation notices for Database#query. Fixes RF #28192
226
-
227
- === 1.3.0.beta.1 / 2010-05-10
228
-
229
- * Enhancements
230
- * Complete rewrite of C-based adapter from SWIG to hand-crafted one [tenderlove]
231
- See API_CHANGES document for details.
232
- This closes: Bug #27300, Bug #27241, Patch #16020
233
- * Improved UTF, Unicode, M17N, all that handling and proper BLOB handling [tenderlove, nurse]
234
-
235
- * Experimental
236
- * Added API to access and load extensions. [kashif]
237
- These functions maps directly into SQLite3 own enable_load_extension()
238
- and load_extension() C-API functions. See SQLite3::Database API documentation for details.
239
- This closes: Patches #9178
240
-
241
- * Bugfixes
242
- * Corrected gem dependencies (runtime and development)
243
- * Fixed threaded tests [Alexey Borzenkov]
244
- * Removed GitHub gemspec
245
- * Fixed "No definition for" warnings from RDoc
246
- * Generate zip and tgz files for releases
247
- * Added Luis Lavena as gem Author (maintainer)
248
- * Prevent mkmf interfere with Mighty Snow Leopard
249
-
250
- === 1.2.5 / 25 Jul 2009
251
-
252
- * Check for illegal nil before executing SQL [Erik Veenstra]
253
- * Switch to Hoe for gem task management and packaging.
254
- * Advertise rake-compiler as development dependency.
255
- * Build gem binaries for Windows.
256
- * Improved Ruby 1.9 support compatibility.
257
- * Taint returned values. Patch #20325.
258
- * Database.open and Database.new now take an optional block [Gerrit Kaiser]
259
-
260
-
261
- === 1.2.4.1 (internal) / 5 Jul 2009
262
-
263
- * Check for illegal nil before executing SQL [Erik Veenstra]
264
- * Switch to Hoe for gem task management and packaging.
265
- * Advertise rake-compiler as development dependency.
266
- * Build gem binaries for Windows.
267
- * Improved Ruby 1.9 support compatibility.
268
-
269
-
270
- === 1.2.4 / 27 Aug 2008
271
-
272
- * Package the updated C file for source builds. [Jamis Buck]
273
-
274
-
275
- === 1.2.3 / 26 Aug 2008
276
-
277
- * Fix incorrect permissions on database.rb and translator.rb [Various]
278
-
279
- * Avoid using Object#extend for greater speedups [Erik Veenstra]
280
-
281
- * Ruby 1.9 compatibility tweaks for Array#zip [jimmy88@gmail.com]
282
-
283
- * Fix linking against Ruby 1.8.5 [Rob Holland <rob@inversepath.com>]
284
-
285
-
286
- === 1.2.2 / 31 May 2008
287
-
288
- * Make the table_info method adjust the returned default value for the rows
289
- so that the sqlite3 change in 3.3.8 and greater can be handled
290
- transparently [Jamis Buck <jamis@37signals.com>]
291
-
292
- * Ruby 1.9 compatibility tweaks [Roman Le Negrate <roman2k@free.fr>]
293
-
294
- * Various performance enhancements [thanks Erik Veenstra]
295
-
296
- * Correct busy_handler documentation [Rob Holland <rob@inversepath.com>]
297
-
298
- * Use int_bind64 on Fixnum values larger than a 32bit C int can take. [Rob Holland <rob@inversepath.com>]
299
-
300
- * Work around a quirk in SQLite's error reporting by calling sqlite3_reset
301
- to produce a more informative error code upon a failure from
302
- sqlite3_step. [Rob Holland <rob@inversepath.com>]
303
-
304
- * Various documentation, test, and style tweaks [Rob Holland <rob@inversepath.com>]
305
-
306
- * Be more granular with time/data translation [Rob Holland <rob@inversepath.com>]
307
-
308
- * Use Date directly for parsing rather than going via Time [Rob Holland <rob@inversepath.com>]
309
-
310
- * Check for the rt library and fdatasync so we link against that when
311
- needed [Rob Holland <rob@inversepath.com>]
312
-
313
- * Rename data structures to avoid collision on win32. based on patch
314
- by: Luis Lavena [Rob Holland <rob@inversepath.com>]
315
-
316
- * Add test for defaults [Daniel Rodríguez Troitiño]
317
-
318
- * Correctly unquote double-quoted pragma defaults [Łukasz Dargiewicz <lukasz.dargiewicz@gmail.com>]
data/Manifest.txt DELETED
@@ -1,60 +0,0 @@
1
- .gemtest
2
- .travis.yml
3
- API_CHANGES.rdoc
4
- CHANGELOG.rdoc
5
- ChangeLog.cvs
6
- Gemfile
7
- LICENSE
8
- Manifest.txt
9
- README.rdoc
10
- Rakefile
11
- appveyor.yml
12
- ext/sqlite3/aggregator.c
13
- ext/sqlite3/aggregator.h
14
- ext/sqlite3/backup.c
15
- ext/sqlite3/backup.h
16
- ext/sqlite3/database.c
17
- ext/sqlite3/database.h
18
- ext/sqlite3/exception.c
19
- ext/sqlite3/exception.h
20
- ext/sqlite3/extconf.rb
21
- ext/sqlite3/sqlite3.c
22
- ext/sqlite3/sqlite3_ruby.h
23
- ext/sqlite3/statement.c
24
- ext/sqlite3/statement.h
25
- faq/faq.rb
26
- faq/faq.yml
27
- lib/sqlite3.rb
28
- lib/sqlite3/constants.rb
29
- lib/sqlite3/database.rb
30
- lib/sqlite3/errors.rb
31
- lib/sqlite3/pragmas.rb
32
- lib/sqlite3/resultset.rb
33
- lib/sqlite3/statement.rb
34
- lib/sqlite3/translator.rb
35
- lib/sqlite3/value.rb
36
- lib/sqlite3/version.rb
37
- rakelib/faq.rake
38
- rakelib/gem.rake
39
- rakelib/native.rake
40
- rakelib/vendor_sqlite3.rake
41
- setup.rb
42
- test/helper.rb
43
- test/test_backup.rb
44
- test/test_collation.rb
45
- test/test_database.rb
46
- test/test_database_flags.rb
47
- test/test_database_readonly.rb
48
- test/test_database_readwrite.rb
49
- test/test_deprecated.rb
50
- test/test_encoding.rb
51
- test/test_integration.rb
52
- test/test_integration_aggregate.rb
53
- test/test_integration_open_close.rb
54
- test/test_integration_pending.rb
55
- test/test_integration_resultset.rb
56
- test/test_integration_statement.rb
57
- test/test_result_set.rb
58
- test/test_sqlite3.rb
59
- test/test_statement.rb
60
- test/test_statement_execute.rb
data/README.rdoc DELETED
@@ -1,118 +0,0 @@
1
- = SQLite3/Ruby Interface
2
-
3
- * https://github.com/sparklemotion/sqlite3-ruby
4
- * http://groups.google.com/group/sqlite3-ruby
5
- * http://rubygems.org/gems/sqlite3
6
- * http://www.rubydoc.info/gems/sqlite3/frames
7
-
8
- {<img src="https://travis-ci.org/sparklemotion/sqlite3-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/sparklemotion/sqlite3-ruby]
9
-
10
- == DESCRIPTION
11
-
12
- This module allows Ruby programs to interface with the SQLite3
13
- database engine (http://www.sqlite.org). You must have the
14
- SQLite engine installed in order to build this module.
15
-
16
- Note that this module is only compatible with SQLite 3.6.16 or newer.
17
-
18
- == SYNOPSIS
19
-
20
- require "sqlite3"
21
-
22
- # Open a database
23
- db = SQLite3::Database.new "test.db"
24
-
25
- # Create a table
26
- rows = db.execute <<-SQL
27
- create table numbers (
28
- name varchar(30),
29
- val int
30
- );
31
- SQL
32
-
33
- # Execute a few inserts
34
- {
35
- "one" => 1,
36
- "two" => 2,
37
- }.each do |pair|
38
- db.execute "insert into numbers values ( ?, ? )", pair
39
- end
40
-
41
- # Find a few rows
42
- db.execute( "select * from numbers" ) do |row|
43
- p row
44
- end
45
-
46
- # Create another table with multiple columns
47
-
48
- db.execute <<-SQL
49
- create table students (
50
- name varchar(50),
51
- email varchar(50),
52
- grade varchar(5),
53
- blog varchar(50)
54
- );
55
- SQL
56
-
57
- # Execute inserts with parameter markers
58
- db.execute("INSERT INTO students (name, email, grade, blog)
59
- VALUES (?, ?, ?, ?)", ["Jane", "me@janedoe.com", "A", "http://blog.janedoe.com"])
60
-
61
- db.execute( "select * from students" ) do |row|
62
- p row
63
- end
64
-
65
-
66
- == Compilation and Installation
67
-
68
- Install SQLite3, enabling the option SQLITE_ENABLE_COLUMN_METADATA (see
69
- www.sqlite.org/compile.html for details).
70
-
71
- Then do the following:
72
-
73
- ruby setup.rb config
74
- ruby setup.rb setup
75
- ruby setup.rb install
76
-
77
- Alternatively, you can download and install the RubyGem package for
78
- SQLite3/Ruby (you must have RubyGems and SQLite3 installed, first):
79
-
80
- gem install sqlite3
81
-
82
- If you have sqlite3 installed in a non-standard location, you can specify the location of the include and lib files by doing:
83
-
84
- gem install sqlite3 -- --with-sqlite3-include=/opt/local/include \
85
- --with-sqlite3-lib=/opt/local/lib
86
-
87
- = SUPPORT!!!
88
-
89
- == OMG! Something has gone wrong! Where do I get help?
90
-
91
- The best place to get help is from the
92
- {sqlite3-ruby mailing list}[http://groups.google.com/group/sqlite3-ruby] which
93
- can be found here:
94
-
95
- * http://groups.google.com/group/sqlite3-ruby
96
-
97
- == I've found a bug! Where do I file it?
98
-
99
- Uh oh. After contacting the mailing list, you've found that you've actually
100
- discovered a bug. You can file the bug at the
101
- {github issues page}[https://github.com/sparklemotion/sqlite3-ruby/issues]
102
- which can be found here:
103
-
104
- * https://github.com/sparklemotion/sqlite3-ruby/issues
105
-
106
- == Usage
107
-
108
- For help figuring out the SQLite3/Ruby interface, check out the
109
- SYNOPSIS as well as the RDoc. It includes examples of
110
- usage. If you have any questions that you feel should be addressed in the
111
- FAQ, please send them to {the mailing list}[http://groups.google.com/group/sqlite3-ruby]
112
-
113
- == Source Code
114
-
115
- The source repository is accessible via git:
116
-
117
- git clone git://github.com/sparklemotion/sqlite3-ruby.git
118
-
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- #
2
- # NOTE: Keep this file clean.
3
- # Add your customizations inside tasks directory.
4
- # Thank You.
5
- #
6
-
7
-
8
- # vim: syntax=ruby
data/appveyor.yml DELETED
@@ -1,36 +0,0 @@
1
- ---
2
- version: "{build}"
3
- branches:
4
- only:
5
- - master
6
- - 1-3-stable
7
- clone_depth: 10
8
- install:
9
- - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
10
- - ruby --version
11
- - gem --version
12
- - gem install bundler --quiet --no-ri --no-rdoc
13
- - bundler --version
14
- - bundle install
15
- build_script:
16
- - rake native gem
17
- test_script:
18
- - rake test
19
- artifacts:
20
- - path: pkg\*.gem
21
-
22
- environment:
23
- matrix:
24
- - ruby_version: "193"
25
- - ruby_version: "200"
26
- - ruby_version: "200-x64"
27
- - ruby_version: "21"
28
- - ruby_version: "21-x64"
29
- - ruby_version: "22"
30
- - ruby_version: "22-x64"
31
- - ruby_version: "23"
32
- - ruby_version: "23-x64"
33
- - ruby_version: "24"
34
- - ruby_version: "24-x64"
35
- - ruby_version: "25"
36
- - ruby_version: "25-x64"
data/faq/faq.rb DELETED
@@ -1,145 +0,0 @@
1
- require 'yaml'
2
- require 'redcloth'
3
-
4
- def process_faq_list( faqs )
5
- puts "<ul>"
6
- faqs.each do |faq|
7
- process_faq_list_item faq
8
- end
9
- puts "</ul>"
10
- end
11
-
12
- def process_faq_list_item( faq )
13
- question = faq.keys.first
14
- answer = faq.values.first
15
-
16
- print "<li>"
17
-
18
- question_text = RedCloth.new(question).to_html.gsub( %r{</?p>},"" )
19
- if answer.is_a?( Array )
20
- puts question_text
21
- process_faq_list answer
22
- else
23
- print "<a href='##{question.object_id}'>#{question_text}</a>"
24
- end
25
-
26
- puts "</li>"
27
- end
28
-
29
- def process_faq_descriptions( faqs, path=nil )
30
- faqs.each do |faq|
31
- process_faq_description faq, path
32
- end
33
- end
34
-
35
- def process_faq_description( faq, path )
36
- question = faq.keys.first
37
- path = ( path ? path + " " : "" ) + question
38
- answer = faq.values.first
39
-
40
- if answer.is_a?( Array )
41
- process_faq_descriptions( answer, path )
42
- else
43
- title = RedCloth.new( path ).to_html.gsub( %r{</?p>}, "" )
44
- answer = RedCloth.new( answer || "" )
45
-
46
- puts "<a name='#{question.object_id}'></a>"
47
- puts "<div class='faq-title'>#{title}</div>"
48
- puts "<div class='faq-answer'>#{add_api_links(answer.to_html)}</div>"
49
- end
50
- end
51
-
52
- API_OBJECTS = [ "Database", "Statement", "ResultSet",
53
- "ParsedStatement", "Pragmas", "Translator" ].inject( "(" ) { |acc,name|
54
- acc << "|" if acc.length > 1
55
- acc << name
56
- acc
57
- } + ")"
58
-
59
- def add_api_links( text )
60
- text.gsub( /#{API_OBJECTS}(#(\w+))?/ ) do
61
- disp_obj = obj = $1
62
-
63
- case obj
64
- when "Pragmas"; disp_obj = "Database"
65
- end
66
-
67
- method = $3
68
- s = "<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/#{obj}.html'>#{disp_obj}"
69
- s << "##{method}" if method
70
- s << "</a>"
71
- s
72
- end
73
- end
74
-
75
- faqs = YAML.load( File.read( "faq.yml" ) )
76
-
77
- puts <<-EOF
78
- <html>
79
- <head>
80
- <title>SQLite3/Ruby FAQ</title>
81
- <style type="text/css">
82
- a, a:visited, a:active {
83
- color: #00F;
84
- text-decoration: none;
85
- }
86
-
87
- a:hover {
88
- text-decoration: underline;
89
- }
90
-
91
- .faq-list {
92
- color: #000;
93
- font-family: vera-sans, verdana, arial, sans-serif;
94
- }
95
-
96
- .faq-title {
97
- background: #007;
98
- color: #FFF;
99
- font-family: vera-sans, verdana, arial, sans-serif;
100
- padding-left: 1em;
101
- padding-top: 0.5em;
102
- padding-bottom: 0.5em;
103
- font-weight: bold;
104
- font-size: large;
105
- border: 1px solid #000;
106
- }
107
-
108
- .faq-answer {
109
- margin-left: 1em;
110
- color: #000;
111
- font-family: vera-sans, verdana, arial, sans-serif;
112
- }
113
-
114
- .faq-answer pre {
115
- margin-left: 1em;
116
- color: #000;
117
- background: #FFE;
118
- font-size: normal;
119
- border: 1px dotted #CCC;
120
- padding: 1em;
121
- }
122
-
123
- h1 {
124
- background: #005;
125
- color: #FFF;
126
- font-family: vera-sans, verdana, arial, sans-serif;
127
- padding-left: 1em;
128
- padding-top: 1em;
129
- padding-bottom: 1em;
130
- font-weight: bold;
131
- font-size: x-large;
132
- border: 1px solid #00F;
133
- }
134
- </style>
135
- </head>
136
- <body>
137
- <h1>SQLite/Ruby FAQ</h1>
138
- <div class="faq-list">
139
- EOF
140
-
141
- process_faq_list( faqs )
142
- puts "</div>"
143
- process_faq_descriptions( faqs )
144
-
145
- puts "</body></html>"