ruby-trello 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83302feba110fb6f1a0d44ef350f853bfbee2dda
4
- data.tar.gz: d1130c82f391fc9ee317a27efcfa7e24cca4333c
3
+ metadata.gz: 81baf76d9e58785fa9dc51f1d712b882b92db245
4
+ data.tar.gz: a73d11ce0d6308962b78802fdca44e60d5d84fec
5
5
  SHA512:
6
- metadata.gz: 6583fbca2e0d7e6c5ec70dab5128cc140c15292eefc4f793b0022fce03ea691d86bf38ad6651a44af924134d044b6a25c40cbcefbb3100cc0a116e04fa634eb4
7
- data.tar.gz: 388cff3c894fb1ca3f6e42892a2df385792484967503da6cd7992a05520f1177457ceee486d040165a2c5ed4c3a9052b7fb2283f036abf6701fff9c9d2201a38
6
+ metadata.gz: 9d99de48aaf068f1bd67db5d5f39fe8aa8b0fe04c40285b5775a0409048f75e0d17ddee6fa98a3d14f79b2319dd607feb30e0742fb79c562070463b4d7d3f648
7
+ data.tar.gz: 62a787fc187af9d034103afd7331bc3f74155750777c07e67aef1838ddb6581af853aef33f7633def4385643b83ba55d4af593aa6b1688a2ea4861366e20deb1
data/README.md CHANGED
@@ -8,6 +8,8 @@ This library implements the [Trello](http://www.trello.com/) [API](http://trello
8
8
  Trello is an awesome tool for organization. Not just aimed at developers, but everybody.
9
9
  Seriously, [check it out](http://www.trello.com/).
10
10
 
11
+ [Full API documentation](http://www.rubydoc.info/gems/ruby-trello).
12
+
11
13
  ## Installation
12
14
 
13
15
  ```
@@ -22,14 +24,22 @@ illustrate that future versions may include ruby 1.9.3+ specific features.
22
24
 
23
25
  ## Configuration
24
26
 
25
- Basic authorization
27
+ Basic authorization:
28
+
29
+ 1. Get your API keys from [trello.com/app-key](https://trello.com/app-key).
30
+ 2. Visit the URL [trello.com/1/authorize], with the following GET parameters:
31
+ - `key`: the API key you got in step 1.
32
+ - `response_type`: "token"
33
+ - `expiration`: "never" if you don't want your token to ever expire. If you leave this blank,
34
+ your generated token will expire after 30 days.
35
+ 3. You should see a page asking you to authorize your Trello application. Click "allow" and you should see a second page with a long alphanumeric string. This is your member token.
26
36
 
27
37
  ```ruby
28
38
  require 'trello'
29
39
 
30
40
  Trello.configure do |config|
31
- config.developer_public_key = TRELLO_DEVELOPER_PUBLIC_KEY
32
- config.member_token = TRELLO_MEMBER_TOKEN
41
+ config.developer_public_key = TRELLO_DEVELOPER_PUBLIC_KEY # The "key" from step 1
42
+ config.member_token = TRELLO_MEMBER_TOKEN # The token from step 3.
33
43
  end
34
44
  ```
35
45
 
@@ -10,6 +10,8 @@ module Trello
10
10
 
11
11
  class << self
12
12
  # Finds a board.
13
+ #
14
+ # @return [Trello::Board]
13
15
  def find(id, params = {})
14
16
  client.find(:board, id, params)
15
17
  end
@@ -23,6 +25,7 @@ module Trello
23
25
  client.create(:board, data)
24
26
  end
25
27
 
28
+ # @return [Array<Trello::Board>] all boards for the current user
26
29
  def all
27
30
  client.get("/members/#{Member.find(:me).username}/boards").json_into(self)
28
31
  end
@@ -45,9 +48,10 @@ module Trello
45
48
  @changed_attributes.clear
46
49
 
47
50
  client.put("/boards/#{self.id}/", {
48
- :name => attributes[:name],
49
- :description => attributes[:description],
50
- :closed => attributes[:closed]
51
+ :name => attributes[:name],
52
+ :description => attributes[:description],
53
+ :closed => attributes[:closed],
54
+ :idOrganization => attributes[:organization_id]
51
55
  }).json_into(self)
52
56
  end
53
57
 
@@ -62,14 +66,18 @@ module Trello
62
66
  self
63
67
  end
64
68
 
69
+ # @return [Boolean]
65
70
  def closed?
66
71
  attributes[:closed]
67
72
  end
68
73
 
74
+ # @return [Boolean]
69
75
  def has_lists?
70
76
  lists.size > 0
71
77
  end
72
78
 
79
+ # Find a card on this Board with the given ID.
80
+ # @return [Trello::Card]
73
81
  def find_card(card_id)
74
82
  client.get("/boards/#{self.id}/cards/#{card_id}").json_into(Card)
75
83
  end
@@ -211,9 +211,14 @@ module Trello
211
211
  MultiAssociation.new(self, labels).proxy
212
212
  end
213
213
 
214
+ # Label colours
215
+ def label_colours
216
+ %w{green yellow orange red purple blue sky lime pink black}
217
+ end
218
+
214
219
  # Add a label
215
220
  def add_label(colour)
216
- unless %w{green yellow orange red purple blue}.include? colour
221
+ unless label_colours.include? colour
217
222
  errors.add(:label, "colour '#{colour}' does not exist")
218
223
  return Trello.logger.warn "The label colour '#{colour}' does not exist."
219
224
  end
@@ -222,9 +227,9 @@ module Trello
222
227
 
223
228
  # Remove a label
224
229
  def remove_label(colour)
225
- unless %w{green yellow orange red purple blue}.include? colour
230
+ unless label_colours.include? colour
226
231
  errors.add(:label, "colour '#{colour}' does not exist")
227
- return Trello.logger.warn "The label colour '#{colour}' does not exist." unless %w{green yellow orange red purple blue}.include? colour
232
+ return Trello.logger.warn "The label colour '#{colour}' does not exist." unless label_colours.include? colour
228
233
  end
229
234
  client.delete("/cards/#{id}/labels/#{colour}")
230
235
  end
@@ -7,12 +7,21 @@ module Trello
7
7
  validates_length_of :description, :in => 1..16384
8
8
 
9
9
  class << self
10
- # Find a specific webhook by its id.
10
+ # Find a specific webhook by its ID.
11
+ #
12
+ # @raise [Trello::Error] if a Webhook with the given ID can't be found.
13
+ # @return [Trello::Webhook] the Webhook with the given ID.
11
14
  def find(id, params = {})
12
15
  client.find(:webhook, id, params)
13
16
  end
14
17
 
15
- # Create a new webhook and save it on Trello.
18
+ # Create a new webhook and save it to Trello.
19
+ #
20
+ # @param [Hash] options
21
+ # @option options [String] :description (optional) A string with a length from 0 to 16384
22
+ # @option options [String] :callback_url (required) A valid URL that is reachable with a HEAD request
23
+ # @option options [String] :id_model (required) id of the model that should be hooked
24
+ # @return [Trello::Webhook]
16
25
  def create(options)
17
26
  client.create(:webhook,
18
27
  'description' => options[:description],
@@ -21,6 +30,7 @@ module Trello
21
30
  end
22
31
  end
23
32
 
33
+ # return [Trello::Webhook] self
24
34
  def update_fields(fields)
25
35
  attributes[:id] = fields['id']
26
36
  attributes[:description] = fields['description']
@@ -56,6 +66,8 @@ module Trello
56
66
  end
57
67
 
58
68
  # Check if the webhook is activated
69
+ #
70
+ # @return [Boolean]
59
71
  def activated?
60
72
  active
61
73
  end
@@ -169,7 +169,7 @@ module Trello
169
169
  end
170
170
 
171
171
  it "puts all fields except id" do
172
- expected_fields = %w{ name description closed }.map { |s| s.to_sym }
172
+ expected_fields = %w{ name description closed idOrganization}.map { |s| s.to_sym }
173
173
 
174
174
  client.should_receive(:put) do |anything, body|
175
175
  body.keys.should =~ expected_fields
@@ -222,7 +222,8 @@ module Trello
222
222
  client.should_receive(:put).with("/boards/#{board.id}/", {
223
223
  :name => "new name",
224
224
  :description => "new description",
225
- :closed => true
225
+ :closed => true,
226
+ :idOrganization => nil
226
227
  }).and_return any_board_json
227
228
  board.update!
228
229
  end
@@ -51,7 +51,8 @@ module Trello
51
51
 
52
52
  result = JSON.generate(cards_details.first.merge(payload.merge(:idList => lists_details.first['id'])))
53
53
 
54
- expected_payload = {name: "Test Card", desc: nil, idList: "abcdef123456789123456789", idMembers: nil, labels: nil }
54
+ expected_payload = {name: "Test Card", desc: nil, idList: "abcdef123456789123456789",
55
+ idMembers: nil, labels: nil, pos: nil }
55
56
 
56
57
  client.should_receive(:post).with("/cards", expected_payload).and_return result
57
58
 
@@ -119,6 +120,10 @@ module Trello
119
120
  it "gets its cover image id" do
120
121
  card.cover_image_id.should_not be_nil
121
122
  end
123
+
124
+ it "gets its pos" do
125
+ card.pos.should_not be_nil
126
+ end
122
127
  end
123
128
 
124
129
  context "actions" do
@@ -250,41 +255,50 @@ module Trello
250
255
  client.stub(:get).with("/cards/abcdef123456789123456789/labels").
251
256
  and_return label_payload
252
257
  labels = card.labels
253
- labels.size.should == 2
258
+ expect(labels.size).to eq(2)
254
259
 
255
- labels[0].color.should == 'yellow'
256
- labels[0].name.should == 'iOS'
260
+ expect(labels[0].color).to eq('yellow')
261
+ expect(labels[0].name).to eq('iOS')
257
262
 
258
- labels[1].color.should == 'purple'
259
- labels[1].name.should == 'Issue or bug'
263
+ expect(labels[1].color).to eq('purple')
264
+ expect(labels[1].name).to eq('Issue or bug')
260
265
  end
261
266
 
262
267
  it "can add a label" do
263
268
  client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :value => 'green' }).
264
269
  and_return "not important"
265
270
  card.add_label('green')
266
- card.errors.should be_empty
271
+ expect(card.errors).to be_empty
267
272
  end
268
273
 
269
274
  it "can remove a label" do
270
275
  client.stub(:delete).with("/cards/abcdef123456789123456789/labels/green").
271
276
  and_return "not important"
272
277
  card.remove_label('green')
273
- card.errors.should be_empty
278
+ expect(card.errors).to be_empty
279
+ end
280
+
281
+ it "can add a label of any valid color" do
282
+ %w(green yellow orange red purple blue sky lime pink black).each do |color|
283
+ client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :value => color }).
284
+ and_return "not important"
285
+ card.add_label(color)
286
+ expect(card.errors).to be_empty
287
+ end
274
288
  end
275
289
 
276
290
  it "throws an error when trying to add a label with an unknown colour" do
277
291
  client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :value => 'green' }).
278
292
  and_return "not important"
279
293
  card.add_label('mauve')
280
- card.errors.full_messages.to_sentence.should == "Label colour 'mauve' does not exist"
294
+ expect(card.errors.full_messages.to_sentence).to eq("Label colour 'mauve' does not exist")
281
295
  end
282
296
 
283
297
  it "throws an error when trying to remove a label with an unknown colour" do
284
298
  client.stub(:delete).with("/cards/abcdef123456789123456789/labels/mauve").
285
299
  and_return "not important"
286
300
  card.remove_label('mauve')
287
- card.errors.full_messages.to_sentence.should == "Label colour 'mauve' does not exist"
301
+ expect(card.errors.full_messages.to_sentence).to eq("Label colour 'mauve' does not exist")
288
302
  end
289
303
  end
290
304
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Tregunna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-19 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel