-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up Zeitwerk for code loading (#1)
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "lib/hanami/db/version" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "hanami-db" | ||
spec.version = "0.0.0" | ||
spec.version = Hanami::DB::VERSION | ||
spec.authors = ["Hanami team"] | ||
spec.email = ["[email protected]"] | ||
spec.summary = "The database layer for Hanami apps" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require "zeitwerk" | ||
|
||
module Hanami | ||
module DB | ||
require_relative "db/gem_inflector" | ||
|
||
# @api private | ||
# @since 2.2.0 | ||
def self.loader | ||
@loader ||= Zeitwerk::Loader.new.tap do |loader| | ||
root = File.expand_path("..", __dir__) | ||
|
||
loader.inflector = GemInflector.new("#{root}/hanami/db.rb") | ||
loader.tag = "hanami-db" | ||
loader.push_dir root | ||
loader.ignore( | ||
"#{root}/hanami-db.rb", | ||
"#{root}/hanami/db/gem_inflector.rb" | ||
) | ||
end | ||
end | ||
loader.setup | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hanami | ||
module DB | ||
# @api private | ||
class GemInflector < Zeitwerk::GemInflector | ||
def camelize(basename, _abspath) | ||
return "DB" if basename == "db" | ||
|
||
super | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hanami | ||
module DB | ||
VERSION = "0.0.0" | ||
end | ||
end |