Skip to content

Commit

Permalink
Merge pull request #131 from rom-rb/fix-matrix
Browse files Browse the repository at this point in the history
update build matrix to scope down to more recent / supported releases
  • Loading branch information
cflipse authored Oct 26, 2023
2 parents 38bae62 + d1ee9cc commit 192cc2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 34 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,13 @@ jobs:
fail-fast: false
matrix:
ruby:
- '3.1'
- '3.0'
- '2.7'
- '2.6'
- '2.5'
- '2.4'
- 'jruby-9.3'
rails:
- "7.0.0"
- "6.1.0"
- "6.0.0"
- "5.2.0"
- "5.1.0"
- "5.0.0"
- "4.2.0"
exclude:
- ruby: "2.4"
rails: "6.0.0"
- ruby: "2.4"
rails: "6.1.0"
- ruby: "2.7"
rails: "4.2.0"
env:
APT_DEPS: libsqlite3-dev
RAILS_VERSION: "${{matrix.rails}}"
Expand Down
29 changes: 10 additions & 19 deletions lib/rom/rails/active_record/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,20 @@ def initialize(env: ::Rails.env, root: ::Rails.root, configurations: ::ActiveRec
#
# @api private
def call
specs = { default: build(default_configuration.configuration_hash) }
specs = {}

if rails6?
configurations.configs_for(env_name: env).each do |config|
specs[config.name.to_sym] = build(config.configuration_hash)
configurations.configs_for(env_name: env).each do |config|
if config.respond_to?(:configuration_hash)
name, hash = [config.name, config.configuration_hash]
else # Rails 6.0
name, hash = [config.spec_name, config.config]
end
end

specs
end

def default_configuration
if rails6?
configurations.configs_for(env_name: env).first
else
configurations.fetch(env)
specs[:default] ||= hash
specs[name.to_sym] = hash
end

specs.transform_values { |hash| build hash.symbolize_keys }
end

# Builds a configuration hash from a flat database config hash.
Expand All @@ -77,12 +74,6 @@ def build(config)
uri = uri_builder.build(adapter, uri_options)
{ uri: uri, options: other_options }
end

private

def rails6?
::ActiveRecord::VERSION::MAJOR >= 6
end
end
end
end
Expand Down

0 comments on commit 192cc2d

Please sign in to comment.