ruby_todo 1.0.1 → 1.0.3

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: 335ebe29df566a811eddbc67c2443bff069e45d3c6b93bc736d68a23e088358d
4
- data.tar.gz: a3408be015a62fa83b971effc2ace94d6b02b34a26c31b13264fbab59af8f69e
3
+ metadata.gz: 342db9ba03efc1c1dce6d88189c62f4e137155e5495e1ad97d7f88df91bc0542
4
+ data.tar.gz: 6dee74213c99437b972b0267391ecf62561da217e167b07626cb4be9b1ffb254
5
5
  SHA512:
6
- metadata.gz: 6c96743c0f93b769157410d51e0cad83a10bd589bd87bf69da09497e36e9fc3779578dbd4e63024fdf83a7774c06fcda05698e595911edb9e127e5f548f0e0e5
7
- data.tar.gz: 00e42b86e41c16193c84fdda638a6ccea20ecdca4f4af7c583808e9be552189f78b1568ac649294a38e1dca9a6be828cfe2ef4f81b46c03f5365b2ba879c00cc
6
+ metadata.gz: c4cacbfd07becb5aca147a972fa83c840e0e9d9c3db68416b922c7cbfc32e574d9bcb8ef91ebbe46b6be783fd5a2013cf5672c5fd99c95e592b84b54a0c9ba40
7
+ data.tar.gz: 91710c2fc5314a1f332694179ed556e7d834f9f6dfc2fd1e7d8af3776b331d31b3e1f0281f61b7e293c2db8d3c64c30bde1168e582eac53dc96b186bd6bffe6c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [1.0.3] - 2025-03-28
2
+
3
+ * Manual release
4
+
5
+
1
6
  ## [1.0.1] - 2025-03-28
2
7
 
3
8
  * Manual release
data/delete_notebooks.rb CHANGED
@@ -4,17 +4,67 @@
4
4
  require_relative "lib/ruby_todo"
5
5
  require_relative "lib/ruby_todo/database"
6
6
 
7
- # Setup the database connection
7
+ # Ensure database connection is established first
8
8
  RubyTodo::Database.setup
9
9
 
10
- # Count notebooks and tasks before deletion
11
- notebook_count = RubyTodo::Notebook.count
12
- task_count = RubyTodo::Task.count
10
+ def count_records
11
+ {
12
+ tasks: RubyTodo::Task.count,
13
+ notebooks: RubyTodo::Notebook.count,
14
+ templates: RubyTodo::Template.count
15
+ }
16
+ end
13
17
 
14
- # Delete tasks first to avoid foreign key constraint errors
15
- RubyTodo::Task.delete_all
16
- puts "Successfully deleted #{task_count} tasks."
18
+ def print_counts(counts, prefix = "")
19
+ puts "#{prefix}Tasks: #{counts[:tasks]}"
20
+ puts "#{prefix}Notebooks: #{counts[:notebooks]}"
21
+ puts "#{prefix}Templates: #{counts[:templates]}"
22
+ end
17
23
 
18
- # Then delete notebooks
19
- RubyTodo::Notebook.delete_all
20
- puts "Successfully deleted #{notebook_count} notebooks."
24
+ def reset_sqlite_sequences
25
+ connection = ActiveRecord::Base.connection
26
+ connection.tables.each do |table|
27
+ connection.execute("DELETE FROM sqlite_sequence WHERE name='#{table}'")
28
+ puts "Reset sequence counter for table: #{table}"
29
+ end
30
+ end
31
+
32
+ begin
33
+ # Get initial record counts
34
+ initial_counts = count_records
35
+ puts "\nCurrent record counts:"
36
+ print_counts(initial_counts)
37
+
38
+ puts "\nResetting database..."
39
+
40
+ # Drop all tables
41
+ ActiveRecord::Base.connection.tables.each do |table|
42
+ ActiveRecord::Base.connection.drop_table(table)
43
+ puts "Dropped table: #{table}"
44
+ end
45
+
46
+ # Recreate the database schema
47
+ puts "\nRecreating database schema..."
48
+ RubyTodo::Database.setup
49
+
50
+ # Reset sequence counters
51
+ puts "\nResetting sequence counters..."
52
+ reset_sqlite_sequences
53
+
54
+ # Verify the reset
55
+ final_counts = count_records
56
+ puts "\nFinal record counts:"
57
+ print_counts(final_counts)
58
+
59
+ puts "\nDatabase reset complete! All tables and sequence counters have been reset."
60
+ rescue ActiveRecord::ConnectionNotEstablished => e
61
+ puts "\nError: Could not establish database connection"
62
+ puts "Make sure the database directory exists at ~/.ruby_todo/"
63
+ puts "Error details: #{e.message}"
64
+ exit 1
65
+ rescue StandardError => e
66
+ puts "\nAn error occurred while resetting the database:"
67
+ puts e.message
68
+ puts e.backtrace
69
+ exit 1
70
+ end
@@ -10,7 +10,7 @@ module RubyTodo
10
10
  ruby_todo task:list [NOTEBOOK]
11
11
  - Lists all tasks in a notebook or all notebooks if no name provided
12
12
  - To filter by status: ruby_todo task:list [NOTEBOOK] --status STATUS
13
- - Example: ruby_todo task:list protectors --status in_progress
13
+ - Example: ruby_todo task:list ExampleNotebook --status in_progress
14
14
 
15
15
  2. Search tasks:
16
16
  ruby_todo task:search SEARCH_TERM
@@ -147,10 +147,10 @@ module RubyTodo
147
147
  prompt += "\n- To move a task to a status: ruby_todo task:move [NOTEBOOK] [TASK_ID] [STATUS]"
148
148
 
149
149
  prompt += "\n\nExamples of specific requests and corresponding commands:"
150
- prompt += "\n- 'show me all high priority tasks' → ruby_todo task:list protectors --priority high"
151
- prompt += "\n- 'list tasks that are in progress' → ruby_todo task:list protectors --status in_progress"
150
+ prompt += "\n- 'show me all high priority tasks' → ruby_todo task:list ExampleNotebook --priority high"
151
+ prompt += "\n- 'list tasks that are in progress' → ruby_todo task:list ExampleNotebook --status in_progress"
152
152
  prompt += "\n- 'show me all notebooks' → ruby_todo notebook:list"
153
- prompt += "\n- 'move task 5 to done' → ruby_todo task:move protectors 5 done"
153
+ prompt += "\n- 'move task 5 to done' → ruby_todo task:move ExampleNotebook 5 done"
154
154
  prompt
155
155
  end
156
156
 
@@ -178,20 +178,24 @@ module RubyTodo
178
178
  end
179
179
 
180
180
  def build_final_instructions
181
+ # Get the default notebook name
182
+ default_notebook = RubyTodo::Notebook.default_notebook&.name || "YourNotebook"
183
+
181
184
  prompt = "\n\nEven if no tasks match a search or if your request isn't about task movement, "
182
- prompt += "I still need you to return a JSON response with commands and explanation."
185
+ prompt += "I still need you to return a JSON response with commands and explanation. The following examples use the current default notebook '#{default_notebook}'."
183
186
  prompt += "\n\nExample JSON Response:"
184
187
  prompt += "\n```json"
185
188
  prompt += "\n{"
186
189
  prompt += "\n \"commands\": ["
187
- prompt += "\n \"ruby_todo task:list protectors\","
188
- prompt += "\n \"ruby_todo stats protectors\""
190
+ prompt += "\n \"ruby_todo task:list #{default_notebook}\","
191
+ prompt += "\n \"ruby_todo stats #{default_notebook}\""
189
192
  prompt += "\n ],"
190
- prompt += "\n \"explanation\": \"Listing all tasks and statistics for the protectors notebook\""
193
+ prompt += "\n \"explanation\": \"Listing all tasks and statistics for the #{default_notebook} notebook\""
191
194
  prompt += "\n}"
192
195
  prompt += "\n```"
193
196
 
194
197
  prompt += "\n\nNote that all commands use colons, not underscores (e.g., 'task:list', not 'task_list')."
198
+ prompt += "\n\nIf no notebook is specified in the user's request, use the default notebook '#{default_notebook}'."
195
199
  prompt
196
200
  end
197
201
 
@@ -278,14 +278,18 @@ module RubyTodo
278
278
  def move_single_task(task, status)
279
279
  say "\nMoving task #{task[:task_id]} in notebook #{task[:notebook]} to #{status}".blue if options[:verbose]
280
280
 
281
- notebook = RubyTodo::Notebook.find_by(name: task[:notebook])
282
- return say "Notebook '#{task[:notebook]}' not found".red unless notebook
281
+ # Try to find the notebook, first by name, then use default if not found
282
+ notebook = RubyTodo::Notebook.find_by(name: task[:notebook]) || RubyTodo::Notebook.default_notebook
283
+ unless notebook
284
+ say "No notebook found (neither specified nor default)".red
285
+ return
286
+ end
283
287
 
284
288
  task_record = notebook.tasks.find_by(id: task[:task_id])
285
- return say "Task #{task[:task_id]} not found in notebook '#{task[:notebook]}'".red unless task_record
289
+ return say "Task #{task[:task_id]} not found in notebook '#{notebook.name}'".red unless task_record
286
290
 
287
291
  if task_record.update(status: status)
288
- say "Task #{task[:task_id]} moved to #{status}".green
292
+ say "Moved task #{task[:task_id]} to #{status}".green
289
293
  else
290
294
  say "Error moving task #{task[:task_id]}: #{task_record.errors.full_messages.join(", ")}".red
291
295
  end
@@ -224,16 +224,21 @@ module RubyTodo
224
224
  private
225
225
 
226
226
  def find_all_tasks
227
+ # Start with the default notebook if it exists
228
+ notebooks = if RubyTodo::Notebook.default_notebook
229
+ [RubyTodo::Notebook.default_notebook]
230
+ else
231
+ RubyTodo::Notebook.all
232
+ end
233
+
227
234
  tasks = []
228
- RubyTodo::Notebook.all.each do |notebook|
235
+ notebooks.each do |notebook|
229
236
  notebook.tasks.each do |task|
230
237
  tasks << {
238
+ notebook: notebook.name,
231
239
  task_id: task.id,
232
240
  title: task.title,
233
- description: task.description,
234
- status: task.status,
235
- tags: task.tags,
236
- notebook: notebook.name
241
+ status: task.status
237
242
  }
238
243
  end
239
244
  end
@@ -248,9 +253,7 @@ module RubyTodo
248
253
  task_info = {
249
254
  task_id: task.id,
250
255
  title: task.title,
251
- description: task.description,
252
256
  status: task.status,
253
- tags: task.tags,
254
257
  notebook: notebook.name
255
258
  }
256
259
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyTodo
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremiah Parrack