ruby-trello-wgibbs 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/README.md +37 -0
  2. data/lib/trello/action.rb +46 -0
  3. data/lib/trello/association.rb +11 -0
  4. data/lib/trello/association_proxy.rb +42 -0
  5. data/lib/trello/authorization.rb +114 -0
  6. data/lib/trello/basic_data.rb +84 -0
  7. data/lib/trello/board.rb +95 -0
  8. data/lib/trello/card.rb +162 -0
  9. data/lib/trello/checklist.rb +82 -0
  10. data/lib/trello/client.rb +49 -0
  11. data/lib/trello/has_actions.rb +9 -0
  12. data/lib/trello/item.rb +18 -0
  13. data/lib/trello/item_state.rb +23 -0
  14. data/lib/trello/label.rb +19 -0
  15. data/lib/trello/list.rb +71 -0
  16. data/lib/trello/member.rb +93 -0
  17. data/lib/trello/multi_association.rb +10 -0
  18. data/lib/trello/net.rb +37 -0
  19. data/lib/trello/notification.rb +48 -0
  20. data/lib/trello/organization.rb +47 -0
  21. data/lib/trello/string.rb +36 -0
  22. data/lib/trello/token.rb +24 -0
  23. data/lib/trello.rb +83 -0
  24. data/spec/action_spec.rb +71 -0
  25. data/spec/basic_auth_policy_spec.rb +56 -0
  26. data/spec/board_spec.rb +196 -0
  27. data/spec/card_spec.rb +213 -0
  28. data/spec/checklist_spec.rb +50 -0
  29. data/spec/client_spec.rb +131 -0
  30. data/spec/integration/how_to_authorize_spec.rb +53 -0
  31. data/spec/integration/how_to_use_boards_spec.rb +48 -0
  32. data/spec/integration/integration_test.rb +40 -0
  33. data/spec/item_spec.rb +27 -0
  34. data/spec/item_state_spec.rb +0 -0
  35. data/spec/list_spec.rb +50 -0
  36. data/spec/member_spec.rb +92 -0
  37. data/spec/notification_spec.rb +83 -0
  38. data/spec/oauth_policy_spec.rb +93 -0
  39. data/spec/organization_spec.rb +26 -0
  40. data/spec/spec_helper.rb +244 -0
  41. data/spec/string_spec.rb +50 -0
  42. data/spec/token_spec.rb +33 -0
  43. metadata +220 -0
@@ -0,0 +1,244 @@
1
+ require 'rubygems'
2
+ unless defined? Rubinius
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ end
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ begin
9
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
10
+ require 'bundler'
11
+ Bundler.setup
12
+ rescue Bundler::GemNotFound => e
13
+ STDERR.puts e.message
14
+ STDERR.puts "Try running `bundle install`."
15
+ exit!
16
+ end
17
+
18
+ Bundler.require(:spec)
19
+
20
+ require 'trello'
21
+ require 'webmock/rspec'
22
+ require 'stringio'
23
+
24
+ $strio = StringIO.new
25
+ Trello.logger = Logger.new($strio)
26
+
27
+ RSpec.configure do |c|
28
+ c.filter_run_excluding :broken => true
29
+ end
30
+
31
+ module Helpers
32
+ def user_details
33
+ {
34
+ "id" => "abcdef123456789012345678",
35
+ "fullName" => "Test User",
36
+ "username" => "me",
37
+ "avatarHash" => "abcdef1234567890abcdef1234567890",
38
+ "bio" => "a rather dumb user",
39
+ "url" => "https://trello.com/me"
40
+ }
41
+ end
42
+
43
+ def user_payload
44
+ JSON.generate(user_details)
45
+ end
46
+
47
+ def boards_details
48
+ [{
49
+ "id" => "abcdef123456789123456789",
50
+ "name" => "Test",
51
+ "desc" => "This is a test board",
52
+ "closed" => false,
53
+ "idOrganization" => "abcdef123456789123456789",
54
+ "url" => "https://trello.com/board/test/abcdef123456789123456789"
55
+ }]
56
+ end
57
+
58
+ def boards_payload
59
+ JSON.generate(boards_details)
60
+ end
61
+
62
+ def checklists_details
63
+ [{
64
+ "id" => "abcdef123456789123456789",
65
+ "name" => "Test Checklist",
66
+ "desc" => "A marvelous little checklist",
67
+ "closed" => false,
68
+ "url" => "https://trello.com/blah/blah",
69
+ "idBoard" => "abcdef123456789123456789",
70
+ "idMembers" => ["abcdef123456789123456789"],
71
+ "checkItems" => {}
72
+ }]
73
+ end
74
+
75
+ def checklists_payload
76
+ JSON.generate(checklists_details)
77
+ end
78
+
79
+ def lists_details
80
+ [{
81
+ "id" => "abcdef123456789123456789",
82
+ "name" => "To Do",
83
+ "closed" => false,
84
+ "idBoard" => "abcdef123456789123456789",
85
+ "cards" => cards_details
86
+ }]
87
+ end
88
+
89
+ def lists_payload
90
+ JSON.generate(lists_details)
91
+ end
92
+
93
+ def cards_details
94
+ [{
95
+ "id" => "abcdef123456789123456789",
96
+ "idShort" => "1",
97
+ "name" => "Do something awesome",
98
+ "desc" => "Awesome things are awesome.",
99
+ "closed" => false,
100
+ "idList" => "abcdef123456789123456789",
101
+ "idBoard" => "abcdef123456789123456789",
102
+ "idMembers" => ["abcdef123456789123456789"],
103
+ "url" => "https://trello.com/card/board/specify-the-type-and-scope-of-the-jit-in-a-lightweight-spec/abcdef123456789123456789/abcdef123456789123456789"
104
+ }]
105
+ end
106
+
107
+ def cards_payload
108
+ JSON.generate(cards_details)
109
+ end
110
+
111
+ def orgs_details
112
+ [{
113
+ "id" => "abcdef123456789123456789",
114
+ "name" => "test",
115
+ "displayName" => "Test Organization",
116
+ "desc" => "This is a test organization",
117
+ "url" => "https://trello.com/test"
118
+ }]
119
+ end
120
+
121
+ def orgs_payload
122
+ JSON.generate(orgs_details)
123
+ end
124
+
125
+ def actions_details
126
+ [{
127
+ "id" => "4ee2482134a81a757a08af47",
128
+ "idMemberCreator" => "abcdef123456789123456789",
129
+ "data"=> {
130
+ "card" => {
131
+ "id" => "4ee2482134a81a757a08af45",
132
+ "name" => "Bytecode outputter"
133
+ },
134
+ "board" => {
135
+ "id" => "4ec54f2f73820a0dea0d1f0e",
136
+ "name" => "Caribou VM"
137
+ },
138
+ "list" => {
139
+ "id" => "4ee238b034a81a757a05cda0",
140
+ "name" => "Assembler"
141
+ }
142
+ },
143
+ "date" => "2012-02-10T11:32:17Z",
144
+ "type" => "createCard"
145
+ }]
146
+ end
147
+
148
+ def actions_payload
149
+ JSON.generate(actions_details)
150
+ end
151
+
152
+ def notification_details
153
+ {
154
+ "id" => "4f30d084d5b0f7ab453bee51",
155
+ "unread" => false,
156
+ "type" => "commentCard",
157
+ "date" => "2012-02-07T07:19:32.393Z",
158
+ "data" => {
159
+ "board" => {
160
+ "id" => "abcdef123456789123456789",
161
+ "name" => "Test"
162
+ },
163
+ "card"=>{
164
+ "id" => "abcdef123456789123456789",
165
+ "name" => "Do something awesome"
166
+ },
167
+ "text" => "test"
168
+ },
169
+ "idMemberCreator" => "abcdef123456789012345678"
170
+ }
171
+ end
172
+
173
+ def notification_payload
174
+ JSON.generate(notification_details)
175
+ end
176
+
177
+ def organization_details
178
+ {
179
+ "id" => "4ee7e59ae582acdec8000291",
180
+ "name" => "publicorg",
181
+ "desc" => "This is a test organization",
182
+ "members" => [{
183
+ "id" => "4ee7df3ce582acdec80000b2",
184
+ "username" => "alicetester",
185
+ "fullName" => "Alice Tester"
186
+ }, {
187
+ "id" => "4ee7df74e582acdec80000b6",
188
+ "username" => "davidtester",
189
+ "fullName" => "David Tester"
190
+ }, {
191
+ "id" => "4ee7e2e1e582acdec8000112",
192
+ "username" => "edtester",
193
+ "fullName" => "Ed Tester"
194
+ }]
195
+ }
196
+ end
197
+
198
+ def organization_payload
199
+ JSON.generate(organization_details)
200
+ end
201
+
202
+ def token_details
203
+ {
204
+ "id" => "4f2c10c7b3eb95a45b294cd5",
205
+ "idMember" => "abcdef123456789123456789",
206
+ "dateCreated" => "2012-02-03T16:52:23.661Z",
207
+ "permissions" => [
208
+ {
209
+ "idModel" => "me",
210
+ "modelType" => "Member",
211
+ "read" => true,
212
+ "write" => true
213
+ },
214
+ {
215
+ "idModel" => "*",
216
+ "modelType" => "Board",
217
+ "read" => true,
218
+ "write" => true
219
+ },
220
+ {
221
+ "idModel" => "*",
222
+ "modelType" => "Organization",
223
+ "read" => true,
224
+ "write" => true
225
+ }
226
+ ]
227
+ }
228
+ end
229
+
230
+ def token_payload
231
+ JSON.generate(token_details)
232
+ end
233
+
234
+ def label_details
235
+ [
236
+ {"color" => "yellow", "name" => "iOS"},
237
+ {"color" => "purple", "name" => "Issue or bug"}
238
+ ]
239
+ end
240
+
241
+ def label_payload
242
+ JSON.generate(label_details)
243
+ end
244
+ end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+ require "trello/string"
3
+
4
+ describe String, "#json_into" do
5
+ include Helpers
6
+
7
+ def example_class
8
+ @example_class ||= Class.new do
9
+ attr_accessor :name, :description
10
+
11
+ def initialize(options = {})
12
+ @name = options['name']
13
+ @description = options['description']
14
+ end
15
+ end
16
+ end
17
+
18
+ it "converts json into an instance of a class" do
19
+ "{}".json_into(example_class).should be_an_instance_of example_class
20
+ end
21
+
22
+ it "supplies the parsed json to the class's ctor as a hash" do
23
+ example_class.should_receive(:new).once.with({
24
+ "name" => "Jazz Kang",
25
+ "description" => "Plonker"
26
+ })
27
+
28
+ json_text = '{"name" : "Jazz Kang", "description": "Plonker"}'
29
+
30
+ json_text.json_into example_class
31
+ end
32
+
33
+ it "can also handle arrays of instances of a class" do
34
+ json_text = <<-JSON
35
+ [
36
+ {"name" : "Jazz Kang", "description": "Plonker"},
37
+ {"name" : "Phil Murphy", "description": "Shoreditch hipster"}
38
+ ]
39
+ JSON
40
+
41
+ result = json_text.json_into example_class
42
+
43
+ result.should be_an Array
44
+ result.size.should == 2
45
+ result.each do |parsed|
46
+ parsed.should be_an_instance_of example_class
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module Trello
4
+ describe Token do
5
+ include Helpers
6
+
7
+ before(:each) do
8
+ Client.stub(:get).with("/tokens/1234").and_return token_payload
9
+ @token = Token.find("1234")
10
+ end
11
+
12
+ context "attributes" do
13
+ it "has an id" do
14
+ @token.id.should == "4f2c10c7b3eb95a45b294cd5"
15
+ end
16
+
17
+ it "gets its created_at date" do
18
+ @token.created_at.should == Time.iso8601("2012-02-03T16:52:23.661Z")
19
+ end
20
+
21
+ it "has a permission grant" do
22
+ @token.permissions.count.should be 3
23
+ end
24
+ end
25
+
26
+ context "members" do
27
+ it "retrieves the member who authorized the token" do
28
+ Client.stub(:get).with("/members/abcdef123456789123456789").and_return user_payload
29
+ @token.member.should == Member.find("abcdef123456789123456789")
30
+ end
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-trello-wgibbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeremy Tregunna
9
+ - Wes Gibbs
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-02-14 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: oauth
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.4.5
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 0.4.5
31
+ - !ruby/object:Gem::Dependency
32
+ name: addressable
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 2.2.6
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 2.2.6
47
+ - !ruby/object:Gem::Dependency
48
+ name: rest-client
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.7
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 1.6.7
63
+ - !ruby/object:Gem::Dependency
64
+ name: activemodel
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: bundler
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: 1.0.0
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: 1.0.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: 2.8.0
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.8.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ description: A wrapper around the trello.com API.
128
+ email: jeremy@tregunna.ca wesgibbs@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files:
132
+ - README.md
133
+ files:
134
+ - lib/trello/action.rb
135
+ - lib/trello/association.rb
136
+ - lib/trello/association_proxy.rb
137
+ - lib/trello/authorization.rb
138
+ - lib/trello/basic_data.rb
139
+ - lib/trello/board.rb
140
+ - lib/trello/card.rb
141
+ - lib/trello/checklist.rb
142
+ - lib/trello/client.rb
143
+ - lib/trello/has_actions.rb
144
+ - lib/trello/item.rb
145
+ - lib/trello/item_state.rb
146
+ - lib/trello/label.rb
147
+ - lib/trello/list.rb
148
+ - lib/trello/member.rb
149
+ - lib/trello/multi_association.rb
150
+ - lib/trello/net.rb
151
+ - lib/trello/notification.rb
152
+ - lib/trello/organization.rb
153
+ - lib/trello/string.rb
154
+ - lib/trello/token.rb
155
+ - lib/trello.rb
156
+ - README.md
157
+ - spec/action_spec.rb
158
+ - spec/basic_auth_policy_spec.rb
159
+ - spec/board_spec.rb
160
+ - spec/card_spec.rb
161
+ - spec/checklist_spec.rb
162
+ - spec/client_spec.rb
163
+ - spec/integration/how_to_authorize_spec.rb
164
+ - spec/integration/how_to_use_boards_spec.rb
165
+ - spec/integration/integration_test.rb
166
+ - spec/item_spec.rb
167
+ - spec/item_state_spec.rb
168
+ - spec/list_spec.rb
169
+ - spec/member_spec.rb
170
+ - spec/notification_spec.rb
171
+ - spec/oauth_policy_spec.rb
172
+ - spec/organization_spec.rb
173
+ - spec/spec_helper.rb
174
+ - spec/string_spec.rb
175
+ - spec/token_spec.rb
176
+ homepage: https://github.com/wgibbs/ruby-trello
177
+ licenses: []
178
+ post_install_message:
179
+ rdoc_options:
180
+ - --charset=UTF-8
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ! '>='
193
+ - !ruby/object:Gem::Version
194
+ version: 1.3.6
195
+ requirements: []
196
+ rubyforge_project: ruby-trello-wgibbs
197
+ rubygems_version: 1.8.24
198
+ signing_key:
199
+ specification_version: 3
200
+ summary: A wrapper around the trello.com API.
201
+ test_files:
202
+ - spec/action_spec.rb
203
+ - spec/basic_auth_policy_spec.rb
204
+ - spec/board_spec.rb
205
+ - spec/card_spec.rb
206
+ - spec/checklist_spec.rb
207
+ - spec/client_spec.rb
208
+ - spec/integration/how_to_authorize_spec.rb
209
+ - spec/integration/how_to_use_boards_spec.rb
210
+ - spec/integration/integration_test.rb
211
+ - spec/item_spec.rb
212
+ - spec/item_state_spec.rb
213
+ - spec/list_spec.rb
214
+ - spec/member_spec.rb
215
+ - spec/notification_spec.rb
216
+ - spec/oauth_policy_spec.rb
217
+ - spec/organization_spec.rb
218
+ - spec/spec_helper.rb
219
+ - spec/string_spec.rb
220
+ - spec/token_spec.rb