asana 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -89,6 +89,9 @@ users = workspace.users
89
89
 
90
90
  # Create a new task in a given workspace and assign it to the current user
91
91
  workspace.create_task(:name => 'Get milk from the grocery store')
92
+
93
+ # Create a new project in a given workspace, current user as a watcher
94
+ workspace.create_project(:name => 'Upgrade Asana gem')
92
95
  ```
93
96
 
94
97
  ### [Projects][]
@@ -109,6 +112,9 @@ project = Asana::Project.find(:project_id)
109
112
  # Get all projects in a given workspace
110
113
  workspace = Asana::Workspace.find(:workspace_id)
111
114
  projects = workspace.projects
115
+
116
+ # Change the name of a project
117
+ project.modify(:name => 'New project name')
112
118
  ```
113
119
 
114
120
  ### [Tasks][]
@@ -136,6 +142,9 @@ workspace.create_task(:name => 'Get milk from the grocery store')
136
142
 
137
143
  # Create a new story for the given task
138
144
  task.create_story(story_settings)
145
+
146
+ # Add a project to the task (tasks can be in multiple projects)
147
+ task.add_project(project.id)
139
148
  ```
140
149
 
141
150
  ### [Stories][]
@@ -156,8 +165,9 @@ stories = task.stories
156
165
  # Get a specific story
157
166
  story = Story.find(:story_id)
158
167
 
159
- # Create a new story for the given task
168
+ # Create a new story for the given task/project
160
169
  task.create_story(story_settings)
170
+ project.create_story(story_settings)
161
171
  ```
162
172
 
163
173
  ## Contributing
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
@@ -18,5 +18,18 @@ module Asana
18
18
  Task.all_by_project(:params => { :project_id => self.id })
19
19
  end
20
20
 
21
+ def modify(modified_fields)
22
+ resource = Resource.new(modified_fields)
23
+ response = Project.put(self.id, nil, resource.to_json)
24
+ Project.new(connection.format.decode(response.body))
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
+
21
34
  end
22
35
  end
@@ -11,10 +11,23 @@ module Asana
11
11
  all(*args)
12
12
  end
13
13
 
14
+ def modify(modified_fields)
15
+ resource = Resource.new(modified_fields)
16
+ response = Task.put(self.id, nil, resource.to_json)
17
+ Task.new(connection.format.decode(response.body))
18
+ end
19
+
14
20
  def projects
15
21
  Project.all_by_task(:params => { :task_id => self.id })
16
22
  end
17
23
 
24
+ def add_project(project_id)
25
+ path = "#{self.id}/addProject"
26
+ resource = Resource.new({:project => project_id})
27
+ Task.post(path, nil, resource.to_json)
28
+ self
29
+ end
30
+
18
31
  def create_story(*args)
19
32
  path = "#{self.id}/stories"
20
33
  options = { :task => self.id }
@@ -8,6 +8,13 @@ module Asana
8
8
  Project.all_by_workspace(:params => { :workspace_id => self.id })
9
9
  end
10
10
 
11
+ def create_project(*args)
12
+ options = { :workspace => self.id }
13
+ project = Project.new(options.merge(args.first))
14
+ response = Project.post(nil, nil, project.to_json)
15
+ Project.new(connection.format.decode(response.body))
16
+ end
17
+
11
18
  def tasks(assignee)
12
19
  query_options = { :workspace => self.id, :assignee => assignee }
13
20
  Task.all_by_workspace(:params => query_options)
@@ -1,3 +1,3 @@
1
1
  module Asana
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../../spec_helper'
2
2
 
3
3
  module Asana
4
4
  describe Project do
@@ -43,12 +43,10 @@ module Asana
43
43
  end
44
44
  end
45
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'
46
+ describe '#modify' do
47
+ it 'should modify the given project with a new name' do
48
+ project = Workspace.all.first.create_project(:name => 'asana-test-project-foo')
49
+ project.modify(:name => 'asana-test-project-bar').name.must_equal 'asana-test-project-bar'
52
50
  end
53
51
  end
54
52
 
@@ -61,5 +59,13 @@ module Asana
61
59
  end
62
60
  end
63
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
+
64
70
  end
65
71
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../../spec_helper'
2
2
 
3
3
  module Asana
4
4
  describe Story do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../../spec_helper'
2
2
 
3
3
  module Asana
4
4
  describe Task do
@@ -21,11 +21,10 @@ module Asana
21
21
  end
22
22
  end
23
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'
24
+ describe '#modify' do
25
+ it 'should modify the given task with a new name' do
26
+ task = Workspace.all.first.create_task(:name => 'asana-test-foo', :assignee => 'me')
27
+ task.modify(:name => 'asana-test-bar').name.must_equal 'asana-test-bar'
29
28
  end
30
29
  end
31
30
 
@@ -38,6 +37,14 @@ module Asana
38
37
  end
39
38
  end
40
39
 
40
+ describe '#add_project' do
41
+ it 'should add the project to the given task' do
42
+ task = Workspace.all.first.create_task(:name => 'asana-test-task-add-project', :assignee => 'me')
43
+ project = Workspace.all.first.create_project(:name => 'asana-test-task-parent-project')
44
+ task.add_project project.id
45
+ end
46
+ end
47
+
41
48
  describe '#create_story' do
42
49
  it 'should create a new story for the given task' do
43
50
  task = Project.all.first.tasks.first
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../../spec_helper'
2
2
 
3
3
  module Asana
4
4
  describe User do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../../spec_helper'
2
2
 
3
3
  module Asana
4
4
  describe Workspace do
@@ -39,11 +39,19 @@ module Asana
39
39
  describe '#create_task' do
40
40
  it 'should create a new task for the given workspace' do
41
41
  workspace = Workspace.all.first
42
- task = workspace.create_task(:name => 'this is it', :assignee => 'me')
42
+ task = workspace.create_task(:name => 'asana-test-task', :assignee => 'me')
43
43
  task.must_be_instance_of Task
44
44
  end
45
45
  end
46
46
 
47
+ describe '#create_project' do
48
+ it 'should create a new project for the given workspace' do
49
+ workspace = Workspace.all.first
50
+ project = workspace.create_project(:name => 'asana-test-project')
51
+ project.must_be_instance_of Project
52
+ end
53
+ end
54
+
47
55
  describe '#update' do
48
56
  it 'should update the given workspace with a new name' do
49
57
  workspace = Workspace.all.last
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.3
4
+ version: 0.0.4
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-24 00:00:00.000000000 Z
12
+ date: 2012-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  requirements: []
174
174
  rubyforge_project:
175
- rubygems_version: 1.8.21
175
+ rubygems_version: 1.8.23
176
176
  signing_key:
177
177
  specification_version: 3
178
178
  summary: Ruby wrapper for the Asana REST API