rtmilk 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +5 -0
- data/Manifest.txt +9 -0
- data/README.txt +4 -0
- data/Rakefile +54 -0
- data/lib/rtmilk/version.rb +9 -0
- data/lib/rtmilk.rb +195 -0
- data/setup.rb +1585 -0
- data/test/rtmilk_test.rb +11 -0
- data/test/test_helper.rb +3 -0
- metadata +54 -0
data/CHANGELOG.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
include FileUtils
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'rtmilk', 'version')
|
13
|
+
|
14
|
+
AUTHOR = "takayama" # can also be an array of Authors
|
15
|
+
EMAIL = "mootoh@gmail.com"
|
16
|
+
DESCRIPTION = 'a "Remember the Milk" wrapper library.'
|
17
|
+
GEM_NAME = "rtmilk" # what ppl will type to install your gem
|
18
|
+
RUBYFORGE_PROJECT = "rtmilk" # The unix name for your project
|
19
|
+
HOMEPATH = "http://rtmilk.rubyforge.org"
|
20
|
+
|
21
|
+
|
22
|
+
NAME = "rtmilk"
|
23
|
+
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
24
|
+
VERS = ENV['VERSION'] || (Rtmilk::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
26
|
+
RDOC_OPTS = ['--quiet', '--title', "rtmilk documentation",
|
27
|
+
"--opname", "index.html",
|
28
|
+
"--line-numbers",
|
29
|
+
"--main", "README",
|
30
|
+
"--inline-source"]
|
31
|
+
|
32
|
+
class Hoe
|
33
|
+
def extra_deps
|
34
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate all the Rake tasks
|
39
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
40
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
41
|
+
p.author = AUTHOR
|
42
|
+
p.description = DESCRIPTION
|
43
|
+
p.email = EMAIL
|
44
|
+
p.summary = DESCRIPTION
|
45
|
+
p.url = HOMEPATH
|
46
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
47
|
+
p.test_globs = ["test/**/*_test.rb"]
|
48
|
+
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
49
|
+
|
50
|
+
# == Optional
|
51
|
+
#p.changes - A description of the release's latest changes.
|
52
|
+
#p.extra_deps - An array of rubygem dependencies.
|
53
|
+
#p.spec_extras - A hash of extra values to set in the gemspec.
|
54
|
+
end
|
data/lib/rtmilk.rb
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
#
|
2
|
+
# for Remember the Milk REST API
|
3
|
+
# http://www.rememberthemilk.com/services/api/overview.rtm
|
4
|
+
#
|
5
|
+
# $Id: rtm.rb 10 2006-12-30 06:37:24Z takayama $
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rtmilk/api.rb'
|
9
|
+
|
10
|
+
=begin rdoc
|
11
|
+
access Remember the Milk REST APIs.
|
12
|
+
=end
|
13
|
+
module RTM
|
14
|
+
|
15
|
+
def RTM.get_timeline
|
16
|
+
API::TimeLines.create
|
17
|
+
end
|
18
|
+
|
19
|
+
# use frob for Desktop Application.
|
20
|
+
# perm should be one of ['read', 'write', 'delete'].
|
21
|
+
def RTM.get_auth_url(h)
|
22
|
+
raise unless API::PERMS.include?(h[:perm])
|
23
|
+
|
24
|
+
API.auth_uri(API.params, h)
|
25
|
+
end
|
26
|
+
|
27
|
+
def RTM.get_frob
|
28
|
+
API::Auth.getFrob
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
class Contact
|
33
|
+
attr_accessor :id, :fullname, :username
|
34
|
+
|
35
|
+
def initialize(id, full=nil, user=nil)
|
36
|
+
@id = id
|
37
|
+
@fullname = full
|
38
|
+
@user = user
|
39
|
+
end
|
40
|
+
end # Contact
|
41
|
+
|
42
|
+
class Group
|
43
|
+
attr_accessor :id, :name
|
44
|
+
end # Group
|
45
|
+
|
46
|
+
class List
|
47
|
+
attr_accessor :id, :name, :deleted, :locked, :archived, :position, :smart, :filter
|
48
|
+
|
49
|
+
def initialize(h)
|
50
|
+
@id = h['id']
|
51
|
+
@name = h['name']
|
52
|
+
@deleted = h['deleted'] == '0'
|
53
|
+
@locked = h['locked'] == '1'
|
54
|
+
@archived = h['archived'] == '1'
|
55
|
+
@position = h['position']
|
56
|
+
@smart = h['smart'] == '1'
|
57
|
+
@filter = h['filter']
|
58
|
+
end
|
59
|
+
|
60
|
+
def setDefault
|
61
|
+
end # setDefault
|
62
|
+
|
63
|
+
def setName(name)
|
64
|
+
end # setName
|
65
|
+
|
66
|
+
def archive
|
67
|
+
end # archive
|
68
|
+
|
69
|
+
def unarchive
|
70
|
+
end # unarchive
|
71
|
+
|
72
|
+
def <=>(other)
|
73
|
+
@name <=> other.name
|
74
|
+
end
|
75
|
+
end # List
|
76
|
+
|
77
|
+
class Lists
|
78
|
+
include Enumerable
|
79
|
+
|
80
|
+
attr_accessor :ls
|
81
|
+
|
82
|
+
def initialize
|
83
|
+
@ls = API::Lists.getList.collect do |x|
|
84
|
+
List.new x
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def each
|
89
|
+
@ls.each do |x|
|
90
|
+
yield x
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def Lists.add(name, filter=nil)
|
95
|
+
timeline = RTM.get_timeline
|
96
|
+
l = API::Lists.add(timeline, name, filter)
|
97
|
+
List.new l
|
98
|
+
end # add
|
99
|
+
|
100
|
+
def [](i)
|
101
|
+
to_a[i]
|
102
|
+
end
|
103
|
+
|
104
|
+
def size
|
105
|
+
to_a.size
|
106
|
+
end
|
107
|
+
end # Lists
|
108
|
+
|
109
|
+
class TaskSeries
|
110
|
+
attr_accessor :id, :created, :modified, :name, :source,
|
111
|
+
:tags, :participants, :notes, :task
|
112
|
+
|
113
|
+
def initialize(h)
|
114
|
+
@id = h['id'] if h['id']
|
115
|
+
@created = h['created'] if h['created']
|
116
|
+
@modified = h['modified'] if h['modified']
|
117
|
+
@name = h['name'] if h['name']
|
118
|
+
@source = h['source'] if h['source']
|
119
|
+
@tags = h['tags'].first['tag'] if h['tags']
|
120
|
+
@participants = h['participants'].first if h['participants']
|
121
|
+
@notes = h['notes'].first if h['notes']
|
122
|
+
|
123
|
+
if h['task']
|
124
|
+
@task = h['task'].collect do |t|
|
125
|
+
Task.new(t)
|
126
|
+
end.flatten.compact
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class Task
|
131
|
+
attr_accessor :id, :due, :has_due_time, :added, :completed,
|
132
|
+
:deleted, :priority, :postponed, :estimate
|
133
|
+
|
134
|
+
def initialize(h)
|
135
|
+
@id = h['id'] if h['id']
|
136
|
+
@due = h['due'] if h['due']
|
137
|
+
@has_due_time = h['has_due_time'] == '1' if h['has_due_time']
|
138
|
+
@added = h['added'] if h['added']
|
139
|
+
@completed = h['completed'] if h['completed']
|
140
|
+
@deleted = h['deleted'] if h['deleted']
|
141
|
+
@priority = h['priority'] if h['priority']
|
142
|
+
@postponed = h['postponed'] if h['postponed']
|
143
|
+
@estimate = h['estimate'] if h['estimate']
|
144
|
+
end
|
145
|
+
end # Task
|
146
|
+
end
|
147
|
+
|
148
|
+
class Tasks
|
149
|
+
include Enumerable
|
150
|
+
|
151
|
+
attr_accessor :ts
|
152
|
+
|
153
|
+
def initialize(list=nil, last=nil)
|
154
|
+
@ts = API::Tasks.getList(list, last).collect do |x|
|
155
|
+
if x['taskseries']
|
156
|
+
x['taskseries'].collect do |t|
|
157
|
+
TaskSeries.new t
|
158
|
+
end
|
159
|
+
else
|
160
|
+
nil
|
161
|
+
end
|
162
|
+
end.flatten.compact
|
163
|
+
end
|
164
|
+
|
165
|
+
def each
|
166
|
+
@ts.each do |x|
|
167
|
+
yield x
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def Tasks.add(name, list)
|
172
|
+
timeline = RTM.get_timeline
|
173
|
+
t = API::Tasks.add(timeline, list, name)
|
174
|
+
TaskSeries.new t
|
175
|
+
end
|
176
|
+
|
177
|
+
def Tasks.delete(series, task, list)
|
178
|
+
timeline = RTM.get_timeline
|
179
|
+
t = API::Tasks.delete(timeline, list, series, task)
|
180
|
+
TaskSeries.new t
|
181
|
+
end
|
182
|
+
|
183
|
+
def [](i)
|
184
|
+
to_a[i]
|
185
|
+
end
|
186
|
+
|
187
|
+
def size
|
188
|
+
to_a.size
|
189
|
+
end
|
190
|
+
|
191
|
+
end # Tasks
|
192
|
+
|
193
|
+
end # RTM
|
194
|
+
|
195
|
+
# vim:fdm=indent
|