bridgetown-activerecord 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/README.md +25 -1
- data/lib/bridgetown-activerecord/initializer.rb +6 -1
- data/lib/bridgetown-activerecord/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1ec1ff457bbf992255599d52b2c8efa8708f80c97dd7c4e9e5b4497adc7edb9
|
4
|
+
data.tar.gz: b8dbab9b63c86433665feda57f3f316c6c01ca4418a17c0bc3bcb2768431d9b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1ecfaec16724b1f609e6ea43b645afd1d8b08bc4d8a1332254d4f7ff32d599d52b7c3f8cfdcd0519cef550ddf61acc68e693290c78b3f2abf251aa7ca78cc30
|
7
|
+
data.tar.gz: c96065139c88134350b93e71109a9090355f2e6954b3be5ea437f106be18ac7f7473e23fe634798b8139227a5ace8a09ae4398166626614c95de6c784f1be77b
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## Unreleased
|
9
9
|
|
10
|
+
## [2.2.0] - 2023-03-13
|
11
|
+
|
12
|
+
- Add support for Sequel with shared DB connection
|
13
|
+
|
14
|
+
## [2.1.0] - 2022-10-10
|
15
|
+
|
16
|
+
- Allow customizing of the models dir
|
17
|
+
|
10
18
|
## [2.0.0] - 2022-10-08
|
11
19
|
|
12
20
|
- Upgrade to initializers system in Bridgetown 1.2
|
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]
|
|
8
8
|
group :test do
|
9
9
|
gem "minitest"
|
10
10
|
gem "minitest-reporters"
|
11
|
+
gem "pg", "~> 1.3"
|
12
|
+
gem "sequel-activerecord_connection", "~> 1.2"
|
11
13
|
gem "shoulda"
|
12
14
|
end
|
13
|
-
|
14
|
-
gem "pg", "~> 1.3", group: :test
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Bridgetown Active Record plugin
|
2
2
|
|
3
|
-
This plugin adds Active Record support to Bridgetown sites (v1.2 or higher). You can pull data from a database (currently PostgreSQL is officially supported) during a static build or during server requests (or both!) and use many of the features you know and love from Active Record in Rails—including migrations!
|
3
|
+
This plugin adds [Active Record](https://guides.rubyonrails.org/active_record_basics.html) support to Bridgetown sites (v1.2 or higher). You can pull data from a database (currently PostgreSQL is officially supported) during a static build or during server requests (or both!) and use many of the features you know and love from Active Record in Rails—including migrations!
|
4
|
+
|
5
|
+
In addition, if you also like using the [Sequel gem](https://github.com/jeremyevans/sequel) for your database access, this plugin can support instantiating Sequel with a shared DB connection via the [sequel-activerecord_connection](https://github.com/janko/sequel-activerecord_connection) extension ([see below](#using-with-sequel)).
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -109,6 +111,28 @@ BridgetownActiveRecord.load_tasks(models_dir: "app/models")
|
|
109
111
|
|
110
112
|
(Don't forget to update your autoload path in `config/initializers.rb` accordingly.)
|
111
113
|
|
114
|
+
## Using with Sequel
|
115
|
+
|
116
|
+
To set up [Sequel](https://github.com/jeremyevans/sequel) using the same database connection as Active Record, follow these steps:
|
117
|
+
|
118
|
+
First, install the sequel-activerecord_connection gem:
|
119
|
+
|
120
|
+
```sh
|
121
|
+
bundle add sequel-activerecord_connection
|
122
|
+
```
|
123
|
+
|
124
|
+
Next, update your configuration in `config/initializers.rb` as follows:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
init :"bridgetown-activerecord", sequel_support: :postgres # or mysql2 or sqlite3
|
128
|
+
```
|
129
|
+
|
130
|
+
Now you should be able to call `DB` to access the Sequel API anywhere in your Bridgetown or Roda code:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
DB.tables # => [:ar_internal_metadata, :schema_migrations, etc.]
|
134
|
+
```
|
135
|
+
|
112
136
|
## Testing
|
113
137
|
|
114
138
|
* Run `bundle exec rake test` to run the test suite
|
@@ -20,9 +20,14 @@ module BridgetownActiveRecord
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
Bridgetown.initializer :"bridgetown-activerecord" do |config|
|
23
|
+
Bridgetown.initializer :"bridgetown-activerecord" do |config, sequel_support: nil|
|
24
24
|
ActiveRecord::Base.establish_connection(
|
25
25
|
BridgetownActiveRecord.db_configuration(config)[Bridgetown.environment]
|
26
26
|
)
|
27
27
|
ActiveRecord::Base.logger = BridgetownActiveRecord.log_writer
|
28
|
+
|
29
|
+
next unless sequel_support
|
30
|
+
|
31
|
+
require "sequel"
|
32
|
+
DB = Sequel.send(sequel_support, extensions: :activerecord_connection) # rubocop:disable Lint/ConstantDefinitionInBlock
|
28
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridgetown-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bridgetown
|