Skip to content
Merged
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
23 changes: 4 additions & 19 deletions lib/generators/ruby_ui/component_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,13 @@ def generate_component
exit
end

say "Generating component files"
end

def copy_main_component_file
main_component_file_path = File.join(component_folder_path, "#{component_folder_name}.rb")

# some components dont't have a main component, eg. Typography
return unless File.exist? main_component_file_path

say "Generating main component"

copy_file main_component_file_path, Rails.root.join("app/components/ruby_ui", "#{component_folder_name}.rb")
say "Generating #{component_name} files..."
end

def copy_related_component_files
return if related_components_file_paths.empty?

say "Generating related components"
say "Generating components"

related_components_file_paths.each do |file_path|
components_file_paths.each do |file_path|
component_file_name = file_path.split("/").last
copy_file file_path, Rails.root.join("app/components/ruby_ui", component_folder_name, component_file_name)
end
Expand Down Expand Up @@ -75,9 +62,7 @@ def component_folder_name = component_name.underscore

def component_folder_path = File.join(self.class.source_root, component_folder_name)

def main_component_file_path = File.join(component_folder_path, "#{component_folder_name}.rb")

def related_components_file_paths = Dir.glob(File.join(component_folder_path, "*.rb")) - [main_component_file_path]
def components_file_paths = Dir.glob(File.join(component_folder_path, "*.rb"))

def js_controller_file_paths = Dir.glob(File.join(component_folder_path, "*.js"))

Expand Down