Class: GemContribute::CLI::PostCloneHooks

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_contribute/cli/post_clone_hooks.rb

Overview

Optional post-clone hooks invoked by ‘fix` when the user passes `-e` (open editor) and/or `-a` (launch AI tool). Extracted so the `fix` state machine stays focused on the fork/clone/branch sequence.

Instance Method Summary collapse

Constructor Details

#initialize(stdout: $stdout, stderr: $stderr, output: nil, config: GemContribute::Config.new, editor_runner: ->(cmd, path) { Kernel.system("#{cmd} #{path.shellescape}") }, ai_runner: ->(cmd, path) { Kernel.system(cmd, chdir: path) }) ⇒ PostCloneHooks

Returns a new instance of PostCloneHooks.



12
13
14
15
16
17
18
19
20
# File 'lib/gem_contribute/cli/post_clone_hooks.rb', line 12

def initialize(stdout: $stdout, stderr: $stderr, output: nil,
               config: GemContribute::Config.new,
               editor_runner: ->(cmd, path) { Kernel.system("#{cmd} #{path.shellescape}") },
               ai_runner: ->(cmd, path) { Kernel.system(cmd, chdir: path) })
  @output = output || Output::Standard.new(out: stdout, err: stderr)
  @config = config
  @editor_runner = editor_runner
  @ai_runner = ai_runner
end

Instance Method Details

#call(local_path, editor:, ai_tool:) ⇒ Object



22
23
24
25
# File 'lib/gem_contribute/cli/post_clone_hooks.rb', line 22

def call(local_path, editor:, ai_tool:)
  open_editor(local_path) if editor
  launch_ai(local_path)   if ai_tool
end