Class: Aircana::Generators::HooksGenerator
- Inherits:
-
BaseGenerator
- Object
- BaseGenerator
- Aircana::Generators::HooksGenerator
- Defined in:
- lib/aircana/generators/hooks_generator.rb
Constant Summary collapse
- ALL_HOOK_TYPES =
All available hook types (for manual creation)
%w[ pre_tool_use post_tool_use user_prompt_submit session_start notification_sqs rubocop_pre_commit rspec_test bundle_install ].freeze
- DEFAULT_HOOK_TYPES =
Default hooks that are auto-installed
%w[ session_start notification_sqs ].freeze
Instance Attribute Summary
Attributes inherited from BaseGenerator
Class Method Summary collapse
- .all_available_hooks ⇒ Object
- .available_default_hooks ⇒ Object
- .create_all_default_hooks ⇒ Object
- .create_default_hook(hook_name) ⇒ Object
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(hook_name: nil) ⇒ HooksGenerator
constructor
A new instance of HooksGenerator.
Constructor Details
#initialize(hook_name: nil) ⇒ HooksGenerator
Returns a new instance of HooksGenerator.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/aircana/generators/hooks_generator.rb', line 50 def initialize(hook_name: nil, **) @hook_name = hook_name if hook_name template_path = File.join(File.dirname(__FILE__), "..", "templates", "hooks", "#{hook_name}.erb") output_path = File.join(Aircana.configuration.scripts_dir, "#{hook_name}.sh") super(file_in: template_path, file_out: output_path) else super(**) end end |
Class Method Details
.all_available_hooks ⇒ Object
31 32 33 |
# File 'lib/aircana/generators/hooks_generator.rb', line 31 def all_available_hooks ALL_HOOK_TYPES end |
.available_default_hooks ⇒ Object
27 28 29 |
# File 'lib/aircana/generators/hooks_generator.rb', line 27 def available_default_hooks DEFAULT_HOOK_TYPES end |
.create_all_default_hooks ⇒ Object
45 46 47 |
# File 'lib/aircana/generators/hooks_generator.rb', line 45 def create_all_default_hooks available_default_hooks.each { |hook_name| create_default_hook(hook_name) } end |
.create_default_hook(hook_name) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/aircana/generators/hooks_generator.rb', line 35 def create_default_hook(hook_name) return unless all_available_hooks.include?(hook_name) template_path = File.join(File.dirname(__FILE__), "..", "templates", "hooks", "#{hook_name}.erb") output_path = File.join(Aircana.configuration.scripts_dir, "#{hook_name}.sh") generator = new(file_in: template_path, file_out: output_path) generator.generate end |
Instance Method Details
#generate ⇒ Object
62 63 64 65 66 |
# File 'lib/aircana/generators/hooks_generator.rb', line 62 def generate result = super make_executable if File.exist?(file_out) result end |