Skip to content

Commit 0ebc750

Browse files
authored
Merge pull request #163 from omniauth/feat/adapter-rom
2 parents e335d44 + 4efbcb8 commit 0ebc750

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2349
-165
lines changed

.github/workflows/current.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,41 @@ jobs:
5252
rubygems: latest
5353
bundler: latest
5454

55+
- ruby: "ruby"
56+
appraisal: "rom-r3"
57+
exec_cmd: "rake spec:orm:rom"
58+
gemfile: "Appraisal.root"
59+
rubygems: latest
60+
bundler: latest
61+
5562
- ruby: "ruby"
5663
appraisal: "sequel-5.86-r3"
5764
exec_cmd: "rake spec:orm:sequel"
5865
gemfile: "Appraisal.root"
5966
rubygems: latest
6067
bundler: latest
6168

62-
# truffleruby-24.1
69+
# truffleruby-24.1 (targets Ruby 3.2 compatibility)
6370
- ruby: "truffleruby"
6471
appraisal: "ar-8-0"
6572
exec_cmd: "rake spec:orm:active_record"
6673
gemfile: "Appraisal.root"
6774
rubygems: default
6875
bundler: default
6976

77+
# # NOTE: When running the following, we get a RuntimeException:
78+
# # java.lang.RuntimeException: Ruby Thread id=90 from /home/runner/.rubies/truffleruby-25.0.0/lib/mri/bundler/worker.rb:90 terminated with internal error:
79+
# # at org.graalvm.ruby/org.truffleruby.core.thread.ThreadManager.printInternalError(ThreadManager.java:312)
80+
# # at org.graalvm.ruby/org.truffleruby.core.thread.ThreadManager.threadMain(ThreadManager.java:301)
81+
# # at org.graalvm.ruby/org.truffleruby.core.thread.ThreadManager.lambda$initialize$1(ThreadManager.java:272)
82+
# # at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotThreadTask$ThreadSpawnRootNode.executeImpl(PolyglotThreadTask.java:144)
83+
# - ruby: "truffleruby"
84+
# appraisal: "rom-r3"
85+
# exec_cmd: "rake spec:orm:rom"
86+
# gemfile: "Appraisal.root"
87+
# rubygems: default
88+
# bundler: default
89+
7090
# jruby-10.0 (targets Ruby 3.4 compatibility)
7191
- ruby: "jruby"
7292
appraisal: "ar-7-1-r3"
@@ -92,6 +112,13 @@ jobs:
92112
# rubygems: default
93113
# bundler: default
94114

115+
- ruby: "jruby"
116+
appraisal: "rom-r3"
117+
exec_cmd: "rake spec:orm:rom"
118+
gemfile: "Appraisal.root"
119+
rubygems: latest
120+
bundler: latest
121+
95122
- ruby: "jruby"
96123
appraisal: "sequel-5.86-r3"
97124
exec_cmd: "rake spec:orm:sequel"

.github/workflows/jruby.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ jobs:
4444
rubygems: default
4545
bundler: default
4646

47+
- ruby: "jruby-9.4"
48+
appraisal: "rom-r3.1"
49+
exec_cmd: "rake spec:orm:rom"
50+
gemfile: "Appraisal.root"
51+
rubygems: default
52+
bundler: default
53+
4754
steps:
4855
- name: Checkout
4956
if: ${{ !env.ACT }}

.github/workflows/legacy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ jobs:
8080
rubygems: '3.6.9'
8181
bundler: '2.6.9'
8282

83+
- ruby: "3.1"
84+
appraisal: "rom-r3.1"
85+
exec_cmd: "rake spec:orm:rom"
86+
gemfile: "Appraisal.root"
87+
rubygems: '3.6.9'
88+
bundler: '2.6.9'
89+
8390
- ruby: "3.1"
8491
appraisal: "sequel-5.86-r3.1"
8592
exec_cmd: "rake spec:orm:sequel"

.github/workflows/supported.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ jobs:
4949
gemfile: "Appraisal.root"
5050
rubygems: latest
5151
bundler: latest
52+
- ruby: "3.2"
53+
appraisal: "rom-r3"
54+
exec_cmd: "rake spec:orm:rom"
55+
gemfile: "Appraisal.root"
56+
rubygems: latest
57+
bundler: latest
5258
- ruby: "3.2"
5359
appraisal: "sequel-5.86-r3"
5460
exec_cmd: "rake spec:orm:sequel"
@@ -75,6 +81,12 @@ jobs:
7581
gemfile: "Appraisal.root"
7682
rubygems: latest
7783
bundler: latest
84+
- ruby: "3.3"
85+
appraisal: "rom-r3"
86+
exec_cmd: "rake spec:orm:rom"
87+
gemfile: "Appraisal.root"
88+
rubygems: latest
89+
bundler: latest
7890
- ruby: "3.3"
7991
appraisal: "sequel-5.86-r3"
8092
exec_cmd: "rake spec:orm:sequel"

.github/workflows/truffle.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,28 @@ jobs:
3737
matrix:
3838
include:
3939
# NOTE: truffleruby does not support upgrading rubygems.
40-
# truffleruby-23.1 (targets Ruby 3.2 compatibility)
40+
# truffleruby-23.1 (targets Ruby 3.1 compatibility)
4141
- ruby: "truffleruby-23.1"
42-
appraisal: "ar-7-1-r3"
42+
appraisal: "ar-7-1-r3.1"
4343
exec_cmd: "rake spec:orm:active_record"
4444
gemfile: "Appraisal.root"
4545
rubygems: default
4646
bundler: default
4747

48+
# # NOTE: When running the following, we get a SyntaxError in dry-types:
49+
# #
50+
# # While loading ./spec_orms/rom_spec.rb a `raise SyntaxError` occurred, RSpec will now quit.
51+
# # Failure/Error: required = zeitwerk_original_require(path)
52+
# #
53+
# # SyntaxError:
54+
# # /home/runner/.rubies/truffleruby-23.1.2/lib/gems/gems/dry-types-1.8.3/lib/dry/types/errors.rb:59: syntax error, unexpected '='
55+
# - ruby: "truffleruby-23.1"
56+
# appraisal: "rom-r3.1"
57+
# exec_cmd: "rake spec:orm:rom"
58+
# gemfile: "Appraisal.root"
59+
# rubygems: default
60+
# bundler: default
61+
4862
steps:
4963
- name: Checkout
5064
if: ${{ (env.ACT && !(startsWith(matrix.ruby, 'jruby')) || startsWith(matrix.ruby, 'truffleruby')) || (!env.ACT && (startsWith(matrix.ruby, 'jruby')) || startsWith(matrix.ruby, 'truffleruby')) }}

.rubocop_gradual.lock

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"README.md:2294530640": [
3-
[275, 3, 100, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3592044714]
2+
"README.md:4226975945": [
3+
[277, 3, 100, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3592044714]
44
],
55
"bin/bundle:247448467": [
66
[64, 5, 20, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 2485198147]
77
],
8-
"lib/omniauth/identity/model.rb:4176389330": [
8+
"lib/omniauth/identity/model.rb:2544890477": [
99
[71, 11, 9, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 4045031525],
1010
[72, 11, 9, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 4045031525],
1111
[72, 40, 9, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 4045031525],
@@ -31,6 +31,18 @@
3131
[57, 13, 125, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3604044426],
3232
[69, 13, 83, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 902334745]
3333
],
34+
"lib/omniauth/identity/models/rom.rb:1006067066": [
35+
[28, 9, 866, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3432708653],
36+
[39, 33, 14, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 3392992668],
37+
[60, 13, 14, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 2710654061],
38+
[61, 25, 14, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 2710654061],
39+
[66, 13, 18, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 3343971124],
40+
[67, 13, 18, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 3343971124],
41+
[71, 13, 20, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 2230320645],
42+
[72, 13, 20, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 2230320645],
43+
[76, 13, 15, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 3094507655],
44+
[77, 14, 15, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 3094507655]
45+
],
3446
"lib/omniauth/identity/models/sequel.rb:101522047": [
3547
[44, 9, 3379, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3595458005]
3648
],
@@ -95,10 +107,13 @@
95107
[14, 1, 61, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/identity/models/mongoid*_spec.rb`.", 2184534986],
96108
[32, 9, 71, "RSpec/SubjectStub: Do not stub methods of the object under test.", 399334056]
97109
],
98-
"spec_orms/sequel_spec.rb:1275922107": [
99-
[22, 1, 60, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/identity/models/sequel*_spec.rb`.", 36626431],
100-
[23, 3, 12, "RSpec/BeforeAfterAll: Beware of using `before(:all)` as it may cause state to leak between tests. If you are using `rspec-rails`, and `use_transactional_fixtures` is enabled, then records created in `before(:all)` are not automatically rolled back.", 86334566],
101-
[34, 7, 42, "Layout/EmptyLinesAfterModuleInclusion: Add an empty line after module inclusion.", 1846499429],
102-
[48, 9, 71, "RSpec/SubjectStub: Do not stub methods of the object under test.", 399334056]
110+
"spec_orms/rom_spec.rb:2272636079": [
111+
[5, 1, 57, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/identity/models/rom*_spec.rb`.", 18469108],
112+
[6, 3, 12, "RSpec/BeforeAfterAll: Beware of using `before(:all)` as it may cause state to leak between tests. If you are using `rspec-rails`, and `use_transactional_fixtures` is enabled, then records created in `before(:all)` are not automatically rolled back.", 86334566]
113+
],
114+
"spec_orms/sequel_spec.rb:1276231279": [
115+
[12, 1, 60, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/identity/models/sequel*_spec.rb`.", 36626431],
116+
[13, 3, 12, "RSpec/BeforeAfterAll: Beware of using `before(:all)` as it may cause state to leak between tests. If you are using `rspec-rails`, and `use_transactional_fixtures` is enabled, then records created in `before(:all)` are not automatically rolled back.", 86334566],
117+
[39, 9, 71, "RSpec/SubjectStub: Do not stub methods of the object under test.", 399334056]
103118
]
104119
}

Appraisals

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#
2222
appraise "unlocked_deps" do
2323
gem "sequel", "~> 5.86", ">= 5.86.0"
24+
gem "rom-sql", "~> 3.7"
2425
eval_gemfile "modular/activerecord/r3/v8.0.gemfile"
2526
eval_gemfile "modular/omniauth/r3/v2.1.gemfile"
2627
eval_gemfile "modular/coverage.gemfile"
@@ -126,6 +127,7 @@ end
126127
# Test Matrix:
127128
# - Ruby 3.0
128129
# - Ruby 3.1
130+
# - TruffleRuby 23.1
129131
appraise "ar-7-1-r3.1" do
130132
eval_gemfile "modular/activerecord/r3/v7.1.gemfile"
131133
eval_gemfile "modular/omniauth/r3/v2.1.gemfile"
@@ -135,7 +137,6 @@ end
135137
# Compat: Ruby >= 2.7
136138
# Test Matrix:
137139
# - Ruby 3.2
138-
# - TruffleRuby 23.1
139140
# - Ruby 3.3
140141
# - JRuby 10.0
141142
appraise "ar-7-1-r3" do
@@ -455,6 +456,32 @@ end
455456
# gem "stringio", ">= 0.0.2"
456457
# end
457458

459+
# Compat: Ruby >= 3.1.0
460+
# Test Matrix:
461+
# - Ruby 3.1
462+
# - TruffleRuby 23.1
463+
# - JRuby 9.4
464+
appraise "rom-r3.1" do
465+
gem "rom-sql", "~> 3.7"
466+
eval_gemfile "modular/activerecord/r3/v7.1.gemfile"
467+
eval_gemfile "modular/omniauth/r3/v2.1.gemfile"
468+
eval_gemfile "modular/x_std_libs/r3.1/libs.gemfile"
469+
end
470+
471+
# Compat: Ruby >= 3.1.0
472+
# Test Matrix:
473+
# - Ruby 3.2
474+
# - TruffleRuby 24.1
475+
# - Ruby 3.3
476+
# - Ruby 3.4
477+
# - JRuby 10.0
478+
appraise "rom-r3" do
479+
gem "rom-sql", "~> 3.7"
480+
eval_gemfile "modular/activerecord/r3/v7.1.gemfile"
481+
eval_gemfile "modular/omniauth/r3/v2.1.gemfile"
482+
eval_gemfile "modular/x_std_libs/r3/libs.gemfile"
483+
end
484+
458485
# Compat: Ruby >= 1.9.2
459486
# Test Matrix:
460487
# - Ruby 2.4
@@ -528,6 +555,7 @@ end
528555
# Only run coverage on the latest version of Ruby
529556
appraise "coverage" do
530557
gem "couch_potato", "~> 1.17"
558+
gem "rom-sql", "~> 3.7"
531559
gem "sequel", "~> 5.86", ">= 5.86.0"
532560
gem "mongoid", "~> 9.0", ">= 9.0.3"
533561
gem "mongoid-rspec", "~> 4.2"

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ gem "mongoid-rspec", "~> 4.2", require: false
3636
gem "nobrainer", "~> 0.44", require: false
3737
gem "sequel", "~> 5.86", require: false
3838
gem "sqlite3", ">= 1", require: false
39+
gem "rom-sql", "~> 3.7", require: false
3940

4041
### Local dev tools
4142
gem "growl"

Gemfile.lock

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ GEM
101101
dry-logic (~> 1.5)
102102
dry-types (~> 1.8)
103103
zeitwerk (~> 2.6)
104+
dry-struct (1.8.0)
105+
dry-core (~> 1.1)
106+
dry-types (~> 1.8, >= 1.8.2)
107+
ice_nine (~> 0.11)
108+
zeitwerk (~> 2.6)
104109
dry-types (1.8.3)
105110
bigdecimal (~> 3.0)
106111
concurrent-ruby (~> 1.0)
@@ -152,6 +157,7 @@ GEM
152157
mutex_m
153158
i18n (1.14.7)
154159
concurrent-ruby (~> 1.0)
160+
ice_nine (0.11.2)
155161
io-console (0.8.1)
156162
irb (1.15.2)
157163
pp (>= 0.6.0)
@@ -292,6 +298,32 @@ GEM
292298
version_gem (>= 1.1.3, < 4)
293299
rethinkdb (2.4.0.0)
294300
rexml (3.4.4)
301+
rom (5.4.2)
302+
rom-changeset (~> 5.4)
303+
rom-core (~> 5.4)
304+
rom-repository (~> 5.4, >= 5.4.2)
305+
rom-changeset (5.4.0)
306+
dry-core (~> 1.0)
307+
rom-core (~> 5.4)
308+
transproc (~> 1.1)
309+
rom-core (5.4.0)
310+
concurrent-ruby (~> 1.1)
311+
dry-configurable (~> 1.0)
312+
dry-core (~> 1.0)
313+
dry-inflector (~> 1.0)
314+
dry-initializer (~> 3.2)
315+
dry-struct (~> 1.0)
316+
dry-types (~> 1.6)
317+
transproc (~> 1.1)
318+
rom-repository (5.4.2)
319+
dry-core (~> 1.0)
320+
dry-initializer (~> 3.2)
321+
rom-core (~> 5.4)
322+
rom-sql (3.7.0)
323+
dry-core (~> 1.1)
324+
dry-types (~> 1.8)
325+
rom (~> 5.4)
326+
sequel (>= 4.49)
295327
rspec (3.13.1)
296328
rspec-core (~> 3.13.0)
297329
rspec-expectations (~> 3.13.0)
@@ -444,6 +476,7 @@ GEM
444476
rspec (~> 3.0)
445477
timecop (>= 0.7, < 1)
446478
timeout (0.4.3)
479+
transproc (1.1.1)
447480
tsort (0.2.0)
448481
tzinfo (2.0.6)
449482
concurrent-ruby (~> 1.0)
@@ -507,6 +540,7 @@ DEPENDENCIES
507540
rdoc (~> 6.11)
508541
reek (~> 6.5)
509542
require_bench (~> 1.0, >= 1.0.4)
543+
rom-sql (~> 3.7)
510544
rspec-pending_for (~> 0.0, >= 0.0.17)
511545
rubocop (~> 1.73, >= 1.73.2)
512546
rubocop-lts (~> 12.1, >= 12.1.1)

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,16 @@ This gem is compatible with a wide range of Ruby versions and Ruby ORMs, as of M
167167
* mongoid 7.3, 7.4, 8.1, 9.0
168168
* bson 4.12, 4.15, 5.0, HEAD
169169
* sequel 5.86+
170-
* At least 5 different database ORM adapters, which connect to 15 different database clients!
170+
* rom-sql (Ruby Object Mapper) 3.7+
171+
* At least 6 different database ORM adapters, which connect to 15 different database clients!
171172

172173
| Databases | Adapter Libraries |
173-
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
174+
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
174175
| MySQL, MariaDB, PostgreSQL, SQLite | [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html) |
175176
| CouchDB | [CouchPotato](https://github.com/langalex/couch_potato) |
176177
| MongoDB | [Mongoid](https://github.com/mongodb/mongoid) |
177178
| RethinkDB | [NoBrainer](http://nobrainer.io/) |
179+
| ADO, Amalgalite, IBM_DB, JDBC, MySQL, MariaDB, ODBC, Oracle, PostgreSQL, SQLAnywhere, SQLite, and TinyTDS | [rom-sql](https://rom-rb.org/) |
178180
| ADO, Amalgalite, IBM_DB, JDBC, MySQL, MariaDB, ODBC, Oracle, PostgreSQL, SQLAnywhere, SQLite, and TinyTDS | [Sequel](http://sequel.jeremyevans.net) |
179181

180182
## 🔧 Basic Usage
@@ -298,7 +300,23 @@ end
298300

299301
### Ruby Object Mapper
300302

301-
Would love to add a mixin for the [Ruby Object Mapper (ROM)](https://rom-rb.org/) if anyone wants to work on it!
303+
[ROM](https://rom-rb.org/) is an ORM for pretty much every database.
304+
305+
Include the `OmniAuth::Identity::Models::Rom` mixin and specify
306+
the `rom_container`, everything else is optional.
307+
308+
```ruby
309+
class Identity
310+
include OmniAuth::Identity::Models::Rom
311+
312+
# Configure the ROM container and relation
313+
rom_container -> { MyDatabase.rom } # See spec_orms/rom_spec.rb for example
314+
rom_relation_name :identities # optional, defaults to :idneitities
315+
owner_relation_name :owners # optional, for loading associated owner
316+
auth_key :email # optional, defaults to :email
317+
password_field :password_digest # optional, defaults to :password_digest
318+
end
319+
```
302320

303321
### Custom Auth Model
304322

0 commit comments

Comments
 (0)