to_llm 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79e005ef579c63795093a10bc0318048894fdaef71f959eaac97ec46d9d12340
4
- data.tar.gz: 297867c42b4a9caf4d803798edd51deae0fcf63815f47a3e742ddd60cbf918ab
3
+ metadata.gz: 4ad8dc7aa1fe23ab7edadb158054251138e6fa9d5b4f7412415f6ac8c6260328
4
+ data.tar.gz: a036334beb2f709b76b240a864429e147055796010a1d9f3f73d40cf6e26a214
5
5
  SHA512:
6
- metadata.gz: 3aaa9070c20e815f41aebb34bb933e4ac289e45b0640edb0abe80af02b818ed3e42d7c902194df3571363229c0b5fd839cd3fc3c8d90e04f6bed6f61f15523a1
7
- data.tar.gz: 9bde15f9c6be326a6659fd7d6d497234de245928c59179c0d5bc2487c254d446228684be518cbca768ec5a479e1449de2410db75ac02ff545cfd1426b7f17e65
6
+ metadata.gz: 70fa48467dda813b75e72b0d8c4b4efd1145a782c6de1b3f63dad2b0e7b29c4e0f2aa953a86bea2221d05cbba0e11e7bf0afb166381f96362e6bb2a7ab8080cd
7
+ data.tar.gz: 8163a2ccb4a46d6a59f5b9987f13ff072ebdf6b831c5d0a02f3d35621d23d0439cecc9978db61548357c8a22140e4ed7854e7481270192645d8a8ca9da5fff8c
@@ -2,6 +2,11 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  namespace :to_llm do
5
+ def clean_content(content)
6
+ cleaned = content.lines.map(&:strip).join("\n")
7
+ cleaned.gsub(/\n{2,}/, "\n")
8
+ end
9
+
5
10
  def run_extraction(extract_type, output_format)
6
11
  extract_type = extract_type&.upcase || "ALL"
7
12
  output_format = output_format&.downcase || "txt"
@@ -58,6 +63,7 @@ namespace :to_llm do
58
63
 
59
64
  # Writes file content in either txt or md format
60
65
  def write_content(path, content, output_format, output_file)
66
+ content = clean_content(content)
61
67
  if output_format == "md"
62
68
  language = detect_language(File.extname(path))
63
69
  <<~MARKDOWN
@@ -70,7 +76,7 @@ namespace :to_llm do
70
76
  # txt format
71
77
  <<~TXT
72
78
  #{path}:
73
- ----------------------------------------------------
79
+ -
74
80
  #{content}
75
81
 
76
82
  TXT
@@ -119,8 +125,11 @@ namespace :to_llm do
119
125
  "Examples:\n" \
120
126
  " rails \"to_llm:extract[ALL,md]\"\n" \
121
127
  " rails \"to_llm:extract[MODELS,txt]\""
122
- task :extract, [:type_and_format] => :environment do |_t, args|
123
- if args[:type_and_format].blank?
128
+ task :extract, [:type, :format] => :environment do |_t, args|
129
+ type = (args[:type] || "ALL").upcase
130
+ format = (args[:format] || "txt").downcase
131
+
132
+ if args[:type].blank? || args[:format].blank?
124
133
  # No parameters passed -> show help message
125
134
  puts "--------------------------------------------------------------------"
126
135
  puts "Usage: rails \"to_llm:extract[TYPE,FORMAT]\""
@@ -133,9 +142,7 @@ namespace :to_llm do
133
142
  next
134
143
  end
135
144
 
136
- # Attempt to parse "TYPE,FORMAT"
137
- type, format = args[:type_and_format].split(",")
138
-
145
+
139
146
  if format.nil?
140
147
  # Old usage
141
148
  puts "You are using the old usage: rails to_llm:extract #{type}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ToLLM
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_llm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Carlos Maciel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-09 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails