ruby-trello 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,7 @@ module Trello
37
37
  autoload :HasActions, 'trello/has_actions'
38
38
  autoload :Item, 'trello/item'
39
39
  autoload :ItemState, 'trello/item_state'
40
+ autoload :Label, 'trello/label'
40
41
  autoload :List, 'trello/list'
41
42
  autoload :Member, 'trello/member'
42
43
  autoload :MultiAssociation, 'trello/multi_association'
@@ -110,6 +110,12 @@ module Trello
110
110
  })
111
111
  end
112
112
 
113
+ # Retrieve a list of labels
114
+ def labels
115
+ labels = Client.get("/cards/#{id}/labels").json_into(Label)
116
+ MultiAssociation.new(self, labels).proxy
117
+ end
118
+
113
119
  # Add a label
114
120
  def add_label(colour)
115
121
  unless %w{green yellow orange red purple blue}.include? colour
@@ -0,0 +1,19 @@
1
+ module Trello
2
+
3
+ # A colored Label attached to a card
4
+ class Label < BasicData
5
+ register_attributes :name, :color
6
+
7
+ # Update the fields of a label.
8
+ #
9
+ # Supply a hash of stringkeyed data retrieved from the Trello API representing
10
+ # a label.
11
+ def update_fields(fields)
12
+ attributes[:name] = fields['name']
13
+ attributes[:color] = fields['color']
14
+ self
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -80,8 +80,8 @@ module Trello
80
80
 
81
81
  def update!
82
82
  Client.put(request_prefix, {
83
- :displayName => full_name,
84
- :bio => bio
83
+ :fullName => full_name,
84
+ :bio => bio
85
85
  }).json_into(self)
86
86
  end
87
87
 
@@ -146,6 +146,19 @@ module Trello
146
146
  end
147
147
 
148
148
  context "labels" do
149
+ it "can retrieve labels" do
150
+ Client.stub(:get).with("/cards/abcdef123456789123456789/labels").
151
+ and_return label_payload
152
+ labels = @card.labels
153
+ labels.size.should == 2
154
+
155
+ labels[0].color.should == 'yellow'
156
+ labels[0].name.should == 'iOS'
157
+
158
+ labels[1].color.should == 'purple'
159
+ labels[1].name.should == 'Issue or bug'
160
+ end
161
+
149
162
  it "can add a label" do
150
163
  Client.stub(:post).with("/cards/abcdef123456789123456789/labels", { :value => 'green' }).
151
164
  and_return "not important"
@@ -230,4 +230,15 @@ module Helpers
230
230
  def token_payload
231
231
  JSON.generate(token_details)
232
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
233
244
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-13 00:00:00.000000000Z
12
+ date: 2012-02-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
16
- requirement: &70256886904160 !ruby/object:Gem::Requirement
16
+ requirement: &70222887650260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.4.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70256886904160
24
+ version_requirements: *70222887650260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: addressable
27
- requirement: &70256886903640 !ruby/object:Gem::Requirement
27
+ requirement: &70222887648300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.2.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70256886903640
35
+ version_requirements: *70222887648300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rest-client
38
- requirement: &70256886903180 !ruby/object:Gem::Requirement
38
+ requirement: &70222887646220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.7
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70256886903180
46
+ version_requirements: *70222887646220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activemodel
49
- requirement: &70256886902760 !ruby/object:Gem::Requirement
49
+ requirement: &70222887645500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70256886902760
57
+ version_requirements: *70222887645500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70256886902180 !ruby/object:Gem::Requirement
60
+ requirement: &70222887625140 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70256886902180
68
+ version_requirements: *70222887625140
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70256886901640 !ruby/object:Gem::Requirement
71
+ requirement: &70222887623700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.8.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70256886901640
79
+ version_requirements: *70222887623700
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &70256886901100 !ruby/object:Gem::Requirement
82
+ requirement: &70222887621880 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70256886901100
90
+ version_requirements: *70222887621880
91
91
  description: A wrapper around the trello.com API.
92
92
  email: jeremy@tregunna.ca
93
93
  executables: []
@@ -107,6 +107,7 @@ files:
107
107
  - lib/trello/has_actions.rb
108
108
  - lib/trello/item.rb
109
109
  - lib/trello/item_state.rb
110
+ - lib/trello/label.rb
110
111
  - lib/trello/list.rb
111
112
  - lib/trello/member.rb
112
113
  - lib/trello/multi_association.rb