Class: ShadcnUiGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/shadcn-ui_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, *options)
  super
  @component_name = component
  @target_rails_root = rails_root || Rails.root
  @options = options.first
end

Instance Attribute Details

#component_nameObject (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

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/generators/shadcn-ui_generator.rb', line 7

def options
  @options
end

#target_rails_rootObject (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



12
13
14
# File 'lib/generators/shadcn-ui_generator.rb', line 12

def self.banner
  "rails generate shadcn-ui <component_name> [--remove] [rails_root_path]"
end

Instance Method Details

#install_componentObject



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_sourcesObject



23
24
25
# File 'lib/generators/shadcn-ui_generator.rb', line 23

def preprocess_sources
  check_target_app
end