├── .github └── workflows │ └── main.yml ├── .gitignore ├── .standard.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── LICENSE-DEPENDENCIES ├── README.md ├── Rakefile ├── bin ├── console ├── release └── setup ├── exe └── sqlpkg ├── lib ├── sqlpkg.rb └── sqlpkg │ ├── commands.rb │ ├── generators │ └── sqlpkg │ │ ├── install_generator.rb │ │ └── templates │ │ └── initializer.rb │ ├── railtie.rb │ ├── upstream.rb │ └── version.rb ├── rakelib └── package.rake ├── sig └── sqlpkg │ └── ruby.rbs ├── sqlpkg.gemspec └── test ├── dummy ├── app │ ├── controllers │ │ └── application_controller.rb │ ├── models │ │ └── application_record.rb │ └── views │ │ └── layouts │ │ └── application.html.erb ├── bin │ ├── rails │ ├── rake │ └── setup ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ └── test.rb │ ├── locales │ │ └── en.yml │ ├── puma.rb │ └── routes.rb ├── log │ ├── .keep │ └── test.log ├── storage │ ├── .keep │ └── test.sqlite3 └── tmp │ ├── .keep │ ├── local_secret.txt │ ├── pids │ └── .keep │ └── storage │ └── .keep ├── generators └── test_install.rb ├── test_helper.rb └── test_sqlpkg.rb /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Ruby 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | pull_request: 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | name: Ruby ${{ matrix.ruby }} 14 | strategy: 15 | matrix: 16 | ruby: 17 | - '3.2.1' 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | - name: Set up Ruby 22 | uses: ruby/setup-ruby@v1 23 | with: 24 | ruby-version: ${{ matrix.ruby }} 25 | bundler-cache: true 26 | - name: Run the default task 27 | run: bundle exec rake 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /_yardoc/ 4 | /coverage/ 5 | /doc/ 6 | /pkg/ 7 | /spec/reports/ 8 | /tmp/ 9 | /exe/*/sqlpkg 10 | .DS_Store 11 | -------------------------------------------------------------------------------- /.standard.yml: -------------------------------------------------------------------------------- 1 | # For available configuration options, see: 2 | # https://github.com/standardrb/standard 3 | ruby_version: 2.6 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [Unreleased] 2 | 3 | ## [0.2.3.2] - 2024-05-05 4 | 5 | - Add method to resolve path to an installed extension 6 | 7 | ## [0.2.3.1] - 2024-05-05 8 | 9 | - Only print the command if the DEBUG env variable is set 10 | 11 | ## [0.2.3] - 2024-05-05 12 | 13 | - Only create the initializer if the enhanced adapter gem isn't installed 14 | - Update the `sqlpkg` upstream version to v0.2.3 15 | 16 | ## [0.2.2] - 2023-12-24 17 | 18 | - ... actually fix the `sqlpkg:install` generator by committing the code 19 | - Ensure `sqlpkg.lock` has the proper content to work with the installer 20 | 21 | ## [0.2.1] - 2023-12-24 22 | 23 | - Fix `sqlpkg:install` generator by actually requiring it 24 | 25 | ## [0.2.0] - 2023-12-24 26 | 27 | - Add `sqlpkg:install` railtie generator 28 | 29 | ## [0.1.1] - 2023-12-23 30 | 31 | - Fix the `exe/sqlpkg` script 32 | 33 | ## [0.1.0] - 2023-12-20 34 | 35 | - Initial release 36 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 8 | 9 | ## Our Standards 10 | 11 | Examples of behavior that contributes to a positive environment for our community include: 12 | 13 | * Demonstrating empathy and kindness toward other people 14 | * Being respectful of differing opinions, viewpoints, and experiences 15 | * Giving and gracefully accepting constructive feedback 16 | * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 17 | * Focusing on what is best not just for us as individuals, but for the overall community 18 | 19 | Examples of unacceptable behavior include: 20 | 21 | * The use of sexualized language or imagery, and sexual attention or 22 | advances of any kind 23 | * Trolling, insulting or derogatory comments, and personal or political attacks 24 | * Public or private harassment 25 | * Publishing others' private information, such as a physical or email 26 | address, without their explicit permission 27 | * Other conduct which could reasonably be considered inappropriate in a 28 | professional setting 29 | 30 | ## Enforcement Responsibilities 31 | 32 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 33 | 34 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 35 | 36 | ## Scope 37 | 38 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 39 | 40 | ## Enforcement 41 | 42 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at stephen.margheim@gmail.com. All complaints will be reviewed and investigated promptly and fairly. 43 | 44 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 45 | 46 | ## Enforcement Guidelines 47 | 48 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 49 | 50 | ### 1. Correction 51 | 52 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 53 | 54 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 55 | 56 | ### 2. Warning 57 | 58 | **Community Impact**: A violation through a single incident or series of actions. 59 | 60 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 61 | 62 | ### 3. Temporary Ban 63 | 64 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 65 | 66 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 67 | 68 | ### 4. Permanent Ban 69 | 70 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 71 | 72 | **Consequence**: A permanent ban from any sort of public interaction within the community. 73 | 74 | ## Attribution 75 | 76 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 77 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 78 | 79 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 80 | 81 | [homepage]: https://www.contributor-covenant.org 82 | 83 | For answers to common questions about this code of conduct, see the FAQ at 84 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 85 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # Specify your gem's dependencies in sqlpkg-ruby.gemspec 6 | gemspec 7 | 8 | gem "rake", "~> 13.0" 9 | 10 | gem "minitest", "~> 5.16" 11 | 12 | gem "standard", "~> 1.3" 13 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | sqlpkg (0.2.3.2) 5 | 6 | GEM 7 | remote: https://rubygems.org/ 8 | specs: 9 | actioncable (7.1.2) 10 | actionpack (= 7.1.2) 11 | activesupport (= 7.1.2) 12 | nio4r (~> 2.0) 13 | websocket-driver (>= 0.6.1) 14 | zeitwerk (~> 2.6) 15 | actionmailbox (7.1.2) 16 | actionpack (= 7.1.2) 17 | activejob (= 7.1.2) 18 | activerecord (= 7.1.2) 19 | activestorage (= 7.1.2) 20 | activesupport (= 7.1.2) 21 | mail (>= 2.7.1) 22 | net-imap 23 | net-pop 24 | net-smtp 25 | actionmailer (7.1.2) 26 | actionpack (= 7.1.2) 27 | actionview (= 7.1.2) 28 | activejob (= 7.1.2) 29 | activesupport (= 7.1.2) 30 | mail (~> 2.5, >= 2.5.4) 31 | net-imap 32 | net-pop 33 | net-smtp 34 | rails-dom-testing (~> 2.2) 35 | actionpack (7.1.2) 36 | actionview (= 7.1.2) 37 | activesupport (= 7.1.2) 38 | nokogiri (>= 1.8.5) 39 | racc 40 | rack (>= 2.2.4) 41 | rack-session (>= 1.0.1) 42 | rack-test (>= 0.6.3) 43 | rails-dom-testing (~> 2.2) 44 | rails-html-sanitizer (~> 1.6) 45 | actiontext (7.1.2) 46 | actionpack (= 7.1.2) 47 | activerecord (= 7.1.2) 48 | activestorage (= 7.1.2) 49 | activesupport (= 7.1.2) 50 | globalid (>= 0.6.0) 51 | nokogiri (>= 1.8.5) 52 | actionview (7.1.2) 53 | activesupport (= 7.1.2) 54 | builder (~> 3.1) 55 | erubi (~> 1.11) 56 | rails-dom-testing (~> 2.2) 57 | rails-html-sanitizer (~> 1.6) 58 | activejob (7.1.2) 59 | activesupport (= 7.1.2) 60 | globalid (>= 0.3.6) 61 | activemodel (7.1.2) 62 | activesupport (= 7.1.2) 63 | activerecord (7.1.2) 64 | activemodel (= 7.1.2) 65 | activesupport (= 7.1.2) 66 | timeout (>= 0.4.0) 67 | activestorage (7.1.2) 68 | actionpack (= 7.1.2) 69 | activejob (= 7.1.2) 70 | activerecord (= 7.1.2) 71 | activesupport (= 7.1.2) 72 | marcel (~> 1.0) 73 | activesupport (7.1.2) 74 | base64 75 | bigdecimal 76 | concurrent-ruby (~> 1.0, >= 1.0.2) 77 | connection_pool (>= 2.2.5) 78 | drb 79 | i18n (>= 1.6, < 2) 80 | minitest (>= 5.1) 81 | mutex_m 82 | tzinfo (~> 2.0) 83 | ast (2.4.2) 84 | base64 (0.2.0) 85 | bigdecimal (3.1.4) 86 | builder (3.2.4) 87 | concurrent-ruby (1.2.2) 88 | connection_pool (2.4.1) 89 | crass (1.0.6) 90 | date (3.3.4) 91 | drb (2.2.0) 92 | ruby2_keywords 93 | erubi (1.12.0) 94 | globalid (1.2.1) 95 | activesupport (>= 6.1) 96 | i18n (1.14.1) 97 | concurrent-ruby (~> 1.0) 98 | io-console (0.6.0) 99 | irb (1.10.1) 100 | rdoc 101 | reline (>= 0.3.8) 102 | json (2.7.1) 103 | language_server-protocol (3.17.0.3) 104 | lint_roller (1.1.0) 105 | loofah (2.22.0) 106 | crass (~> 1.0.2) 107 | nokogiri (>= 1.12.0) 108 | mail (2.8.1) 109 | mini_mime (>= 0.1.1) 110 | net-imap 111 | net-pop 112 | net-smtp 113 | marcel (1.0.2) 114 | mini_mime (1.1.5) 115 | mini_portile2 (2.8.5) 116 | minitest (5.20.0) 117 | mutex_m (0.2.0) 118 | net-imap (0.4.7) 119 | date 120 | net-protocol 121 | net-pop (0.1.2) 122 | net-protocol 123 | net-protocol (0.2.2) 124 | timeout 125 | net-smtp (0.4.0) 126 | net-protocol 127 | nio4r (2.7.0) 128 | nokogiri (1.15.5) 129 | mini_portile2 (~> 2.8.2) 130 | racc (~> 1.4) 131 | parallel (1.24.0) 132 | parser (3.2.2.4) 133 | ast (~> 2.4.1) 134 | racc 135 | psych (5.1.2) 136 | stringio 137 | racc (1.7.3) 138 | rack (3.0.8) 139 | rack-session (2.0.0) 140 | rack (>= 3.0.0) 141 | rack-test (2.1.0) 142 | rack (>= 1.3) 143 | rackup (2.1.0) 144 | rack (>= 3) 145 | webrick (~> 1.8) 146 | rails (7.1.2) 147 | actioncable (= 7.1.2) 148 | actionmailbox (= 7.1.2) 149 | actionmailer (= 7.1.2) 150 | actionpack (= 7.1.2) 151 | actiontext (= 7.1.2) 152 | actionview (= 7.1.2) 153 | activejob (= 7.1.2) 154 | activemodel (= 7.1.2) 155 | activerecord (= 7.1.2) 156 | activestorage (= 7.1.2) 157 | activesupport (= 7.1.2) 158 | bundler (>= 1.15.0) 159 | railties (= 7.1.2) 160 | rails-dom-testing (2.2.0) 161 | activesupport (>= 5.0.0) 162 | minitest 163 | nokogiri (>= 1.6) 164 | rails-html-sanitizer (1.6.0) 165 | loofah (~> 2.21) 166 | nokogiri (~> 1.14) 167 | railties (7.1.2) 168 | actionpack (= 7.1.2) 169 | activesupport (= 7.1.2) 170 | irb 171 | rackup (>= 1.0.0) 172 | rake (>= 12.2) 173 | thor (~> 1.0, >= 1.2.2) 174 | zeitwerk (~> 2.6) 175 | rainbow (3.1.1) 176 | rake (13.1.0) 177 | rdoc (6.6.2) 178 | psych (>= 4.0.0) 179 | regexp_parser (2.8.3) 180 | reline (0.4.1) 181 | io-console (~> 0.5) 182 | rexml (3.2.6) 183 | rubocop (1.57.2) 184 | json (~> 2.3) 185 | language_server-protocol (>= 3.17.0) 186 | parallel (~> 1.10) 187 | parser (>= 3.2.2.4) 188 | rainbow (>= 2.2.2, < 4.0) 189 | regexp_parser (>= 1.8, < 3.0) 190 | rexml (>= 3.2.5, < 4.0) 191 | rubocop-ast (>= 1.28.1, < 2.0) 192 | ruby-progressbar (~> 1.7) 193 | unicode-display_width (>= 2.4.0, < 3.0) 194 | rubocop-ast (1.30.0) 195 | parser (>= 3.2.1.0) 196 | rubocop-performance (1.19.1) 197 | rubocop (>= 1.7.0, < 2.0) 198 | rubocop-ast (>= 0.4.0) 199 | ruby-progressbar (1.13.0) 200 | ruby2_keywords (0.0.5) 201 | rubyzip (2.3.2) 202 | sqlite3 (1.6.9) 203 | mini_portile2 (~> 2.8.0) 204 | standard (1.32.1) 205 | language_server-protocol (~> 3.17.0.2) 206 | lint_roller (~> 1.0) 207 | rubocop (~> 1.57.2) 208 | standard-custom (~> 1.0.0) 209 | standard-performance (~> 1.2) 210 | standard-custom (1.0.2) 211 | lint_roller (~> 1.0) 212 | rubocop (~> 1.50) 213 | standard-performance (1.2.1) 214 | lint_roller (~> 1.1) 215 | rubocop-performance (~> 1.19.1) 216 | stringio (3.1.0) 217 | thor (1.3.0) 218 | timeout (0.4.1) 219 | tzinfo (2.0.6) 220 | concurrent-ruby (~> 1.0) 221 | unicode-display_width (2.5.0) 222 | webrick (1.8.1) 223 | websocket-driver (0.7.6) 224 | websocket-extensions (>= 0.1.0) 225 | websocket-extensions (0.1.5) 226 | zeitwerk (2.6.12) 227 | 228 | PLATFORMS 229 | arm64-darwin-21 230 | ruby 231 | x86_64-linux 232 | 233 | DEPENDENCIES 234 | minitest (~> 5.16) 235 | rails 236 | rake (~> 13.0) 237 | rubyzip 238 | sqlite3 239 | sqlpkg! 240 | standard (~> 1.3) 241 | 242 | BUNDLED WITH 243 | 2.5.1 244 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2023 Stephen Margheim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE-DEPENDENCIES: -------------------------------------------------------------------------------- 1 | sqlpkg-ruby may redistribute executables from the https://github.com/nalgeon/sqlpkg project 2 | 3 | The license for that software can be found at https://github.com/nalgeon/sqlpkg/blob/main/LICENSE which is reproduced here for your convenience: 4 | 5 | MIT License 6 | 7 | Copyright (c) 2023+ Anton Zhiyanov 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sqlpkg-ruby 2 | 3 | [sqlpkg](https://sqlpkg.org/) is the (unofficial) SQLite package registry. This gem provides a Ruby interface to [its CLI](https://github.com/nalgeon/sqlpkg-cli). 4 | 5 | ## Installation 6 | 7 | Install the gem and add to the application's Gemfile by executing: 8 | ```shell 9 | bundle add sqlpkg 10 | ``` 11 | 12 | If bundler is not being used to manage dependencies, install the gem by executing: 13 | ```shell 14 | gem install sqlpkg 15 | ``` 16 | 17 | After installing the gem, run the installer: 18 | ```shell 19 | rails generate sqlpkg:install 20 | ``` 21 | 22 | The installer does three things: 23 | 24 | 1. creates an empty `.sqlpkg/` directory, which ensures that `sqlpkg` will run in "project scope" and not "global scope" (see [the `sqlpkg-cli` README](https://github.com/nalgeon/sqlpkg-cli#project-vs-global-scope) for more information) 25 | 2. creates an empty `sqlpkg.lock` file, which `sqlpkg` will use to store information about the installed packages (see [the `sqlpkg-cli` README](https://github.com/nalgeon/sqlpkg-cli#lockfile) for more information) 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 27 | 28 | Once properly integrated into your Rails application, you can install any extension listed on [the `sqlpkg` registry](https://sqlpkg.org/all/) by executing: 29 | ```shell 30 | bundle exec sqlpkg install PACKAGE_IDENTIFIER 31 | ``` 32 | 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. 34 | 35 | This gem wraps the standalone executable version of the [sqlpkg-cli](https://github.com/nalgeon/sqlpkg-cli#download-and-install-preferred-method). These executables are platform specific, so there are actually separate underlying gems per platform, but the correct gem will automatically be picked for your platform. 36 | 37 | Supported platforms are: 38 | 39 | * arm64-darwin (macos-arm64) 40 | * x86_64-darwin (macos-x64) 41 | * arm64-linux (linux-arm64) 42 | * x86_64-linux (linux-x64) 43 | 44 | ### Using a local installation of `sqlpkg` 45 | 46 | If you are not able to use the vendored standalone executables (for example, if you're on an unsupported platform), you can use a local installation of the `sqlpkg` executable by setting an environment variable named `SQLPKG_INSTALL_DIR` to the directory containing the executable. 47 | 48 | For example, if you've installed `sqlpkg` so that the executable is found at `/usr/local/bin/sqlpkg`, then you should set your environment variable like so: 49 | 50 | ``` sh 51 | SQLPKG_INSTALL_DIR=/usr/local/bin 52 | ``` 53 | 54 | This also works with relative paths. If you've installed into your app's directory at `./.bin/sqlpkg`: 55 | 56 | ``` sh 57 | SQLPKG_INSTALL_DIR=.bin 58 | ``` 59 | 60 | ## Usage 61 | 62 | ```shell 63 | bundle exec sqlpkg help 64 | ┌────────────────────────────────────────────────┐ 65 | │ sqlpkg is an SQLite package manager. │ 66 | │ Use it to install or update SQLite extensions. │ 67 | │ │ 68 | │ Commands: │ 69 | │ help Display help │ 70 | │ info Display package information │ 71 | │ init Init project scope │ 72 | │ install Install packages │ 73 | │ list List installed packages │ 74 | │ uninstall Uninstall package │ 75 | │ update Update installed packages │ 76 | │ version Display version │ 77 | │ which Display path to extension file │ 78 | └────────────────────────────────────────────────┘ 79 | ``` 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 | 117 | ## Development 118 | 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. 120 | 121 | To install this gem onto your local machine, run `bundle exec rake install`. For maintainers, to release a new version, run `bin/release $VERSION`, which will create a git tag for the version, push git commits and tags, and push all of the platform-specific `.gem` files to [rubygems.org](https://rubygems.org). 122 | 123 | ## Contributing 124 | 125 | Bug reports and pull requests are welcome on GitHub at https://github.com/fractaledmind/sqlpkg-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/fractaledmind/sqlpkg-ruby/blob/main/CODE_OF_CONDUCT.md). 126 | 127 | ## License 128 | 129 | The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). 130 | 131 | ## Code of Conduct 132 | 133 | Everyone interacting in the Sqlpkg::Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fractaledmind/sqlpkg-ruby/blob/main/CODE_OF_CONDUCT.md). 134 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "bundler/gem_tasks" 4 | require "minitest/test_task" 5 | 6 | Minitest::TestTask.create 7 | 8 | require "standard/rake" 9 | 10 | task default: %i[test standard] 11 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require "bundler/setup" 5 | require "sqlpkg/ruby" 6 | 7 | # You can add fixtures and/or initialization code here to make experimenting 8 | # with your gem easier. You can also use a different console, if you like. 9 | 10 | require "irb" 11 | IRB.start(__FILE__) 12 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION=$1 4 | 5 | if [ -z "$VERSION" ]; then 6 | echo "Usage: $0 " 7 | exit 1 8 | fi 9 | 10 | printf "module Sqlpkg\n VERSION = \"$VERSION\"\nend\n" > ./lib/sqlpkg/version.rb 11 | bundle 12 | git add Gemfile.lock lib/sqlpkg/version.rb CHANGELOG.md 13 | git commit -m "Bump version for $VERSION" 14 | git push 15 | git tag v$VERSION 16 | git push --tags 17 | 18 | rake package 19 | for gem in pkg/sqlpkg-$VERSION*.gem ; do 20 | gem push "$gem" --host https://rubygems.org 21 | rm "$gem" 22 | done 23 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /exe/sqlpkg: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby 2 | # because rubygems shims assume a gem's executables are Ruby 3 | 4 | require "sqlpkg/commands" 5 | 6 | begin 7 | command = [Sqlpkg::Commands.executable, *ARGV] 8 | puts command.inspect if ENV["DEBUG"] 9 | exec(*command) 10 | rescue Sqlpkg::Commands::UnsupportedPlatformException, Sqlpkg::Commands::ExecutableNotFoundException => e 11 | warn("ERROR: " + e.message) 12 | exit 1 13 | end 14 | -------------------------------------------------------------------------------- /lib/sqlpkg.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 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 33 | end 34 | 35 | require_relative "sqlpkg/version" 36 | require_relative "sqlpkg/upstream" 37 | require_relative "sqlpkg/commands" 38 | require_relative "sqlpkg/railtie" if defined?(::Rails::Railtie) 39 | -------------------------------------------------------------------------------- /lib/sqlpkg/commands.rb: -------------------------------------------------------------------------------- 1 | require_relative "upstream" 2 | 3 | module Sqlpkg 4 | module Commands 5 | DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "..", "exe")) 6 | GEM_NAME = "sqlpkg" 7 | 8 | # raised when the host platform is not supported by upstream sqlpkg's binary releases 9 | class UnsupportedPlatformException < StandardError 10 | end 11 | 12 | # raised when the sqlpkg executable could not be found where we expected it to be 13 | class ExecutableNotFoundException < StandardError 14 | end 15 | 16 | # raised when SQLPKG_INSTALL_DIR does not exist 17 | class DirectoryNotFoundException < StandardError 18 | end 19 | 20 | def self.platform 21 | [:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-") 22 | end 23 | 24 | def self.executable(exe_path: DEFAULT_DIR) 25 | sqlpkg_install_dir = ENV["SQLPKG_INSTALL_DIR"] 26 | if sqlpkg_install_dir 27 | if File.directory?(sqlpkg_install_dir) 28 | warn "NOTE: using SQLPKG_INSTALL_DIR to find sqlpkg executable: #{sqlpkg_install_dir}" 29 | exe_path = sqlpkg_install_dir 30 | exe_file = File.expand_path(File.join(sqlpkg_install_dir, "sqlpkg")) 31 | else 32 | raise DirectoryNotFoundException, <<~MESSAGE 33 | SQLPKG_INSTALL_DIR is set to #{sqlpkg_install_dir}, but that directory does not exist. 34 | MESSAGE 35 | end 36 | else 37 | if Sqlpkg::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) } 38 | raise UnsupportedPlatformException, <<~MESSAGE 39 | sqlpkg-ruby does not support the #{platform} platform 40 | Please install sqlpkg following instructions at https://github.com/nalgeon/sqlpkg-cli#download-and-install-preferred-method 41 | MESSAGE 42 | end 43 | 44 | exe_file = Dir.glob(File.expand_path(File.join(exe_path, "*", "sqlpkg"))).find do |f| 45 | Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), GEM_NAME) 46 | end 47 | end 48 | 49 | if exe_file.nil? || !File.exist?(exe_file) 50 | raise ExecutableNotFoundException, <<~MESSAGE 51 | Cannot find the sqlpkg executable for #{platform} in #{exe_path} 52 | 53 | If you're using bundler, please make sure you're on the latest bundler version: 54 | 55 | gem install bundler 56 | bundle update --bundler 57 | 58 | Then make sure your lock file includes this platform by running: 59 | 60 | bundle lock --add-platform #{platform} 61 | bundle install 62 | 63 | See `bundle lock --help` output for details. 64 | 65 | If you're still seeing this message after taking those steps, try running 66 | `bundle config` and ensure `force_ruby_platform` isn't set to `true`. See 67 | https://github.com/fractaledmind/sqlpkg-ruby#check-bundle_force_ruby_platform 68 | for more details. 69 | MESSAGE 70 | end 71 | 72 | exe_file 73 | end 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /lib/sqlpkg/generators/sqlpkg/install_generator.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "rails/generators/base" 4 | 5 | module Sqlpkg 6 | module Generators 7 | class InstallGenerator < ::Rails::Generators::Base 8 | source_root File.expand_path("templates", __dir__) 9 | 10 | def ensure_sqlpkg_project_scope_directory 11 | empty_directory ".sqlpkg" 12 | end 13 | 14 | def create_empty_sqlpkg_lockfile 15 | create_file "sqlpkg.lock", <<~CONTENT 16 | { 17 | "packages": {} 18 | } 19 | CONTENT 20 | end 21 | 22 | def copy_initializer_file 23 | return if defined? EnhancedSQLite3::Adapter 24 | 25 | template "initializer.rb", "config/initializers/sqlpkg.rb" 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/sqlpkg/generators/sqlpkg/templates/initializer.rb: -------------------------------------------------------------------------------- 1 | module SqlpkgLoader 2 | def configure_connection 3 | super 4 | 5 | @raw_connection.enable_load_extension(true) 6 | Dir.glob(".sqlpkg/**/*.{dll,so,dylib}") do |extension_path| 7 | @raw_connection.load_extension(extension_path) 8 | end 9 | @raw_connection.enable_load_extension(false) 10 | end 11 | end 12 | 13 | ActiveSupport.on_load(:active_record_sqlite3adapter) do 14 | prepend SqlpkgLoader 15 | end 16 | -------------------------------------------------------------------------------- /lib/sqlpkg/railtie.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "rails/railtie" 4 | 5 | module Sqlpkg 6 | class Railtie < ::Rails::Railtie 7 | # Load the `sqlpkg:install` generator into the host Rails app 8 | generators do 9 | require_relative "generators/sqlpkg/install_generator" 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/sqlpkg/upstream.rb: -------------------------------------------------------------------------------- 1 | module Sqlpkg 2 | # constants describing the upstream tailwindcss project 3 | module Upstream 4 | VERSION = "0.2.3" 5 | 6 | # rubygems platform name => upstream release filename 7 | NATIVE_PLATFORMS = { 8 | "arm64-darwin" => "sqlpkg-cli_#{VERSION}_darwin_arm64.tar.gz", 9 | "arm64-linux" => "sqlpkg-cli_#{VERSION}_linux_arm64.tar.gz", 10 | "x86_64-darwin" => "sqlpkg-cli_#{VERSION}_darwin_amd64.tar.gz", 11 | "x86_64-linux" => "sqlpkg-cli_#{VERSION}_linux_amd64.tar.gz" 12 | } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/sqlpkg/version.rb: -------------------------------------------------------------------------------- 1 | module Sqlpkg 2 | VERSION = "0.2.3.2" 3 | end 4 | -------------------------------------------------------------------------------- /rakelib/package.rake: -------------------------------------------------------------------------------- 1 | # 2 | # Rake tasks to manage native gem packages with binary executables from nalgeon/sqlpkg-cli 3 | # 4 | # TL;DR: run "rake package" 5 | # 6 | # The native platform gems (defined by Sqlpkg::Upstream::NATIVE_PLATFORMS) will each contain 7 | # two files in addition to what the vanilla ruby gem contains: 8 | # 9 | # exe/ 10 | # ├── sqlpkg # generic ruby script to find and run the binary 11 | # └── / 12 | # └── sqlpkg # the sqlpkg binary executable 13 | # 14 | # The ruby script `exe/sqlpkg` is installed into the user's path, and it simply locates the 15 | # binary and executes it. Note that this script is required because rubygems requires that 16 | # executables declared in a gemspec must be Ruby scripts. 17 | # 18 | # As a concrete example, an x86_64-linux system will see these files on disk after installing 19 | # sqlpkg-0.x.x-x86_64-linux.gem: 20 | # 21 | # exe/ 22 | # ├── sqlpkg 23 | # └── x86_64-linux/ 24 | # └── sqlpkg 25 | # 26 | # So the full set of gem files created will be: 27 | # 28 | # - pkg/sqlpkg-1.0.0.gem 29 | # - pkg/sqlpkg-1.0.0-arm64-linux.gem 30 | # - pkg/sqlpkg-1.0.0-arm64-darwin.gem 31 | # - pkg/sqlpkg-1.0.0-x86_64-darwin.gem 32 | # - pkg/sqlpkg-1.0.0-x86_64-linux.gem 33 | # 34 | # Note that in addition to the native gems, a vanilla "ruby" gem will also be created without 35 | # either the `exe/sqlpkg` script or a binary executable present. 36 | # 37 | # 38 | # New rake tasks created: 39 | # 40 | # - rake gem:ruby # Build the ruby gem 41 | # - rake gem:arm64-linux # Build the aarch64-linux gem 42 | # - rake gem:arm64-darwin # Build the arm64-darwin gem 43 | # - rake gem:x86_64-darwin # Build the x86_64-darwin gem 44 | # - rake gem:x86_64-linux # Build the x86_64-linux gem 45 | # - rake download # Download all sqlpkg binaries 46 | # 47 | # Modified rake tasks: 48 | # 49 | # - rake gem # Build all the gem files 50 | # - rake package # Build all the gem files (same as `gem`) 51 | # - rake repackage # Force a rebuild of all the gem files 52 | # 53 | # Note also that the binary executables will be lazily downloaded when needed, but you can 54 | # explicitly download them with the `rake download` command. 55 | # 56 | require "rubygems/package" 57 | require "rubygems/package_task" 58 | require "open-uri" 59 | require "zlib" 60 | require "zip" 61 | require_relative "../lib/sqlpkg/upstream" 62 | 63 | def sqlpkg_download_url(filename) 64 | "https://github.com/nalgeon/sqlpkg-cli/releases/download/#{Sqlpkg::Upstream::VERSION}/#{filename}" 65 | end 66 | 67 | SQLPKG_RAILS_GEMSPEC = Bundler.load_gemspec("sqlpkg.gemspec") 68 | 69 | gem_path = Gem::PackageTask.new(SQLPKG_RAILS_GEMSPEC).define 70 | desc "Build the ruby gem" 71 | task "gem:ruby" => [gem_path] 72 | 73 | exepaths = [] 74 | Sqlpkg::Upstream::NATIVE_PLATFORMS.each do |platform, filename| 75 | SQLPKG_RAILS_GEMSPEC.dup.tap do |gemspec| 76 | exedir = File.join(gemspec.bindir, platform) # "exe/x86_64-linux" 77 | exepath = File.join(exedir, "sqlpkg") # "exe/x86_64-linux/sqlpkg" 78 | exepaths << exepath 79 | 80 | # modify a copy of the gemspec to include the native executable 81 | gemspec.platform = platform 82 | gemspec.files += [exepath, "LICENSE-DEPENDENCIES"] 83 | 84 | # create a package task 85 | gem_path = Gem::PackageTask.new(gemspec).define 86 | desc "Build the #{platform} gem" 87 | task "gem:#{platform}" => [gem_path] 88 | 89 | directory exedir 90 | file exepath => [exedir] do 91 | release_url = sqlpkg_download_url(filename) 92 | warn "Downloading #{exepath} from #{release_url} ..." 93 | 94 | # lazy, but fine for now. 95 | URI.open(release_url) do |remote| # standard:disable Security/Open 96 | if release_url.end_with?(".zip") 97 | Zip::File.open_buffer(remote) do |zip_file| 98 | zip_file.extract("sqlpkg", exepath) 99 | end 100 | elsif release_url.end_with?(".gz") 101 | Zlib::GzipReader.wrap(remote) do |gz| 102 | Gem::Package::TarReader.new(gz) do |reader| 103 | reader.seek("sqlpkg") do |file| 104 | File.binwrite(exepath, file.read) 105 | end 106 | end 107 | end 108 | end 109 | end 110 | FileUtils.chmod(0o755, exepath, verbose: true) 111 | end 112 | end 113 | end 114 | 115 | desc "Download all sqlpkg binaries" 116 | task "download" => exepaths 117 | -------------------------------------------------------------------------------- /sig/sqlpkg/ruby.rbs: -------------------------------------------------------------------------------- 1 | module Sqlpkg 2 | module Ruby 3 | VERSION: String 4 | # See the writing guide of rbs: https://github.com/ruby/rbs#guides 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /sqlpkg.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative "lib/sqlpkg/version" 4 | 5 | Gem::Specification.new do |spec| 6 | spec.name = "sqlpkg" 7 | spec.version = Sqlpkg::VERSION 8 | spec.authors = ["Stephen Margheim"] 9 | spec.email = ["stephen.margheim@gmail.com"] 10 | 11 | spec.summary = "Integrate sqlpkg with the RubyGems infrastructure." 12 | spec.homepage = "https://github.com/fractaledmind/sqlpkg-ruby" 13 | spec.license = "MIT" 14 | spec.required_ruby_version = ">= 3.0.0" 15 | 16 | spec.metadata = { 17 | "homepage_uri" => spec.homepage, 18 | "rubygems_mfa_required" => "true", 19 | "source_code_uri" => spec.homepage, 20 | "changelog_uri" => "https://github.com/fractaledmind/sqlpkg-ruby/CHANGELOG.md" 21 | } 22 | 23 | spec.files = Dir["lib/**/*", "LICENSE", "Rakefile", "README.md"] 24 | spec.bindir = "exe" 25 | spec.executables << "sqlpkg" 26 | 27 | # Uncomment to register a new dependency of your gem 28 | # spec.add_dependency "example-gem", "~> 1.0" 29 | spec.add_development_dependency "rubyzip" 30 | spec.add_development_dependency "rails" 31 | spec.add_development_dependency "sqlite3" 32 | 33 | # For more information and examples about making a new gem, check out our 34 | # guide at: https://bundler.io/guides/creating_gem.html 35 | end 36 | -------------------------------------------------------------------------------- /test/dummy/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | end 3 | -------------------------------------------------------------------------------- /test/dummy/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /test/dummy/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Dummy 5 | 6 | <%= csrf_meta_tags %> 7 | <%= csp_meta_tag %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/dummy/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /test/dummy/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /test/dummy/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path("..", __dir__) 6 | 7 | def system!(*args) 8 | system(*args, exception: true) 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts "== Installing dependencies ==" 17 | system! "gem install bundler --conservative" 18 | system("bundle check") || system!("bundle install") 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?("config/database.yml") 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! "bin/rails db:prepare" 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! "bin/rails log:clear tmp:clear" 30 | 31 | puts "\n== Restarting application server ==" 32 | system! "bin/rails restart" 33 | end 34 | -------------------------------------------------------------------------------- /test/dummy/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /test/dummy/config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require "rails" 4 | # Pick the frameworks you want: 5 | require "active_model/railtie" 6 | # require "active_job/railtie" 7 | require "active_record/railtie" 8 | # require "active_storage/engine" 9 | require "action_controller/railtie" 10 | # require "action_mailer/railtie" 11 | # require "action_mailbox/engine" 12 | # require "action_text/engine" 13 | require "action_view/railtie" 14 | # require "action_cable/engine" 15 | require "rails/test_unit/railtie" 16 | 17 | # Require the gems listed in Gemfile, including any gems 18 | # you've limited to :test, :development, or :production. 19 | Bundler.require(*Rails.groups) 20 | 21 | module Dummy 22 | class Application < Rails::Application 23 | config.load_defaults Rails::VERSION::STRING.to_f 24 | 25 | # For compatibility with applications that use this config 26 | config.action_controller.include_all_helpers = false 27 | 28 | # Please, add to the `ignore` list any other `lib` subdirectories that do 29 | # not contain `.rb` files, or that should not be reloaded or eager loaded. 30 | # Common ones are `templates`, `generators`, or `middleware`, for example. 31 | config.autoload_lib(ignore: %w[assets tasks]) 32 | 33 | # Configuration for the application, engines, and railties goes here. 34 | # 35 | # These settings can be overridden in specific environments using the files 36 | # in config/environments, which are processed later. 37 | # 38 | # config.time_zone = "Central Time (US & Canada)" 39 | # config.eager_load_paths << Rails.root.join("extras") 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /test/dummy/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) 3 | 4 | require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) 5 | $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) 6 | -------------------------------------------------------------------------------- /test/dummy/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem "sqlite3" 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: storage/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: storage/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: storage/production.sqlite3 26 | -------------------------------------------------------------------------------- /test/dummy/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /test/dummy/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | # While tests run files are not watched, reloading is not necessary. 12 | config.enable_reloading = false 13 | 14 | # Eager loading loads your entire application. When running a single test locally, 15 | # this is usually not necessary, and can slow down your test suite. However, it's 16 | # recommended that you enable it in continuous integration systems to ensure eager 17 | # loading is working properly before deploying your code. 18 | config.eager_load = ENV["CI"].present? 19 | 20 | # Configure public file server for tests with Cache-Control for performance. 21 | config.public_file_server.enabled = true 22 | config.public_file_server.headers = { 23 | "Cache-Control" => "public, max-age=#{1.hour.to_i}" 24 | } 25 | 26 | # Show full error reports and disable caching. 27 | config.consider_all_requests_local = true 28 | config.action_controller.perform_caching = false 29 | config.cache_store = :null_store 30 | 31 | # Render exception templates for rescuable exceptions and raise for other exceptions. 32 | config.action_dispatch.show_exceptions = :rescuable 33 | 34 | # Disable request forgery protection in test environment. 35 | config.action_controller.allow_forgery_protection = false 36 | 37 | # Store uploaded files on the local file system in a temporary directory. 38 | # config.active_storage.service = :test 39 | 40 | # config.action_mailer.perform_caching = false 41 | 42 | # Tell Action Mailer not to deliver emails to the real world. 43 | # The :test delivery method accumulates sent emails in the 44 | # ActionMailer::Base.deliveries array. 45 | # config.action_mailer.delivery_method = :test 46 | 47 | # Print deprecation notices to the stderr. 48 | config.active_support.deprecation = :stderr 49 | 50 | # Raise exceptions for disallowed deprecations. 51 | config.active_support.disallowed_deprecation = :raise 52 | 53 | # Tell Active Support which deprecation messages to disallow. 54 | config.active_support.disallowed_deprecation_warnings = [] 55 | 56 | # Raises error for missing translations. 57 | # config.i18n.raise_on_missing_translations = true 58 | 59 | # Annotate rendered view with file names. 60 | # config.action_view.annotate_rendered_view_with_filenames = true 61 | 62 | # Raise error when a before_action's only/except options reference missing actions 63 | config.action_controller.raise_on_missing_callback_actions = true 64 | end 65 | -------------------------------------------------------------------------------- /test/dummy/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization and 2 | # are automatically loaded by Rails. If you want to use locales other than 3 | # English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more about the API, please read the Rails Internationalization guide 20 | # at https://guides.rubyonrails.org/i18n.html. 21 | # 22 | # Be aware that YAML interprets the following case-insensitive strings as 23 | # booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings 24 | # must be quoted to be interpreted as strings. For example: 25 | # 26 | # en: 27 | # "yes": yup 28 | # enabled: "ON" 29 | 30 | en: 31 | hello: "Hello world" 32 | -------------------------------------------------------------------------------- /test/dummy/config/puma.rb: -------------------------------------------------------------------------------- 1 | # This configuration file will be evaluated by Puma. The top-level methods that 2 | # are invoked here are part of Puma's configuration DSL. For more information 3 | # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. 4 | 5 | # Puma can serve each request in a thread from an internal thread pool. 6 | # The `threads` method setting takes two numbers: a minimum and maximum. 7 | # Any libraries that use thread pools should be configured to match 8 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 9 | # and maximum; this matches the default thread size of Active Record. 10 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 11 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 12 | threads min_threads_count, max_threads_count 13 | 14 | # Specifies that the worker count should equal the number of processors in production. 15 | if ENV["RAILS_ENV"] == "production" 16 | require "concurrent-ruby" 17 | worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) 18 | workers worker_count if worker_count > 1 19 | end 20 | 21 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 22 | # terminating a worker in development environments. 23 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" 24 | 25 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 26 | port ENV.fetch("PORT") { 3000 } 27 | 28 | # Specifies the `environment` that Puma will run in. 29 | environment ENV.fetch("RAILS_ENV") { "development" } 30 | 31 | # Specifies the `pidfile` that Puma will use. 32 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 33 | 34 | # Allow puma to be restarted by `bin/rails restart` command. 35 | plugin :tmp_restart 36 | -------------------------------------------------------------------------------- /test/dummy/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html 3 | 4 | # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. 5 | # Can be used by load balancers and uptime monitors to verify that the app is live. 6 | get "up" => "rails/health#show", :as => :rails_health_check 7 | 8 | # Defines the root path route ("/") 9 | # root "posts#index" 10 | end 11 | -------------------------------------------------------------------------------- /test/dummy/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fractaledmind/sqlpkg-ruby/73bd270fb1a1a7fa165f860e7ad5ee9cfeaf784c/test/dummy/log/.keep -------------------------------------------------------------------------------- /test/dummy/log/test.log: -------------------------------------------------------------------------------- 1 |  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY) 2 |  (0.1ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL) 3 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 4 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 5 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 6 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 7 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 8 | TRANSACTION (0.0ms) begin transaction 9 | ----------------------------------------------------------------------------- 10 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 11 | ----------------------------------------------------------------------------- 12 | TRANSACTION (0.0ms) rollback transaction 13 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 14 | TRANSACTION (0.0ms) begin transaction 15 | ----------------------------------------------------------------------------- 16 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 17 | ----------------------------------------------------------------------------- 18 | TRANSACTION (0.0ms) rollback transaction 19 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 20 | TRANSACTION (0.0ms) begin transaction 21 | ----------------------------------------------------------------------------- 22 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 23 | ----------------------------------------------------------------------------- 24 | TRANSACTION (0.0ms) rollback transaction 25 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 26 | TRANSACTION (0.0ms) begin transaction 27 | ----------------------------------------------------------------------------- 28 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 29 | ----------------------------------------------------------------------------- 30 | TRANSACTION (0.0ms) rollback transaction 31 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 32 | TRANSACTION (0.0ms) begin transaction 33 | ----------------------------------------------------------------------------- 34 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 35 | ----------------------------------------------------------------------------- 36 | TRANSACTION (0.0ms) rollback transaction 37 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 38 | TRANSACTION (0.0ms) begin transaction 39 | ----------------------------------------------------------------------------- 40 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 41 | ----------------------------------------------------------------------------- 42 | TRANSACTION (0.0ms) rollback transaction 43 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 44 | TRANSACTION (0.0ms) begin transaction 45 | ----------------------------------------------------------------------------- 46 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 47 | ----------------------------------------------------------------------------- 48 | TRANSACTION (0.0ms) rollback transaction 49 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 50 | TRANSACTION (0.0ms) begin transaction 51 | ----------------------------------------------------------------------------- 52 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 53 | ----------------------------------------------------------------------------- 54 | TRANSACTION (0.0ms) rollback transaction 55 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 56 | TRANSACTION (0.0ms) begin transaction 57 | ----------------------------------------------------------------------------- 58 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 59 | ----------------------------------------------------------------------------- 60 | TRANSACTION (0.0ms) rollback transaction 61 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 62 | TRANSACTION (0.0ms) begin transaction 63 | ----------------------------------------------------------------------------- 64 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 65 | ----------------------------------------------------------------------------- 66 | TRANSACTION (0.0ms) rollback transaction 67 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 68 | TRANSACTION (0.0ms) begin transaction 69 | ----------------------------------------------------------------------------- 70 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 71 | ----------------------------------------------------------------------------- 72 | TRANSACTION (0.1ms) rollback transaction 73 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 74 | TRANSACTION (0.0ms) begin transaction 75 | ----------------------------------------------------------------------------- 76 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 77 | ----------------------------------------------------------------------------- 78 | TRANSACTION (0.0ms) rollback transaction 79 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 80 | TRANSACTION (0.0ms) begin transaction 81 | ----------------------------------------------------------------------------- 82 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 83 | ----------------------------------------------------------------------------- 84 | TRANSACTION (0.0ms) rollback transaction 85 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 86 | TRANSACTION (0.0ms) begin transaction 87 | ----------------------------------------------------------------------------- 88 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 89 | ----------------------------------------------------------------------------- 90 | TRANSACTION (0.0ms) rollback transaction 91 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 92 | TRANSACTION (0.0ms) begin transaction 93 | ----------------------------------------------------------------------------- 94 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 95 | ----------------------------------------------------------------------------- 96 | TRANSACTION (0.0ms) rollback transaction 97 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 98 | TRANSACTION (0.0ms) begin transaction 99 | ----------------------------------------------------------------------------- 100 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 101 | ----------------------------------------------------------------------------- 102 | TRANSACTION (0.1ms) rollback transaction 103 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 104 | TRANSACTION (0.0ms) begin transaction 105 | ----------------------------------------------------------------------------- 106 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 107 | ----------------------------------------------------------------------------- 108 | TRANSACTION (0.2ms) rollback transaction 109 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 110 | TRANSACTION (0.0ms) begin transaction 111 | ----------------------------------------------------------------------------- 112 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 113 | ----------------------------------------------------------------------------- 114 | TRANSACTION (0.0ms) rollback transaction 115 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 116 | TRANSACTION (0.0ms) begin transaction 117 | ----------------------------------------------------------------------------- 118 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 119 | ----------------------------------------------------------------------------- 120 | TRANSACTION (0.1ms) rollback transaction 121 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 122 | TRANSACTION (0.0ms) begin transaction 123 | ----------------------------------------------------------------------------- 124 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 125 | ----------------------------------------------------------------------------- 126 | TRANSACTION (0.1ms) rollback transaction 127 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 128 | TRANSACTION (0.0ms) begin transaction 129 | ----------------------------------------------------------------------------- 130 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 131 | ----------------------------------------------------------------------------- 132 | TRANSACTION (0.2ms) rollback transaction 133 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 134 | TRANSACTION (0.0ms) begin transaction 135 | ----------------------------------------------------------------------------- 136 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 137 | ----------------------------------------------------------------------------- 138 | TRANSACTION (0.1ms) rollback transaction 139 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 140 | TRANSACTION (0.0ms) begin transaction 141 | ----------------------------------------------------------------------------- 142 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 143 | ----------------------------------------------------------------------------- 144 | TRANSACTION (0.0ms) rollback transaction 145 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 146 | TRANSACTION (0.0ms) begin transaction 147 | ----------------------------------------------------------------------------- 148 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 149 | ----------------------------------------------------------------------------- 150 | TRANSACTION (0.0ms) rollback transaction 151 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 152 | TRANSACTION (0.0ms) begin transaction 153 | ----------------------------------------------------------------------------- 154 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 155 | ----------------------------------------------------------------------------- 156 | TRANSACTION (0.0ms) rollback transaction 157 | Started GET "/" for 127.0.0.1 at 2023-12-11 18:57:33 +0100 158 | 159 | ActionController::RoutingError (No route matches [GET] "/"): 160 | 161 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 162 | Started GET "/" for 127.0.0.1 at 2023-12-11 18:57:53 +0100 163 | 164 | ActionController::RoutingError (No route matches [GET] "/"): 165 | 166 | TRANSACTION (0.0ms) begin transaction 167 | ----------------------------------------------------------------------------- 168 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 169 | ----------------------------------------------------------------------------- 170 | TRANSACTION (0.0ms) rollback transaction 171 | ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 172 | TRANSACTION (0.0ms) begin transaction 173 | ----------------------------------------------------------------------------- 174 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 175 | ----------------------------------------------------------------------------- 176 | TRANSACTION (0.0ms) rollback transaction 177 | Started GET "/" for 127.0.0.1 at 2023-12-11 18:58:06 +0100 178 | 179 | ActionController::RoutingError (No route matches [GET] "/"): 180 | 181 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 182 | TRANSACTION (0.0ms) begin transaction 183 | ----------------------------------------------------------------------------- 184 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 185 | ----------------------------------------------------------------------------- 186 | TRANSACTION (0.0ms) rollback transaction 187 | Started GET "/" for 127.0.0.1 at 2023-12-11 19:00:06 +0100 188 | 189 | ActionController::RoutingError (No route matches [GET] "/"): 190 | 191 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 192 | TRANSACTION (0.0ms) begin transaction 193 | ----------------------------------------------------------------------------- 194 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 195 | ----------------------------------------------------------------------------- 196 | TRANSACTION (0.0ms) rollback transaction 197 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 198 | TRANSACTION (0.0ms) begin transaction 199 | ----------------------------------------------------------------------------- 200 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 201 | ----------------------------------------------------------------------------- 202 | TRANSACTION (0.0ms) rollback transaction 203 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 204 | TRANSACTION (0.0ms) begin transaction 205 | ----------------------------------------------------------------------------- 206 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 207 | ----------------------------------------------------------------------------- 208 | TRANSACTION (0.0ms) rollback transaction 209 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 210 | TRANSACTION (0.0ms) begin transaction 211 | ----------------------------------------------------------------------------- 212 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 213 | ----------------------------------------------------------------------------- 214 | TRANSACTION (0.0ms) rollback transaction 215 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 216 | TRANSACTION (0.0ms) begin transaction 217 | ----------------------------------------------------------------------------- 218 | LitestreamGeneratorTest: test_should_generate_a_Litestream_configuration_file 219 | ----------------------------------------------------------------------------- 220 | TRANSACTION (0.0ms) rollback transaction 221 | ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 222 | TRANSACTION (0.0ms) begin transaction 223 | -------------------------------------------------- 224 | SqlpkgGeneratorTest: test_should_generate_lockfile 225 | -------------------------------------------------- 226 | TRANSACTION (0.0ms) rollback transaction 227 | TRANSACTION (0.0ms) begin transaction 228 | ----------------------------------------------------- 229 | SqlpkgGeneratorTest: test_should_generate_initializer 230 | ----------------------------------------------------- 231 | TRANSACTION (0.0ms) rollback transaction 232 | TRANSACTION (0.0ms) begin transaction 233 | ----------------------------------------------------------------- 234 | SqlpkgGeneratorTest: test_should_generate_project_scope_directory 235 | ----------------------------------------------------------------- 236 | TRANSACTION (0.0ms) rollback transaction 237 | -------------------------------------------------------------------------------- /test/dummy/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fractaledmind/sqlpkg-ruby/73bd270fb1a1a7fa165f860e7ad5ee9cfeaf784c/test/dummy/storage/.keep -------------------------------------------------------------------------------- /test/dummy/storage/test.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fractaledmind/sqlpkg-ruby/73bd270fb1a1a7fa165f860e7ad5ee9cfeaf784c/test/dummy/storage/test.sqlite3 -------------------------------------------------------------------------------- /test/dummy/tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fractaledmind/sqlpkg-ruby/73bd270fb1a1a7fa165f860e7ad5ee9cfeaf784c/test/dummy/tmp/.keep -------------------------------------------------------------------------------- /test/dummy/tmp/local_secret.txt: -------------------------------------------------------------------------------- 1 | 2e674226836fd5b8d265fbc2088757c026b86086afb1ea213271ec09b432cce56122da2e7ba0ab5e70ab06f5b1b07fdf386b0cea6b28efce5afaa11d5aa1e76f -------------------------------------------------------------------------------- /test/dummy/tmp/pids/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fractaledmind/sqlpkg-ruby/73bd270fb1a1a7fa165f860e7ad5ee9cfeaf784c/test/dummy/tmp/pids/.keep -------------------------------------------------------------------------------- /test/dummy/tmp/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fractaledmind/sqlpkg-ruby/73bd270fb1a1a7fa165f860e7ad5ee9cfeaf784c/test/dummy/tmp/storage/.keep -------------------------------------------------------------------------------- /test/generators/test_install.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | require "rails/generators" 5 | require "sqlpkg/generators/sqlpkg/install_generator" 6 | 7 | class SqlpkgGeneratorTest < Rails::Generators::TestCase 8 | tests Sqlpkg::Generators::InstallGenerator 9 | destination File.expand_path("../tmp", __dir__) 10 | 11 | setup :prepare_destination 12 | 13 | def after_teardown 14 | FileUtils.rm_rf destination_root 15 | super 16 | end 17 | 18 | test "should generate project scope directory" do 19 | run_generator 20 | 21 | assert_directory ".sqlpkg" 22 | end 23 | 24 | test "should generate lockfile" do 25 | run_generator 26 | 27 | assert_file "sqlpkg.lock" 28 | end 29 | 30 | test "should generate initializer" do 31 | run_generator 32 | 33 | assert_file "config/initializers/sqlpkg.rb" do |content| 34 | assert_match "@raw_connection.load_extension(extension_path)", content 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | ENV["RAILS_ENV"] = "test" 4 | 5 | $LOAD_PATH.unshift File.expand_path("../lib", __dir__) 6 | 7 | require_relative "../test/dummy/config/environment" 8 | ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] 9 | require "rails/test_help" 10 | require "sqlpkg" 11 | 12 | require "minitest/autorun" 13 | -------------------------------------------------------------------------------- /test/test_sqlpkg.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | class TestSqlpkg < Minitest::Test 6 | def test_that_it_has_a_version_number 7 | refute_nil ::Sqlpkg::VERSION 8 | end 9 | 10 | def test_path_for_when_glob_returns_paths 11 | path = "./.sqlpkg/nalgeon/uuid/uuid.dylib" 12 | Dir.stub :glob, [path] do 13 | assert_equal path, Sqlpkg.path_for("nalgeon/uuid") 14 | end 15 | end 16 | 17 | def test_path_for_when_glob_returns_empty_array 18 | assert_raises Sqlpkg::ExtensionNotInstalledError do 19 | Sqlpkg.path_for("nalgeon/uuid") 20 | end 21 | end 22 | 23 | def test_accessor_when_glob_returns_paths 24 | path = "./.sqlpkg/nalgeon/uuid/uuid.dylib" 25 | Dir.stub :glob, [path] do 26 | assert_equal path, Sqlpkg["nalgeon/uuid"] 27 | end 28 | end 29 | 30 | def test_accessor_when_glob_returns_empty_array 31 | assert_raises Sqlpkg::ExtensionNotInstalledError do 32 | Sqlpkg["nalgeon/uuid"] 33 | end 34 | end 35 | end 36 | --------------------------------------------------------------------------------