ruby-wunderlist 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,8 +31,24 @@ require "wunderlist/list"
31
31
  require "wunderlist/task"
32
32
 
33
33
  module Wunderlist
34
+ ##
35
+ # The API class provides access to the Wunderlist API over HTTP.
34
36
  class API
35
- attr_reader :domain, :path, :email, :session
37
+ ##
38
+ # Domain of the Wunderlist API
39
+ attr_reader :domain
40
+
41
+ ##
42
+ # Path of the Wunderlist API
43
+ attr_reader :path
44
+
45
+ ##
46
+ # Your email address from login
47
+ attr_reader :email
48
+
49
+ ##
50
+ # Wunderlist Session ID
51
+ attr_reader :session
36
52
 
37
53
  def initialize(domain = "www.wunderlist.com", path = "/")
38
54
  @domain = domain
@@ -41,6 +57,8 @@ module Wunderlist
41
57
  @logged_in = false
42
58
  end
43
59
 
60
+ ##
61
+ # Request new session and connects it with your login credentials
44
62
  def login(email, password)
45
63
  get_session if @session == nil
46
64
  return true if @logged_in
@@ -54,25 +72,35 @@ module Wunderlist
54
72
  @logged_in
55
73
  end
56
74
 
75
+ ##
76
+ # Login with a session ID without login credentials
57
77
  def login_by_session(sessid)
58
78
  return if @logged_in
59
79
  @logged_in = true
60
80
  @session = sessid
61
81
  end
62
82
 
83
+ ##
84
+ # Delete internal list caching
63
85
  def flush
64
86
  @lists = nil
65
87
  end
66
88
 
89
+ ##
90
+ # Return all lists
67
91
  def lists
68
92
  @lists = load_lists if @lists == nil
69
93
  @lists
70
94
  end
71
95
 
96
+ ##
97
+ # Get INBOX list
72
98
  def inbox
73
99
  lists.values.detect { |list| list.inbox }
74
100
  end
75
101
 
102
+ ##
103
+ # Load and parse tasks from Wunderlist API
76
104
  def tasks(list)
77
105
  list_obj = list.is_a?(Wunderlist::List) ? list : lists[list]
78
106
  list = list.id if list.is_a? Wunderlist::List
@@ -99,10 +127,14 @@ module Wunderlist
99
127
  result
100
128
  end
101
129
 
130
+ ##
131
+ # Create new empty List
102
132
  def create_list(name)
103
133
  Wunderlist::List.new(name, false, self).save
104
134
  end
105
135
 
136
+ ##
137
+ # Save List or Task
106
138
  def save(obj)
107
139
  if obj.is_a? Wunderlist::List
108
140
  return save_list obj
@@ -111,6 +143,8 @@ module Wunderlist
111
143
  end
112
144
  end
113
145
 
146
+ ##
147
+ # Destroy List or Task
114
148
  def destroy(obj)
115
149
  if obj.is_a? Wunderlist::List
116
150
  return destroy_list obj
@@ -22,49 +22,68 @@
22
22
  # SOFTWARE.
23
23
 
24
24
  module Wunderlist
25
+ ##
26
+ # A FilterableList represents an array of Tasks and provides methods to
27
+ # filter the list by the tasks
25
28
  class FilterableList
29
+ ##
30
+ # Array of tasks
26
31
  attr_accessor :tasks
27
32
 
28
33
  def initialize(tasks = [])
29
34
  @tasks = tasks
30
35
  end
31
36
 
37
+ ##
38
+ # Get all tasks whose date is today
32
39
  def today
33
40
  FilterableList.new(tasks.clone.keep_if do |t|
34
41
  t.date == Date.today && !t.done
35
42
  end)
36
43
  end
37
44
 
45
+ ##
46
+ # Get all tasks which are important
38
47
  def priority
39
48
  FilterableList.new(tasks.clone.keep_if do |t|
40
49
  t.important && !t.done
41
50
  end)
42
51
  end
43
52
 
53
+ ##
54
+ # Get all tasks which are not important
44
55
  def not_priority
45
56
  FilterableList.new(tasks.clone.keep_if do |t|
46
57
  !t.important && !t.done
47
58
  end)
48
59
  end
49
60
 
61
+ ##
62
+ # Get all done tasks
50
63
  def done
51
64
  FilterableList.new(tasks.clone.keep_if do |t|
52
65
  t.done == true
53
66
  end)
54
67
  end
55
68
 
69
+ ##
70
+ # Get all non-done tasks
56
71
  def not_done
57
72
  FilterableList.new(tasks.clone.keep_if do |t|
58
73
  t.done != true
59
74
  end)
60
75
  end
61
76
 
77
+ ##
78
+ # Get all overdue tasks
62
79
  def overdue
63
80
  FilterableList.new(tasks.clone.keep_if do |t|
64
81
  t.date && t.date < Date.today && !t.done
65
82
  end)
66
83
  end
67
84
 
85
+ ##
86
+ # Get all non-overdue tasks
68
87
  def not_overdue
69
88
  FilterableList.new(tasks.clone.keep_if do |t|
70
89
  (!t.date || t.date < Date.today) && !t.done
@@ -83,8 +102,28 @@ module Wunderlist
83
102
  end
84
103
  end
85
104
 
105
+ ##
106
+ # A List is a FilterableList which can be synchronized with an API object
86
107
  class List < FilterableList
87
- attr_accessor :id, :name, :inbox, :shared, :api
108
+ ##
109
+ # ID of the list on the Wunderlist server
110
+ attr_accessor :id
111
+
112
+ ##
113
+ # Name of the list
114
+ attr_accessor :name
115
+
116
+ ##
117
+ # Value which determines whether this list is a INBOX or or not
118
+ attr_accessor :inbox
119
+
120
+ ##
121
+ # true, if list is shared, otherwise false
122
+ attr_accessor :shared
123
+
124
+ ##
125
+ # Reference to the associated API object. Necessary for many methods.
126
+ attr_accessor :api
88
127
 
89
128
  def initialize(name = nil, inbox = nil, api = nil)
90
129
  @name = name
@@ -92,25 +131,35 @@ module Wunderlist
92
131
  @api = api
93
132
  end
94
133
 
134
+ ##
135
+ # Get all tasks
95
136
  def tasks
96
137
  @tasks = @api.tasks self if @tasks == nil
97
138
  @tasks
98
139
  end
99
140
 
141
+ ##
142
+ # Create task with specified name and date
100
143
  def create_task(name, date = nil)
101
144
  Wunderlist::Task.new(name, date, self, @api).save
102
145
  end
103
146
 
147
+ ##
148
+ # Save list with api
104
149
  def save(api = nil)
105
150
  @api ||= api
106
151
  @api.save(self)
107
152
  end
108
153
 
154
+ ##
155
+ # Destroy list with api
109
156
  def destroy(api = nil)
110
157
  @api ||= api
111
158
  @api.destroy(self)
112
159
  end
113
160
 
161
+ ##
162
+ # Remove tasks cache
114
163
  def flush
115
164
  @tasks = nil
116
165
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-wunderlist
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-02 00:00:00.000000000 Z
12
+ date: 2012-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &13927660 !ruby/object:Gem::Requirement
16
+ requirement: &16374580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13927660
24
+ version_requirements: *16374580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &13926500 !ruby/object:Gem::Requirement
27
+ requirement: &16372620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *13926500
35
+ version_requirements: *16372620
36
36
  description:
37
37
  email: fritz+wunderlist@grimpen.net
38
38
  executables: []
@@ -40,9 +40,9 @@ extensions: []
40
40
  extra_rdoc_files: []
41
41
  files:
42
42
  - lib/wunderlist.rb
43
- - lib/wunderlist/list.rb
44
43
  - lib/wunderlist/task.rb
45
44
  - lib/wunderlist/api.rb
45
+ - lib/wunderlist/list.rb
46
46
  homepage: http://grimpen.net/wunderlist
47
47
  licenses:
48
48
  - MIT
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 1.8.11
67
+ rubygems_version: 1.8.13
68
68
  signing_key:
69
69
  specification_version: 3
70
70
  summary: Wunderlist Bindings for Ruby