todoist-ruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/todoist/misc/activity.rb +1 -1
- data/lib/todoist/misc/backups.rb +1 -1
- data/lib/todoist/misc/items.rb +1 -1
- data/lib/todoist/misc/projects.rb +3 -3
- data/lib/todoist/misc/query.rb +1 -1
- data/lib/todoist/util/parse_helper.rb +25 -6
- data/lib/todoist/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d36fbf13110d44679219837d5b8e7fa0b9f0f079
|
4
|
+
data.tar.gz: 7b6ed748aaadf0b41a5387ce597201eb5c1187fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ddbea8f9a2663df0322e42bf804799b8fec78b0914f7171b3cb0e99c884d91793e9f5579ca2de8140c83fa0e87574cc8e2740cf451db47445ff4069dec0b27
|
7
|
+
data.tar.gz: 8d26cf0c27ad96dc3195d07ef04dbde27330903f729098253b823f27cf55317a1da5c744701096866875d8c23e4002605c2a3e0d67a53f80899474dd20fdc166
|
data/README.md
CHANGED
@@ -190,6 +190,11 @@ rake spec:clean["misc_items"]
|
|
190
190
|
|
191
191
|
Once tests pass cleanly, subsquent runs that do not change the network requests run quickly since no network calls are made and in fact ```rake``` can be run with no issues.
|
192
192
|
|
193
|
+
## Version History
|
194
|
+
|
195
|
+
* 0.1.2: Renamed method ```Todoist::Util::ParseHelper.make_objects_as_array``` to ```Todoist::Util::ParseHelper.make_objects_as_hash``` to reflect the fact that it was actually returning hashes. Added the aforementioned deleted method to return arrays and finally altered ```Todoist::Misc::Completed``` to return objects as arrays instead of hashes due to the fact that recurring completed items were being de-duped unintentionally and data was being lost as a result.
|
196
|
+
* 0.1.1: Initial release.
|
197
|
+
|
193
198
|
## Contributing
|
194
199
|
|
195
200
|
Bug reports and pull requests are welcome on GitHub at https://github.com/h6y3/todoist-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/lib/todoist/misc/backups.rb
CHANGED
data/lib/todoist/misc/items.rb
CHANGED
@@ -46,7 +46,7 @@ module Todoist
|
|
46
46
|
result = NetworkHelper.getResponse(Config::TODOIST_ITEMS_GET_COMMAND, params)
|
47
47
|
item = ParseHelper.make_object(result["item"])
|
48
48
|
project = ParseHelper.make_object(result["project"])
|
49
|
-
notes = result["notes"] ? ParseHelper.
|
49
|
+
notes = result["notes"] ? ParseHelper.make_objects_as_hash(result["notes"]) : nil
|
50
50
|
return {"item" => item, "project" => project, "notes" => notes}
|
51
51
|
end
|
52
52
|
|
@@ -6,7 +6,7 @@ module Todoist
|
|
6
6
|
# Get archived projects. Returns projects as documented here.
|
7
7
|
def get_archived_projects()
|
8
8
|
result = NetworkHelper.getResponse(Config::TODOIST_PROJECTS_GET_ARCHIVED_COMMAND)
|
9
|
-
return ParseHelper.
|
9
|
+
return ParseHelper.make_objects_as_hash(result)
|
10
10
|
end
|
11
11
|
|
12
12
|
# Gets project information including all notes.
|
@@ -15,7 +15,7 @@ module Todoist
|
|
15
15
|
result = NetworkHelper.getResponse(Config::TODOIST_PROJECTS_GET_COMMAND, {project_id: project.id, all_data: true})
|
16
16
|
|
17
17
|
project = result["project"] ? ParseHelper.make_object(result["project"]) : nil
|
18
|
-
notes = result["notes"] ? ParseHelper.
|
18
|
+
notes = result["notes"] ? ParseHelper.make_objects_as_hash(result["notes"]) : nil
|
19
19
|
return {"project" => project, "notes" => notes}
|
20
20
|
end
|
21
21
|
|
@@ -23,7 +23,7 @@ module Todoist
|
|
23
23
|
def get_project_data(project)
|
24
24
|
result = NetworkHelper.getResponse(Config::TODOIST_PROJECTS_GET_DATA_COMMAND, {project_id: project.id})
|
25
25
|
project = result["project"] ? ParseHelper.make_object(result["project"]) : nil
|
26
|
-
items = result["items"] ? ParseHelper.
|
26
|
+
items = result["items"] ? ParseHelper.make_objects_as_hash(result["items"]) : nil
|
27
27
|
return {"project" => project, "items" => items}
|
28
28
|
end
|
29
29
|
end
|
data/lib/todoist/misc/query.rb
CHANGED
@@ -14,7 +14,7 @@ module Todoist
|
|
14
14
|
def queries(queries)
|
15
15
|
result = NetworkHelper.getResponse(Config::TODOIST_QUERY_COMMAND,
|
16
16
|
queries: queries.to_json)
|
17
|
-
return ParseHelper.
|
17
|
+
return ParseHelper.make_objects_as_hash(result, "query")
|
18
18
|
end
|
19
19
|
|
20
20
|
# Given a query, return result. See return structure in comments above.
|
@@ -32,23 +32,42 @@ module Todoist
|
|
32
32
|
datetime.strftime("%Y-%m-%dT%H:%M")
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.make_objects_as_array(
|
36
|
-
|
35
|
+
def self.make_objects_as_array(object_datas, key = "id")
|
36
|
+
objects_as_array = []
|
37
37
|
|
38
|
-
|
38
|
+
object_datas.each do |object_data|
|
39
39
|
begin
|
40
40
|
object = make_object(object_data)
|
41
|
-
|
41
|
+
objects_as_array << object
|
42
42
|
rescue
|
43
43
|
# Occasionally the API returns arrays of arrays of hashes
|
44
44
|
if object_data.kind_of? Array
|
45
45
|
|
46
46
|
object = make_object(object_data[1])
|
47
|
-
|
47
|
+
objects_as_array << object
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
-
return
|
51
|
+
return objects_as_array
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.make_objects_as_hash(object_datas, key = "id")
|
55
|
+
objects_as_hash = {}
|
56
|
+
|
57
|
+
object_datas.each do |object_data|
|
58
|
+
begin
|
59
|
+
object = make_object(object_data)
|
60
|
+
objects_as_hash[object.send(key)] = object
|
61
|
+
rescue
|
62
|
+
# Occasionally the API returns arrays of arrays of hashes
|
63
|
+
if object_data.kind_of? Array
|
64
|
+
|
65
|
+
object = make_object(object_data[1])
|
66
|
+
objects_as_hash[object.send(key)] = object
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return objects_as_hash
|
52
71
|
end
|
53
72
|
|
54
73
|
def self.make_object(object_as_hash)
|
data/lib/todoist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todoist-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Han Yuan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -224,4 +224,3 @@ signing_key:
|
|
224
224
|
specification_version: 4
|
225
225
|
summary: This gem provides access to the latest Todoist API.
|
226
226
|
test_files: []
|
227
|
-
has_rdoc:
|