Skip to content

Commit 153039c

Browse files
committed
Clean up unnecessary code
1 parent 1194883 commit 153039c

File tree

9 files changed

+26
-249
lines changed

9 files changed

+26
-249
lines changed

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ PATH
22
remote: .
33
specs:
44
ruby_ui (1.0.0.pre.alpha.4)
5-
phlex (>= 2.0.0.beta2)
6-
rouge (~> 4.2.0)
7-
tailwind_merge (~> 0.12)
85

96
GEM
107
remote: https://rubygems.org/
@@ -63,9 +60,12 @@ PLATFORMS
6360

6461
DEPENDENCIES
6562
minitest (~> 5.0)
63+
phlex (>= 2.0.0.beta2)
6664
rake (~> 13.0)
65+
rouge (~> 4.2.0)
6766
ruby_ui!
6867
standard (~> 1.0)
68+
tailwind_merge (~> 0.12)
6969

7070
BUNDLED WITH
7171
2.5.22

lib/ruby_ui.rb

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "json"
4-
require "phlex"
5-
63
module RubyUI
7-
extend Phlex::Kit
8-
9-
def self.setup
10-
yield self
11-
create_namespace_module if namespace
12-
end
13-
14-
def self.create_namespace_module
15-
source_module = self
16-
mod = namespace.to_s.split("::").inject(Object) do |parent, const|
17-
parent.const_get(const)
18-
rescue
19-
parent.const_set(const, Module.new)
20-
end
21-
22-
mod.singleton_class.class_eval do
23-
define_method :const_missing do |name|
24-
source_module.const_defined?(name) ? source_module.const_get(name) : super(name)
25-
end
26-
27-
define_method :method_missing do |name, *args, &block|
28-
source_module.respond_to?(name) ? source_module.send(name, *args, &block) : super(name, *args, &block)
29-
end
30-
31-
define_method :respond_to_missing? do |name, include_private = false|
32-
source_module.respond_to?(name) || super(name, include_private)
33-
end
34-
end
35-
end
36-
37-
def self.namespace
38-
@namespace ||= nil
39-
end
40-
41-
def self.namespace=(value)
42-
@namespace = value
43-
end
44-
end
45-
46-
# Require the Base class first
47-
require_relative "ruby_ui/base"
48-
49-
# Manually require all the files
50-
Dir.glob(File.join(__dir__, "ruby_ui", "**", "*.rb")).sort.each { |file| require file }
51-
52-
# If you need to require generators (assuming they're needed)
53-
if defined?(Rails::Generators)
54-
require_relative "generators/ruby_ui/base_generator"
55-
require_relative "generators/ruby_ui/install/install_generator"
56-
require_relative "generators/ruby_ui/component_generator"
4+
VERSION = "1.0.0-alpha.4"
575
end

lib/ruby_ui/base.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ def initialize(**user_attrs)
1313
@attrs[:class] = TAILWIND_MERGER.merge(@attrs[:class]) if @attrs[:class]
1414
end
1515

16-
if defined?(Rails) && Rails.env.development?
17-
def before_template
18-
comment { "Before #{self.class.name}" }
19-
super
20-
end
21-
end
22-
2316
private
2417

2518
def default_attrs

lib/ruby_ui/index.js

Lines changed: 0 additions & 72 deletions
This file was deleted.

lib/ruby_ui/railtie.rb

Lines changed: 0 additions & 52 deletions
This file was deleted.

lib/ruby_ui/version.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

ruby_ui.gemspec

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative "lib/ruby_ui/version"
1+
require_relative "lib/ruby_ui"
22

33
Gem::Specification.new do |s|
44
s.name = "ruby_ui"
@@ -15,10 +15,9 @@ Gem::Specification.new do |s|
1515

1616
s.required_ruby_version = ">= 3.3.1"
1717

18-
s.add_dependency "phlex", ">= 2.0.0.beta2"
19-
s.add_dependency "rouge", "~> 4.2.0"
20-
s.add_dependency "tailwind_merge", "~> 0.12"
21-
18+
s.add_development_dependency "phlex", ">= 2.0.0.beta2"
19+
s.add_development_dependency "rouge", "~> 4.2.0"
20+
s.add_development_dependency "tailwind_merge", "~> 0.12"
2221
s.add_development_dependency "rake", "~> 13.0"
2322
s.add_development_dependency "standard", "~> 1.0"
2423
s.add_development_dependency "minitest", "~> 5.0"

test/ruby_ui/setup_test.rb

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/test_helper.rb

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
# frozen_string_literal: true
22

3-
require "bundler/setup"
4-
5-
Bundler.require(:default)
6-
3+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4+
require "ruby_ui"
75
require "phlex"
8-
# require "phlex/testing/view_helper"
6+
require "json"
7+
98
require "minitest/autorun"
109

11-
class TestContext < Phlex::HTML
12-
def view_template(&)
13-
div(&)
10+
module RubyUI
11+
extend Phlex::Kit
12+
13+
Dir.glob("lib/ruby_ui/**/*.rb").map do |path|
14+
class_name = path.split("/").last.delete_suffix(".rb").split("_").map(&:capitalize).join.to_sym
15+
16+
autoload class_name, path
1417
end
1518
end
1619

1720
def phlex_context(&)
18-
render TestContext.new, &
21+
render Phlex::HTML.new, &
1922
end
2023

21-
# this is a monkey patch for https://github.com/phlex-ruby/phlex/pull/809
22-
module Phlex::Testing
23-
module Basic
24-
def render(view, &)
25-
if view.is_a?(Class) && view < Phlex::SGML
26-
view = view.new
24+
module Phlex
25+
module Testing
26+
module ViewHelper
27+
def render(component, &)
28+
component.call(view_context:, &)
2729
end
2830

29-
view.call(view_context:, &)
30-
end
31-
32-
def view_context
33-
nil
31+
def view_context = nil
3432
end
3533
end
36-
ViewHelper = Basic
3734
end
3835

3936
# this is a tracepoint that will output the path of all files loaded that contain the string "phlex"

0 commit comments

Comments
 (0)