Skip to content

Commit

Permalink
Setup zeitwerk (#107)
Browse files Browse the repository at this point in the history
* Setup zeitwerk
* Update Gemfiles
* Fix rubocop exclude
* Remove gemfiles lock files
  • Loading branch information
Spone authored Feb 23, 2022
1 parent 8518a8f commit 5ce26bf
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
11 changes: 7 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ AllCops:
TargetRubyVersion: 2.7
NewCops: enable
Exclude:
- bin/**/*
- lib/generators/**/templates/**/*
- gemfiles/**/*
- vendor/**/*
- '.git/**/*'
- 'bin/**/*'
- 'gemfiles/**/*'
- 'lib/generators/**/templates/**/*'
- 'node_modules/**/*'
- 'tmp/**/*'
- 'vendor/**/*'

Style/StringLiterals:
Enabled: true
Expand Down
5 changes: 3 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PATH
actionview (>= 6.0.0, < 7.1)
activesupport (>= 6.0.0, < 7.1)
view_component (>= 2.34.0, < 3.0)
zeitwerk (~> 2.5)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -240,7 +241,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.5.3)
zeitwerk (2.5.4)

PLATFORMS
ruby
Expand All @@ -264,4 +265,4 @@ DEPENDENCIES
view_component-form!

BUNDLED WITH
2.2.30
2.2.32
5 changes: 1 addition & 4 deletions app/components/view_component/form/base_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ class << self
attr_accessor :default_options
end

if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("6.1")
require "view_component/form/class_names_helper"
include ClassNamesHelper
end
include ClassNamesHelper if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("6.1")

attr_reader :form, :object_name, :options

Expand Down
11 changes: 9 additions & 2 deletions lib/view_component/form.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# frozen_string_literal: true

require_relative "form/version"
require "view_component"
require "zeitwerk"

loader = Zeitwerk::Loader.for_gem
form = "#{__dir__}/form.rb"
loader.ignore(form)
loader.push_dir("#{__dir__}/form", namespace: ViewComponent::Form)
loader.setup

require_relative "form/engine"
require_relative "form/builder"
2 changes: 0 additions & 2 deletions lib/view_component/form/builder.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "action_view"

module ViewComponent
module Form
class Builder < ActionView::Helpers::FormBuilder
Expand Down
2 changes: 0 additions & 2 deletions lib/view_component/form/engine.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "rails/engine"

module ViewComponent
module Form
# :nodoc:
Expand Down
1 change: 1 addition & 0 deletions view_component-form.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "actionview", [">= 6.0.0", "< 7.1"]
spec.add_dependency "activesupport", [">= 6.0.0", "< 7.1"]
spec.add_dependency "view_component", [">= 2.34.0", "< 3.0"]
spec.add_dependency "zeitwerk", ["~> 2.5"]
end

0 comments on commit 5ce26bf

Please sign in to comment.