@@ -9,8 +9,14 @@ module Generators
99 class InstallGenerator < Rails ::Generators ::Base
1010 source_root File . expand_path ( "templates" , __dir__ )
1111
12- class_option :guide , type : :string , default : "select" , desc : "Which guide to install (or 'select' to choose interactively)"
13- class_option :with_rules , type : :boolean , default : false , desc : "Copy editor rules (.cursorrules, RuboCop, Solargraph) if available"
12+ class_option :guide ,
13+ type : :string ,
14+ default : "select" ,
15+ desc : "Which guide to install (or 'select' to choose interactively)"
16+ class_option :with_rules ,
17+ type : :boolean ,
18+ default : false ,
19+ desc : "Copy editor rules (.cursorrules, RuboCop, Solargraph) if available"
1420
1521 def create_config
1622 template "config/memory_bank.yml.erb" , "config/memory_bank.yml"
@@ -66,9 +72,8 @@ def resolve_guide_source(guide, guides_path)
6672 def select_guide_interactively ( guides_path )
6773 builtin = available_builtin_guides
6874 external = available_external_guides ( guides_path )
69- options = [ ]
70- builtin . each { |g | options << [ "📦 #{ g } (builtin)" , :builtin , g , nil ] }
71- external . each { |g , path | options << [ "🔧 #{ g } (external)" , :external , g , path ] }
75+ options = builtin . map { |g | [ "📦 #{ g } (builtin)" , :builtin , g , nil ] } +
76+ external . map { |g , path | [ "🔧 #{ g } (external)" , :external , g , path ] }
7277
7378 if options . empty?
7479 say "No guides available. Falling back to builtin 'rails_web'" , :yellow
@@ -78,11 +83,11 @@ def select_guide_interactively(guides_path)
7883 say "\n 🚀 Memory Bank Initializer (Rails)" , :green
7984 say "=================================\n "
8085 options . each_with_index do |( label , _kind , _slug , _path ) , idx |
81- say format ( "%2d) %s" , idx + 1 , label )
86+ say format ( "%<num> 2d) %<label> s" , num : idx + 1 , label : label )
8287 end
8388 choice = ask ( "\n ? What type of memory bank would you like to install? (1-#{ options . size } )" ) . to_i
8489 choice = 1 if choice < 1 || choice > options . size
85- label , kind , slug , full_path = options [ choice - 1 ]
90+ _label , kind , slug , full_path = options [ choice - 1 ]
8691 [ slug , kind , full_path ]
8792 end
8893
@@ -94,8 +99,10 @@ def available_builtin_guides
9499
95100 def available_external_guides ( guides_path )
96101 return [ ] unless guides_path
102+
97103 expanded = File . expand_path ( guides_path )
98104 return [ ] unless Dir . exist? ( expanded )
105+
99106 Dir . children ( expanded ) . filter_map do |entry |
100107 full = File . join ( expanded , entry )
101108 guide_md = File . join ( full , "developmentGuide.md" )
@@ -112,9 +119,9 @@ def copy_external_guide_files(external_dir)
112119 FileUtils . cp ( source_md , File . join ( destination_root , ".memory_bank" , "developmentGuide.md" ) )
113120
114121 rules = File . join ( external_dir , ".cursorrules" )
115- if options [ "with_rules" ] && File . exist? ( rules )
116- FileUtils . cp ( rules , File . join ( destination_root , ".cursorrules" ) )
117- end
122+ return unless options [ "with_rules" ] && File . exist? ( rules )
123+
124+ FileUtils . cp ( rules , File . join ( destination_root , ".cursorrules" ) )
118125 end
119126
120127 def install_editor_rules
@@ -131,5 +138,3 @@ def install_editor_rules
131138 end
132139 end
133140end
134-
135-
0 commit comments