Skip to content

Commit

Permalink
feat: use zeitwrek as autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
seuros committed Jan 12, 2024
1 parent 176f8af commit 8b9f43a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 207 deletions.
1 change: 1 addition & 0 deletions lib/trailblazer-finder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative 'trailblazer/finder'
47 changes: 15 additions & 32 deletions lib/trailblazer/finder.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
# frozen_string_literal: true

require "forwardable"
require "trailblazer"
require "dry-types"
require "ostruct"
require 'forwardable'
require 'dry-types'
require 'ostruct'
require 'zeitwerk'
require 'trailblazer/operation'
require 'trailblazer/macro'

require_relative "finder/utils/array"
require_relative "finder/utils/hash"
require_relative "finder/utils/string"
require_relative "finder/utils/splitter"
require_relative "finder/utils/extra"
require_relative "finder/adapters/active_record/predicates"
require_relative "finder/adapters/active_record/paging"
require_relative "finder/adapters/active_record/sorting"
require_relative "finder/adapters/kaminari/paging"
require_relative "finder/adapters/will_paginate/paging"
require_relative "finder/adapters/sequel/predicates"
require_relative "finder/adapters/sequel/paging"
require_relative "finder/adapters/sequel/sorting"
require_relative "finder/adapters/basic/predicates"
require_relative "finder/adapters/basic/paging"
require_relative "finder/adapters/basic/sorting"
require_relative "finder/activities/prepare"
require_relative "finder/activities/process"
require_relative "finder/activities/find"
require_relative "finder/helpers/basic"
require_relative "finder/helpers/sorting"
require_relative "finder/dsl"
require_relative "finder/find"
require_relative "finder/base"
require_relative "operation/finder"
loader = Zeitwerk::Loader.for_gem_extension(Trailblazer)
adapters = "#{__dir__}/finder/adapters"
loader.do_not_eager_load(adapters)
loader.setup

module Trailblazer
class Finder
module Types
include Dry.Types(default: :nominal)
end
EXT_ORM_ADAPTERS = Types::Strict::String.enum("ActiveRecord", "Sequel")
ORM_ADAPTERS = EXT_ORM_ADAPTERS | Types::Strict::String.enum("Basic")
PAGING_ADAPTERS = Types::Strict::String.enum("Kaminari", "WillPaginate")
EXT_ORM_ADAPTERS = Types::Strict::String.enum('ActiveRecord', 'Sequel')
ORM_ADAPTERS = EXT_ORM_ADAPTERS | Types::Strict::String.enum('Basic')
PAGING_ADAPTERS = Types::Strict::String.enum('Kaminari', 'WillPaginate')

include Base
end
end

loader.eager_load
3 changes: 1 addition & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

require 'bundler/setup'
require 'trailblazer/developer'
require 'trailblazer/activity'
require 'trailblazer/activity/testing'
require 'trailblazer/finder'
require 'trailblazer-finder'
require 'minitest-trailblazer'
require 'minitest/trailblazer_spec'

Expand Down
173 changes: 0 additions & 173 deletions test/trailblazer/finder/dsl_test.rb

This file was deleted.

2 changes: 2 additions & 0 deletions trailblazer-finder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Gem::Specification.new do |spec|
spec.metadata['changelog_uri'] = 'https://github.com/trailblazer/trailblazer-finder/blob/master/CHANGELOG.md'

spec.add_dependency "dry-types", ">= 1.0.0"
spec.add_dependency "trailblazer-macro", ">= 2.1.15"
spec.add_dependency "trailblazer-activity", ">= 0.13.0"
spec.add_dependency "zeitwerk", ">= 2.6.0"

spec.add_development_dependency "activerecord"
spec.add_development_dependency "bundler"
Expand Down

0 comments on commit 8b9f43a

Please sign in to comment.