todoro 0.1.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +30 -0
- data/app/assets/stylesheets/todoro/application.css +15 -0
- data/app/controllers/todoro/application_controller.rb +4 -0
- data/app/controllers/todoro/task_lists_controller.rb +61 -0
- data/app/controllers/todoro/tasks_controller.rb +53 -0
- data/app/helpers/todoro/application_helper.rb +4 -0
- data/app/helpers/todoro/task_lists_helper.rb +4 -0
- data/app/helpers/todoro/tasks_helper.rb +4 -0
- data/app/jobs/todoro/application_job.rb +4 -0
- data/app/mailers/todoro/application_mailer.rb +6 -0
- data/app/models/concerns/taskable.rb +21 -0
- data/app/models/todoro/application_record.rb +5 -0
- data/app/models/todoro/reminder.rb +7 -0
- data/app/models/todoro/task.rb +23 -0
- data/app/models/todoro/task_list.rb +8 -0
- data/app/views/layouts/todoro/application.html.erb +17 -0
- data/app/views/todoro/task_lists/_form.html.erb +12 -0
- data/app/views/todoro/task_lists/edit.html.erb +5 -0
- data/app/views/todoro/task_lists/index.html.erb +15 -0
- data/app/views/todoro/task_lists/new.html.erb +5 -0
- data/app/views/todoro/task_lists/show.html.erb +21 -0
- data/app/views/todoro/tasks/_form.html.erb +18 -0
- data/app/views/todoro/tasks/edit.html.erb +5 -0
- data/app/views/todoro/tasks/new.html.erb +5 -0
- data/config/routes.rb +11 -0
- data/db/migrate/20250214104107_create_todoro_task_lists.rb +10 -0
- data/db/migrate/20250214104109_create_todoro_tasks.rb +20 -0
- data/db/migrate/20250214104111_create_todoro_reminders.rb +12 -0
- data/lib/tasks/todoro_tasks.rake +4 -0
- data/lib/todoro/engine.rb +11 -0
- data/lib/todoro/taskable.rb +36 -0
- data/lib/todoro/version.rb +3 -0
- data/lib/todoro.rb +6 -0
- metadata +100 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 78c58e8c3cbbd35a3847423990ebb2842bc6a51288252164b2a17270709bbe94
|
|
4
|
+
data.tar.gz: 8d0c16555e3294e5ba374096d0d06e72ccc240dfd8e395926471861251c01295
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: eb958edea41a965cb244c358959fc7926d2b2a9cbe59714a6518f3d06ccc7dba34a9605ba6ef01d73a5f2aa22849f5b58ef554c31a4f536eb7b7cc6a5b55c425
|
|
7
|
+
data.tar.gz: 5799d3406ca9ddc3c973037bc62964e47439d6e666f46dae99be96dcee50f2c8dde1dfbfc294362690f5fba425d62551751122916095de5ccfb94085d119dd31
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2025 Despo Pentara, Evangelos Giataganas
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Todoro
|
|
2
|
+
A lightweight Rails engine that lets any model manage task lists and tasks with a simple, flexible API.
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
|
|
6
|
+
Include Taskable in the model(s) that can have tasks
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
class Project < ApplicationRecord
|
|
10
|
+
acts_as_taskable
|
|
11
|
+
end
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Now, a Project can have task lists and tasks!
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
project = Project.create(name: "Website Redesign")
|
|
18
|
+
task_list = project.create_task_list("Development Tasks")
|
|
19
|
+
task = project.add_task_to_list(task_list, "Build homepage", "Implement UI components")
|
|
20
|
+
|
|
21
|
+
puts project.tasks # Lists all tasks in all its task lists
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Add to your Gemfile:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
gem "todoro"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
And then execute:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
$ bundle
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or install it yourself as:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
$ gem install todoro
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "bundler/setup"
|
|
2
|
+
|
|
3
|
+
APP_RAKEFILE = File.expand_path("spec/todoapp/Rakefile", __dir__)
|
|
4
|
+
load "rails/tasks/engine.rake"
|
|
5
|
+
|
|
6
|
+
load "rails/tasks/statistics.rake"
|
|
7
|
+
|
|
8
|
+
require "bundler/gem_tasks"
|
|
9
|
+
|
|
10
|
+
require 'rdoc/task'
|
|
11
|
+
|
|
12
|
+
desc 'Generate documentation for Todoro.'
|
|
13
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
14
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
15
|
+
rdoc.title = 'Todoro'
|
|
16
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
|
17
|
+
rdoc.rdoc_files.include('README.md')
|
|
18
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
require 'rspec/core/rake_task'
|
|
22
|
+
|
|
23
|
+
# Define the "spec" task, at task load time rather than inside another task
|
|
24
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
25
|
+
|
|
26
|
+
desc 'Run all tests'
|
|
27
|
+
task all_tests: :environment do
|
|
28
|
+
ENV['RUN_ALL_TESTS'] = 'true'
|
|
29
|
+
Rake::Task['spec'].invoke
|
|
30
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
|
11
|
+
* It is generally better to create a new file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module Todoro
|
|
2
|
+
class TaskListsController < ApplicationController
|
|
3
|
+
before_action :set_task_list, only: %i[show edit update destroy]
|
|
4
|
+
before_action :set_taskable, only: %i[index new create]
|
|
5
|
+
|
|
6
|
+
def index
|
|
7
|
+
@task_lists = @taskable.task_lists
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def show; end
|
|
11
|
+
|
|
12
|
+
def new
|
|
13
|
+
@task_list = @taskable.task_lists.new
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create
|
|
17
|
+
@task_list = @taskable.task_lists.new(task_list_params)
|
|
18
|
+
if @task_list.save
|
|
19
|
+
redirect_to taskable_task_lists_path(taskable: @taskable), notice: "Task list created successfully."
|
|
20
|
+
else
|
|
21
|
+
render :new
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def edit; end
|
|
26
|
+
|
|
27
|
+
def update
|
|
28
|
+
if @task_list.update(task_list_params)
|
|
29
|
+
redirect_to taskable_task_lists_path(taskable: @task_list.taskable), notice: "Task list updated successfully."
|
|
30
|
+
else
|
|
31
|
+
render :edit
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def destroy
|
|
36
|
+
taskable = @task_list.taskable
|
|
37
|
+
@task_list.destroy
|
|
38
|
+
redirect_to taskable_task_lists_path(taskable: taskable), notice: "Task list deleted."
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def set_task_list
|
|
44
|
+
@task_list = TaskList.find(params[:id])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def set_taskable
|
|
48
|
+
@taskable = find_taskable
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def find_taskable
|
|
52
|
+
return unless params[:taskable] && params[:taskable_id]
|
|
53
|
+
|
|
54
|
+
params[:taskable].constantize.find(params[:taskable_id])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def task_list_params
|
|
58
|
+
params.require(:task_list).permit(:name)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Todoro
|
|
2
|
+
class TasksController < ApplicationController
|
|
3
|
+
before_action :set_task_list
|
|
4
|
+
before_action :set_task, only: %i[edit update destroy complete]
|
|
5
|
+
|
|
6
|
+
def new
|
|
7
|
+
@task = @task_list.tasks.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create
|
|
11
|
+
@task = @task_list.tasks.new(task_params)
|
|
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."
|
|
14
|
+
else
|
|
15
|
+
render :new
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def edit; end
|
|
20
|
+
|
|
21
|
+
def update
|
|
22
|
+
if @task.update(task_params)
|
|
23
|
+
redirect_to @task_list, notice: "Task updated successfully."
|
|
24
|
+
else
|
|
25
|
+
render :edit
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def destroy
|
|
30
|
+
@task.destroy
|
|
31
|
+
redirect_to @task_list, notice: "Task deleted."
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def complete
|
|
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."
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def set_task_list
|
|
42
|
+
@task_list = Todoro::TaskList.find(params[:task_list_id])
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def set_task
|
|
46
|
+
@task = @task_list.tasks.find(params[:id])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def task_params
|
|
50
|
+
params.require(:task).permit(:title, :description, :expiry_date, :status)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Todoro
|
|
2
|
+
module Taskable
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
has_many :task_lists, as: :taskable, class_name: "Todoro::TaskList", dependent: :destroy
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def tasks
|
|
10
|
+
Todoro::Task.joins(:task_list).where(task_lists: { taskable_id: id, taskable_type: self.class.name })
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def create_task_list(name)
|
|
14
|
+
task_lists.create(name: name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def add_task_to_list(task_list, title, description, expiry_date = nil)
|
|
18
|
+
task_list.tasks.create(title: title, description: description, expiry_date: expiry_date, status: "pending")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Todoro
|
|
2
|
+
class Task < ApplicationRecord
|
|
3
|
+
belongs_to :task_list
|
|
4
|
+
has_many :reminders, dependent: :destroy
|
|
5
|
+
|
|
6
|
+
validates :title, presence: true
|
|
7
|
+
validates :description, presence: true
|
|
8
|
+
validates :status, presence: true, inclusion: { in: %w[pending completed] }
|
|
9
|
+
|
|
10
|
+
enum :status, { pending: "pending", completed: "completed" }
|
|
11
|
+
|
|
12
|
+
after_create :set_default_reminders
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def set_default_reminders
|
|
17
|
+
return unless expiry_date
|
|
18
|
+
|
|
19
|
+
reminders.create(remind_at: expiry_date - 1.hour)
|
|
20
|
+
reminders.create(remind_at: expiry_date - 1.day)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Todoro</title>
|
|
5
|
+
<%= csrf_meta_tags %>
|
|
6
|
+
<%= csp_meta_tag %>
|
|
7
|
+
|
|
8
|
+
<%= yield :head %>
|
|
9
|
+
|
|
10
|
+
<%= stylesheet_link_tag "todoro/application", media: "all" %>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
|
|
14
|
+
<%= yield %>
|
|
15
|
+
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<%= form_with model: [taskable, task_list], local: true do |form| %>
|
|
2
|
+
<div class="form-group">
|
|
3
|
+
<%= form.label :name %>
|
|
4
|
+
<%= form.text_field :name, class: "form-control", required: true %>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<%= form.hidden_field :taskable_id, value: taskable.id %>
|
|
8
|
+
<%= form.hidden_field :taskable_type, value: taskable.class.name %>
|
|
9
|
+
|
|
10
|
+
<%= form.submit class: "btn btn-success" %>
|
|
11
|
+
<% end %>
|
|
12
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<h1>Task Lists for <%= @taskable.class.name %>: <%= @taskable.try(:name) || "Unknown" %></h1>
|
|
2
|
+
|
|
3
|
+
<%= link_to "Create New Task List", new_taskable_task_list_path(taskable: @taskable.class.name, taskable_id: @taskable.id), class: "btn btn-primary" %>
|
|
4
|
+
|
|
5
|
+
<ul>
|
|
6
|
+
<% @task_lists.each do |task_list| %>
|
|
7
|
+
<li>
|
|
8
|
+
<%= link_to task_list.name, taskable_task_list_path(taskable: @taskable.class.name, taskable_id: @taskable.id, id: task_list.id) %>
|
|
9
|
+
(<%= link_to "Edit", edit_taskable_task_list_path(taskable: @taskable.class.name, taskable_id: @taskable.id, id: task_list.id) %> |
|
|
10
|
+
<%= link_to "Delete", taskable_task_list_path(taskable: @taskable.class.name, taskable_id: @taskable.id, id: task_list.id), method: :delete, data: { confirm: "Are you sure?" } %>)
|
|
11
|
+
</li>
|
|
12
|
+
<% end %>
|
|
13
|
+
</ul>
|
|
14
|
+
|
|
15
|
+
<%= link_to "Back", root_path, class: "btn btn-secondary" %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<h1><%= @task_list.name %></h1>
|
|
2
|
+
|
|
3
|
+
<%= link_to "Edit", edit_taskable_task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), class: "btn btn-warning" %>
|
|
4
|
+
<%= link_to "Delete", taskable_task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger" %>
|
|
5
|
+
|
|
6
|
+
<h2>Tasks</h2>
|
|
7
|
+
<%= link_to "Add Task", new_taskable_task_list_task_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, task_list_id: @task_list.id), class: "btn btn-primary" %>
|
|
8
|
+
|
|
9
|
+
<ul>
|
|
10
|
+
<% @task_list.tasks.each do |task| %>
|
|
11
|
+
<li>
|
|
12
|
+
<%= task.title %> - <%= task.status %>
|
|
13
|
+
(<%= link_to "Edit", edit_taskable_task_list_task_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, task_list_id: @task_list.id, id: task.id) %> |
|
|
14
|
+
<%= link_to "Complete", complete_taskable_task_list_task_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, task_list_id: @task_list.id, id: task.id), method: :patch if task.status == "pending" %> |
|
|
15
|
+
<%= link_to "Delete", taskable_task_list_task_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, task_list_id: @task_list.id, id: task.id), method: :delete, data: { confirm: "Are you sure?" } %>)
|
|
16
|
+
</li>
|
|
17
|
+
<% end %>
|
|
18
|
+
</ul>
|
|
19
|
+
|
|
20
|
+
<%= link_to "Back to Task Lists", taskable_task_lists_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id), class: "btn btn-secondary" %>
|
|
21
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%= form_with model: [task.task_list, task], local: true do |form| %>
|
|
2
|
+
<div class="form-group">
|
|
3
|
+
<%= form.label :title %>
|
|
4
|
+
<%= form.text_field :title, class: "form-control", required: true %>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="form-group">
|
|
8
|
+
<%= form.label :description %>
|
|
9
|
+
<%= form.text_area :description, class: "form-control", required: true %>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div class="form-group">
|
|
13
|
+
<%= form.label :expiry_date %>
|
|
14
|
+
<%= form.datetime_select :expiry_date, class: "form-control" %>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<%= form.submit class: "btn btn-success" %>
|
|
18
|
+
<% end %>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class CreateTodoroTasks < ActiveRecord::Migration[8.0]
|
|
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[8.0]
|
|
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,36 @@
|
|
|
1
|
+
module Todoro
|
|
2
|
+
module Taskable
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
has_many :task_lists, as: :taskable, class_name: "Todoro::TaskList", dependent: :destroy
|
|
7
|
+
has_many :tasks, through: :task_lists, class_name: "Todoro::Task"
|
|
8
|
+
|
|
9
|
+
after_initialize :ensure_taskable_registered
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class_methods do
|
|
13
|
+
def acts_as_taskable
|
|
14
|
+
include Todoro::Taskable
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create_task_list(name)
|
|
19
|
+
task_lists.create(name: name)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add_task_to_list(task_list, title, description, expiry_date = nil)
|
|
23
|
+
task_list.tasks.create(title: title, description: description, expiry_date: expiry_date, status: "pending")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def ensure_taskable_registered
|
|
29
|
+
# Placeholder for additional logic if needed in future (like logging)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
ActiveSupport.on_load(:active_record) do
|
|
35
|
+
extend Todoro::Taskable::ClassMethods
|
|
36
|
+
end
|
data/lib/todoro.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: todoro
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Despo Pentara
|
|
8
|
+
- Evangelos Giataganas
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-02-14 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 8.0.1
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 8.0.1
|
|
27
|
+
description: A lightweight Rails engine that lets any model manage task lists and
|
|
28
|
+
tasks with a simple, flexible API.
|
|
29
|
+
email:
|
|
30
|
+
- despo@shift42.io
|
|
31
|
+
- evangelos@shift42.io
|
|
32
|
+
executables: []
|
|
33
|
+
extensions: []
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- MIT-LICENSE
|
|
37
|
+
- README.md
|
|
38
|
+
- Rakefile
|
|
39
|
+
- app/assets/stylesheets/todoro/application.css
|
|
40
|
+
- app/controllers/todoro/application_controller.rb
|
|
41
|
+
- app/controllers/todoro/task_lists_controller.rb
|
|
42
|
+
- app/controllers/todoro/tasks_controller.rb
|
|
43
|
+
- app/helpers/todoro/application_helper.rb
|
|
44
|
+
- app/helpers/todoro/task_lists_helper.rb
|
|
45
|
+
- app/helpers/todoro/tasks_helper.rb
|
|
46
|
+
- app/jobs/todoro/application_job.rb
|
|
47
|
+
- app/mailers/todoro/application_mailer.rb
|
|
48
|
+
- app/models/concerns/taskable.rb
|
|
49
|
+
- app/models/todoro/application_record.rb
|
|
50
|
+
- app/models/todoro/reminder.rb
|
|
51
|
+
- app/models/todoro/task.rb
|
|
52
|
+
- app/models/todoro/task_list.rb
|
|
53
|
+
- app/views/layouts/todoro/application.html.erb
|
|
54
|
+
- app/views/todoro/task_lists/_form.html.erb
|
|
55
|
+
- app/views/todoro/task_lists/edit.html.erb
|
|
56
|
+
- app/views/todoro/task_lists/index.html.erb
|
|
57
|
+
- app/views/todoro/task_lists/new.html.erb
|
|
58
|
+
- app/views/todoro/task_lists/show.html.erb
|
|
59
|
+
- app/views/todoro/tasks/_form.html.erb
|
|
60
|
+
- app/views/todoro/tasks/edit.html.erb
|
|
61
|
+
- app/views/todoro/tasks/new.html.erb
|
|
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
|
+
- lib/tasks/todoro_tasks.rake
|
|
67
|
+
- lib/todoro.rb
|
|
68
|
+
- lib/todoro/engine.rb
|
|
69
|
+
- lib/todoro/taskable.rb
|
|
70
|
+
- lib/todoro/version.rb
|
|
71
|
+
homepage: https://github.com/shift42/todoro
|
|
72
|
+
licenses:
|
|
73
|
+
- MIT
|
|
74
|
+
metadata:
|
|
75
|
+
homepage_uri: https://github.com/shift42/todoro
|
|
76
|
+
documentation_uri: https://rubydoc.info/github/shift42/todoro
|
|
77
|
+
changelog_uri: https://github.com/shift42/todoro/blob/main/CHANGELOG.md
|
|
78
|
+
source_code_uri: https://github.com/shift42/todoro
|
|
79
|
+
bug_tracker_uri: https://github.com/shift42/todoro/issues
|
|
80
|
+
wiki_uri: https://github.com/shift42/todoro/wiki
|
|
81
|
+
rdoc_options: []
|
|
82
|
+
require_paths:
|
|
83
|
+
- lib
|
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: 2.7.0
|
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
requirements: []
|
|
95
|
+
rubygems_version: 3.6.1
|
|
96
|
+
specification_version: 4
|
|
97
|
+
summary: Todoro is a lightweight Rails engine that makes it easy to add task lists
|
|
98
|
+
and tasks to any model. It integrates seamlessly into any Rails app, offering a
|
|
99
|
+
simple and flexible way to organize and track tasks.
|
|
100
|
+
test_files: []
|