Skip to content

Commit

Permalink
switch to zeitwerk
Browse files Browse the repository at this point in the history
  • Loading branch information
thedumbtechguy committed Apr 5, 2024
1 parent 58306e1 commit fda5ebf
Show file tree
Hide file tree
Showing 74 changed files with 141 additions and 359 deletions.
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GIT
PATH
remote: .
specs:
plutonium (0.6.2)
plutonium (0.7.0)
active_interaction (~> 5.3)
dry-initializer (~> 3.1)
listen (~> 3.8)
Expand All @@ -23,6 +23,7 @@ PATH
simple_form (~> 5.3)
view_component (~> 3)
view_component-form (~> 0.2.6)
zeitwerk

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 3 additions & 3 deletions app/views/components/action_button/action_button_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class ActionButtonComponent < Plutonium::UI::Base
module Plutonium::Ui
class ActionButtonComponent < Plutonium::Ui::Base
option :label
option :to
option :method
Expand All @@ -12,4 +12,4 @@ class ActionButtonComponent < Plutonium::UI::Base
end
end

Plutonium::ComponentRegistry.register :action_button, to: Plutonium::UI::ActionButtonComponent
Plutonium::ComponentRegistry.register :action_button, to: Plutonium::Ui::ActionButtonComponent
2 changes: 1 addition & 1 deletion app/views/components/base.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "view_component"
require "dry-initializer"

module Plutonium::UI
module Plutonium::Ui
class Base < ViewComponent::Base
extend Dry::Initializer
include Plutonium::Helpers::ComponentHelper
Expand Down
6 changes: 3 additions & 3 deletions app/views/components/block/block_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class BlockComponent < Plutonium::UI::Base
module Plutonium::Ui
class BlockComponent < Plutonium::Ui::Base
option :rounded, optional: true
option :scroll, optional: true

Expand Down Expand Up @@ -37,4 +37,4 @@ def rounded_classes
end
end

Plutonium::ComponentRegistry.register :block, to: Plutonium::UI::BlockComponent
Plutonium::ComponentRegistry.register :block, to: Plutonium::Ui::BlockComponent
6 changes: 3 additions & 3 deletions app/views/components/breadcrumbs/breadcrumbs_component.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Plutonium::UI
class BreadcrumbsComponent < Plutonium::UI::Base
module Plutonium::Ui
class BreadcrumbsComponent < Plutonium::Ui::Base
option :resource_class
option :parent, optional: true
option :resource, optional: true
end
end

Plutonium::ComponentRegistry.register :breadcrumbs, to: Plutonium::UI::BreadcrumbsComponent
Plutonium::ComponentRegistry.register :breadcrumbs, to: Plutonium::Ui::BreadcrumbsComponent
6 changes: 3 additions & 3 deletions app/views/components/button/button_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class ButtonComponent < Plutonium::UI::Base
module Plutonium::Ui
class ButtonComponent < Plutonium::Ui::Base
option :label
option :to, optional: true
option :icon, optional: true
Expand Down Expand Up @@ -120,4 +120,4 @@ def default_color_classes
end
end

Plutonium::ComponentRegistry.register :button, to: Plutonium::UI::ButtonComponent
Plutonium::ComponentRegistry.register :button, to: Plutonium::Ui::ButtonComponent
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Plutonium::UI
class DynaFrameContentComponent < Plutonium::UI::Base
module Plutonium::Ui
class DynaFrameContentComponent < Plutonium::Ui::Base
end
end

Plutonium::ComponentRegistry.register :dyna_frame_content, to: Plutonium::UI::DynaFrameContentComponent
Plutonium::ComponentRegistry.register :dyna_frame_content, to: Plutonium::Ui::DynaFrameContentComponent
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class DynaFrameHostComponent < Plutonium::UI::Base
module Plutonium::Ui
class DynaFrameHostComponent < Plutonium::Ui::Base
option :src

def id
Expand All @@ -8,4 +8,4 @@ def id
end
end

Plutonium::ComponentRegistry.register :dyna_frame_host, to: Plutonium::UI::DynaFrameHostComponent
Plutonium::ComponentRegistry.register :dyna_frame_host, to: Plutonium::Ui::DynaFrameHostComponent
6 changes: 3 additions & 3 deletions app/views/components/empty_card/empty_card_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Plutonium::UI
class EmptyCardComponent < Plutonium::UI::Base
module Plutonium::Ui
class EmptyCardComponent < Plutonium::Ui::Base
option :message
end
end

Plutonium::ComponentRegistry.register :empty_card, to: Plutonium::UI::EmptyCardComponent
Plutonium::ComponentRegistry.register :empty_card, to: Plutonium::Ui::EmptyCardComponent
2 changes: 1 addition & 1 deletion app/views/components/form/form_builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "simple_form"

module Plutonium::UI
module Plutonium::Ui
class FormBuilder < SimpleForm::FormBuilder
def input(attribute_name, options = {}, &block)
label_class = options.dig(:label_html, :class)
Expand Down
6 changes: 3 additions & 3 deletions app/views/components/form/form_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class FormComponent < Plutonium::UI::Base
module Plutonium::Ui
class FormComponent < Plutonium::Ui::Base
option :form
option :preferred_action_after_submit, default: proc { "show" }

Expand All @@ -20,4 +20,4 @@ def action_after_submit_label(action)
end
end

Plutonium::ComponentRegistry.register :form, to: Plutonium::UI::FormComponent
Plutonium::ComponentRegistry.register :form, to: Plutonium::Ui::FormComponent
6 changes: 3 additions & 3 deletions app/views/components/header/header_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Plutonium::UI
class HeaderComponent < Plutonium::UI::Base
module Plutonium::Ui
class HeaderComponent < Plutonium::Ui::Base
option :title
end
end

Plutonium::ComponentRegistry.register :header, to: Plutonium::UI::HeaderComponent
Plutonium::ComponentRegistry.register :header, to: Plutonium::Ui::HeaderComponent
6 changes: 3 additions & 3 deletions app/views/components/pagination/pagination_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "pagy"

module Plutonium::UI
class PaginationComponent < Plutonium::UI::Base
module Plutonium::Ui
class PaginationComponent < Plutonium::Ui::Base
include Pagy::Frontend

option :pager
Expand Down Expand Up @@ -88,4 +88,4 @@ def active_link_classes
end
end

Plutonium::ComponentRegistry.register :pagination, to: Plutonium::UI::PaginationComponent
Plutonium::ComponentRegistry.register :pagination, to: Plutonium::Ui::PaginationComponent
6 changes: 3 additions & 3 deletions app/views/components/panel/panel_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class PanelComponent < Plutonium::UI::Base
module Plutonium::Ui
class PanelComponent < Plutonium::Ui::Base
option :title, optional: true

def classname
Expand All @@ -8,4 +8,4 @@ def classname
end
end

Plutonium::ComponentRegistry.register :panel, to: Plutonium::UI::PanelComponent
Plutonium::ComponentRegistry.register :panel, to: Plutonium::Ui::PanelComponent
6 changes: 3 additions & 3 deletions app/views/components/sidebar/sidebar_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class SidebarComponent < Plutonium::UI::Base
module Plutonium::Ui
class SidebarComponent < Plutonium::Ui::Base
private

def sidebar_class
Expand All @@ -12,4 +12,4 @@ def sidebar_container_class
end
end

Plutonium::ComponentRegistry.register :sidebar, to: Plutonium::UI::SidebarComponent
Plutonium::ComponentRegistry.register :sidebar, to: Plutonium::Ui::SidebarComponent
6 changes: 3 additions & 3 deletions app/views/components/sidebar_menu/sidebar_menu_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class SidebarMenuComponent < Plutonium::UI::Base
module Plutonium::Ui
class SidebarMenuComponent < Plutonium::Ui::Base
option :separated, optional: true

private
Expand All @@ -10,4 +10,4 @@ def menu_class
end
end

Plutonium::ComponentRegistry.register :sidebar_menu, to: Plutonium::UI::SidebarMenuComponent
Plutonium::ComponentRegistry.register :sidebar_menu, to: Plutonium::Ui::SidebarMenuComponent
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class SidebarMenuItemComponent < Plutonium::UI::Base
module Plutonium::Ui
class SidebarMenuItemComponent < Plutonium::Ui::Base
option :name
option :value
option :indicator, optional: true
Expand All @@ -20,4 +20,4 @@ def sub_link_button_class
end
end

Plutonium::ComponentRegistry.register :sidebar_menu_item, to: Plutonium::UI::SidebarMenuItemComponent
Plutonium::ComponentRegistry.register :sidebar_menu_item, to: Plutonium::Ui::SidebarMenuItemComponent
6 changes: 3 additions & 3 deletions app/views/components/skeleton/table/table_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Plutonium::UI::Skeleton
class TableComponent < Plutonium::UI::Base
module Plutonium::Ui::Skeleton
class TableComponent < Plutonium::Ui::Base
end
end

Plutonium::ComponentRegistry.register :skeleton__table, to: Plutonium::UI::Skeleton::TableComponent
Plutonium::ComponentRegistry.register :skeleton__table, to: Plutonium::Ui::Skeleton::TableComponent
6 changes: 3 additions & 3 deletions app/views/components/tab_bar/tab_bar_component.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Plutonium::UI
class TabBarComponent < Plutonium::UI::Base
module Plutonium::Ui
class TabBarComponent < Plutonium::Ui::Base
# def base_classname
# "base classnames here"
# end
end
end

Plutonium::ComponentRegistry.register :tab_bar, to: Plutonium::UI::TabBarComponent
Plutonium::ComponentRegistry.register :tab_bar, to: Plutonium::Ui::TabBarComponent
6 changes: 3 additions & 3 deletions app/views/components/table/table_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class TableComponent < Plutonium::UI::Base
module Plutonium::Ui
class TableComponent < Plutonium::Ui::Base
option :resource_class
option :resources
option :record_actions
Expand Down Expand Up @@ -60,4 +60,4 @@ def table_header(name, label, search_object)
end
end

Plutonium::ComponentRegistry.register :table, to: Plutonium::UI::TableComponent
Plutonium::ComponentRegistry.register :table, to: Plutonium::Ui::TableComponent
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Plutonium::UI
class TableSearchInputComponent < Plutonium::UI::Base
module Plutonium::Ui
class TableSearchInputComponent < Plutonium::Ui::Base
option :search_object
# def classname
# "custom classnames here #{super}"
# end
end
end

Plutonium::ComponentRegistry.register :table_search_input, to: Plutonium::UI::TableSearchInputComponent
Plutonium::ComponentRegistry.register :table_search_input, to: Plutonium::Ui::TableSearchInputComponent
6 changes: 3 additions & 3 deletions app/views/components/table_toolbar/table_toolbar_component.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Plutonium::UI
class TableToolbarComponent < Plutonium::UI::Base
module Plutonium::Ui
class TableToolbarComponent < Plutonium::Ui::Base
option :resource_class
option :search_object
option :actions
end
end

Plutonium::ComponentRegistry.register :table_toolbar, to: Plutonium::UI::TableToolbarComponent
Plutonium::ComponentRegistry.register :table_toolbar, to: Plutonium::Ui::TableToolbarComponent
6 changes: 3 additions & 3 deletions app/views/components/toolbar/toolbar_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Plutonium::UI
class ToolbarComponent < Plutonium::UI::Base
module Plutonium::Ui
class ToolbarComponent < Plutonium::Ui::Base
option :resource
option :actions, default: proc { {} }

Expand All @@ -15,4 +15,4 @@ def toolbar_actions_classes
end
end

Plutonium::ComponentRegistry.register :toolbar, to: Plutonium::UI::ToolbarComponent
Plutonium::ComponentRegistry.register :toolbar, to: Plutonium::Ui::ToolbarComponent
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "simple_form"

# Register components
Dir.glob(Plutonium.lib_root.join("simple_form_components", "*.rb")) { |component| load component }
Dir.glob(Plutonium.lib_root.join("form_component", "*.rb")) { |component| load component }

# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
Expand Down
2 changes: 1 addition & 1 deletion lib/active_model/validations/array_validator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# require 'active_model/validations/each_validator'
require "active_model"

module ActiveModel
module Validations
Expand Down
2 changes: 1 addition & 1 deletion lib/active_model/validations/attached_validator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
require "active_model"

module ActiveModel
module Validations
Expand Down
2 changes: 1 addition & 1 deletion lib/active_model/validations/url_validator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
require "active_model"

module ActiveModel
module Validations
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/pu/gen/component/component_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def component_module
end

def component_namespace
["Plutonium::UI", component_module].compact.join "::"
["Plutonium::Ui", component_module].compact.join "::"
end

def component_reference
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/pu/gen/component/templates/component.rb.tt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module <%= component_namespace %>
class <%= component_classname %> < Plutonium::UI::Base
class <%= component_classname %> < Plutonium::Ui::Base
# def base_classname
# "base classnames here"
# end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module <%= package_name %>
<%- if rodauth_account.present? -%>
include Plutonium::Auth.rodauth(:<%= rodauth_account %>)
<%- elsif public_access? -%>
include Plutonium::Auth::PublicAccess
include Plutonium::Auth::Public
<%- end -%>
# add concerns above.

Expand Down
34 changes: 8 additions & 26 deletions lib/plutonium.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
require "active_support"
require "zeitwerk"

loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
loader.ignore("#{__dir__}/generators")
loader.ignore("#{__dir__}/plutonium/railtie.rb")
loader.enable_reloading if defined?(Rails.env) && Rails.env.development?
loader.setup

require_relative "plutonium/version"
require_relative "plutonium/railtie" if defined?(Rails::Railtie)

module Plutonium
# require_relative "active_model/validations/array_validator"
# require_relative "active_model/validations/attached_validator"
# require_relative "active_model/validations/url_validator"

extend ActiveSupport::Autoload

class Error < StandardError; end

def self.root
Expand Down Expand Up @@ -45,23 +44,6 @@ def self.script_link
# end
end
end

autoload :Config

eager_autoload do
autoload :Application
autoload :Auth
autoload :Builders
autoload :ComponentRegistry
autoload :Core
autoload :Helpers
autoload :Icons
autoload :Pkg
autoload :Policy
autoload :Reactor
autoload :Resource
autoload :Rodauth
end
end

require_relative "../app/views/components/base" if defined?(Rails)
Plutonium::ZEITWERK_LOADER = loader

0 comments on commit fda5ebf

Please sign in to comment.