things-client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -5
- data/VERSION +1 -1
- data/lib/appscript/reference.rb +14 -0
- data/lib/things.rb +2 -5
- data/lib/things/app.rb +0 -5
- data/lib/things/area.rb +5 -0
- data/lib/things/list.rb +39 -12
- data/lib/things/person.rb +42 -0
- data/lib/things/project.rb +4 -0
- data/lib/things/reference/record.rb +21 -9
- data/lib/things/todo.rb +81 -1
- data/spec/things/app_spec.rb +3 -16
- data/spec/things/area_spec.rb +23 -8
- data/spec/things/list_spec.rb +5 -0
- data/spec/things/person_spec.rb +13 -0
- data/spec/things/project_spec.rb +0 -8
- data/spec/things/tag_spec.rb +1 -9
- data/spec/things/todo_spec.rb +53 -13
- data/spec/things_spec.rb +4 -1
- metadata +7 -5
- data/lib/things/collections/todo.rb +0 -42
- data/spec/things/collections/todo_spec.rb +0 -54
data/README.rdoc
CHANGED
@@ -4,16 +4,23 @@ Things is a Ruby API for the popular GTD app Things, available on the Mac.
|
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
7
|
-
|
7
|
+
The gem is hosted on Gemcutter. To install it, use the following command:
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
sudo gem install things-client --source http://gemcutter.org
|
10
|
+
|
11
|
+
To get the latest version, clone the gem from github and run rake install:
|
12
|
+
|
13
|
+
git clone http://github.com/marcinbunsch/things-client
|
14
|
+
cd things-client
|
11
15
|
rake check_dependencies:runtime
|
12
|
-
rake
|
13
|
-
sudo gem install pkg/things-0.0.1.gem
|
16
|
+
sudo rake install
|
14
17
|
|
15
18
|
== Usage
|
16
19
|
|
20
|
+
Before using this gem you must require it by calling:
|
21
|
+
|
22
|
+
require 'things'
|
23
|
+
|
17
24
|
=== Application
|
18
25
|
|
19
26
|
The Application can be accessed at all times by calling Things::App. It has a few useful methods which will be described below. If you want Things to gain focus and move to the front of the window stack, you can call the Things::App.activate method.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/appscript/reference.rb
CHANGED
@@ -5,5 +5,19 @@ module Appscript #:nodoc:
|
|
5
5
|
def todos
|
6
6
|
to_dos
|
7
7
|
end
|
8
|
+
|
9
|
+
def identify
|
10
|
+
name = self.to_s.match(/Things.app"\)\.([^\.]*)/)[1]
|
11
|
+
|
12
|
+
begin
|
13
|
+
name = name.gsub('_', '')
|
14
|
+
# inflections
|
15
|
+
name = 'persons' if name == 'people'
|
16
|
+
Things.const_get(name.capitalize[0..-2])
|
17
|
+
rescue NameError
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
8
22
|
end
|
9
23
|
end
|
data/lib/things.rb
CHANGED
@@ -13,11 +13,8 @@ module Things
|
|
13
13
|
autoload :Area, File.dirname(__FILE__) + '/things/area'
|
14
14
|
autoload :Project, File.dirname(__FILE__) + '/things/project'
|
15
15
|
autoload :Tag, File.dirname(__FILE__) + '/things/tag'
|
16
|
-
|
17
|
-
|
18
|
-
autoload :Todo, File.dirname(__FILE__) + '/things/collections/todo'
|
19
|
-
end
|
20
|
-
|
16
|
+
autoload :Person, File.dirname(__FILE__) + '/things/person'
|
17
|
+
|
21
18
|
module Reference
|
22
19
|
autoload :Base, File.dirname(__FILE__) + '/things/reference/base'
|
23
20
|
autoload :Inheritance, File.dirname(__FILE__) + '/things/reference/inheritance'
|
data/lib/things/app.rb
CHANGED
data/lib/things/area.rb
CHANGED
data/lib/things/list.rb
CHANGED
@@ -1,18 +1,45 @@
|
|
1
1
|
module Things
|
2
|
-
class List
|
2
|
+
class List < Reference::Base
|
3
|
+
|
3
4
|
DEFAULTS = [:inbox, :today, :next, :scheduled, :someday, :projects, :logbook, :trash]
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
|
6
|
+
def todos
|
7
|
+
Things::Todo.convert(reference.todos.get)
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Returns an Appscript Reference to the entire collection of todos
|
13
|
+
def reference
|
14
|
+
Things::App.instance.lists
|
15
|
+
end
|
16
|
+
|
17
|
+
# Converts a collection of reference into a collection of objects
|
18
|
+
def convert(references)
|
19
|
+
references = [references] if !references.is_a?(Array)
|
20
|
+
references.collect { |todo| build(todo) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def all
|
24
|
+
convert(reference.get)
|
25
|
+
end
|
26
|
+
|
27
|
+
# build a new instance and link it to the supplied reference
|
28
|
+
#
|
29
|
+
# Returns a object associated with a reference
|
30
|
+
def build(reference)
|
31
|
+
todo = self.new
|
32
|
+
todo.reference = reference
|
33
|
+
todo
|
34
|
+
end
|
8
35
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
36
|
+
DEFAULTS.each do |list|
|
37
|
+
class_eval <<-"eval"
|
38
|
+
def #{list}
|
39
|
+
convert(reference['#{list.to_s.capitalize}'].get).first
|
40
|
+
end
|
41
|
+
eval
|
16
42
|
end
|
43
|
+
end
|
17
44
|
end
|
18
45
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Things
|
2
|
+
# Things::Person
|
3
|
+
#
|
4
|
+
# People in Things cannot be created, they are fetched from Address Book
|
5
|
+
class Person < Reference::Record
|
6
|
+
|
7
|
+
properties :name
|
8
|
+
# identifier is required for creation
|
9
|
+
identifier :person
|
10
|
+
# collection is used for findings
|
11
|
+
collection :people
|
12
|
+
|
13
|
+
# Find a Person in Address Book and add a teammate in Things
|
14
|
+
#
|
15
|
+
# Returns a Things::Person object
|
16
|
+
def self.create(address_book_name)
|
17
|
+
reference = Things::App.instance.add_teammate_named(address_book_name)
|
18
|
+
raise 'Could not find person in Address Book' if reference == :missing_value
|
19
|
+
build(reference)
|
20
|
+
end
|
21
|
+
|
22
|
+
def todos
|
23
|
+
Things::Todo.convert(reference.todos.get)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Not supported by Things::Person
|
27
|
+
#
|
28
|
+
# Raises a RuntimeError when called
|
29
|
+
def save
|
30
|
+
raise 'Currently Things does not support this method'
|
31
|
+
end
|
32
|
+
|
33
|
+
# Not supported by Things::Person
|
34
|
+
#
|
35
|
+
# Raises a RuntimeError when called
|
36
|
+
def delete
|
37
|
+
reference.delete
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/lib/things/project.rb
CHANGED
@@ -21,16 +21,16 @@ module Things
|
|
21
21
|
if args
|
22
22
|
@_properties += args
|
23
23
|
@_properties.each do |property|
|
24
|
-
attr_writer(property) if !instance_methods.include?(property.to_s)
|
24
|
+
attr_writer(property) if !instance_methods.include?(property.to_s+'=')
|
25
25
|
if !instance_methods.include?(property.to_s )
|
26
26
|
class_eval <<-"eval"
|
27
27
|
def #{property}
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
@#{property}
|
28
|
+
return @#{property} if @#{property}
|
29
|
+
fetched = @reference.#{property}.get rescue nil
|
30
|
+
if fetched.is_a?(Appscript::Reference)
|
31
|
+
fetched = fetched.identify.build(fetched)
|
33
32
|
end
|
33
|
+
@#{property} = fetched if fetched and fetched != :missing_value
|
34
34
|
end
|
35
35
|
eval
|
36
36
|
end
|
@@ -58,12 +58,24 @@ module Things
|
|
58
58
|
if new?
|
59
59
|
properties = {}
|
60
60
|
(self.class.properties - [:id_]).each do |property|
|
61
|
-
|
61
|
+
if value = self.send(property)
|
62
|
+
properties[property] = value.respond_to?(:reference) ? value.reference : value
|
63
|
+
end
|
62
64
|
end
|
63
|
-
|
65
|
+
# only set name in make, then set the rest of the properties
|
66
|
+
name = properties.delete(:name)
|
67
|
+
self.reference = Things::App.instance.make(:new => self.class.identifier, :with_properties => { :name => name })
|
68
|
+
properties.each_pair { |name, property| self.reference.send(name).set(property) }
|
64
69
|
else
|
65
70
|
(self.class.properties - [:id_]).each do |property|
|
66
|
-
|
71
|
+
if value = self.send(property)
|
72
|
+
self.reference.send(property).set(value.respond_to?(:reference) ? value.reference : value)
|
73
|
+
else
|
74
|
+
begin
|
75
|
+
self.reference.send(property).delete
|
76
|
+
rescue
|
77
|
+
end
|
78
|
+
end
|
67
79
|
end
|
68
80
|
end
|
69
81
|
self
|
data/lib/things/todo.rb
CHANGED
@@ -2,7 +2,7 @@ module Things
|
|
2
2
|
# Things::Todo
|
3
3
|
class Todo < Reference::Record
|
4
4
|
|
5
|
-
properties :name, :notes, :completion_date
|
5
|
+
properties :name, :notes, :completion_date, :delegate, :status, :area, :project
|
6
6
|
# identifier is required for creation
|
7
7
|
identifier :to_do
|
8
8
|
# collection is used for findings
|
@@ -11,8 +11,88 @@ module Things
|
|
11
11
|
# Move a todo to a different list <br />
|
12
12
|
# Moving to Trash will delete the todo
|
13
13
|
def move(list)
|
14
|
+
list = list.reference if !list.is_a?(Appscript::Reference)
|
14
15
|
Things::App.instance.move(reference, { :to => list })
|
15
16
|
end
|
16
17
|
|
18
|
+
# Set the status to :completed
|
19
|
+
#
|
20
|
+
# Does not save the Todo
|
21
|
+
def complete
|
22
|
+
self.status = :completed
|
23
|
+
end
|
24
|
+
|
25
|
+
# Set the status to :completed
|
26
|
+
#
|
27
|
+
# Saves the Todo
|
28
|
+
def complete!
|
29
|
+
complete
|
30
|
+
self.save
|
31
|
+
end
|
32
|
+
|
33
|
+
# Check whether the Todo is completed or not
|
34
|
+
def completed?
|
35
|
+
self.status == :completed
|
36
|
+
end
|
37
|
+
|
38
|
+
# Set the status to :open
|
39
|
+
#
|
40
|
+
# Does not save the Todo
|
41
|
+
def open
|
42
|
+
self.status = :open
|
43
|
+
end
|
44
|
+
|
45
|
+
# Set the status to :open
|
46
|
+
#
|
47
|
+
# Saves the Todo
|
48
|
+
def open!
|
49
|
+
open
|
50
|
+
self.save
|
51
|
+
end
|
52
|
+
|
53
|
+
# Check whether the Todo is open or not
|
54
|
+
def open?
|
55
|
+
self.status == :open
|
56
|
+
end
|
57
|
+
|
58
|
+
# class methods, for accessing collections
|
59
|
+
class << self
|
60
|
+
|
61
|
+
# Returns an Appscript Reference to the entire collection of todos
|
62
|
+
def reference
|
63
|
+
Things::App.instance.todos
|
64
|
+
end
|
65
|
+
|
66
|
+
# Converts a collection of reference into a collection of objects
|
67
|
+
def convert(references)
|
68
|
+
references.to_a.collect { |todo| build(todo) }
|
69
|
+
end
|
70
|
+
|
71
|
+
# these are references and should be stored somewhere else...
|
72
|
+
Things::List::DEFAULTS.each do |list|
|
73
|
+
class_eval <<-"eval"
|
74
|
+
def #{list}
|
75
|
+
convert(Things::List.#{list}.reference.todos.get)
|
76
|
+
end
|
77
|
+
eval
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns an array of Things::Todo objects
|
81
|
+
def all
|
82
|
+
convert(reference.get)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Get all not completed Todos
|
86
|
+
# Note this returns an array of Todos, not references
|
87
|
+
# TODO: find a better way of filtering references
|
88
|
+
def active
|
89
|
+
result = (reference.get - Things::List.trash.reference.todos.get).select do |todo|
|
90
|
+
todo.completion_date.get == :missing_value
|
91
|
+
end
|
92
|
+
convert(result.compact)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
17
97
|
end
|
18
98
|
end
|
data/spec/things/app_spec.rb
CHANGED
@@ -12,13 +12,9 @@ describe "Things::App" do
|
|
12
12
|
|
13
13
|
describe '#activate' do
|
14
14
|
|
15
|
-
it 'should
|
16
|
-
|
17
|
-
|
18
|
-
#Things::App.instance!.quit if `ps x | grep Things`.include?('Things.app')
|
19
|
-
#{}`ps x | grep Things`.should_not match('Things.app')
|
20
|
-
#Things::App.instance!.activate
|
21
|
-
#{}`ps x | grep Things`.should match('Things.app')
|
15
|
+
it 'should put the app in the front' do
|
16
|
+
Things::App.instance!.activate
|
17
|
+
Things::App.instance.frontmost.get.should == true
|
22
18
|
end
|
23
19
|
|
24
20
|
end
|
@@ -30,14 +26,5 @@ describe "Things::App" do
|
|
30
26
|
end
|
31
27
|
|
32
28
|
end
|
33
|
-
|
34
|
-
describe '#todos' do
|
35
29
|
|
36
|
-
it "should return Things::Collections::Todo" do
|
37
|
-
Things::App.todos.should == Things::Collections::Todo
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
30
|
end
|
data/spec/things/area_spec.rb
CHANGED
@@ -3,17 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe "Things::Area" do
|
4
4
|
|
5
5
|
before do
|
6
|
-
Things::App.activate
|
7
6
|
@area = Things::Area.new(:name => 'TEST - Foo')
|
8
7
|
end
|
9
8
|
|
10
|
-
after do
|
11
|
-
# close all windows when done
|
12
|
-
Things::App.instance.windows.get.each do |window|
|
13
|
-
Things::App.instance!.close(window)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
describe "#self.new" do
|
18
10
|
|
19
11
|
it "should create a new Things::Area instance with properties" do
|
@@ -148,6 +140,29 @@ describe "Things::Area" do
|
|
148
140
|
|
149
141
|
end
|
150
142
|
|
143
|
+
describe '#todos' do
|
144
|
+
|
145
|
+
before do
|
146
|
+
@foo = Things::Todo.new(:name => 'TEST - Foo')
|
147
|
+
@bar = Things::Todo.new(:name => 'TEST - Bar')
|
148
|
+
end
|
149
|
+
|
150
|
+
after do
|
151
|
+
@foo.delete
|
152
|
+
@bar.delete
|
153
|
+
Things::App.instance.empty_trash
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should get todo assigner to a area" do
|
157
|
+
@area.save
|
158
|
+
@foo.area= @area
|
159
|
+
@foo.save
|
160
|
+
@foo.area.should == @area
|
161
|
+
@area.delete
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
151
166
|
|
152
167
|
|
153
168
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Things::Person" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Appscript.app('Address Book').make(:new => :person, :with_properties => { :organization => 'ThingsClientTest', :company => true })
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should add a new person" do
|
10
|
+
@person = Things::Person.create('ThingsClientTest')
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/spec/things/project_spec.rb
CHANGED
@@ -3,17 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe "Things::Project" do
|
4
4
|
|
5
5
|
before do
|
6
|
-
Things::App.activate
|
7
6
|
@project = Things::Project.new(:name => 'TEST - Foo')
|
8
7
|
end
|
9
8
|
|
10
|
-
after do
|
11
|
-
# close all windows when done
|
12
|
-
Things::App.instance.windows.get.each do |window|
|
13
|
-
Things::App.instance!.close(window)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
describe "#self.new" do
|
18
10
|
|
19
11
|
it "should create a new Things::Project instance with properties" do
|
data/spec/things/tag_spec.rb
CHANGED
@@ -3,17 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe "Things::Tag" do
|
4
4
|
|
5
5
|
before do
|
6
|
-
Things::App.activate
|
7
6
|
@tag = Things::Tag.new(:name => 'TEST - Foo')
|
8
7
|
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
# close all windows when done
|
12
|
-
Things::App.instance.windows.get.each do |window|
|
13
|
-
Things::App.instance!.close(window)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
8
|
+
|
17
9
|
describe "#self.new" do
|
18
10
|
|
19
11
|
it "should create a new Things::Tag instance with properties" do
|
data/spec/things/todo_spec.rb
CHANGED
@@ -3,17 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe "Things::Todo" do
|
4
4
|
|
5
5
|
before do
|
6
|
-
Things::App.activate
|
7
6
|
@todo = Things::Todo.new(:name => 'TEST - Foo', :notes => 'TEST - Fooer')
|
8
7
|
end
|
9
8
|
|
10
|
-
after do
|
11
|
-
# close all windows when done
|
12
|
-
Things::App.instance.windows.get.each do |window|
|
13
|
-
Things::App.instance!.close(window)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
describe "#self.new" do
|
18
10
|
|
19
11
|
it "should create a new Things::Todo instance with properties" do
|
@@ -23,7 +15,7 @@ describe "Things::Todo" do
|
|
23
15
|
|
24
16
|
it "should not be sent to Things yet" do
|
25
17
|
@todo.id_.should == nil
|
26
|
-
active = (Things::App.instance.todos.get - Things::List.trash.todos.get)
|
18
|
+
active = (Things::App.instance.todos.get - Things::List.trash.reference.todos.get)
|
27
19
|
active.collect { |todo| todo.name.get }.should_not include("TEST - Foo")
|
28
20
|
end
|
29
21
|
|
@@ -53,7 +45,7 @@ describe "Things::Todo" do
|
|
53
45
|
it "should create the todo" do
|
54
46
|
@todo.id_.should_not be_nil
|
55
47
|
@todo.new?.should == false
|
56
|
-
active = (Things::App.instance.todos.get - Things::List.trash.todos.get)
|
48
|
+
active = (Things::App.instance.todos.get - Things::List.trash.reference.todos.get)
|
57
49
|
active.collect { |todo| todo.name.get }.should include("TEST - Foo")
|
58
50
|
end
|
59
51
|
|
@@ -96,13 +88,13 @@ describe "Things::Todo" do
|
|
96
88
|
|
97
89
|
before do
|
98
90
|
@todo.save
|
99
|
-
Things::App.lists.inbox.todos.name.get.should include(@todo.name)
|
91
|
+
Things::App.lists.inbox.reference.todos.name.get.should include(@todo.name)
|
100
92
|
end
|
101
93
|
|
102
94
|
it "should remove a todo" do
|
103
95
|
@todo.delete
|
104
|
-
Things::App.lists.inbox.todos.name.get.should_not include(@todo.name)
|
105
|
-
Things::App.lists.trash.todos.name.get.should include(@todo.name)
|
96
|
+
Things::App.lists.inbox.reference.todos.name.get.should_not include(@todo.name)
|
97
|
+
Things::App.lists.trash.reference.todos.name.get.should include(@todo.name)
|
106
98
|
end
|
107
99
|
|
108
100
|
after do
|
@@ -155,6 +147,54 @@ describe "Things::Todo" do
|
|
155
147
|
|
156
148
|
end
|
157
149
|
|
150
|
+
describe "#self.all" do
|
151
|
+
before do
|
152
|
+
@todo_a = Things::Todo.create(:name => 'TEST - AAA')
|
153
|
+
@todo_b = Things::Todo.create(:name => 'TEST - BBB')
|
154
|
+
end
|
155
|
+
|
156
|
+
after do
|
157
|
+
@todo_a.delete
|
158
|
+
@todo_b.delete
|
159
|
+
Things::App.instance.empty_trash
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should return a collection of all todos as Things::Todo objects" do
|
163
|
+
Things::Todo.all.collect(&:id_).should include(@todo_a.id_)
|
164
|
+
Things::Todo.all.collect(&:id_).should include(@todo_b.id_)
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
end
|
158
169
|
|
170
|
+
describe "#self.active" do
|
171
|
+
|
172
|
+
before do
|
173
|
+
@todo_a = Things::Todo.create(:name => 'TEST - AAA')
|
174
|
+
@todo_b = Things::Todo.create(:name => 'TEST - BBB')
|
175
|
+
Things::Todo.active.collect(&:id_).should include(@todo_a.id_)
|
176
|
+
Things::Todo.active.collect(&:id_).should include(@todo_b.id_)
|
177
|
+
end
|
178
|
+
|
179
|
+
after do
|
180
|
+
@todo_a.delete
|
181
|
+
@todo_b.delete
|
182
|
+
Things::App.instance.empty_trash
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should not include completed todos" do
|
186
|
+
@todo_b.completion_date = Time.now
|
187
|
+
@todo_b.save
|
188
|
+
Things::Todo.active.collect(&:id_).should include(@todo_a.id_)
|
189
|
+
Things::Todo.active.collect(&:id_).should_not include(@todo_b.id_)
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should not include deleted todos" do
|
193
|
+
@todo_a.delete
|
194
|
+
Things::Todo.active.collect(&:id_).should_not include(@todo_a.id_)
|
195
|
+
Things::Todo.active.collect(&:id_).should include(@todo_b.id_)
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
159
199
|
|
160
200
|
end
|
data/spec/things_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: things-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Bunsch
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-23 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,8 +52,8 @@ files:
|
|
52
52
|
- lib/things.rb
|
53
53
|
- lib/things/app.rb
|
54
54
|
- lib/things/area.rb
|
55
|
-
- lib/things/collections/todo.rb
|
56
55
|
- lib/things/list.rb
|
56
|
+
- lib/things/person.rb
|
57
57
|
- lib/things/project.rb
|
58
58
|
- lib/things/reference/base.rb
|
59
59
|
- lib/things/reference/inheritance.rb
|
@@ -65,7 +65,8 @@ files:
|
|
65
65
|
- spec/spec_helper.rb
|
66
66
|
- spec/things/app_spec.rb
|
67
67
|
- spec/things/area_spec.rb
|
68
|
-
- spec/things/
|
68
|
+
- spec/things/list_spec.rb
|
69
|
+
- spec/things/person_spec.rb
|
69
70
|
- spec/things/project_spec.rb
|
70
71
|
- spec/things/tag_spec.rb
|
71
72
|
- spec/things/todo_spec.rb
|
@@ -103,7 +104,8 @@ test_files:
|
|
103
104
|
- spec/spec_helper.rb
|
104
105
|
- spec/things/app_spec.rb
|
105
106
|
- spec/things/area_spec.rb
|
106
|
-
- spec/things/
|
107
|
+
- spec/things/list_spec.rb
|
108
|
+
- spec/things/person_spec.rb
|
107
109
|
- spec/things/project_spec.rb
|
108
110
|
- spec/things/tag_spec.rb
|
109
111
|
- spec/things/todo_spec.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Things
|
2
|
-
module Collections
|
3
|
-
class Todo
|
4
|
-
|
5
|
-
class << self
|
6
|
-
|
7
|
-
# Returns an Appscript Reference to the entire collection of todos
|
8
|
-
def reference
|
9
|
-
Things::App.instance.todos
|
10
|
-
end
|
11
|
-
|
12
|
-
# these are references and should be stored somewhere else...
|
13
|
-
Things::List::DEFAULTS.each do |list|
|
14
|
-
class_eval <<-"eval"
|
15
|
-
def #{list}
|
16
|
-
Things::App.lists.#{list}.todos
|
17
|
-
end
|
18
|
-
eval
|
19
|
-
end
|
20
|
-
|
21
|
-
# Returns an array of Things::Todo objects
|
22
|
-
def all
|
23
|
-
reference.get.collect { |todo| Things::Todo.build(todo) }
|
24
|
-
end
|
25
|
-
|
26
|
-
# Get all not completed Todos
|
27
|
-
# Note this returns an array of Todos, not references
|
28
|
-
# TODO: find a better way of filtering references
|
29
|
-
def active
|
30
|
-
result = (reference.get - Things::List.trash.todos.get).collect do |todo|
|
31
|
-
Things::Todo.build(todo) if todo.completion_date.get.to_s == 'missing_value'
|
32
|
-
end
|
33
|
-
result.compact
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
describe "Things::Collections::Todo" do
|
4
|
-
|
5
|
-
describe "#self.all" do
|
6
|
-
before do
|
7
|
-
@todo_a = Things::Todo.create(:name => 'TEST - AAA')
|
8
|
-
@todo_b = Things::Todo.create(:name => 'TEST - BBB')
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
@todo_a.delete
|
13
|
-
@todo_b.delete
|
14
|
-
Things::App.instance.empty_trash
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should return a collection of all todos as Things::Todo objects" do
|
18
|
-
Things::Collections::Todo.all.collect(&:id_).should include(@todo_a.id_)
|
19
|
-
Things::Collections::Todo.all.collect(&:id_).should include(@todo_b.id_)
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#self.active" do
|
26
|
-
|
27
|
-
before do
|
28
|
-
@todo_a = Things::Todo.create(:name => 'TEST - AAA')
|
29
|
-
@todo_b = Things::Todo.create(:name => 'TEST - BBB')
|
30
|
-
Things::Collections::Todo.active.collect(&:id_).should include(@todo_a.id_)
|
31
|
-
Things::Collections::Todo.active.collect(&:id_).should include(@todo_b.id_)
|
32
|
-
end
|
33
|
-
|
34
|
-
after do
|
35
|
-
@todo_a.delete
|
36
|
-
@todo_b.delete
|
37
|
-
Things::App.instance.empty_trash
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should not include completed todos" do
|
41
|
-
@todo_b.completion_date = Time.now
|
42
|
-
@todo_b.save
|
43
|
-
Things::Collections::Todo.active.collect(&:id_).should include(@todo_a.id_)
|
44
|
-
Things::Collections::Todo.active.collect(&:id_).should_not include(@todo_b.id_)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should not include deleted todos" do
|
48
|
-
@todo_a.delete
|
49
|
-
Things::Collections::Todo.active.collect(&:id_).should_not include(@todo_a.id_)
|
50
|
-
Things::Collections::Todo.active.collect(&:id_).should include(@todo_b.id_)
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|