todoro 0.1.3 → 0.1.4

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: a9df4d399bddcdec90b476afd3f277a388c9ed04a60c3388cbd339f33f9bc78a
4
- data.tar.gz: 4d56a850c3674c38e6abeaae287afe234f6a6fee73edb09722b8d066f3a61095
3
+ metadata.gz: 1e52adb97a2a743b91e09a3b654b3ac9d7782298c6ee3b933bad51d1a2a94caf
4
+ data.tar.gz: d8b17e1c03b70d67aec43528fe6b8acec2e9519e6ad0c2797f48af22012b5147
5
5
  SHA512:
6
- metadata.gz: 4b9fd5d72efb5b3a6bb3b8b5c1b024405ab5f43b9f626607ce6ea2b740f8498abe14d045cd0c3d31256132ff80ab042664209985f48b02b72dbd07f0479f9890
7
- data.tar.gz: c2d103b2d0b301652b364ceeecc0e65e057e6431c79386a52e54a8ba26d841988394683337ee09d4f9c8ee8c4395edbc70152f7597427fc2ca0e432695a8abe0
6
+ metadata.gz: 4638b8767f43a852653c6f68ef6ae718fc70a1281f39d09d32554facf1038d4507e11f46669de3b39d4345153876a6dad15aa1d74a120021a2f4416cd64f25e1
7
+ data.tar.gz: 0b5232015299955bf5f2825bcbe540fcad438f75d1346fa7c3758d23978f6f0d80c46ebe2cfc473101a743861e76fc3030b7b77021b400a4b5d2c6d885302ccb
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
+ To enhance the **Todoro** gem's documentation, here's an updated version of the `README.md` file that includes instructions on mounting the engine and customizing the mount path:
2
+
3
+ ```markdown
1
4
  # Todoro
5
+
2
6
  A lightweight Rails engine that lets any model manage task lists and tasks with a simple, flexible API.
3
7
 
4
8
  ![Totoro](totoro.png)
@@ -13,25 +17,26 @@ gem "todoro"
13
17
 
14
18
  And then execute:
15
19
 
16
- ```bash
17
- $ bundle
20
+ ```sh
21
+ $ bundle install
18
22
  ```
19
23
 
20
24
  Or install it yourself as:
21
25
 
22
- ```bash
26
+ ```sh
23
27
  $ gem install todoro
24
28
  ```
25
29
 
26
30
  ## Usage
27
31
 
28
- Generate the required migrations
32
+ Generate the required migrations:
29
33
 
30
- ```ruby
31
- rails generate todoro:install
34
+ ```sh
35
+ $ rails generate todoro:install
36
+ $ rails db:migrate
32
37
  ```
33
38
 
34
- Include Taskable in the model(s) that can have tasks
39
+ Include `acts_as_taskable` in the model(s) that can have tasks:
35
40
 
36
41
  ```ruby
37
42
  class Project < ApplicationRecord
@@ -39,9 +44,9 @@ class Project < ApplicationRecord
39
44
  end
40
45
  ```
41
46
 
42
- Now, a Project can have task lists and tasks!
47
+ Now, a `Project` can have task lists and tasks:
43
48
 
44
- ```bash
49
+ ```ruby
45
50
  project = Project.create(name: "Website Redesign")
46
51
  task_list = project.create_task_list("Development Tasks")
47
52
  task = project.add_task_to_list(task_list, "Build homepage", "Implement UI components")
@@ -49,6 +54,38 @@ task = project.add_task_to_list(task_list, "Build homepage", "Implement UI compo
49
54
  puts project.tasks # Lists all tasks in all its task lists
50
55
  ```
51
56
 
57
+ ## Mounting the Engine
58
+
59
+ To access Todoro's routes, mount the engine in your application's routes file:
60
+
61
+ ```ruby
62
+ # config/routes.rb
63
+ Rails.application.routes.draw do
64
+ mount Todoro::Engine, at: '/todoro'
65
+ # Other routes...
66
+ end
67
+ ```
68
+
69
+ This makes Todoro's features accessible under the `/todoro` path (e.g., `http://yourdomain.com/todoro`).
70
+
71
+ ### Customizing the Mount Path
72
+
73
+ You can mount Todoro at any path that fits your application's structure:
74
+
75
+ - To mount at the root:
76
+
77
+ ```ruby
78
+ Rails.application.routes.draw do
79
+ mount Todoro::Engine, at: '/'
80
+ # Other routes...
81
+ end
82
+ ```
83
+
84
+ Now, Todoro's routes are available at the root URL (e.g., `http://yourdomain.com/`).
85
+
52
86
 
53
87
  ## License
54
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88
+
89
+ The gem is available as open source under the terms of the [MIT License](MIT-LICENSE).
90
+
91
+ ```
@@ -16,7 +16,7 @@ module Todoro
16
16
  def create
17
17
  @task_list = @taskable.task_lists.new(task_list_params)
18
18
  if @task_list.save
19
- redirect_to taskable_task_lists_path(taskable: @taskable), notice: "Task list created successfully."
19
+ redirect_to task_lists_path(taskable: @taskable), notice: "Task list created successfully."
20
20
  else
21
21
  render :new
22
22
  end
@@ -26,7 +26,7 @@ module Todoro
26
26
 
27
27
  def update
28
28
  if @task_list.update(task_list_params)
29
- redirect_to taskable_task_lists_path(taskable: @task_list.taskable), notice: "Task list updated successfully."
29
+ redirect_to task_lists_path(taskable: @task_list.taskable), notice: "Task list updated successfully."
30
30
  else
31
31
  render :edit
32
32
  end
@@ -35,7 +35,7 @@ module Todoro
35
35
  def destroy
36
36
  taskable = @task_list.taskable
37
37
  @task_list.destroy
38
- redirect_to taskable_task_lists_path(taskable: taskable), notice: "Task list deleted."
38
+ redirect_to task_lists_path(taskable: taskable), notice: "Task list deleted."
39
39
  end
40
40
 
41
41
  private
@@ -10,7 +10,7 @@ module Todoro
10
10
  def create
11
11
  @task = @task_list.tasks.new(task_params)
12
12
  if @task.save
13
- redirect_to todoro.taskable_task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task created successfully."
13
+ redirect_to task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task created successfully."
14
14
  else
15
15
  render :new
16
16
  end
@@ -33,7 +33,7 @@ module Todoro
33
33
 
34
34
  def complete
35
35
  @task.update(status: "completed")
36
- redirect_to todoro.taskable_task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task marked as completed."
36
+ redirect_to task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task marked as completed."
37
37
  end
38
38
 
39
39
  private
data/config/routes.rb CHANGED
@@ -1,10 +1,8 @@
1
1
  Todoro::Engine.routes.draw do
2
- resources :taskables, only: [] do
3
- resources :task_lists do
4
- resources :tasks do
5
- member do
6
- patch :complete
7
- end
2
+ resources :task_lists do
3
+ resources :tasks do
4
+ member do
5
+ patch :complete
8
6
  end
9
7
  end
10
8
  end
@@ -0,0 +1,10 @@
1
+ class CreateTodoroTaskLists < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
+ def change
3
+ create_table :todoro_task_lists do |t|
4
+ t.string :name, null: false
5
+ t.references :taskable, polymorphic: true, null: false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ class CreateTodoroTasks < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
+ def change
3
+ create_table :todoro_tasks do |t|
4
+ t.string :title
5
+ t.text :description, null: false # Description is required
6
+ t.datetime :expiry_date
7
+ t.string :status, null: false, default: "pending" # Status is required
8
+ t.references :task_list, null: false, foreign_key: { to_table: :todoro_task_lists }
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ # Enforce status constraint
14
+ execute <<-SQL
15
+ ALTER TABLE todoro_tasks
16
+ ADD CONSTRAINT status_check
17
+ CHECK (status IN ('pending', 'completed'));
18
+ SQL
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ class CreateTodoroReminders < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
+ def change
3
+ create_table :todoro_reminders do |t|
4
+ t.references :task, null: false, foreign_key: { to_table: :todoro_tasks }
5
+ t.datetime :remind_at, null: false # Enforce remind_at is mandatory
6
+
7
+
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class AddIndexesToTodoroTasks < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
+ def change
3
+ add_index :todoro_task_lists, [ :taskable_type, :taskable_id ]
4
+ add_index :todoro_tasks, :status
5
+ add_index :todoro_tasks, :expiry_date
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Todoro
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Despo Pentara
@@ -60,6 +60,10 @@ files:
60
60
  - app/views/todoro/tasks/edit.html.erb
61
61
  - app/views/todoro/tasks/new.html.erb
62
62
  - config/routes.rb
63
+ - db/migrate/20250215225042_create_todoro_task_lists.rb
64
+ - db/migrate/20250215225043_create_todoro_tasks.rb
65
+ - db/migrate/20250215225044_create_todoro_reminders.rb
66
+ - db/migrate/20250215225045_add_indexes_to_todoro_tasks.rb
63
67
  - lib/generators/todoro/install_generator.rb
64
68
  - lib/generators/todoro/templates/add_indexes_to_todoro_tasks.rb
65
69
  - lib/generators/todoro/templates/create_todoro_reminders.rb