Module: Roast::Tools
- Extended by:
- Tools
- Included in:
- Tools
- Defined in:
- lib/roast/tools.rb,
lib/roast/tools/cmd.rb,
lib/roast/tools/grep.rb,
lib/roast/tools/read_file.rb,
lib/roast/tools/write_file.rb,
lib/roast/tools/search_file.rb,
lib/roast/tools/coding_agent.rb
Defined Under Namespace
Modules: Cmd, CodingAgent, Grep, ReadFile, SearchFile, WriteFile
Constant Summary
collapse
- CACHE =
ActiveSupport::Cache::FileStore.new(File.join(Dir.pwd, ".roast", "cache"))
Instance Method Summary
collapse
Instance Method Details
#file_to_prompt(file) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/roast/tools.rb', line 19
def file_to_prompt(file)
<<~PROMPT
# #{file}
#{File.read(file)}
PROMPT
rescue StandardError => e
Roast::Helpers::Logger.error("In current directory: #{Dir.pwd}\n")
Roast::Helpers::Logger.error("Error reading file #{file}\n")
raise e end
|
#setup_exit_handler(context) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/roast/tools.rb', line 40
def setup_exit_handler(context)
at_exit do
if $ERROR_INFO && !$ERROR_INFO.is_a?(SystemExit) puts "\n\nExiting due to error: #{$ERROR_INFO.class}: #{$ERROR_INFO.message}\n"
end
end
end
|
#setup_interrupt_handler(object_to_inspect) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/roast/tools.rb', line 32
def setup_interrupt_handler(object_to_inspect)
Signal.trap("INT") do
puts "\n\nCaught CTRL-C! Printing before exiting:\n"
puts JSON.pretty_generate(object_to_inspect)
exit(1)
end
end
|