Class: SharedTools::Tools::Disk::FileMoveTool

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/shared_tools/tools/disk/file_move_tool.rb

Overview

Examples:

tool = SharedTools::Tools::Disk::FileMoveTool.new(root: "./project")
tool.execute(
  path: "./README.txt",
  destination: "./README.md",
)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver: nil, logger: nil) ⇒ FileMoveTool

Returns a new instance of FileMoveTool.



24
25
26
27
# File 'lib/shared_tools/tools/disk/file_move_tool.rb', line 24

def initialize(driver: nil, logger: nil)
  @driver = driver || SharedTools::Tools::Disk::LocalDriver.new(root: Dir.pwd)
  @logger = logger || RubyLLM.logger
end

Class Method Details

.nameObject



15
# File 'lib/shared_tools/tools/disk/file_move_tool.rb', line 15

def self.name = 'disk_file_move'

Instance Method Details

#execute(path:, destination:) ⇒ String

Parameters:

  • path (String)
  • destination (String)

Returns:

  • (String)


33
34
35
36
37
38
39
# File 'lib/shared_tools/tools/disk/file_move_tool.rb', line 33

def execute(path:, destination:)
  @logger.info("#{self.class.name}#execute path=#{path.inspect} destination=#{destination.inspect}")
  @driver.file_move(path:, destination:)
rescue SecurityError => e
  @logger.info("ERROR: #{e.message}")
  raise e
end