Commit 7fa21c03e7fa82f63998389257d2d36984d184cd

Added code to handle fetching of label info
Rakefile
(1 / 1)
  
2121PROJ.name = 'todoist-ng'
2222PROJ.authors = 'James Britt'
2323PROJ.email = 'james.britt@gmail.com'
24PROJ.url = 'none'
24PROJ.url = 'http://www.gitorious.com/projects/todoist-ng'
2525PROJ.version = Neurogami::Todoist::Setup::VERSION
2626PROJ.rubyforge.name = 'todoist-ng'
2727
  
99 class Project
1010
1111 include Constants
12
12
1313 @@token = 'NO_TOKEN!'
1414 @@labels = nil
1515 @@projects = nil
1818 def self.token= t
1919 @@token = t
2020 end
21 def self.token
22 @@token
23 end
2124
2225 def initialize details
2326 details.each { |k,v| eval "@#{k} = '#{v}'"}
2427 @items = nil
2528 end
2629
27
28
2930 def uncompleted_items
3031 # http://todoist.com/API/getUncompletedItems?project_id=22073&token=fb5f22601ec566e48083213f7573e908a7a272e5
3132 begin
151151 # http://todoist.com/API/getLabels?token=fb5f22601ec566e48083213f7573e908a7a272e5
152152 return @@labels if @@labels && !reload
153153 @@labels = JSON.parse(open( "#{BASE_URL}/getLabels?token=#{@@token}").read)
154 end
155
156 def self.label_from_id id
157 # The todoist returns labels as a hash, where the key is a string that points
158 # to another hash, and that other hash has a ID.
159 # When you get an Item, and ask for its labels, you get that ID instead
160 # of a simple string. :(
161 # So, this method gets you the label info for that ID
162 self.labels.each do |k, v|
163 return v if v['id'].to_i == id.to_i
164 end
165 nil
154166 end
155167
156168
  
22 module Todoist
33 class Setup
44 # :stopdoc:
5 VERSION = '0.2.0'
5 VERSION = '0.2.1'
66
77 def self.version
88 VERSION