asana 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -11
- data/asana.gemspec +1 -0
- data/lib/asana.rb +1 -0
- data/lib/asana/resource.rb +4 -0
- data/lib/asana/resources/project.rb +8 -0
- data/lib/asana/resources/story.rb +3 -0
- data/lib/asana/resources/task.rb +13 -5
- data/lib/asana/resources/user.rb +2 -0
- data/lib/asana/resources/workspace.rb +6 -3
- data/lib/asana/version.rb +1 -1
- data/spec/asana/resources/project_spec.rb +24 -10
- data/spec/asana/resources/story_spec.rb +12 -6
- data/spec/asana/resources/task_spec.rb +33 -1
- data/spec/asana/resources/user_spec.rb +8 -18
- data/spec/asana/resources/workspace_spec.rb +32 -17
- metadata +18 -2
data/README.md
CHANGED
@@ -54,7 +54,7 @@ the API.
|
|
54
54
|
users = Asana::User.all
|
55
55
|
|
56
56
|
# Get a specific user
|
57
|
-
user = Asana::User.find(:
|
57
|
+
user = Asana::User.find(:user_id)
|
58
58
|
|
59
59
|
# Get the user associated with the API key being used
|
60
60
|
user = Asana::User.me
|
@@ -76,19 +76,19 @@ users = workspace.users
|
|
76
76
|
workspaces = Asana::Workspace.all
|
77
77
|
|
78
78
|
# Get a specific workspace
|
79
|
-
workspace = Asana::Workspace.find(:
|
79
|
+
workspace = Asana::Workspace.find(:workspace_id)
|
80
80
|
|
81
81
|
# Get all projects in a given workspace
|
82
82
|
projects = workspace.projects
|
83
83
|
|
84
|
-
# Get all tasks in a given workspace
|
84
|
+
# Get all tasks in a given workspace that are assigned to the given user
|
85
85
|
tasks = workspace.tasks(:user_id)
|
86
86
|
|
87
87
|
# Get all users with access to a given workspace
|
88
88
|
users = workspace.users
|
89
89
|
|
90
90
|
# Create a new task in a given workspace and assign it to the current user
|
91
|
-
workspace.create_task(
|
91
|
+
workspace.create_task(:name => 'Get milk from the grocery store')
|
92
92
|
```
|
93
93
|
|
94
94
|
### [Projects][]
|
@@ -97,14 +97,14 @@ workspace.create_task(task_settings)
|
|
97
97
|
> single workspace and is accessible to a subset of users in that workspace
|
98
98
|
> depending on its permissions.
|
99
99
|
|
100
|
-
**Note:** It is not possible to create a project from the API.
|
100
|
+
**Note:** It is not possible to create or delete a project from the API.
|
101
101
|
|
102
102
|
```ruby
|
103
103
|
# Get all projects
|
104
104
|
projects = Asana::Project.all
|
105
105
|
|
106
106
|
# Get a specific project
|
107
|
-
project = Asana::Project.find(:
|
107
|
+
project = Asana::Project.find(:project_id)
|
108
108
|
|
109
109
|
# Get all projects in a given workspace
|
110
110
|
workspace = Asana::Workspace.find(:workspace_id)
|
@@ -120,11 +120,11 @@ projects = workspace.projects
|
|
120
120
|
|
121
121
|
```ruby
|
122
122
|
# Get all tasks in a given project
|
123
|
-
project = Asana::Project(:project_id)
|
123
|
+
project = Asana::Project.find(:project_id)
|
124
124
|
tasks = project.tasks
|
125
125
|
|
126
126
|
# Get all tasks in a given workspace
|
127
|
-
workspace = Asana::Workspace(:workspace_id)
|
127
|
+
workspace = Asana::Workspace.find(:workspace_id)
|
128
128
|
tasks = workspace.tasks
|
129
129
|
|
130
130
|
# Get all stories for a given task
|
@@ -132,7 +132,7 @@ task = tasks.first
|
|
132
132
|
stories = task.stories
|
133
133
|
|
134
134
|
# Create a new task in a given workspace and assign it to the current user
|
135
|
-
workspace.create_task(
|
135
|
+
workspace.create_task(:name => 'Get milk from the grocery store')
|
136
136
|
|
137
137
|
# Create a new story for the given task
|
138
138
|
task.create_story(story_settings)
|
@@ -145,14 +145,17 @@ task.create_story(story_settings)
|
|
145
145
|
> such as creating or assigning tasks, or moving tasks between projects.
|
146
146
|
> Comments are also a form of user-generated story.
|
147
147
|
|
148
|
-
**Note:** It is not possible to update a story from the API.
|
148
|
+
**Note:** It is not possible to update or delete a story from the API.
|
149
149
|
|
150
150
|
```ruby
|
151
151
|
# Get all stories for a given task
|
152
|
-
project = Asana::Project(:project_id)
|
152
|
+
project = Asana::Project.find(:project_id)
|
153
153
|
task = project.tasks.first
|
154
154
|
stories = task.stories
|
155
155
|
|
156
|
+
# Get a specific story
|
157
|
+
story = Story.find(:story_id)
|
158
|
+
|
156
159
|
# Create a new story for the given task
|
157
160
|
task.create_story(story_settings)
|
158
161
|
```
|
data/asana.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.add_development_dependency 'growl', '~> 1.0.3'
|
14
14
|
gem.add_development_dependency 'guard-minitest', '~> 0.5.0'
|
15
15
|
gem.add_development_dependency 'minitest', '~> 2.12.1'
|
16
|
+
gem.add_development_dependency 'rake', '~> 0.9.2.2'
|
16
17
|
gem.add_development_dependency 'vcr', '~> 2.1.0'
|
17
18
|
gem.add_development_dependency 'webmock', '~> 1.8.6'
|
18
19
|
|
data/lib/asana.rb
CHANGED
data/lib/asana/resource.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
module Asana
|
2
2
|
class Project < Asana::Resource
|
3
|
+
|
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
|
4
11
|
|
5
12
|
def self.all_by_workspace(*args)
|
6
13
|
parent_resources :workspace
|
@@ -10,5 +17,6 @@ module Asana
|
|
10
17
|
def tasks
|
11
18
|
Task.all_by_project(:params => { :project_id => self.id })
|
12
19
|
end
|
20
|
+
|
13
21
|
end
|
14
22
|
end
|
data/lib/asana/resources/task.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Asana
|
2
2
|
class Task < Asana::Resource
|
3
|
+
|
3
4
|
def self.all_by_project(*args)
|
4
5
|
parent_resources :project
|
5
6
|
all(*args)
|
@@ -10,14 +11,21 @@ module Asana
|
|
10
11
|
all(*args)
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
14
|
+
def projects
|
15
|
+
Project.all_by_task(:params => { :task_id => self.id })
|
15
16
|
end
|
16
17
|
|
17
18
|
def create_story(*args)
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
path = "#{self.id}/stories"
|
20
|
+
options = { :task => self.id }
|
21
|
+
story = Story.new(options.merge(args.first))
|
22
|
+
response = Task.post(path, nil, story.to_json)
|
23
|
+
Story.new(connection.format.decode(response.body))
|
24
|
+
end
|
25
|
+
|
26
|
+
def stories
|
27
|
+
Story.all_by_task(:params => { :task_id => self.id })
|
21
28
|
end
|
29
|
+
|
22
30
|
end
|
23
31
|
end
|
data/lib/asana/resources/user.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Asana
|
2
2
|
class Workspace < Asana::Resource
|
3
|
+
|
3
4
|
alias :create :method_not_allowed
|
4
5
|
alias :destroy :method_not_allowed
|
5
6
|
|
@@ -13,13 +14,15 @@ module Asana
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def create_task(*args)
|
16
|
-
|
17
|
-
|
18
|
-
Task.post(nil,
|
17
|
+
options = { :workspace => self.id, :assignee => 'me' }
|
18
|
+
task = Task.new(options.merge(args.first))
|
19
|
+
response = Task.post(nil, nil, task.to_json)
|
20
|
+
Task.new(connection.format.decode(response.body))
|
19
21
|
end
|
20
22
|
|
21
23
|
def users
|
22
24
|
User.all_by_workspace(:params => { :workspace_id => self.id })
|
23
25
|
end
|
26
|
+
|
24
27
|
end
|
25
28
|
end
|
data/lib/asana/version.rb
CHANGED
@@ -4,7 +4,7 @@ module Asana
|
|
4
4
|
describe Project do
|
5
5
|
|
6
6
|
before do
|
7
|
-
VCR.insert_cassette('projects', :record => :
|
7
|
+
VCR.insert_cassette('projects', :record => :all)
|
8
8
|
Asana.configure do |c|
|
9
9
|
c.api_key = ENV['ASANA_API_KEY']
|
10
10
|
end
|
@@ -22,15 +22,6 @@ module Asana
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe '.all_by_workspace' do
|
26
|
-
it 'should return all projects for the given workspace' do
|
27
|
-
workspace = Workspace.all.first
|
28
|
-
projects = workspace.projects
|
29
|
-
projects.must_be_instance_of Array
|
30
|
-
projects.first.must_be_instance_of Project
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
25
|
describe '.create' do
|
35
26
|
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
36
27
|
project = Project.new
|
@@ -38,6 +29,29 @@ module Asana
|
|
38
29
|
end
|
39
30
|
end
|
40
31
|
|
32
|
+
describe '.find' do
|
33
|
+
it 'should return a single project' do
|
34
|
+
project = Project.find(Project.all.first.id)
|
35
|
+
project.must_be_instance_of Project
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#destroy' do
|
40
|
+
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
41
|
+
project = Project.all.first
|
42
|
+
lambda { project.destroy}.must_raise ActiveResource::MethodNotAllowed
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#update' do
|
47
|
+
it 'should update the given project with a new name' do
|
48
|
+
project = Project.all.last
|
49
|
+
#project.name.wont_equal 'foo'
|
50
|
+
project.update_attribute(:name, 'foo')
|
51
|
+
project.name.must_equal 'foo'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
41
55
|
describe '#tasks' do
|
42
56
|
it 'should return all tasks for the given project' do
|
43
57
|
projects = Project.all.first
|
@@ -4,7 +4,7 @@ module Asana
|
|
4
4
|
describe Story do
|
5
5
|
|
6
6
|
before do
|
7
|
-
VCR.insert_cassette('stories', :record => :
|
7
|
+
VCR.insert_cassette('stories', :record => :all)
|
8
8
|
Asana.configure do |c|
|
9
9
|
c.api_key = ENV['ASANA_API_KEY']
|
10
10
|
end
|
@@ -14,11 +14,17 @@ module Asana
|
|
14
14
|
VCR.eject_cassette
|
15
15
|
end
|
16
16
|
|
17
|
-
describe '
|
18
|
-
it 'should
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
describe '.find' do
|
18
|
+
it 'should return a single story' do
|
19
|
+
story_id = Project.all.first.tasks.first.stories.first.id
|
20
|
+
Story.find(story_id).must_be_instance_of Story
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#destroy' do
|
25
|
+
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
26
|
+
story = Project.all.first.tasks.first.stories.first
|
27
|
+
lambda { story.destroy }.must_raise ActiveResource::MethodNotAllowed
|
22
28
|
end
|
23
29
|
end
|
24
30
|
|
@@ -4,7 +4,7 @@ module Asana
|
|
4
4
|
describe Task do
|
5
5
|
|
6
6
|
before do
|
7
|
-
VCR.insert_cassette('tasks', :record => :
|
7
|
+
VCR.insert_cassette('tasks', :record => :all)
|
8
8
|
Asana.configure do |c|
|
9
9
|
c.api_key = ENV['ASANA_API_KEY']
|
10
10
|
end
|
@@ -14,6 +14,38 @@ module Asana
|
|
14
14
|
VCR.eject_cassette
|
15
15
|
end
|
16
16
|
|
17
|
+
describe '.find' do
|
18
|
+
it 'should return a single task' do
|
19
|
+
task = Task.find(Workspace.all.first.tasks(:me).first.id)
|
20
|
+
task.must_be_instance_of Task
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#update' do
|
25
|
+
it 'should update the given task with a new name' do
|
26
|
+
task = Task.find(Workspace.all.first.tasks(:me).first.id)
|
27
|
+
task.update_attribute(:name, 'bar')
|
28
|
+
task.name.must_equal 'bar'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#projects' do
|
33
|
+
it 'should return all projects for the given task' do
|
34
|
+
task = Project.all.first.tasks.first
|
35
|
+
projects = task.projects
|
36
|
+
projects.must_be_instance_of Array
|
37
|
+
projects.first.must_be_instance_of Project
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#create_story' do
|
42
|
+
it 'should create a new story for the given task' do
|
43
|
+
task = Project.all.first.tasks.first
|
44
|
+
story = task.create_story(:text => 'foo')
|
45
|
+
story.must_be_instance_of Story
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
17
49
|
describe '#stories' do
|
18
50
|
it 'should return all stories for the given task' do
|
19
51
|
task = Project.all.first.tasks.first
|
@@ -4,7 +4,7 @@ module Asana
|
|
4
4
|
describe User do
|
5
5
|
|
6
6
|
before do
|
7
|
-
VCR.insert_cassette('users', :record => :
|
7
|
+
VCR.insert_cassette('users', :record => :all)
|
8
8
|
Asana.configure do |c|
|
9
9
|
c.api_key = ENV['ASANA_API_KEY']
|
10
10
|
end
|
@@ -15,23 +15,13 @@ module Asana
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '.all' do
|
18
|
-
it 'should return all users for all of the user\'s workspaces' do
|
18
|
+
it 'should return all users for all of the given user\'s workspaces' do
|
19
19
|
users = User.all
|
20
20
|
users.must_be_instance_of Array
|
21
21
|
users.first.must_be_instance_of User
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe '.all_by_workspace' do
|
26
|
-
it 'should return all users for the given workspace' do
|
27
|
-
user = User.me
|
28
|
-
workspace = user.workspaces.first
|
29
|
-
users = workspace.users
|
30
|
-
users.must_be_instance_of Array
|
31
|
-
users.first.must_be_instance_of User
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
25
|
describe '.find' do
|
36
26
|
it 'should return the user with the given ID' do
|
37
27
|
user = User.me
|
@@ -49,24 +39,24 @@ module Asana
|
|
49
39
|
end
|
50
40
|
end
|
51
41
|
|
52
|
-
describe '#
|
42
|
+
describe '#destroy' do
|
53
43
|
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
54
44
|
user = User.me
|
55
|
-
lambda { user.
|
45
|
+
lambda { user.destroy }.must_raise ActiveResource::MethodNotAllowed
|
56
46
|
end
|
57
47
|
end
|
58
48
|
|
59
|
-
describe '#
|
49
|
+
describe '#save' do
|
60
50
|
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
61
51
|
user = User.me
|
62
|
-
lambda { user.
|
52
|
+
lambda { user.save }.must_raise ActiveResource::MethodNotAllowed
|
63
53
|
end
|
64
54
|
end
|
65
55
|
|
66
|
-
describe '#
|
56
|
+
describe '#update' do
|
67
57
|
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
68
58
|
user = User.me
|
69
|
-
lambda { user.
|
59
|
+
lambda { user.update_attribute(:name, 'foo') }.must_raise ActiveResource::MethodNotAllowed
|
70
60
|
end
|
71
61
|
end
|
72
62
|
|
@@ -4,7 +4,7 @@ module Asana
|
|
4
4
|
describe Workspace do
|
5
5
|
|
6
6
|
before do
|
7
|
-
VCR.insert_cassette('workspaces', :record => :
|
7
|
+
VCR.insert_cassette('workspaces', :record => :all)
|
8
8
|
Asana.configure do |c|
|
9
9
|
c.api_key = ENV['ASANA_API_KEY']
|
10
10
|
end
|
@@ -22,11 +22,40 @@ module Asana
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe '.find' do
|
26
|
+
it 'should return a single workspace' do
|
27
|
+
workspace = Workspace.find(Workspace.all.first.id)
|
28
|
+
workspace.must_be_instance_of Workspace
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#create' do
|
33
|
+
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
34
|
+
workspace = Workspace.new
|
35
|
+
lambda { workspace.save }.must_raise ActiveResource::MethodNotAllowed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
25
39
|
describe '#create_task' do
|
26
40
|
it 'should create a new task for the given workspace' do
|
27
41
|
workspace = Workspace.all.first
|
28
|
-
task = workspace.create_task(:name => '
|
29
|
-
task.must_be_instance_of
|
42
|
+
task = workspace.create_task(:name => 'this is it', :assignee => 'me')
|
43
|
+
task.must_be_instance_of Task
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#update' do
|
48
|
+
it 'should update the given workspace with a new name' do
|
49
|
+
workspace = Workspace.all.last
|
50
|
+
workspace.update_attribute(:name, 'foo')
|
51
|
+
workspace.name.must_equal 'foo'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#destroy' do
|
56
|
+
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
57
|
+
workspace = Workspace.all.first
|
58
|
+
lambda { workspace.destroy }.must_raise ActiveResource::MethodNotAllowed
|
30
59
|
end
|
31
60
|
end
|
32
61
|
|
@@ -58,19 +87,5 @@ module Asana
|
|
58
87
|
end
|
59
88
|
end
|
60
89
|
|
61
|
-
describe '#create' do
|
62
|
-
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
63
|
-
workspace = Workspace.new
|
64
|
-
lambda { workspace.save }.must_raise ActiveResource::MethodNotAllowed
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#destroy' do
|
69
|
-
it 'should raise an ActiveResource::MethodNotAllowed exception' do
|
70
|
-
workspace = Workspace.all.first
|
71
|
-
lambda { workspace.destroy }.must_raise ActiveResource::MethodNotAllowed
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
90
|
end
|
76
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 2.12.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.9.2.2
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.9.2.2
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: vcr
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|