thingamajig 0.1.0 → 0.1.1
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 +5 -5
- data/README.md +13 -0
- data/lib/thingamajig/area.rb +2 -30
- data/lib/thingamajig/list.rb +50 -0
- data/lib/thingamajig/modules/container.rb +62 -0
- data/lib/thingamajig/project.rb +6 -11
- data/lib/thingamajig/todo.rb +36 -1
- data/lib/thingamajig/version.rb +1 -1
- data/lib/thingamajig.rb +11 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7a05d7b894dc4289c7b38a376b145b2935617697c5f3d7f0242b133604dbd90
|
4
|
+
data.tar.gz: 576194daa2c5e3b431ae642e8a1eb68f483c39d06025d3232fa142d977802c31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36f28972b740fe22abac00189f7a6d9918d64f60bd64104bc916fd2b500e55b6a15109bca18e38cfa35619c369193ea51bd084e024768ececc73f32010dcf124
|
7
|
+
data.tar.gz: fc8a87b362eea6ac557d8977de079243c8e56b36584d4cdf605c2eb3edd908e5c4234e05d74e0f4fa4d23f6e894d252f4781afba3fb29895446e72b79404fc10
|
data/README.md
CHANGED
@@ -46,6 +46,8 @@ This README is severaly lacking in instructions. Here's some sample code that mi
|
|
46
46
|
end
|
47
47
|
```
|
48
48
|
|
49
|
+
### Naming
|
50
|
+
|
49
51
|
If you're tired of typing "Thingamajig" out in full, feel free to alias it:
|
50
52
|
|
51
53
|
```ruby
|
@@ -70,6 +72,17 @@ Or install it yourself as:
|
|
70
72
|
|
71
73
|
$ gem install thingamajig
|
72
74
|
|
75
|
+
## Example Usage
|
76
|
+
|
77
|
+
I use Thingamajig extensively in my personal automated workflows. You can find the source code here: https://github.com/dv/dotworkflows
|
78
|
+
|
79
|
+
## Research
|
80
|
+
|
81
|
+
A lot of this was done through trial-and-error. Helpful resources:
|
82
|
+
|
83
|
+
- [The official documentation by Cultured Code](https://culturedcode.com/things/download/Things3AppleScriptGuide.pdf) (beware, it's full of mistakes).
|
84
|
+
- Example of connecting to the underlying SQLite3 database: https://github.com/lucbeaulieu/KanbanView
|
85
|
+
|
73
86
|
## Development
|
74
87
|
|
75
88
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/thingamajig/area.rb
CHANGED
@@ -1,41 +1,13 @@
|
|
1
1
|
class Thingamajig
|
2
2
|
class Area < OsaObject
|
3
|
+
include Container
|
4
|
+
|
3
5
|
def self.find_by(name:)
|
4
6
|
Thingamajig::Area.new(Thingamajig.new.osa_object.areas[name])
|
5
7
|
end
|
6
8
|
|
7
|
-
# an Area's To Do list actually contains Projects & Todos, that's
|
8
|
-
# why we need some extra filtering
|
9
|
-
def todos(filter = nil)
|
10
|
-
query = todos_query
|
11
|
-
query = query.and(filter) if filter
|
12
|
-
|
13
|
-
osa_object.to_dos[query].get.map do |osa_todo|
|
14
|
-
Thingamajig::Todo.new osa_todo
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def projects(filter = nil)
|
19
|
-
query = projects_query
|
20
|
-
query = query.and(filter) if filter
|
21
|
-
|
22
|
-
osa_object.to_dos[query].get.map do |osa_project|
|
23
|
-
Thingamajig::Project.new osa_project
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
9
|
def inspect
|
28
10
|
"#<Thingamajig::Area '#{name}'>"
|
29
11
|
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def projects_query
|
34
|
-
Appscript.its.class_.eq(:project)
|
35
|
-
end
|
36
|
-
|
37
|
-
def todos_query
|
38
|
-
Appscript.its.class_.ne(:project)
|
39
|
-
end
|
40
12
|
end
|
41
13
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Thingamajig
|
2
|
+
class List < OsaObject
|
3
|
+
include Container
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def find_by(name:)
|
7
|
+
Thingamajig::List.new(Thingamajig.new.osa_object.lists[name])
|
8
|
+
end
|
9
|
+
|
10
|
+
def inbox
|
11
|
+
find_by(name: "Inbox")
|
12
|
+
end
|
13
|
+
|
14
|
+
def today
|
15
|
+
find_by(name: "Today")
|
16
|
+
end
|
17
|
+
|
18
|
+
def anytime
|
19
|
+
find_by(name: "Anytime")
|
20
|
+
end
|
21
|
+
|
22
|
+
def upcoming
|
23
|
+
find_by(name: "Upcoming")
|
24
|
+
end
|
25
|
+
|
26
|
+
def someday
|
27
|
+
find_by(name: "Someday")
|
28
|
+
end
|
29
|
+
|
30
|
+
def logbook
|
31
|
+
find_by(name: "Logbook")
|
32
|
+
end
|
33
|
+
|
34
|
+
def trash
|
35
|
+
find_by(name: "Trash")
|
36
|
+
end
|
37
|
+
|
38
|
+
# Projects scheduled for the future, not in an area ("later projects") in sidebar
|
39
|
+
def later_projects
|
40
|
+
Thingamajig::List.new(Thingamajig.new.osa_object.lists.ID("THMLonelyLaterProjectsListSource"))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def inspect
|
45
|
+
"#<Thingamajig::List '#{name}'>"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Thingamajig::Container
|
2
|
+
# Some containers have todos and projects in one list
|
3
|
+
def items(filter = nil)
|
4
|
+
result_reference =
|
5
|
+
if filter
|
6
|
+
osa_object.to_dos[filter]
|
7
|
+
else
|
8
|
+
osa_object.to_dos
|
9
|
+
end
|
10
|
+
|
11
|
+
results = result_reference.get
|
12
|
+
|
13
|
+
wrap_collection(results)
|
14
|
+
end
|
15
|
+
|
16
|
+
def todos(filter = nil)
|
17
|
+
query = todos_query
|
18
|
+
query = query.and(filter) if filter
|
19
|
+
|
20
|
+
items(query)
|
21
|
+
end
|
22
|
+
|
23
|
+
def projects(filter = nil)
|
24
|
+
query = projects_query
|
25
|
+
query = query.and(filter) if filter
|
26
|
+
|
27
|
+
items(query)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def wrap_item(item)
|
33
|
+
item_class = item.class_.get
|
34
|
+
|
35
|
+
case item_class
|
36
|
+
when :to_do, :selected_to_do
|
37
|
+
Thingamajig::Todo.new(item)
|
38
|
+
when :project
|
39
|
+
Thingamajig::Project.new(item)
|
40
|
+
when :area
|
41
|
+
Thingamajig::Area.new(item)
|
42
|
+
when :list
|
43
|
+
Thingamajig::List.new(item)
|
44
|
+
else
|
45
|
+
raise "Don't know what #{item_class} is."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def wrap_collection(collection)
|
50
|
+
collection.map do |item|
|
51
|
+
wrap_item(item)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def projects_query
|
56
|
+
Appscript.its.class_.eq(:project)
|
57
|
+
end
|
58
|
+
|
59
|
+
def todos_query
|
60
|
+
Appscript.its.class_.ne(:project)
|
61
|
+
end
|
62
|
+
end
|
data/lib/thingamajig/project.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
class Thingamajig
|
2
|
-
class Project <
|
2
|
+
class Project < Todo
|
3
|
+
include Container
|
4
|
+
|
3
5
|
def self.find_by(name:)
|
4
6
|
Thingamajig::Project.new(Thingamajig.new.osa_object.projects[name])
|
5
7
|
end
|
6
8
|
|
7
|
-
def todos(filter = nil)
|
8
|
-
osa_todos = osa_object.to_dos
|
9
|
-
osa_todos = osa_todos[filter] if filter
|
10
|
-
|
11
|
-
osa_todos.get.map do |osa_todo|
|
12
|
-
Thingamajig::Todo.new osa_todo
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
9
|
def create_todo!(name, notes)
|
17
|
-
|
10
|
+
new_osa_object = osa_object.make(new: :to_do, with_properties: {name: name, notes: notes})
|
11
|
+
|
12
|
+
Thingamajig::Todo.new(new_osa_object)
|
18
13
|
end
|
19
14
|
|
20
15
|
def inspect
|
data/lib/thingamajig/todo.rb
CHANGED
@@ -20,12 +20,47 @@ class Thingamajig
|
|
20
20
|
activation_date && activation_date <= Date.today.to_time
|
21
21
|
end
|
22
22
|
|
23
|
+
# Use `activate!` to move to Today with today's date as the activation
|
24
|
+
# date. This moving to Today list means it will also pop up at the top
|
25
|
+
# of the Today list in the UI.
|
26
|
+
#
|
27
|
+
# This is different from using the `schedule` command which retains the
|
28
|
+
# position in Today list from earlier.
|
29
|
+
def activate!
|
30
|
+
osa_object.move(to: Thingamajig::List.today.osa_object)
|
31
|
+
end
|
32
|
+
|
33
|
+
def deactivate!
|
34
|
+
osa_object.move(to: Thingamajig::List.anytime.osa_object)
|
35
|
+
end
|
36
|
+
|
23
37
|
def activation_date=(new_activation_date)
|
24
38
|
if completed? || canceled?
|
25
39
|
self.completion_date = nil
|
26
40
|
end
|
27
41
|
|
28
|
-
|
42
|
+
if new_activation_date.present?
|
43
|
+
osa_object.schedule(for: new_activation_date)
|
44
|
+
else
|
45
|
+
deactivate!
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Adds a todo to the bottom of the project
|
50
|
+
def project=(new_project)
|
51
|
+
if new_project
|
52
|
+
super(new_project.osa_object)
|
53
|
+
else
|
54
|
+
osa_object.project.delete
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def area=(new_area)
|
59
|
+
if new_area
|
60
|
+
super(new_area.osa_object)
|
61
|
+
else
|
62
|
+
osa_object.area.delete
|
63
|
+
end
|
29
64
|
end
|
30
65
|
|
31
66
|
def inspect
|
data/lib/thingamajig/version.rb
CHANGED
data/lib/thingamajig.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
require "rb-scpt"
|
2
2
|
require "thingamajig/version"
|
3
3
|
require "thingamajig/osa_object"
|
4
|
+
require "thingamajig/modules/container"
|
5
|
+
|
4
6
|
require "thingamajig/area"
|
5
|
-
require "thingamajig/
|
7
|
+
require "thingamajig/list"
|
6
8
|
require "thingamajig/todo"
|
9
|
+
require "thingamajig/project"
|
10
|
+
|
7
11
|
|
8
12
|
class Thingamajig
|
9
13
|
attr :app
|
@@ -21,4 +25,10 @@ class Thingamajig
|
|
21
25
|
Thingamajig::Project.new(osa_project)
|
22
26
|
end
|
23
27
|
end
|
28
|
+
|
29
|
+
def todos
|
30
|
+
app.to_dos.get.map do |osa_todo|
|
31
|
+
Thingamajig::Todo.new(osa_todo)
|
32
|
+
end
|
33
|
+
end
|
24
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thingamajig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Verhasselt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,8 @@ files:
|
|
71
71
|
- bin/setup
|
72
72
|
- lib/thingamajig.rb
|
73
73
|
- lib/thingamajig/area.rb
|
74
|
+
- lib/thingamajig/list.rb
|
75
|
+
- lib/thingamajig/modules/container.rb
|
74
76
|
- lib/thingamajig/osa_object.rb
|
75
77
|
- lib/thingamajig/project.rb
|
76
78
|
- lib/thingamajig/todo.rb
|
@@ -80,7 +82,7 @@ homepage: https://github.com/dv/thingamajig
|
|
80
82
|
licenses:
|
81
83
|
- MIT
|
82
84
|
metadata: {}
|
83
|
-
post_install_message:
|
85
|
+
post_install_message:
|
84
86
|
rdoc_options: []
|
85
87
|
require_paths:
|
86
88
|
- lib
|
@@ -95,9 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
97
|
- !ruby/object:Gem::Version
|
96
98
|
version: '0'
|
97
99
|
requirements: []
|
98
|
-
|
99
|
-
|
100
|
-
signing_key:
|
100
|
+
rubygems_version: 3.0.3
|
101
|
+
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: A library providing an OOPy API for a local Things 3 Mac app
|
103
104
|
test_files: []
|