minmb-teambox-client 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/Gemfile +11 -0
  2. data/Gemfile.lock +54 -0
  3. data/History +6 -0
  4. data/License +20 -0
  5. data/README.rdoc +30 -0
  6. data/Rakefile +44 -0
  7. data/VERSION +1 -0
  8. data/examples/conversation.rb +12 -0
  9. data/examples/task.rb +17 -0
  10. data/examples/users.rb +19 -0
  11. data/lib/teambox-client/models/activity.rb +27 -0
  12. data/lib/teambox-client/models/comment.rb +55 -0
  13. data/lib/teambox-client/models/conversation.rb +26 -0
  14. data/lib/teambox-client/models/divider.rb +15 -0
  15. data/lib/teambox-client/models/invitation.rb +21 -0
  16. data/lib/teambox-client/models/membership.rb +15 -0
  17. data/lib/teambox-client/models/note.rb +15 -0
  18. data/lib/teambox-client/models/organization.rb +18 -0
  19. data/lib/teambox-client/models/page.rb +20 -0
  20. data/lib/teambox-client/models/page_slot.rb +16 -0
  21. data/lib/teambox-client/models/person.rb +19 -0
  22. data/lib/teambox-client/models/project.rb +52 -0
  23. data/lib/teambox-client/models/task.rb +66 -0
  24. data/lib/teambox-client/models/task_list.rb +26 -0
  25. data/lib/teambox-client/models/teambox_data.rb +16 -0
  26. data/lib/teambox-client/models/upload.rb +27 -0
  27. data/lib/teambox-client/models/user.rb +11 -0
  28. data/lib/teambox-client/reference_list.rb +49 -0
  29. data/lib/teambox-client/result_set.rb +72 -0
  30. data/lib/teambox-client/teambox.rb +288 -0
  31. data/lib/teambox-client/teambox_oauth.rb +37 -0
  32. data/lib/teambox-client.rb +8 -0
  33. data/minmb-teambox-client.gemspec +96 -0
  34. data/spec/client_spec.rb +17 -0
  35. data/spec/conversation_spec.rb +29 -0
  36. data/spec/project_spec.rb +11 -0
  37. data/spec/resource_spec.rb +77 -0
  38. data/spec/result_set_spec.rb +55 -0
  39. data/spec/spec_helper.rb +7 -0
  40. data/spec/task_lists_spec.rb +17 -0
  41. data/spec/tasks_spec.rb +18 -0
  42. metadata +251 -0
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe Teambox::Resource do
4
+
5
+ describe "with an attached result list" do
6
+ before do
7
+ @result_set = Teambox::ResultSet.new(nil, nil, [], [{'type' => 'User', 'id' => 1}, {'type' => 'User', 'id' => 2}])
8
+ @resource = Teambox::Resource.new({'id' => 123, 'user_id' => 1}, @result_set)
9
+ @data = {'user_id' => 1234}
10
+ @data_ids = {'user_ids' => [11,22,33],
11
+ 'users' => [{'type' => 'User', 'id' => 11, 'login' => 'tom'},
12
+ {'type' => 'User', 'id' => 22, 'login' => 'dick'},
13
+ {'type' => 'User', 'id' => 33, 'login' => 'harry'}]}
14
+ end
15
+
16
+ it "should use the reference list from the list" do
17
+ @resource.references.object_id.should == @result_set.references.object_id
18
+ end
19
+
20
+ it "should return a user reference from the list" do
21
+ @resource.get_reference('User', 1).class.should == Teambox::User
22
+ end
23
+
24
+ it "should set a reference" do
25
+ @resource.set_reference('User', {'id' => 3})
26
+ @resource.get_reference('User', 3).class.should == Teambox::User
27
+ end
28
+
29
+ it "should make a dummy reference" do
30
+ @resource.get_or_make_reference('User', @data, 'user_id').class.should == Teambox::User
31
+ end
32
+
33
+ it "should make many dummy references" do
34
+ @resource.get_or_make_references('User', @data_ids, 'user_ids').length.should == 3
35
+ end
36
+
37
+ it "should make many dummy references with dummy data" do
38
+ list = @resource.get_or_make_references('User', @data_ids, 'user_ids', 'users')
39
+ list.length.should == 3
40
+ list.map(&:login).sort.should == ['tom','dick','harry'].sort
41
+ end
42
+ end
43
+
44
+ describe "without an attached result list" do
45
+ before do
46
+ @resource = Teambox::Resource.new({'id' => 123, 'user_id' => 1, 'references' => [{'type' => 'User', 'id' => 1}, {'type' => 'User', 'id' => 2}]})
47
+ @data = {'user_id' => 1234}
48
+ @data_ids = {'user_ids' => [11,22,33],
49
+ 'users' => [{'type' => 'User', 'id' => 11, 'login' => 'tom'},
50
+ {'type' => 'User', 'id' => 22, 'login' => 'dick'},
51
+ {'type' => 'User', 'id' => 33, 'login' => 'harry'}]}
52
+ end
53
+
54
+ it "should return a user reference" do
55
+ @resource.get_reference('User', 1).class.should == Teambox::User
56
+ end
57
+
58
+ it "should set a reference" do
59
+ @resource.set_reference('User', {'id' => 3})
60
+ @resource.get_reference('User', 3).class.should == Teambox::User
61
+ end
62
+
63
+ it "should make a dummy reference" do
64
+ @resource.get_or_make_reference('User', @data, 'user_id').class.should == Teambox::User
65
+ end
66
+
67
+ it "should make many dummy references" do
68
+ @resource.get_or_make_references('User', @data_ids, 'user_ids').length.should == 3
69
+ end
70
+
71
+ it "should make many dummy references with dummy data" do
72
+ list = @resource.get_or_make_references('User', @data_ids, 'user_ids', 'users')
73
+ list.length.should == 3
74
+ list.map(&:login).sort.should == ['tom','dick','harry'].sort
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Teambox::ResultSet do
4
+ before do
5
+ @client = make_teambox_client
6
+ end
7
+
8
+ it "should be the result of getting a list of comments" do
9
+ list = @client.get('/projects/earthworks/comments')
10
+ list.class.should == Teambox::ResultSet
11
+ list.each { |c| c.class.should == Teambox::Comment }
12
+ list.first_id.should < list.last_id
13
+ end
14
+
15
+ it "should get older and newer comments" do
16
+ list = @client.get('/projects/earthworks/comments', {:count => 2})
17
+ list.length.should == 2
18
+
19
+ # older
20
+ prev_list = list.prev
21
+ prev_list.length.should == 2
22
+ prev_list.first_id.should < list.first_id
23
+
24
+ # newer
25
+ next_list = prev_list.next
26
+ next_list.length.should == 2
27
+ next_list.first_id.should > prev_list.first_id
28
+ next_list.first_id.should == list.first_id
29
+ end
30
+
31
+ it "should get all comments" do
32
+ comment_list = []
33
+ list = @client.get('/projects/earthworks/comments', {:count => 2})
34
+
35
+ while !list.empty?
36
+ list.each {|c| comment_list << c}
37
+ list = list.prev
38
+ end
39
+
40
+ comment_list.length.should > 10
41
+ uniq_comment_list = comment_list.map{ |c|c.id }.uniq
42
+ uniq_comment_list.length.should == comment_list.length
43
+ end
44
+
45
+ it "should get associated objects" do
46
+ list = @client.get('/projects/earthworks/comments')
47
+
48
+ list.each do |l|
49
+ l.user.class.should == Teambox::User
50
+ ([Teambox::Conversation, Teambox::Task].include?(l.target.class)).should == true
51
+ l.target.user_id.should_not == nil
52
+ l.target.user.class.should == Teambox::User
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ require 'lib/teambox-client'
2
+
3
+ TEAMBOX_SERVER = ENV["TEAMBOX_SERVER"] || "http://localhost:3000"
4
+
5
+ def make_teambox_client(user='frank')
6
+ Teambox::Client.new({:base_uri => "#{TEAMBOX_SERVER}/api/1", :auth => {:user => user, :password => 'papapa'}})
7
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Teambox::TaskList do
4
+ before do
5
+ @client = make_teambox_client
6
+ @project = @client.project('earthworks')
7
+ end
8
+
9
+ it "should query task lists" do
10
+ @project.task_lists.length.should_not == 0
11
+ end
12
+
13
+ it "should make a task list" do
14
+ conversation = @project.create_task_list({:name => 'CAPSLOCK CRITERIA'})
15
+ conversation.name.should == 'CAPSLOCK CRITERIA'
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Teambox::Task do
4
+ before do
5
+ @client = make_teambox_client
6
+ @project = @client.project('earthworks')
7
+ @task_list = @project.task_lists(:count => 1)[0]
8
+ end
9
+
10
+ it "should query tasks" do
11
+ @project.tasks.length.should_not == 0
12
+ end
13
+
14
+ it "should make a task" do
15
+ conversation = @project.create_task(@task_list, {:name => 'TELL EVERYONE ABOUT CAPSLOCK DAY'})
16
+ conversation.name.should == 'TELL EVERYONE ABOUT CAPSLOCK DAY'
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,251 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minmb-teambox-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Pablo Villalba
9
+ - James Urquhart
10
+ - Martin Häger
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2012-08-28 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: minmb-teambox-client
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: rspec
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ - !ruby/object:Gem::Dependency
81
+ name: rake
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: jeweler
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rspec
114
+ requirement: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ - !ruby/object:Gem::Dependency
129
+ name: httparty
130
+ requirement: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ~>
134
+ - !ruby/object:Gem::Version
135
+ version: 0.7.4
136
+ type: :runtime
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ version: 0.7.4
144
+ - !ruby/object:Gem::Dependency
145
+ name: oauth2
146
+ requirement: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ~>
150
+ - !ruby/object:Gem::Version
151
+ version: 0.1.1
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 0.1.1
160
+ - !ruby/object:Gem::Dependency
161
+ name: json
162
+ requirement: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ~>
166
+ - !ruby/object:Gem::Version
167
+ version: 1.5.1
168
+ type: :runtime
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ~>
174
+ - !ruby/object:Gem::Version
175
+ version: 1.5.1
176
+ description: Provides methods to read and write to Teambox for ruby apps
177
+ email: martin.hager@minmb.se
178
+ executables: []
179
+ extensions: []
180
+ extra_rdoc_files:
181
+ - README.rdoc
182
+ files:
183
+ - Gemfile
184
+ - Gemfile.lock
185
+ - History
186
+ - License
187
+ - README.rdoc
188
+ - Rakefile
189
+ - VERSION
190
+ - examples/conversation.rb
191
+ - examples/task.rb
192
+ - examples/users.rb
193
+ - lib/teambox-client.rb
194
+ - lib/teambox-client/models/activity.rb
195
+ - lib/teambox-client/models/comment.rb
196
+ - lib/teambox-client/models/conversation.rb
197
+ - lib/teambox-client/models/divider.rb
198
+ - lib/teambox-client/models/invitation.rb
199
+ - lib/teambox-client/models/membership.rb
200
+ - lib/teambox-client/models/note.rb
201
+ - lib/teambox-client/models/organization.rb
202
+ - lib/teambox-client/models/page.rb
203
+ - lib/teambox-client/models/page_slot.rb
204
+ - lib/teambox-client/models/person.rb
205
+ - lib/teambox-client/models/project.rb
206
+ - lib/teambox-client/models/task.rb
207
+ - lib/teambox-client/models/task_list.rb
208
+ - lib/teambox-client/models/teambox_data.rb
209
+ - lib/teambox-client/models/upload.rb
210
+ - lib/teambox-client/models/user.rb
211
+ - lib/teambox-client/reference_list.rb
212
+ - lib/teambox-client/result_set.rb
213
+ - lib/teambox-client/teambox.rb
214
+ - lib/teambox-client/teambox_oauth.rb
215
+ - minmb-teambox-client.gemspec
216
+ - spec/client_spec.rb
217
+ - spec/conversation_spec.rb
218
+ - spec/project_spec.rb
219
+ - spec/resource_spec.rb
220
+ - spec/result_set_spec.rb
221
+ - spec/spec_helper.rb
222
+ - spec/task_lists_spec.rb
223
+ - spec/tasks_spec.rb
224
+ homepage: http://github.com/minmb/teambox-ruby-client
225
+ licenses: []
226
+ post_install_message:
227
+ rdoc_options: []
228
+ require_paths:
229
+ - lib
230
+ required_ruby_version: !ruby/object:Gem::Requirement
231
+ none: false
232
+ requirements:
233
+ - - ! '>='
234
+ - !ruby/object:Gem::Version
235
+ version: '0'
236
+ segments:
237
+ - 0
238
+ hash: 3209666234866811690
239
+ required_rubygems_version: !ruby/object:Gem::Requirement
240
+ none: false
241
+ requirements:
242
+ - - ! '>='
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
245
+ requirements: []
246
+ rubyforge_project:
247
+ rubygems_version: 1.8.24
248
+ signing_key:
249
+ specification_version: 3
250
+ summary: A ruby gem wrapper for Teambox API
251
+ test_files: []