Class: ShadcnUiGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ShadcnUiGenerator
- Defined in:
- lib/generators/shadcn-ui_generator.rb
Instance Attribute Summary collapse
-
#component_name ⇒ Object
readonly
Returns the value of attribute component_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#target_rails_root ⇒ Object
readonly
Returns the value of attribute target_rails_root.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args, *options) ⇒ ShadcnUiGenerator
constructor
A new instance of ShadcnUiGenerator.
- #install_component ⇒ Object
- #preprocess_sources ⇒ Object
Constructor Details
#initialize(args, *options) ⇒ ShadcnUiGenerator
Returns a new instance of ShadcnUiGenerator.
16 17 18 19 20 21 |
# File 'lib/generators/shadcn-ui_generator.rb', line 16 def initialize(args, *) super @component_name = component @target_rails_root = rails_root || Rails.root @options = .first end |
Instance Attribute Details
#component_name ⇒ Object (readonly)
Returns the value of attribute component_name.
7 8 9 |
# File 'lib/generators/shadcn-ui_generator.rb', line 7 def component_name @component_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/generators/shadcn-ui_generator.rb', line 7 def @options end |
#target_rails_root ⇒ Object (readonly)
Returns the value of attribute target_rails_root.
7 8 9 |
# File 'lib/generators/shadcn-ui_generator.rb', line 7 def target_rails_root @target_rails_root end |
Class Method Details
.banner ⇒ Object
12 13 14 |
# File 'lib/generators/shadcn-ui_generator.rb', line 12 def self. "rails generate shadcn-ui <component_name> [--remove] [rails_root_path]" end |
Instance Method Details
#install_component ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/generators/shadcn-ui_generator.rb', line 27 def install_component if component_valid? copy_files else display_available_components end end |
#preprocess_sources ⇒ Object
23 24 25 |
# File 'lib/generators/shadcn-ui_generator.rb', line 23 def preprocess_sources check_target_app end |