refactor: store processed content for crinja (later)
This commit is contained in:
parent
aa2ddc0302
commit
fccbce8869
3 changed files with 18 additions and 10 deletions
|
@ -1,8 +1,8 @@
|
|||
version: 2.0
|
||||
shards:
|
||||
completion:
|
||||
git: https://github.com/f/completion.git
|
||||
version: 0.1.0+git.commit.d8799381b2de14430496199260eca64eb329625f
|
||||
crinja:
|
||||
git: https://github.com/straight-shoota/crinja.git
|
||||
version: 0.8.1
|
||||
|
||||
magic:
|
||||
git: https://github.com/dscottboggs/magic.cr.git
|
||||
|
|
|
@ -10,6 +10,8 @@ authors:
|
|||
- Glenn Y. Rolland <glenux@glenux.net>
|
||||
|
||||
dependencies:
|
||||
crinja:
|
||||
github: straight-shoota/crinja
|
||||
magic:
|
||||
github: dscottboggs/magic.cr
|
||||
walk:
|
||||
|
|
20
src/cli.cr
20
src/cli.cr
|
@ -95,6 +95,7 @@ module CodePreloader
|
|||
def exec_pack(pack_options)
|
||||
abort("Unexpected nil value for pack_options!") if pack_options.nil?
|
||||
|
||||
preloaded_content = {} of String => NamedTuple(mime: String, content: String)
|
||||
output_file_path = pack_options.output_file_path
|
||||
repository_path_list = pack_options.repository_path_list
|
||||
header_prompt_file_path = pack_options.header_prompt_file_path
|
||||
|
@ -134,7 +135,14 @@ module CodePreloader
|
|||
STDERR.puts "Processing repository: #{repository_path_list}".colorize(:yellow)
|
||||
filelist.each do |file_path|
|
||||
STDERR.puts "Processing file: #{file_path}".colorize(:yellow)
|
||||
process_file(file_path, output_file)
|
||||
file_result = process_file(file_path, output_file)
|
||||
|
||||
output_file.puts "@@ File \"#{file_path}\" (Mime-Type: #{file_result[:mime]})"
|
||||
output_file.puts ""
|
||||
if file_result[:text_content] !~ /^\s*$/
|
||||
output_file.puts(file_result[:text_content])
|
||||
output_file.puts ""
|
||||
end
|
||||
end
|
||||
|
||||
footer_prompt_file_path.try { output_file.puts footer_prompt }
|
||||
|
@ -159,12 +167,10 @@ module CodePreloader
|
|||
)
|
||||
end
|
||||
|
||||
output_file.puts "@@ File \"#{file_path}\" (Mime-Type: #{mime.inspect})"
|
||||
output_file.puts ""
|
||||
if clean_content !~ /^\s*$/
|
||||
output_file.puts(clean_content)
|
||||
output_file.puts ""
|
||||
end
|
||||
return {
|
||||
mime: mime,
|
||||
text_content: clean_content
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue