Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ PATH
remote: .
specs:
ruby_ui (1.0.0.pre.alpha.4)
phlex (>= 2.0.0.beta2)
rouge (~> 4.2.0)
tailwind_merge (~> 0.12)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -63,9 +60,12 @@ PLATFORMS

DEPENDENCIES
minitest (~> 5.0)
phlex (>= 2.0.0.beta2)
rake (~> 13.0)
rouge (~> 4.2.0)
ruby_ui!
standard (~> 1.0)
tailwind_merge (~> 0.12)

BUNDLED WITH
2.5.22
54 changes: 1 addition & 53 deletions lib/ruby_ui.rb
Original file line number Diff line number Diff line change
@@ -1,57 +1,5 @@
# frozen_string_literal: true

require "json"
require "phlex"

module RubyUI
extend Phlex::Kit

def self.setup
yield self
create_namespace_module if namespace
end

def self.create_namespace_module
source_module = self
mod = namespace.to_s.split("::").inject(Object) do |parent, const|
parent.const_get(const)
rescue
parent.const_set(const, Module.new)
end

mod.singleton_class.class_eval do
define_method :const_missing do |name|
source_module.const_defined?(name) ? source_module.const_get(name) : super(name)
end

define_method :method_missing do |name, *args, &block|
source_module.respond_to?(name) ? source_module.send(name, *args, &block) : super(name, *args, &block)
end

define_method :respond_to_missing? do |name, include_private = false|
source_module.respond_to?(name) || super(name, include_private)
end
end
end

def self.namespace
@namespace ||= nil
end

def self.namespace=(value)
@namespace = value
end
end

# Require the Base class first
require_relative "ruby_ui/base"

# Manually require all the files
Dir.glob(File.join(__dir__, "ruby_ui", "**", "*.rb")).sort.each { |file| require file }

# If you need to require generators (assuming they're needed)
if defined?(Rails::Generators)
require_relative "generators/ruby_ui/base_generator"
require_relative "generators/ruby_ui/install/install_generator"
require_relative "generators/ruby_ui/component_generator"
VERSION = "1.0.0-alpha.4"
end
7 changes: 0 additions & 7 deletions lib/ruby_ui/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ def initialize(**user_attrs)
@attrs[:class] = TAILWIND_MERGER.merge(@attrs[:class]) if @attrs[:class]
end

if defined?(Rails) && Rails.env.development?
def before_template
comment { "Before #{self.class.name}" }
super
end
end

private

def default_attrs
Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_ui/combobox/combobox_list.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "securerandom"

module RubyUI
class ComboboxList < Base
def initialize(**attrs)
Expand Down
72 changes: 0 additions & 72 deletions lib/ruby_ui/index.js

This file was deleted.

52 changes: 0 additions & 52 deletions lib/ruby_ui/railtie.rb

This file was deleted.

5 changes: 0 additions & 5 deletions lib/ruby_ui/version.rb

This file was deleted.

9 changes: 4 additions & 5 deletions ruby_ui.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative "lib/ruby_ui/version"
require_relative "lib/ruby_ui"

Gem::Specification.new do |s|
s.name = "ruby_ui"
Expand All @@ -15,10 +15,9 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 3.3.1"

s.add_dependency "phlex", ">= 2.0.0.beta2"
s.add_dependency "rouge", "~> 4.2.0"
s.add_dependency "tailwind_merge", "~> 0.12"

s.add_development_dependency "phlex", ">= 2.0.0.beta2"
s.add_development_dependency "rouge", "~> 4.2.0"
s.add_development_dependency "tailwind_merge", "~> 0.12"
s.add_development_dependency "rake", "~> 13.0"
s.add_development_dependency "standard", "~> 1.0"
s.add_development_dependency "minitest", "~> 5.0"
Expand Down
31 changes: 0 additions & 31 deletions test/ruby_ui/setup_test.rb

This file was deleted.

39 changes: 18 additions & 21 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
# frozen_string_literal: true

require "bundler/setup"

Bundler.require(:default)

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "ruby_ui"
require "phlex"
# require "phlex/testing/view_helper"
require "json"
require "securerandom"
require "minitest/autorun"

class TestContext < Phlex::HTML
def view_template(&)
div(&)
module RubyUI
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to make RubyUI.ComponentName work. On user apps, we will generate something like:

Rails.autoloaders.main.push_dir(
  "#{Rails.root}/app/components/ruby_ui", namespace: RubyUI
)

extend Phlex::Kit

Dir.glob("lib/ruby_ui/**/*.rb").map do |path|
class_name = path.split("/").last.delete_suffix(".rb").split("_").map(&:capitalize).join.to_sym

autoload class_name, path
end
end

def phlex_context(&)
render TestContext.new, &
render Phlex::HTML.new, &
end

# this is a monkey patch for https://github.com/phlex-ruby/phlex/pull/809
module Phlex::Testing
module Basic
def render(view, &)
if view.is_a?(Class) && view < Phlex::SGML
view = view.new
module Phlex
module Testing
module ViewHelper
def render(component, &)
component.call(view_context:, &)
end

view.call(view_context:, &)
end

def view_context
nil
def view_context = nil
end
end
ViewHelper = Basic
end

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