Class: ViewPrimitives::Generators::AddGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ViewPrimitives::Generators::AddGenerator
show all
- Includes:
- ComponentCopier, Detector
- Defined in:
- lib/generators/view_primitives/add/add_generator.rb
Constant Summary
Constants included
from Detector
Detector::JS_CONTROLLER_DIRS, Detector::TAILWIND_ENTRIES
Instance Method Summary
collapse
included
Instance Method Details
#copy_components ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/generators/view_primitives/add/add_generator.rb', line 20
def copy_components
@copied = []
@unknown = []
components.each do |name|
if Components.supported.include?(name)
@copied << name if copy_component(name)
else
@unknown << name
say " Unknown component: #{name}. Supported: #{Components.supported.join(", ")}", :red
end
end
end
|
#report_setup_notes ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/generators/view_primitives/add/add_generator.rb', line 44
def report_setup_notes
@copied&.each do |name|
note = Components::SETUP_NOTES[name]
next unless note
say ""
say " ── Setup required for #{name} ──────────────────────────", :yellow
note.each_line { |line| say " #{line.chomp}", :cyan }
say ""
end
abort if @abort_after_notes
end
|
#report_summary ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/generators/view_primitives/add/add_generator.rb', line 34
def report_summary
say "" if @copied&.any? || @unknown&.any?
say " Copied: #{@copied.join(", ")}", :green if @copied&.any?
return if @unknown.blank?
say " Failed: #{@unknown.join(", ")} (unknown)", :red
say " Run `rails g view_primitives:list` to see all available components.", :cyan
@abort_after_notes = true
end
|