asana 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWVkYTQzZjIzNWRmYWY4OWE1OWUyN2E4ZDIzY2MyOWYzMmE3MzI5Zg==
5
+ data.tar.gz: !binary |-
6
+ NjU1MzU5MGIwM2RhMWE3ZGUzZDQxMTdkZjE5NTY2MTZmYmQ5YjkyMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NWUxMWUwMWIwZWFkMTdkODUxOTM1N2Q3YjYyNmE0NmFjYjIwOTYxNGNlOTk3
10
+ MDQyYTQ3ODg5ZTllZjhlZDE0ZmZkOTNmMWM5NGEyZTMyYTU1MTc0NjlmYzA3
11
+ OTg0OGE1Y2JmZDQ3NTljYzdjN2U0OTk5YmJkNmUwOTM1NDc0ZWY=
12
+ data.tar.gz: !binary |-
13
+ M2E3YjUwNDE1YWJmYTRiMmZkMjA1OTYyYjVkMDc3NDdiZThhYzdlZTMwMTA0
14
+ ZDk5Y2QxNWUyZTA0ZDQzMGJkMmFiMTRkMDVjMmQ1ZTAwMDRkMGExY2U3Yjg2
15
+ M2U3NGUyNmYxMDJlYmQxODNiNTI5YzZiOGE0ZWNiZjA3YjJmMjY=
data/README.md CHANGED
@@ -87,11 +87,17 @@ tasks = workspace.tasks(:user_id)
87
87
  # Get all users with access to a given workspace
88
88
  users = workspace.users
89
89
 
90
+ # Get all tags in a given workspace
91
+ tags = workspace.tags
92
+
90
93
  # Create a new task in a given workspace and assign it to the current user
91
94
  workspace.create_task(:name => 'Get milk from the grocery store')
92
95
 
93
96
  # Create a new project in a given workspace, current user as a watcher
94
97
  workspace.create_project(:name => 'Upgrade Asana gem')
98
+
99
+ # Create a new tag in a given workspace
100
+ workspace.create_tag(:name => 'Programming')
95
101
  ```
96
102
 
97
103
  ### [Projects][]
@@ -133,6 +139,10 @@ tasks = project.tasks
133
139
  workspace = Asana::Workspace.find(:workspace_id)
134
140
  tasks = workspace.tasks
135
141
 
142
+ # Get all tasks with a given tag
143
+ tag = Asana::Tag.find(:tag_id)
144
+ tasks = tag.tasks
145
+
136
146
  # Get all stories for a given task
137
147
  task = tasks.first
138
148
  stories = task.stories
@@ -147,6 +157,33 @@ task.create_story(story_settings)
147
157
  task.add_project(project.id)
148
158
  ```
149
159
 
160
+ ### [Tags][]
161
+
162
+ > A tag is a label that can be attached to any task in Asana. It exists in
163
+ > a single workspace or organization.
164
+ >
165
+ > Tags have some metadata associated with them, but it is possible that we will
166
+ > simplify them in the future so it is not encouraged to rely too heavily on
167
+ > it. Unlike projects, tags do not provide any ordering on the tasks they are
168
+ > associated with.
169
+
170
+ ```ruby
171
+ # Get all tags in a given workspace
172
+ workspace = Asana::Workspace.find(:workspace_id)
173
+ tags = workspace.tags
174
+
175
+ # Get all tasks with a given tag
176
+ tag = Asana::Tag.find(:tag_id)
177
+ tasks = tag.tasks
178
+
179
+ # Create a new tag in a given workspace
180
+ workspace.create_tag(:name => 'Programming')
181
+
182
+ # Update a tag
183
+ tag = Asana::Tag.find(:tag_id)
184
+ tag.modify(:name => 'Development')
185
+ ```
186
+
150
187
  ### [Stories][]
151
188
 
152
189
  > A story represents an activity associated with an object in the Asana
@@ -167,7 +204,6 @@ story = Story.find(:story_id)
167
204
 
168
205
  # Create a new story for the given task/project
169
206
  task.create_story(story_settings)
170
- project.create_story(story_settings)
171
207
  ```
172
208
 
173
209
  ## Contributing
@@ -186,3 +222,4 @@ project.create_story(story_settings)
186
222
  [Projects]: http://developer.asana.com/documentation/#projects
187
223
  [Tasks]: http://developer.asana.com/documentation/#tasks
188
224
  [Stories]: http://developer.asana.com/documentation/#stories
225
+ [Tags]: http://developer.asana.com/documentation/#tags
@@ -10,8 +10,7 @@ Gem::Specification.new do |gem|
10
10
 
11
11
  gem.add_dependency 'activeresource', '~> 3.2.3'
12
12
 
13
- gem.add_development_dependency 'growl', '~> 1.0.3'
14
- gem.add_development_dependency 'guard-minitest', '~> 0.5.0'
13
+ gem.add_development_dependency 'guard-minitest', '~> 1.0.0'
15
14
  gem.add_development_dependency 'minitest', '~> 2.12.1'
16
15
  gem.add_development_dependency 'rake', '~> 0.9.2.2'
17
16
  gem.add_development_dependency 'vcr', '~> 2.1.0'
@@ -4,6 +4,7 @@ require 'asana/config'
4
4
  require 'asana/version'
5
5
 
6
6
  require 'asana/resources/project'
7
+ require 'asana/resources/tag'
7
8
  require 'asana/resources/story'
8
9
  require 'asana/resources/task'
9
10
  require 'asana/resources/user'
@@ -23,13 +23,6 @@ module Asana
23
23
  response = Project.put(self.id, nil, resource.to_json)
24
24
  Project.new(connection.format.decode(response.body))
25
25
  end
26
-
27
- def create_story(*args)
28
- path = "#{self.id}/stories"
29
- story = Story.new(args.first)
30
- response = Project.post(path, nil, story.to_json)
31
- Story.new(connection.format.decode(response.body))
32
- end
33
26
 
34
27
  end
35
28
  end
@@ -0,0 +1,28 @@
1
+ module Asana
2
+ class Tag < Asana::Resource
3
+
4
+ alias :create :method_not_allowed
5
+ alias :destroy :method_not_allowed
6
+
7
+ def self.all_by_task(*args)
8
+ parent_resources :task
9
+ all(*args)
10
+ end
11
+
12
+ def self.all_by_workspace(*args)
13
+ parent_resources :workspace
14
+ all(*args)
15
+ end
16
+
17
+ def tasks
18
+ Task.all_by_tag(:params => { :tag_id => self.id })
19
+ end
20
+
21
+ def modify(modified_fields)
22
+ resource = Resource.new(modified_fields)
23
+ response = Tag.put(self.id, nil, resource.to_json)
24
+ Tag.new(connection.format.decode(response.body))
25
+ end
26
+
27
+ end
28
+ end
@@ -6,6 +6,11 @@ module Asana
6
6
  all(*args)
7
7
  end
8
8
 
9
+ def self.all_by_tag(*args)
10
+ parent_resources :tag
11
+ all(*args)
12
+ end
13
+
9
14
  def self.all_by_workspace(*args)
10
15
  parent_resources :workspace
11
16
  all(*args)
@@ -21,6 +26,10 @@ module Asana
21
26
  Project.all_by_task(:params => { :task_id => self.id })
22
27
  end
23
28
 
29
+ def tags
30
+ Tag.all_by_task(:params => { :task_id => self.id })
31
+ end
32
+
24
33
  def add_project(project_id)
25
34
  path = "#{self.id}/addProject"
26
35
  resource = Resource.new({:project => project_id})
@@ -28,6 +37,13 @@ module Asana
28
37
  self
29
38
  end
30
39
 
40
+ def add_tag(tag_id)
41
+ path = "#{self.id}/addTag"
42
+ resource = Resource.new({:tag => tag_id})
43
+ Task.post(path, nil, resource.to_json)
44
+ self
45
+ end
46
+
31
47
  def create_story(*args)
32
48
  path = "#{self.id}/stories"
33
49
  options = { :task => self.id }
@@ -40,5 +56,18 @@ module Asana
40
56
  Story.all_by_task(:params => { :task_id => self.id })
41
57
  end
42
58
 
59
+ def create_subtask(*args)
60
+ path = "#{self.id}/subtasks"
61
+ options = { :task => self.id }
62
+ task = Task.new(options.merge(args.first))
63
+ response = Task.post(path, nil, task.to_json)
64
+ Task.new(connection.format.decode(response.body).merge parent: self)
65
+ end
66
+
67
+ def subtasks
68
+ path = "#{self.id}/subtasks"
69
+ Task.get(path, nil).map { |subtask| Task.new(subtask.merge(parent: self)) }
70
+ end
71
+
43
72
  end
44
73
  end
@@ -27,6 +27,17 @@ module Asana
27
27
  Task.new(connection.format.decode(response.body))
28
28
  end
29
29
 
30
+ def tags
31
+ Tag.all_by_workspace(:params => { :workspace_id => self.id })
32
+ end
33
+
34
+ def create_tag(*args)
35
+ options = { :workspace => self.id }
36
+ tag = Tag.new(options.merge(args.first))
37
+ response = Tag.post(nil, nil, tag.to_json)
38
+ Tag.new(connection.format.decode(response.body))
39
+ end
40
+
30
41
  def users
31
42
  User.all_by_workspace(:params => { :workspace_id => self.id })
32
43
  end
@@ -1,3 +1,3 @@
1
1
  module Asana
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -59,13 +59,5 @@ module Asana
59
59
  end
60
60
  end
61
61
 
62
- describe '#create_story' do
63
- it 'should create a new story for the given project' do
64
- project = Workspace.all.first.create_project(:name => 'asana-test-project-story')
65
- story = project.create_story(:text => 'foo')
66
- story.must_be_instance_of Story
67
- end
68
- end
69
-
70
62
  end
71
63
  end
@@ -0,0 +1,63 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ module Asana
4
+ describe Tag do
5
+
6
+ before do
7
+ VCR.insert_cassette('tags', :record => :all)
8
+ Asana.configure do |c|
9
+ c.api_key = ENV['ASANA_API_KEY']
10
+ end
11
+ end
12
+
13
+ after do
14
+ VCR.eject_cassette
15
+ end
16
+
17
+ describe '.all' do
18
+ it 'should return all of the user\'s tags' do
19
+ tags = Tag.all
20
+ tags.must_be_instance_of Array
21
+ tags.first.must_be_instance_of Tag
22
+ end
23
+ end
24
+
25
+ describe '.create' do
26
+ it 'should raise an ActiveResource::MethodNotAllowed exception' do
27
+ tag = Tag.new
28
+ lambda { tag.save }.must_raise ActiveResource::MethodNotAllowed
29
+ end
30
+ end
31
+
32
+ describe '.find' do
33
+ it 'should return a single tag' do
34
+ tag = Tag.find(Tag.all.first.id)
35
+ tag.must_be_instance_of Tag
36
+ end
37
+ end
38
+
39
+ describe '#destroy' do
40
+ it 'should raise an ActiveResource::MethodNotAllowed exception' do
41
+ tag = Tag.all.first
42
+ lambda { tag.destroy}.must_raise ActiveResource::MethodNotAllowed
43
+ end
44
+ end
45
+
46
+ describe '#modify' do
47
+ it 'should modify the given tag with a new name' do
48
+ tag = Workspace.all.first.create_tag(:name => 'asana-test-tag-foo')
49
+ tag.modify(:name => 'asana-test-tag-bar').name.must_equal 'asana-test-tag-bar'
50
+ end
51
+ end
52
+
53
+ describe '#tasks' do
54
+ it 'should return all tasks for the given tag' do
55
+ tag = Tag.all.first
56
+ tasks = tag.tasks
57
+ tasks.must_be_instance_of Array
58
+ tasks.first.must_be_instance_of Task
59
+ end
60
+ end
61
+
62
+ end
63
+ end
@@ -44,7 +44,15 @@ module Asana
44
44
  task.add_project project.id
45
45
  end
46
46
  end
47
-
47
+
48
+ describe '#add_tag' do
49
+ it 'should add the tag to the given task' do
50
+ task = Workspace.all.first.create_task(:name => 'asana-test-task-add-tag', :assignee => 'me')
51
+ tag = Workspace.all.first.create_tag(:name => 'asana-test-task-parent-tag')
52
+ task.add_tag tag.id
53
+ end
54
+ end
55
+
48
56
  describe '#create_story' do
49
57
  it 'should create a new story for the given task' do
50
58
  task = Project.all.first.tasks.first
@@ -62,5 +70,26 @@ module Asana
62
70
  end
63
71
  end
64
72
 
73
+ describe '#create_subtask' do
74
+ it 'should create a new subtask for the given task' do
75
+ task = Project.all.first.tasks.first
76
+ subtask = task.create_subtask(:name => 'asana-test-subtask', :assignee => 'me')
77
+ subtask.must_be_instance_of Task
78
+ subtask.parent.must_be_instance_of Task
79
+ subtask.parent.id.must_equal task.id
80
+ end
81
+ end
82
+
83
+ describe '#subtasks' do
84
+ it 'should return all subtasks for the given task' do
85
+ task = Project.all.first.tasks.first
86
+ subtasks = task.subtasks
87
+ subtasks.must_be_instance_of Array
88
+ subtasks.first.must_be_instance_of Task
89
+ subtasks.first.parent.must_be_instance_of Task
90
+ subtasks.first.parent.id.must_equal task.id
91
+ end
92
+ end
93
+
65
94
  end
66
95
  end
@@ -50,7 +50,7 @@ module Asana
50
50
  project = workspace.create_project(:name => 'asana-test-project')
51
51
  project.must_be_instance_of Project
52
52
  end
53
- end
53
+ end
54
54
 
55
55
  describe '#update' do
56
56
  it 'should update the given workspace with a new name' do
@@ -76,6 +76,15 @@ module Asana
76
76
  end
77
77
  end
78
78
 
79
+ describe '#tags' do
80
+ it 'should return all tags for the given workspace' do
81
+ workspace = Workspace.all.first
82
+ tags = workspace.tags
83
+ tags.must_be_instance_of Array
84
+ tags.first.must_be_instance_of Tag
85
+ end
86
+ end
87
+
79
88
  describe '#tasks' do
80
89
  it 'should return all tasks for the given workspace' do
81
90
  workspace = Workspace.all.first
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asana
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Bright
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-25 00:00:00.000000000 Z
11
+ date: 2013-07-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activeresource
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,47 +20,27 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.2.3
30
- - !ruby/object:Gem::Dependency
31
- name: growl
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 1.0.3
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.0.3
46
27
  - !ruby/object:Gem::Dependency
47
28
  name: guard-minitest
48
29
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
30
  requirements:
51
31
  - - ~>
52
32
  - !ruby/object:Gem::Version
53
- version: 0.5.0
33
+ version: 1.0.0
54
34
  type: :development
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
37
  requirements:
59
38
  - - ~>
60
39
  - !ruby/object:Gem::Version
61
- version: 0.5.0
40
+ version: 1.0.0
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: minitest
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
45
  - - ~>
68
46
  - !ruby/object:Gem::Version
@@ -70,7 +48,6 @@ dependencies:
70
48
  type: :development
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
52
  - - ~>
76
53
  - !ruby/object:Gem::Version
@@ -78,7 +55,6 @@ dependencies:
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: rake
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
59
  - - ~>
84
60
  - !ruby/object:Gem::Version
@@ -86,7 +62,6 @@ dependencies:
86
62
  type: :development
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
66
  - - ~>
92
67
  - !ruby/object:Gem::Version
@@ -94,7 +69,6 @@ dependencies:
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: vcr
96
71
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
72
  requirements:
99
73
  - - ~>
100
74
  - !ruby/object:Gem::Version
@@ -102,7 +76,6 @@ dependencies:
102
76
  type: :development
103
77
  prerelease: false
104
78
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
79
  requirements:
107
80
  - - ~>
108
81
  - !ruby/object:Gem::Version
@@ -110,7 +83,6 @@ dependencies:
110
83
  - !ruby/object:Gem::Dependency
111
84
  name: webmock
112
85
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
86
  requirements:
115
87
  - - ~>
116
88
  - !ruby/object:Gem::Version
@@ -118,7 +90,6 @@ dependencies:
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
93
  requirements:
123
94
  - - ~>
124
95
  - !ruby/object:Gem::Version
@@ -142,45 +113,46 @@ files:
142
113
  - lib/asana/resource.rb
143
114
  - lib/asana/resources/project.rb
144
115
  - lib/asana/resources/story.rb
116
+ - lib/asana/resources/tag.rb
145
117
  - lib/asana/resources/task.rb
146
118
  - lib/asana/resources/user.rb
147
119
  - lib/asana/resources/workspace.rb
148
120
  - lib/asana/version.rb
149
121
  - spec/asana/resources/project_spec.rb
150
122
  - spec/asana/resources/story_spec.rb
123
+ - spec/asana/resources/tag_spec.rb
151
124
  - spec/asana/resources/task_spec.rb
152
125
  - spec/asana/resources/user_spec.rb
153
126
  - spec/asana/resources/workspace_spec.rb
154
127
  - spec/spec_helper.rb
155
128
  homepage: http://github.com/rbright/asana
156
129
  licenses: []
130
+ metadata: {}
157
131
  post_install_message:
158
132
  rdoc_options: []
159
133
  require_paths:
160
134
  - lib
161
135
  required_ruby_version: !ruby/object:Gem::Requirement
162
- none: false
163
136
  requirements:
164
137
  - - ! '>='
165
138
  - !ruby/object:Gem::Version
166
139
  version: '0'
167
140
  required_rubygems_version: !ruby/object:Gem::Requirement
168
- none: false
169
141
  requirements:
170
142
  - - ! '>='
171
143
  - !ruby/object:Gem::Version
172
144
  version: '0'
173
145
  requirements: []
174
146
  rubyforge_project:
175
- rubygems_version: 1.8.23
147
+ rubygems_version: 2.0.5
176
148
  signing_key:
177
- specification_version: 3
149
+ specification_version: 4
178
150
  summary: Ruby wrapper for the Asana REST API
179
151
  test_files:
180
152
  - spec/asana/resources/project_spec.rb
181
153
  - spec/asana/resources/story_spec.rb
154
+ - spec/asana/resources/tag_spec.rb
182
155
  - spec/asana/resources/task_spec.rb
183
156
  - spec/asana/resources/user_spec.rb
184
157
  - spec/asana/resources/workspace_spec.rb
185
158
  - spec/spec_helper.rb
186
- has_rdoc: