-
Notifications
You must be signed in to change notification settings - Fork 62
Add generator for all components #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| module RubyUI | ||
| module Generators | ||
| module Component | ||
| class AllGenerator < Rails::Generators::Base | ||
| namespace "ruby_ui:component:all" | ||
|
|
||
| source_root File.expand_path("../../../ruby_ui", __dir__) | ||
|
|
||
| def generate_components | ||
| say "Generating all components..." | ||
|
|
||
| Dir.children(self.class.source_root).each do |folder_name| | ||
| puts "folder_name: #{folder_name}" | ||
cirdes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| next if folder_name == "base.rb" | ||
|
|
||
| component_name = folder_name.camelize | ||
cirdes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run "bin/rails generate ruby_ui:component #{component_name} --force true" | ||
|
||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do something like
Dir.glob("path/to/ruby_ui/*/")you will get ruby_ui folders, then you won't need to donext if folder_name == "base.rb".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It started to return the full path. I decided to check if the string ends_with?(".rb") to make it more generic and robust
folder_name: /Users/cirdes/Workspace/ruby-ui/ruby_ui/lib/ruby_ui/accordion/