wndrlst 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43ccceb9e95a49a76649c8b7b4b61c9a99431bd2
4
- data.tar.gz: bae292da0ec3cb0b071bc20d265959cfa8f1c15f
3
+ metadata.gz: a4952147fbba79cf96d9278ea1f706e52be86a4e
4
+ data.tar.gz: ebdddf7211d41c55f01c925a05acf2e88f74471d
5
5
  SHA512:
6
- metadata.gz: 9df69eb605bfc05ed2957f5c7fc9355dbaa51584a4548456e72cb88ebbdb8d7f5c1d5eb6b67fe9c5d1a9d4064374d91d6bc0b1b0c63725a8c0fc27b99b2163e7
7
- data.tar.gz: 19577152420fcef2f939f84c5a55544fe8bdc81232de36559556cd2e3f6051fbf826ef0d6776862b5c86fb15876c0ad9d39004e5909a9424dec5590419e9c5c4
6
+ metadata.gz: af6a373c8638b5a6c3955d381381630d178d14c20877d1710bd3ea19a1d512b55a5e70bdea8e1b5c4225e1d628a418f8680c708eb5eb7e8426b4760456624356
7
+ data.tar.gz: 54d17eb487bda333a2a5b08ca089773cb0e4628189b85ab12eb3242cb9da727c7b1eef1e8a238b1d3cba9cec0c44a4d239d25ff86218553ca106b8fcc0efca2d
data/README.md CHANGED
@@ -24,6 +24,11 @@ Or install it yourself as:
24
24
 
25
25
  TODO: Write usage instructions here
26
26
 
27
+ ## History
28
+
29
+ v0.0.2: Add Method(list_id, task_title_by_list_name, tasks_by_list_name), rspec test add(a part).
30
+ v0.0.1: Initial version.
31
+
27
32
  ## Development
28
33
 
29
34
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/wndrlst.rb CHANGED
@@ -7,6 +7,7 @@ module Wndrlst
7
7
  class API
8
8
 
9
9
  BASE_ENDPOINT = "https://a.wunderlist.com/api/v1"
10
+ attr_reader :params
10
11
 
11
12
  def initialize(client_id, access_token)
12
13
  @client_id = client_id
@@ -18,52 +19,71 @@ module Wndrlst
18
19
  end
19
20
 
20
21
  def user
21
- get(generate_url('user', @params))
22
+ get(generate_url('user', params))
22
23
  end
23
24
 
24
25
  def lists
25
- get(generate_url('lists', @params))
26
+ get(generate_url('lists', params))
26
27
  end
27
28
 
28
29
  def list(id)
29
- get(generate_url('lists', @params, id))
30
+ get(generate_url('lists', params, id))
31
+ end
32
+
33
+ def list_titles
34
+ lists.collect{|list| list[:title]}
30
35
  end
31
36
 
32
37
  def tasks(list_id, completed=false)
33
- @params['list_id'] = list_id
34
- @params['completed'] = completed
38
+ params = @params
39
+ params['list_id'] = list_id
40
+ params['completed'] = completed
41
+
42
+ get(generate_url('tasks', params, params))
43
+ end
44
+
45
+ def task_titles(list_id, completed=false)
46
+ tasks(list_id, completed).collecct {|task| task[:title]}
47
+ end
35
48
 
36
- get(generate_url('tasks', @params))
49
+ def tasks_by_list_name(title, completed=false)
50
+ tasks(list_id(title), completed)
51
+ end
52
+
53
+ def task_title_by_list_name(title, completed=false)
54
+ tasks_by_list_name(title, completed).collect{|task| task[:title]}
37
55
  end
38
56
 
39
57
  def task(id)
40
- get(generate_url('tasks', @params, id))
58
+ get(generate_url('tasks', params, id))
41
59
  end
42
60
 
43
61
  def subtasks(task_id, completed=false)
44
- @params['task_id'] = task_id
45
- @params['completed'] = completed
62
+ params = @params
63
+ params['task_id'] = task_id
64
+ params['completed'] = completed
46
65
 
47
- get(generate_url('subtasks', @params))
66
+ get(generate_url('subtasks', params))
48
67
  end
49
68
 
50
69
  def subtasks_from_list(list_id, completed=false)
51
- @params['list_id'] = list_id
52
- @params['completed'] = completed
70
+ params = @params
71
+ params['list_id'] = list_id
72
+ params['completed'] = completed
53
73
 
54
- get(generate_url('subtasks', @params))
74
+ get(generate_url('subtasks', params))
55
75
  end
56
76
 
57
77
  private
58
78
 
59
79
  def generate_url(resource, params, target_id=nil)
60
- params = @params.collect {|p, v| "#{p}=#{v}&"}.join("")
61
- params.slice!(-1)
80
+ req_params = params.collect {|p, v| "#{p}=#{v}&"}.join("")
81
+ req_params.slice!(-1)
62
82
 
63
83
  if target_id
64
- "#{BASE_ENDPOINT}/#{resource}/#{target_id}?#{params}"
84
+ "#{BASE_ENDPOINT}/#{resource}/#{target_id}?#{req_params}"
65
85
  else
66
- "#{BASE_ENDPOINT}/#{resource}?#{params}"
86
+ "#{BASE_ENDPOINT}/#{resource}?#{req_params}"
67
87
  end
68
88
  end
69
89
 
@@ -76,5 +96,15 @@ module Wndrlst
76
96
 
77
97
  JSON.parse(response.read)
78
98
  end
99
+
100
+ def list_id(title)
101
+ list_id = ""
102
+ lists.each do |list|
103
+ if list[:title] == title
104
+ list_id = list[:id]
105
+ end
106
+ end
107
+ list_id
108
+ end
79
109
  end
80
110
  end
@@ -1,3 +1,3 @@
1
1
  module Wndrlst
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wndrlst
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - katsumata_ryo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler