Skip to content

Commit fc3bb20

Browse files
committed
feat: introduce VERSION_INFO hash
which will remain mostly undocumented for now Also: document the various "version" constants
1 parent ef13fcb commit fc3bb20

File tree

8 files changed

+32
-7
lines changed

8 files changed

+32
-7
lines changed

.rdoc_options

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ exclude:
1414
- "bin"
1515
- "rakelib"
1616
- "ext/sqlite3/extconf.rb"
17+
- "vendor"
18+
- "ports"
19+
- "tmp"
1720
hyperlink_all: false
1821
line_numbers: false
1922
locale:

ext/sqlite3/sqlite3.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,13 @@ Init_sqlite3_native(void)
201201
rb_define_singleton_method(mSqlite3, "libversion", libversion, 0);
202202
rb_define_singleton_method(mSqlite3, "threadsafe", threadsafe_p, 0);
203203
rb_define_singleton_method(mSqlite3, "status", rb_sqlite3_status, -1);
204+
205+
/* (String) The version of the sqlite3 library compiled with (e.g., "3.46.1") */
204206
rb_define_const(mSqlite3, "SQLITE_VERSION", rb_str_new2(SQLITE_VERSION));
207+
208+
/* (Integer) The version of the sqlite3 library compiled with (e.g., 346001) */
205209
rb_define_const(mSqlite3, "SQLITE_VERSION_NUMBER", INT2FIX(SQLITE_VERSION_NUMBER));
206-
rb_define_const(mSqlite3, "SQLITE_LOADED_VERSION", rb_str_new2(sqlite3_libversion()));
207210

211+
/* (String) The version of the sqlite3 library loaded at runtime (e.g., "3.46.1") */
212+
rb_define_const(mSqlite3, "SQLITE_LOADED_VERSION", rb_str_new2(sqlite3_libversion()));
208213
}

lib/sqlite3.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ def self.threadsafe?
1515
threadsafe > 0
1616
end
1717
end
18+
19+
require "sqlite3/version_info"

lib/sqlite3/version.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module SQLite3
2+
# (String) the version of the sqlite3 gem, e.g. "2.1.1"
23
VERSION = "2.2.0"
34
end

lib/sqlite3/version_info.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module SQLite3
2+
# a hash of descriptive metadata about the current version of the sqlite3 gem
3+
VERSION_INFO = {
4+
ruby: RUBY_DESCRIPTION,
5+
gem: {
6+
version: SQLite3::VERSION
7+
},
8+
sqlite: {
9+
compiled: SQLite3::SQLITE_VERSION,
10+
loaded: SQLite3::SQLITE_LOADED_VERSION,
11+
sqlcipher: SQLite3.sqlcipher?,
12+
threadsafe: SQLite3.threadsafe?
13+
}
14+
}
15+
end

rakelib/check-manifest.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ task :check_manifest do
1010
.git
1111
.github
1212
.ruby-lsp
13+
adr
1314
bin
1415
doc
1516
gems

sqlite3.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ Gem::Specification.new do |s|
6767
"lib/sqlite3/resultset.rb",
6868
"lib/sqlite3/statement.rb",
6969
"lib/sqlite3/value.rb",
70-
"lib/sqlite3/version.rb"
70+
"lib/sqlite3/version.rb",
71+
"lib/sqlite3/version_info.rb"
7172
]
7273

7374
s.extra_rdoc_files = [

test/helper.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
require "sqlite3"
22
require "minitest/autorun"
3+
require "yaml"
34

4-
puts "info: ruby version: #{RUBY_DESCRIPTION}"
5-
puts "info: gem version: #{SQLite3::VERSION}"
6-
puts "info: sqlite version: #{SQLite3::SQLITE_VERSION}/#{SQLite3::SQLITE_LOADED_VERSION}"
7-
puts "info: sqlcipher?: #{SQLite3.sqlcipher?}"
8-
puts "info: threadsafe?: #{SQLite3.threadsafe?}"
5+
puts SQLite3::VERSION_INFO.to_yaml
96

107
module SQLite3
118
class TestCase < Minitest::Test

0 commit comments

Comments
 (0)