sqlpkg 0.2.3-arm64-darwin → 0.2.3.2-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -9
- data/exe/sqlpkg +1 -1
- data/lib/sqlpkg/version.rb +1 -1
- data/lib/sqlpkg.rb +29 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b23a044f3d086939a8e24d5ef1fc5455b2cbb36bc29bc5cb946bfe1ba7f02a
|
4
|
+
data.tar.gz: a24777c6290f4c7ef47c69a95f78a759c3dcd967445a6807950ec8b4cd862cdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e36f899ca619ef0fc1de4500f4f2c8b868bcf7e832ed15ee080b9a75a51200d98294ff61166037114d85584296e25d0c599e0deae8d009532d538ff7430c5e2d
|
7
|
+
data.tar.gz: d8ed3a6d53a19bc2333d9399e556dff4f5d446c0b83c63ef20df65d048f5b3a1df6c13da97128f8d111ebe17c68d3ab06d3511c5fc03069ef52249aca4fa517f
|
data/README.md
CHANGED
@@ -5,16 +5,19 @@
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Install the gem and add to the application's Gemfile by executing:
|
8
|
-
|
9
|
-
|
8
|
+
```shell
|
9
|
+
bundle add sqlpkg
|
10
|
+
```
|
10
11
|
|
11
12
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
-
|
13
|
-
|
13
|
+
```shell
|
14
|
+
gem install sqlpkg
|
15
|
+
```
|
14
16
|
|
15
17
|
After installing the gem, run the installer:
|
16
|
-
|
17
|
-
|
18
|
+
```shell
|
19
|
+
rails generate sqlpkg:install
|
20
|
+
```
|
18
21
|
|
19
22
|
The installer does three things:
|
20
23
|
|
@@ -23,8 +26,9 @@ The installer does three things:
|
|
23
26
|
3. creates an initializer file at `config/initializers/sqlpkg.rb` which will patch the `SQLite3Adapter` to automatically load the extensions installed in the `.sqlpkg/` directory whenever the database is opened
|
24
27
|
|
25
28
|
Once properly integrated into your Rails application, you can install any extension listed on [the `sqlpkg` registry](https://sqlpkg.org/all/) by executing:
|
26
|
-
|
27
|
-
|
29
|
+
```shell
|
30
|
+
bundle exec sqlpkg install PACKAGE_IDENTIFIER
|
31
|
+
```
|
28
32
|
|
29
33
|
When exploring the [the `sqlpkg` registry](https://sqlpkg.org/all/), the `PACKAGE_IDENTIFIER` needed to install an extension is the title found in the cards, always in `owner/name` format.
|
30
34
|
|
@@ -56,7 +60,7 @@ SQLPKG_INSTALL_DIR=.bin
|
|
56
60
|
## Usage
|
57
61
|
|
58
62
|
```shell
|
59
|
-
|
63
|
+
bundle exec sqlpkg help
|
60
64
|
┌────────────────────────────────────────────────┐
|
61
65
|
│ sqlpkg is an SQLite package manager. │
|
62
66
|
│ Use it to install or update SQLite extensions. │
|
@@ -74,6 +78,42 @@ $ bundle exec sqlpkg help
|
|
74
78
|
└────────────────────────────────────────────────┘
|
75
79
|
```
|
76
80
|
|
81
|
+
You can get the path to an installed extension using the `Sqlpkg.path_for` method, e.g.:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
Sqlpkg.path_for("nalgeon/uuid")
|
85
|
+
# => "./.sqlpkg/nalgeon/uuid/uuid.dylib"
|
86
|
+
```
|
87
|
+
|
88
|
+
You can also use the shorter `.[]` alias:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
Sqlpkg["nalgeon/uuid"]
|
92
|
+
# => "./.sqlpkg/nalgeon/uuid/uuid.dylib"
|
93
|
+
```
|
94
|
+
|
95
|
+
If you try to access an extension that hasn't been installed, a `Sqlpkg::ExtensionNotInstalledError` will be raised:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
Sqlpkg["nalgeon/ulid"]
|
99
|
+
# raises Sqlpkg::ExtensionNotInstalledError
|
100
|
+
```
|
101
|
+
|
102
|
+
This feature is particulary useful for the [new Rails feature](https://github.com/rails/rails/pull/53827) and [`sqlite3-ruby` feature](https://github.com/sparklemotion/sqlite3-ruby/pull/586) that allows automatically loading extensions via the `extensions` keyword defined in the Rails `config/database.yml` or the `SQLite3::Database.new` method call. You can now use either:
|
103
|
+
|
104
|
+
```yaml
|
105
|
+
development:
|
106
|
+
adapter: sqlite3
|
107
|
+
extensions:
|
108
|
+
- <%= Sqlpkg.path_for("asg017/ulid") %>
|
109
|
+
```
|
110
|
+
|
111
|
+
or if you are using `SQLite3::Database` directly:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
db = SQLite3::Database.new(":memory:", extensions: [Sqlpkg.path_for("asg017/ulid")])
|
115
|
+
```
|
116
|
+
|
77
117
|
## Development
|
78
118
|
|
79
119
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/sqlpkg
CHANGED
@@ -5,7 +5,7 @@ require "sqlpkg/commands"
|
|
5
5
|
|
6
6
|
begin
|
7
7
|
command = [Sqlpkg::Commands.executable, *ARGV]
|
8
|
-
puts command.inspect
|
8
|
+
puts command.inspect if ENV["DEBUG"]
|
9
9
|
exec(*command)
|
10
10
|
rescue Sqlpkg::Commands::UnsupportedPlatformException, Sqlpkg::Commands::ExecutableNotFoundException => e
|
11
11
|
warn("ERROR: " + e.message)
|
data/lib/sqlpkg/version.rb
CHANGED
data/lib/sqlpkg.rb
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sqlpkg
|
4
|
+
DIR = ".sqlpkg"
|
5
|
+
FILE_PATTERN = "*.{dylib,so,dll}"
|
6
|
+
|
7
|
+
Error = Class.new(StandardError)
|
8
|
+
ExtensionNotInstalledError = Class.new(Error)
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# File path for identified extension
|
12
|
+
# => "./.sqlpkg/nalgeon/uuid/uuid.dylib"
|
13
|
+
def path_for(identifier)
|
14
|
+
path_glob = File.join(file_dir, identifier, FILE_PATTERN)
|
15
|
+
path = Dir.glob(path_glob).first
|
16
|
+
|
17
|
+
path || raise(ExtensionNotInstalledError, "No extension found for identifier: #{identifier}")
|
18
|
+
end
|
19
|
+
alias_method :[], :path_for
|
20
|
+
|
21
|
+
# The directory where `sqlpkg` stores installed extensions
|
22
|
+
# => "./.sqlpkg"
|
23
|
+
def file_dir
|
24
|
+
File.join(__dir__, DIR)
|
25
|
+
end
|
26
|
+
|
27
|
+
# List of file paths for all installed extensions
|
28
|
+
# => ["./.sqlpkg/asg017/ulid/ulid0.dylib", "./.sqlpkg/nalgeon/uuid/uuid.dylib"]
|
29
|
+
def installed_extension_paths
|
30
|
+
Dir.glob File.join(file_dir, "**", FILE_PATTERN)
|
31
|
+
end
|
32
|
+
end
|
4
33
|
end
|
5
34
|
|
6
35
|
require_relative "sqlpkg/version"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlpkg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.3
|
4
|
+
version: 0.2.3.2
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- Stephen Margheim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.5.
|
99
|
+
rubygems_version: 3.5.23
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Integrate sqlpkg with the RubyGems infrastructure.
|