asana-ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/asana.gemspec +1 -1
- data/lib/asana/resources/tag.rb +3 -1
- data/lib/asana/resources/task.rb +1 -1
- data/lib/asana/resources/workspace.rb +27 -5
- data/lib/asana/version.rb +1 -1
- data/spec/asana/resources/project_spec.rb +2 -3
- data/spec/asana/resources/tag_spec.rb +17 -0
- data/spec/asana/resources/task_spec.rb +1 -2
- data/spec/asana/resources/user_spec.rb +1 -2
- data/spec/asana/resources/workspace_spec.rb +45 -7
- data/spec/spec_helper.rb +2 -4
- metadata +71 -50
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fcb87ac5035e40cf6275846cbeb6eb1d2bfa544c
|
4
|
+
data.tar.gz: 64791fb64e5711bd87b63eec22392c4a24fb3fc1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dab1fb334f808dd446e96b13a7f3bab3d02cfe76d6bde00934d0eeed21ff58e6a21c78e79408156ba0a96b0394989c5a909d32ff7e383e178f1eb0bf94b249be
|
7
|
+
data.tar.gz: f117a8d20c4e1de00c7544050183183f29187b23797017ef99e761d8c73e70401b110cd4ab430d54a8eb3329af2dc7616032a510918d3ac45cb2ecf759a605a2
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
asana-ruby
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/asana.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_development_dependency 'rspec', '~> 2.11'
|
22
22
|
gem.add_development_dependency 'guard'
|
23
23
|
gem.add_development_dependency 'guard-rspec'
|
24
|
-
gem.add_development_dependency 'vcr', '
|
24
|
+
gem.add_development_dependency 'vcr', '2.6.0'
|
25
25
|
gem.add_development_dependency 'webmock', '~> 1.8.8'
|
26
26
|
gem.add_development_dependency 'pry'
|
27
27
|
gem.add_development_dependency 'pry-debugger'
|
data/lib/asana/resources/tag.rb
CHANGED
data/lib/asana/resources/task.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'pry'
|
2
1
|
module Asana
|
3
2
|
class Workspace < Asana::Resource
|
4
3
|
def create_task(options = {})
|
@@ -20,24 +19,47 @@ module Asana
|
|
20
19
|
def tasks(options = {})
|
21
20
|
options.merge!(assignee: 'me') unless options[:assignee] or options['assignee']
|
22
21
|
|
23
|
-
|
22
|
+
url = "tasks?assignee=#{options[:assignee]}"
|
23
|
+
|
24
|
+
url += "&include_archived=true" if options[:include_archived]
|
25
|
+
|
26
|
+
get(url).map { |h| Asana::Task.find h["id"] }
|
24
27
|
rescue Exception => e
|
25
28
|
$stderr.puts "ERROR: #{e.message}"
|
26
29
|
$stderr.puts "RESPONSE: #{e.response.body}" if e.respond_to?(:response)
|
27
30
|
end
|
28
31
|
|
32
|
+
def completed_tasks
|
33
|
+
tasks.select(&:completed?)
|
34
|
+
end
|
35
|
+
|
29
36
|
# TODO imporve this when Asana API is more advanced
|
30
37
|
def find_or_create_tag(options = {})
|
31
|
-
|
38
|
+
options[:name].strip! if options[:name]
|
39
|
+
|
40
|
+
# try to load from cache first, if not found, force reload, if still not found, create one
|
41
|
+
find_tag_from_list(tags, options) || find_tag_from_list(tags(true), options) || create_tag(options)
|
32
42
|
end
|
33
43
|
|
34
44
|
def create_tag(options = {})
|
35
45
|
response = post("tags", nil, {data: options}.to_json)
|
36
|
-
Asana::Tag.new(connection.format.decode(response.body))
|
46
|
+
Asana::Tag.new(connection.format.decode(response.body), true)
|
37
47
|
end
|
38
48
|
|
39
|
-
|
49
|
+
# Resource.new(record, true) is the trick to initialize a persisted record
|
50
|
+
def tags(force_reload = false)
|
51
|
+
return @tags if defined?(@tags) and !force_reload
|
52
|
+
@tags ||= get(:tags).map{|h| Asana::Tag.new(h, true)}
|
53
|
+
end
|
54
|
+
|
55
|
+
# expensive query: reload each task by id
|
56
|
+
# only use this if Asana::Tag.new(tag, true) doesn't work as expected
|
57
|
+
def load_tags_by_id
|
40
58
|
get(:tags).map{|h| Asana::Tag.find h["id"]}
|
41
59
|
end
|
60
|
+
|
61
|
+
def find_tag_from_list(tag_list, options = {})
|
62
|
+
tag_list.find {|t| t.name && options[:name] && t.name.strip == options[:name] }
|
63
|
+
end
|
42
64
|
end
|
43
65
|
end
|
data/lib/asana/version.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Asana
|
4
|
-
describe Project do
|
5
|
-
use_vcr_cassette
|
4
|
+
describe Project, vcr: true do
|
6
5
|
before do
|
7
6
|
authorize_with_asana
|
8
7
|
end
|
@@ -10,7 +9,7 @@ module Asana
|
|
10
9
|
describe '.all' do
|
11
10
|
it 'should return all of the user\'s projects' do
|
12
11
|
projects = Project.all
|
13
|
-
projects.should be_instance_of
|
12
|
+
projects.should be_instance_of ActiveResource::Collection
|
14
13
|
projects.first.should be_instance_of Project
|
15
14
|
end
|
16
15
|
end
|
@@ -2,6 +2,23 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Asana
|
4
4
|
describe Tag do
|
5
|
+
describe "#tasks" do
|
6
|
+
let(:tag) { Tag.new }
|
5
7
|
|
8
|
+
before do
|
9
|
+
Asana.configure do |nothing|
|
10
|
+
end
|
11
|
+
|
12
|
+
tag.stub(:id).and_return("1234")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should get the info from /tags/<tag id>/tasks" do
|
16
|
+
fake_response = double("response", body: "{}")
|
17
|
+
fake_connection = double("ActiveResource::Connection")
|
18
|
+
expect(fake_connection).to receive(:get).with("/api/1.0/tags/1234/tasks", anything()).and_return(fake_response)
|
19
|
+
expect(tag).to receive(:connection).and_return(fake_connection)
|
20
|
+
tag.tasks
|
21
|
+
end
|
22
|
+
end
|
6
23
|
end
|
7
24
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Asana
|
4
|
-
describe Workspace do
|
5
|
-
use_vcr_cassette
|
4
|
+
describe Workspace, vcr: true do
|
6
5
|
before do
|
7
6
|
authorize_with_asana
|
8
7
|
end
|
@@ -40,25 +39,64 @@ module Asana
|
|
40
39
|
it "should return task instances" do
|
41
40
|
workspace.tasks.first.should be_instance_of Task
|
42
41
|
end
|
42
|
+
|
43
|
+
context "with include_archived set to true in options" do
|
44
|
+
it "should pass the option as part of the query string for the API endpoint" do
|
45
|
+
stub_request(:any, "app.asana.com")
|
46
|
+
workspace.tasks(include_archived: true)
|
47
|
+
|
48
|
+
to_url = %r{app.asana.com/api/1.0/workspaces/#{workspace.id}/tasks}
|
49
|
+
a_request(:get, to_url).with(
|
50
|
+
query: hash_including({include_archived: 'true'})
|
51
|
+
).should have_been_made
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe ".completed_tasks" do
|
57
|
+
it "returns only completed tasks" do
|
58
|
+
expect(workspace.completed_tasks.all?(&:completed)).to be
|
59
|
+
end
|
43
60
|
end
|
44
61
|
|
45
62
|
describe "tags" do
|
63
|
+
let(:fake_tag) { double("Asana::Tag", name: "Test") }
|
64
|
+
|
46
65
|
subject { workspace }
|
47
66
|
its(:tags) { should be_instance_of Array }
|
48
67
|
it "should return task instances" do
|
49
68
|
workspace.tags.first.should be_instance_of Tag
|
50
69
|
end
|
70
|
+
|
71
|
+
it "should memoize tags" do
|
72
|
+
expect(Asana::Tag).to receive(:new).and_return(fake_tag)
|
73
|
+
Asana::Tag.stub(:new).and_return(fake_tag)
|
74
|
+
expect(workspace).to receive(:get).once.and_return([fake_tag])
|
75
|
+
workspace.tags # first time
|
76
|
+
workspace.tags # second time
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should return the same result with force_reload (if no changes)" do
|
80
|
+
expect(workspace.tags.size).to be > 0 # it'd be meaningless to compare if there are no tags
|
81
|
+
expect(workspace.tags).to eq workspace.tags(true)
|
82
|
+
end
|
51
83
|
end
|
52
84
|
|
53
85
|
describe ".find_or_create_tag" do
|
86
|
+
let(:fake_tag) { double("Asana::Tag", name: "Test") }
|
87
|
+
|
88
|
+
before do
|
89
|
+
expect(workspace).to receive(:tags).at_least(:once).and_return([fake_tag])
|
90
|
+
end
|
91
|
+
|
54
92
|
it "should not create two tags of the same name" do
|
55
|
-
|
56
|
-
|
57
|
-
tag1.id.should == tag2.id
|
93
|
+
test_tag = workspace.find_or_create_tag(name: "Test")
|
94
|
+
expect(test_tag).to be(fake_tag)
|
58
95
|
end
|
59
96
|
|
60
|
-
it "should
|
61
|
-
|
97
|
+
it "should create a tag that doesn't yet exist" do
|
98
|
+
new_tag = workspace.find_or_create_tag(name: "Nope")
|
99
|
+
expect(new_tag).to be_instance_of(Asana::Tag)
|
62
100
|
end
|
63
101
|
end
|
64
102
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'asana'
|
2
|
+
require 'webmock/rspec'
|
2
3
|
require 'vcr'
|
3
4
|
require 'active_resource'
|
4
5
|
|
@@ -6,10 +7,7 @@ VCR.configure do |c|
|
|
6
7
|
c.cassette_library_dir = 'spec/fixtures/cassettes'
|
7
8
|
c.hook_into :webmock
|
8
9
|
c.default_cassette_options = { :record => :new_episodes }
|
9
|
-
|
10
|
-
|
11
|
-
RSpec.configure do |c|
|
12
|
-
c.extend VCR::RSpec::Macros
|
10
|
+
c.configure_rspec_metadata!
|
13
11
|
end
|
14
12
|
|
15
13
|
def authorize_with_asana
|
metadata
CHANGED
@@ -1,115 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asana-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Harley Trung
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activeresource
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rake
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rspec
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
45
|
- - ~>
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '2.11'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.11'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: guard
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: guard-rspec
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - '>='
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: vcr
|
71
|
-
requirement:
|
72
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
73
86
|
requirements:
|
74
|
-
- -
|
87
|
+
- - '='
|
75
88
|
- !ruby/object:Gem::Version
|
76
|
-
version: 2.
|
89
|
+
version: 2.6.0
|
77
90
|
type: :development
|
78
91
|
prerelease: false
|
79
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.6.0
|
80
97
|
- !ruby/object:Gem::Dependency
|
81
98
|
name: webmock
|
82
|
-
requirement:
|
83
|
-
none: false
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
84
100
|
requirements:
|
85
101
|
- - ~>
|
86
102
|
- !ruby/object:Gem::Version
|
87
103
|
version: 1.8.8
|
88
104
|
type: :development
|
89
105
|
prerelease: false
|
90
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.8.8
|
91
111
|
- !ruby/object:Gem::Dependency
|
92
112
|
name: pry
|
93
|
-
requirement:
|
94
|
-
none: false
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
95
114
|
requirements:
|
96
|
-
- -
|
115
|
+
- - '>='
|
97
116
|
- !ruby/object:Gem::Version
|
98
117
|
version: '0'
|
99
118
|
type: :development
|
100
119
|
prerelease: false
|
101
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
102
125
|
- !ruby/object:Gem::Dependency
|
103
126
|
name: pry-debugger
|
104
|
-
requirement:
|
105
|
-
none: false
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
106
128
|
requirements:
|
107
|
-
- -
|
129
|
+
- - '>='
|
108
130
|
- !ruby/object:Gem::Version
|
109
131
|
version: '0'
|
110
132
|
type: :development
|
111
133
|
prerelease: false
|
112
|
-
version_requirements:
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
113
139
|
description: Ruby API wrapper for Asana, supporting workspaces, projects, tasks, tags,
|
114
140
|
users and stories
|
115
141
|
email:
|
@@ -119,6 +145,8 @@ extensions: []
|
|
119
145
|
extra_rdoc_files: []
|
120
146
|
files:
|
121
147
|
- .gitignore
|
148
|
+
- .ruby-gemset
|
149
|
+
- .ruby-version
|
122
150
|
- Gemfile
|
123
151
|
- Guardfile
|
124
152
|
- LICENSE
|
@@ -146,33 +174,26 @@ files:
|
|
146
174
|
- spec/spec_helper.rb
|
147
175
|
homepage: ''
|
148
176
|
licenses: []
|
177
|
+
metadata: {}
|
149
178
|
post_install_message:
|
150
179
|
rdoc_options: []
|
151
180
|
require_paths:
|
152
181
|
- lib
|
153
182
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
183
|
requirements:
|
156
|
-
- -
|
184
|
+
- - '>='
|
157
185
|
- !ruby/object:Gem::Version
|
158
186
|
version: '0'
|
159
|
-
segments:
|
160
|
-
- 0
|
161
|
-
hash: 4158906422461001836
|
162
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
188
|
requirements:
|
165
|
-
- -
|
189
|
+
- - '>='
|
166
190
|
- !ruby/object:Gem::Version
|
167
191
|
version: '0'
|
168
|
-
segments:
|
169
|
-
- 0
|
170
|
-
hash: 4158906422461001836
|
171
192
|
requirements: []
|
172
193
|
rubyforge_project:
|
173
|
-
rubygems_version:
|
194
|
+
rubygems_version: 2.0.3
|
174
195
|
signing_key:
|
175
|
-
specification_version:
|
196
|
+
specification_version: 4
|
176
197
|
summary: Ruby wrapper for Asana
|
177
198
|
test_files:
|
178
199
|
- spec/asana/asana_spec.rb
|