todoro 0.1.2 → 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: 3484fe0d4b42818d6da75b14b1338263923ba16af50f7e004604f456a9793f89
4
- data.tar.gz: db0eb21bd21af52c31e146e1500990b6621bef2989d311f367c14d9b4cb83fac
3
+ metadata.gz: 1e52adb97a2a743b91e09a3b654b3ac9d7782298c6ee3b933bad51d1a2a94caf
4
+ data.tar.gz: d8b17e1c03b70d67aec43528fe6b8acec2e9519e6ad0c2797f48af22012b5147
5
5
  SHA512:
6
- metadata.gz: 7bbcbdd4e9b607f5e1dadaa596e5ce1b712269762c481826823b46c564516e43eceaca8de23c186c3a28036b975966e79157df31c7550c47ac1a21de35c620a9
7
- data.tar.gz: eacfe1c557993e63efac5e8161cc8517b511627fbb2236fea10e7b7cf4e6c664bc4de12d907b9e7580be9931ca400c5adb7b0b322b58f1ab38e706b3488c53b5
6
+ metadata.gz: 4638b8767f43a852653c6f68ef6ae718fc70a1281f39d09d32554facf1038d4507e11f46669de3b39d4345153876a6dad15aa1d74a120021a2f4416cd64f25e1
7
+ data.tar.gz: 0b5232015299955bf5f2825bcbe540fcad438f75d1346fa7c3758d23978f6f0d80c46ebe2cfc473101a743861e76fc3030b7b77021b400a4b5d2c6d885302ccb
data/README.md CHANGED
@@ -1,11 +1,42 @@
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)
5
9
 
10
+ ## Installation
11
+
12
+ Add to your Gemfile:
13
+
14
+ ```ruby
15
+ gem "todoro"
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ ```sh
21
+ $ bundle install
22
+ ```
23
+
24
+ Or install it yourself as:
25
+
26
+ ```sh
27
+ $ gem install todoro
28
+ ```
29
+
6
30
  ## Usage
7
31
 
8
- Include Taskable in the model(s) that can have tasks
32
+ Generate the required migrations:
33
+
34
+ ```sh
35
+ $ rails generate todoro:install
36
+ $ rails db:migrate
37
+ ```
38
+
39
+ Include `acts_as_taskable` in the model(s) that can have tasks:
9
40
 
10
41
  ```ruby
11
42
  class Project < ApplicationRecord
@@ -13,9 +44,9 @@ class Project < ApplicationRecord
13
44
  end
14
45
  ```
15
46
 
16
- Now, a Project can have task lists and tasks!
47
+ Now, a `Project` can have task lists and tasks:
17
48
 
18
- ```bash
49
+ ```ruby
19
50
  project = Project.create(name: "Website Redesign")
20
51
  task_list = project.create_task_list("Development Tasks")
21
52
  task = project.add_task_to_list(task_list, "Build homepage", "Implement UI components")
@@ -23,25 +54,38 @@ task = project.add_task_to_list(task_list, "Build homepage", "Implement UI compo
23
54
  puts project.tasks # Lists all tasks in all its task lists
24
55
  ```
25
56
 
26
- ## Installation
57
+ ## Mounting the Engine
27
58
 
28
- Add to your Gemfile:
59
+ To access Todoro's routes, mount the engine in your application's routes file:
29
60
 
30
61
  ```ruby
31
- gem "todoro"
62
+ # config/routes.rb
63
+ Rails.application.routes.draw do
64
+ mount Todoro::Engine, at: '/todoro'
65
+ # Other routes...
66
+ end
32
67
  ```
33
68
 
34
- And then execute:
69
+ This makes Todoro's features accessible under the `/todoro` path (e.g., `http://yourdomain.com/todoro`).
35
70
 
36
- ```bash
37
- $ bundle
38
- ```
71
+ ### Customizing the Mount Path
39
72
 
40
- Or install it yourself as:
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/`).
41
85
 
42
- ```bash
43
- $ gem install todoro
44
- ```
45
86
 
46
87
  ## License
47
- 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
@@ -1,4 +1,4 @@
1
- class CreateTodoroTaskLists < ActiveRecord::Migration[8.0]
1
+ class CreateTodoroTaskLists < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
2
  def change
3
3
  create_table :todoro_task_lists do |t|
4
4
  t.string :name, null: false
@@ -1,4 +1,4 @@
1
- class CreateTodoroTasks < ActiveRecord::Migration[8.0]
1
+ class CreateTodoroTasks < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
2
  def change
3
3
  create_table :todoro_tasks do |t|
4
4
  t.string :title
@@ -1,4 +1,4 @@
1
- class CreateTodoroReminders < ActiveRecord::Migration[8.0]
1
+ class CreateTodoroReminders < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
2
  def change
3
3
  create_table :todoro_reminders do |t|
4
4
  t.references :task, null: false, foreign_key: { to_table: :todoro_tasks }
@@ -1,4 +1,4 @@
1
- class AddIndexesToTodoroTasks < ActiveRecord::Migration[8.0]
1
+ class AddIndexesToTodoroTasks < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
2
  def change
3
3
  add_index :todoro_task_lists, [ :taskable_type, :taskable_id ]
4
4
  add_index :todoro_tasks, :status
@@ -0,0 +1,22 @@
1
+ require "rails/generators"
2
+ require "rails/generators/active_record"
3
+
4
+ module Todoro
5
+ module Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def create_migrations
11
+ migration_template "create_todoro_task_lists.rb", "db/migrate/create_todoro_task_lists.rb"
12
+ migration_template "create_todoro_tasks.rb", "db/migrate/create_todoro_tasks.rb"
13
+ migration_template "create_todoro_reminders.rb", "db/migrate/create_todoro_reminders.rb"
14
+ migration_template "add_indexes_to_todoro_tasks.rb", "db/migrate/add_indexes_to_todoro_tasks.rb"
15
+ end
16
+
17
+ def self.next_migration_number(dirname)
18
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
19
+ end
20
+ end
21
+ end
22
+ 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
@@ -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,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
@@ -1,3 +1,3 @@
1
1
  module Todoro
2
- VERSION = "0.1.2"
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.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Despo Pentara
@@ -60,10 +60,15 @@ 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/20250214104107_create_todoro_task_lists.rb
64
- - db/migrate/20250214104109_create_todoro_tasks.rb
65
- - db/migrate/20250214104111_create_todoro_reminders.rb
66
- - db/migrate/20250215024110_add_indexes_to_todoro_tasks.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
67
+ - lib/generators/todoro/install_generator.rb
68
+ - lib/generators/todoro/templates/add_indexes_to_todoro_tasks.rb
69
+ - lib/generators/todoro/templates/create_todoro_reminders.rb
70
+ - lib/generators/todoro/templates/create_todoro_task_lists.rb
71
+ - lib/generators/todoro/templates/create_todoro_tasks.rb
67
72
  - lib/tasks/todoro_tasks.rake
68
73
  - lib/todoro.rb
69
74
  - lib/todoro/engine.rb