Content-Length: 368077 | pFad | http://github.com/hanami/hanami/pull/1430/commits/0bf06979f19df57eeb6f1725d75781a4fcf1d6cd

91 Add DB provider adapter config & sensible defaults by timriley · Pull Request #1430 · hanami/hanami · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DB provider adapter config & sensible defaults #1430

Merged
merged 16 commits into from
Jul 1, 2024
Merged
Next Next commit
Add custom config class for DB provider source
  • Loading branch information
timriley committed Jun 22, 2024
commit 0bf06979f19df57eeb6f1725d75781a4fcf1d6cd
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ gem "hanami-webconsole", github: "hanami/webconsole", branch: "main"

gem "hanami-devtools", github: "hanami/devtools", branch: "main"

gem "dry-system", github: "dry-rb/dry-system", branch: "main"
gem "dry-configurable", github: "dry-rb/dry-configurable", branch: "allow-multiple-includes"
gem "dry-inflector", github: "dry-rb/dry-inflector", branch: "main"
gem "dry-system", github: "dry-rb/dry-system", branch: "main"

# This is needed for settings specs to pass
gem "dry-types"
Expand Down
3 changes: 3 additions & 0 deletions lib/hanami/providers/db.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "dry/configurable"
require "dry/core"

module Hanami
Expand All @@ -9,6 +10,8 @@ module Providers
class DB < Dry::System::Provider::Source
extend Dry::Core::Cache

include Dry::Configurable(config_class: Providers::DB::Config)

setting :database_url

setting :adapter, default: :sql
Expand Down
12 changes: 12 additions & 0 deletions lib/hanami/providers/db/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Hanami
module Providers
class DB < Dry::System::Provider::Source
# @api public
# @since 2.2.0
class Config < Dry::Configurable::Config
end
end
end
end
34 changes: 34 additions & 0 deletions spec/integration/db/provider_config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

RSpec.describe "DB / Provider / Config", :app_integration do
before do
@env = ENV.to_h
allow(Hanami::Env).to receive(:loaded?).and_return(false)
end

after do
ENV.replace(@env)
end

it "is a Hanami::Providers::DB::Config" do
with_tmp_directory(Dir.mktmpdir) do
write "config/app.rb", <<~RUBY
require "hanami"

module TestApp
class App < Hanami::App
end
end
RUBY

write "config/db/.keep", ""

ENV["DATABASE_URL"] = "sqlite::memory"

require "hanami/prepare"

provider = Hanami.app.container.providers[:db]
expect(provider.source.config).to be_an_instance_of Hanami::Providers::DB::Config
end
end
end
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/hanami/hanami/pull/1430/commits/0bf06979f19df57eeb6f1725d75781a4fcf1d6cd

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy