Module: GlimHelpers
- Defined in:
- lib/glim_helpers.rb
Instance Method Summary collapse
- #include_file(entry_path, relative_path = nil) ⇒ Object
-
#include_files(path, prefix = '') ⇒ Object
TODO: modify this so that you can also include a single file, list of files, etc.
- #prompt_output_files ⇒ Object
Instance Method Details
#include_file(entry_path, relative_path = nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/glim_helpers.rb', line 24 def include_file(entry_path, relative_path = nil) relative_path ||= entry_path raise("File not found: #{entry_path}") if !File.file?(entry_path) result = "\n<file pathname=\"#{relative_path}\">" result += File.read(entry_path) result + "</file>\n" end |
#include_files(path, prefix = '') ⇒ Object
TODO: modify this so that you can also include a single file, list of files, etc
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/glim_helpers.rb', line 4 def include_files(path, prefix='') putt :include_files, "include_files(path: #{path}, prefix: #{prefix})" result = "" Dir.foreach(path) do |entry| next if entry.start_with?('.') entry_path = File.join(path, entry) relative_path = File.join(prefix, entry) if File.directory?(entry_path) result += include_files(entry_path, relative_path) else # elsif File.file?(entry_path) # result += "\n```\n# File: #{relative_path}\n" # result += File.read(entry_path) # result += "\n```\n" result += include_file(entry_path, relative_path) end end result end |
#prompt_output_files ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/glim_helpers.rb', line 33 def prompt_output_files <<-GLIM_PROMPT TODO fix this for xml SYSTEM MESSAGE: ALWAYS, when asked to generate source code or other text files, use the following format: <file pathname="path_to_file/hello.rb"> puts "Hello from Line 1" puts "hello from Line 2" </file> So, the example above shows how you would include a file called "hello.rb" that belongs in the subdirectory "path_to_file" of the current directory. The file would contain two "puts" statements. Use this for all text files you generate, not just source code. GLIM_PROMPT end |