Skip to content

Commit eb076a8

Browse files
committed
Only support modern sqlite3-ruby, remove railtie
1 parent 695b165 commit eb076a8

File tree

6 files changed

+16
-65
lines changed

6 files changed

+16
-65
lines changed

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
PATH
22
remote: .
33
specs:
4-
sqlite_extensions-uuid (0.0.1)
4+
sqlite_extensions-uuid (0.0.2)
5+
sqlite3 (>= 2.4.0)
56

67
GEM
78
remote: https://rubygems.org/
@@ -46,7 +47,7 @@ GEM
4647
rubocop-ast (1.32.3)
4748
parser (>= 3.3.1.0)
4849
ruby-progressbar (1.13.0)
49-
sqlite3 (2.1.0-x86_64-linux-gnu)
50+
sqlite3 (2.4.0-x86_64-linux-gnu)
5051
stringio (3.1.1)
5152
unicode-display_width (2.6.0)
5253

@@ -59,7 +60,6 @@ DEPENDENCIES
5960
rake
6061
rake-compiler
6162
rubocop
62-
sqlite3 (~> 2.1.0)
6363
sqlite_extensions-uuid!
6464

6565
BUNDLED WITH

README.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
# sqlite_extensions-uuid
22

3-
SQLite's [uuid v4 extension](https://sqlite.org/src/file/ext/misc/uuid.c?t=version-3.46.1), packaged as a gem.
3+
SQLite's [UUID v4 extension](https://sqlite.org/src/file/ext/misc/uuid.c?t=version-3.46.1), packaged as a gem.
44

5-
Useful for using UUIDs as primary keys in a Rails app.
5+
The main use-case is to allow using UUIDs as primary keys with SQLite in [Rails](https://rubyonrails.org/) apps.
66

77
## Installation
88

9-
Add this to your gemfile:
9+
Add this to your `Gemfile`:
1010

1111
```ruby
12-
gem "sqlite_extensions-uuid",
13-
git: "https://github.com/jethrodaniel/sqlite_extensions-uuid",
14-
require: "sqlite_extensions/uuid/rails"
12+
gem "sqlite_extensions-uuid", github: "jethrodaniel/sqlite_extensions-uuid"
1513
```
1614

17-
If you're _not_ using Rails, you can omit the `require` above.
18-
1915
## Usage
2016

2117
SQLite's uuid extension provides the following:
@@ -24,28 +20,24 @@ SQLite's uuid extension provides the following:
2420
- `uuid_str(X)` - convert a UUID X into a well-formed UUID string
2521
- `uuid_blob(X)` - convert a UUID X into a 16-byte blob
2622

27-
In a rails app:
23+
For example, in a rails app:
2824

2925
```ruby
3026
ActiveRecord::Base.connection.execute("select uuid_str(uuid())")
3127
#=> [{"uuid_str(uuid())"=>"56392d30-a2cf-47b9-895a-f8c1a1677bfc"}]
3228
```
3329

34-
For more information, see the extension's [source code](https://sqlite.org/src/file/ext/misc/uuid.c?t=version-3.46.1).
30+
For more information about the extension itself, see the extension's [source code](https://sqlite.org/src/file/ext/misc/uuid.c?t=version-3.46.1).
3531

36-
## Design
32+
## How it works
3733

3834
This gem compiles SQLite's uuid extension into a shared library using Ruby's native-gem functionality.
3935

40-
It doesn't actually compile a Ruby native extension, it just uses the ruby extension process to compile the SQLite library.
41-
42-
It then exposes a method (`SqliteExtensions::UUID.to_path`) which returns the location of that shared library, which can be passed to [sqlite3](https://github.com/sparklemotion/sqlite3-ruby)'s `load_extension` method.
43-
44-
For Rails, it also exposes a [railtie](https://api.rubyonrails.org/v7.2/classes/Rails/Railtie.html) (via `require: "sqlite_extensions/uuid/rails"`) that patches Rails' [configure_connection](https://github.com/rails/rails/blob/v8.0.0.rc1/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L815) method for the SQLite adapter, so that all SQLite database connections load the extension.
36+
It doesn't _actually_ compile a Ruby native extension, it just uses the ruby extension process to compile the SQLite UUID library.
4537

46-
This doesn't scale well to supporting multiple SQLite extensions, but works fine if all you need is the UUID extension.
38+
It then exposes a method, `SqliteExtensions::UUID.to_path`, which returns the location of that shared library.
4739

48-
Ideally, Rails will eventually provide an official way to configure the SQLite connection, at which point we can migrate the railtie to that approach.
40+
This can be passed to [sqlite3](https://github.com/sparklemotion/sqlite3-ruby) in `Database.new(extensions: [])` or `Database#load_extension`.
4941

5042
## Development
5143

lib/sqlite_extensions/uuid/rails.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/sqlite_extensions/uuid/railtie.rb

Lines changed: 0 additions & 33 deletions
This file was deleted.

sqlite_extensions-uuid.gemspec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gem::Specification.new do |spec|
44
spec.name = "sqlite_extensions-uuid"
5-
spec.version = "0.0.1"
5+
spec.version = "0.0.2"
66
spec.authors = ["Mark Delk"]
77
spec.email = ["[email protected]"]
88

@@ -15,19 +15,18 @@ Gem::Specification.new do |spec|
1515

1616
spec.files = %w[
1717
lib/sqlite_extensions/uuid.rb
18-
lib/sqlite_extensions/uuid/rails.rb
19-
lib/sqlite_extensions/uuid/railtie.rb
2018
ext/sqlite_extensions/uuid/sqlite3ext.h
2119
ext/sqlite_extensions/uuid/sqlite3.h
2220
ext/sqlite_extensions/uuid/uuid.c
2321
]
2422
spec.require_paths = ["lib"]
2523
spec.extensions = ["ext/sqlite_extensions/uuid/extconf.rb"]
2624

25+
spec.add_dependency "sqlite3", ">= 2.4.0"
26+
2727
spec.add_development_dependency "debug", ">= 1.0.0"
2828
spec.add_development_dependency "minitest"
2929
spec.add_development_dependency "rake"
3030
spec.add_development_dependency "rake-compiler"
3131
spec.add_development_dependency "rubocop"
32-
spec.add_development_dependency "sqlite3", "~> 2.1.0"
3332
end

test/test_uuid.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,4 @@ def test_it_works
4242
uuid
4343
)
4444
end
45-
46-
def test_rails_integration
47-
skip "TODO"
48-
end
4945
end

0 commit comments

Comments
 (0)