ruby-trello 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/trello.rb CHANGED
@@ -49,8 +49,9 @@ module Trello
49
49
  autoload :Configuration, 'trello/configuration'
50
50
  autoload :HasActions, 'trello/has_actions'
51
51
  autoload :Item, 'trello/item'
52
- autoload :CheckItemState, 'trello/item_state'
52
+ autoload :CheckItemState, 'trello/item_state'
53
53
  autoload :Label, 'trello/label'
54
+ autoload :LabelName, 'trello/label_name'
54
55
  autoload :List, 'trello/list'
55
56
  autoload :Member, 'trello/member'
56
57
  autoload :MultiAssociation, 'trello/multi_association'
@@ -1,7 +1,7 @@
1
1
  module Trello
2
2
  # A file or url that is linked to a Trello card
3
3
  class Attachment < BasicData
4
- register_attributes :name, :id
4
+ register_attributes :name, :id, :url, :bytes, :member_id, :date, :is_upload, :mime_type
5
5
  # Update the fields of an attachment.
6
6
  #
7
7
  # Supply a hash of stringkeyed data retrieved from the Trello API representing
@@ -9,6 +9,12 @@ module Trello
9
9
  def update_fields(fields)
10
10
  attributes[:name] = fields['name']
11
11
  attributes[:id] = fields['id']
12
+ attributes[:url] = fields['url']
13
+ attributes[:bytes] = fields['bytes'].to_i
14
+ attributes[:member_id] = fields['idMember']
15
+ attributes[:date] = Time.parse(fields['date'])
16
+ attributes[:is_upload] = fields['isUpload']
17
+ attributes[:mime_type] = fields['mimeType']
12
18
  self
13
19
  end
14
20
  end
data/lib/trello/board.rb CHANGED
@@ -96,6 +96,11 @@ module Trello
96
96
  # Returns a reference to the organization this board belongs to.
97
97
  one :organization, :path => :organizations, :using => :organization_id
98
98
 
99
+ def labels
100
+ labels = client.get("/boards/#{id}/labelnames").json_into(LabelName)
101
+ MultiAssociation.new(self, labels).proxy
102
+ end
103
+
99
104
  # :nodoc:
100
105
  def request_prefix
101
106
  "/boards/#{id}"
data/lib/trello/card.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Trello
2
2
  # A Card is a container that can house checklists and comments; it resides inside a List.
3
3
  class Card < BasicData
4
- register_attributes :id, :short_id, :name, :description, :due, :closed, :url, :board_id, :member_ids, :list_id, :pos,
5
- :readonly => [ :id, :short_id, :url, :board_id, :member_ids ]
4
+ register_attributes :id, :short_id, :name, :description, :due, :closed, :url, :board_id, :member_ids, :list_id, :pos, :last_activity_date,
5
+ :readonly => [ :id, :short_id, :url, :board_id, :member_ids, :last_activity_date ]
6
6
  validates_presence_of :id, :name, :list_id
7
7
  validates_length_of :name, :in => 1..16384
8
8
  validates_length_of :description, :in => 0..16384
@@ -29,17 +29,18 @@ module Trello
29
29
  # Supply a hash of string keyed data retrieved from the Trello API representing
30
30
  # a card.
31
31
  def update_fields(fields)
32
- attributes[:id] = fields['id']
33
- attributes[:short_id] = fields['idShort']
34
- attributes[:name] = fields['name']
35
- attributes[:description] = fields['desc']
36
- attributes[:due] = Time.iso8601(fields['due']) rescue nil
37
- attributes[:closed] = fields['closed']
38
- attributes[:url] = fields['url']
39
- attributes[:board_id] = fields['idBoard']
40
- attributes[:member_ids] = fields['idMembers']
41
- attributes[:list_id] = fields['idList']
42
- attributes[:pos] = fields['pos']
32
+ attributes[:id] = fields['id']
33
+ attributes[:short_id] = fields['idShort']
34
+ attributes[:name] = fields['name']
35
+ attributes[:description] = fields['desc']
36
+ attributes[:due] = Time.iso8601(fields['due']) rescue nil
37
+ attributes[:closed] = fields['closed']
38
+ attributes[:url] = fields['url']
39
+ attributes[:board_id] = fields['idBoard']
40
+ attributes[:member_ids] = fields['idMembers']
41
+ attributes[:list_id] = fields['idList']
42
+ attributes[:pos] = fields['pos']
43
+ attributes[:last_activity_date] = Time.iso8601(fields['dateLastActivity']) rescue nil
43
44
  self
44
45
  end
45
46
 
@@ -0,0 +1,26 @@
1
+ module Trello
2
+
3
+ # A colored Label attached to a card
4
+ class LabelName < BasicData
5
+ register_attributes :yellow, :red, :orange, :green, :purple, :blue
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[:yellow] = fields['yellow']
13
+ attributes[:red] = fields['red']
14
+ attributes[:orange] = fields['orange']
15
+ attributes[:green] = fields['green']
16
+ attributes[:purple] = fields['purple']
17
+ attributes[:blue] = fields['blue']
18
+ self
19
+ end
20
+
21
+ one :board, :path => :boards, :using => :board_id
22
+
23
+ many :cards, :filter => :all
24
+
25
+ end
26
+ end
data/lib/trello/net.rb CHANGED
@@ -4,11 +4,13 @@ module Trello
4
4
 
5
5
  class TInternet
6
6
  class << self
7
+ require "rest_client"
8
+
7
9
  def execute(request)
8
10
  try_execute request
9
11
  end
10
12
 
11
- private
13
+ private
12
14
 
13
15
  def try_execute(request)
14
16
  begin
@@ -16,14 +18,12 @@ module Trello
16
18
  result = execute_core request
17
19
  Response.new(200, {}, result)
18
20
  end
19
- rescue Exception => e
21
+ rescue RestClient::Exception => e
20
22
  Response.new(e.http_code, {}, e.http_body)
21
23
  end
22
24
  end
23
25
 
24
26
  def execute_core(request)
25
- require "rest_client"
26
-
27
27
  RestClient.proxy = ENV['HTTP_PROXY'] if ENV['HTTP_PROXY']
28
28
  RestClient::Request.execute(
29
29
  :method => request.verb,
data/spec/board_spec.rb CHANGED
@@ -77,6 +77,15 @@ module Trello
77
77
  end
78
78
  end
79
79
 
80
+ context "labels" do
81
+ it "gets the specific labels for the board" do
82
+ client.stub(:get).with("/boards/abcdef123456789123456789/labelnames").
83
+ and_return label_name_payload
84
+
85
+ board.labels.count.should eq(6)
86
+ end
87
+ end
88
+
80
89
  context "find_card" do
81
90
  it "gets a card" do
82
91
  client.stub(:get).with("/boards/abcdef123456789123456789/cards/1").
data/spec/card_spec.rb CHANGED
@@ -107,6 +107,10 @@ module Trello
107
107
  it "gets its url" do
108
108
  card.url.should_not be_nil
109
109
  end
110
+
111
+ it "gets its last active date" do
112
+ card.last_activity_date.should_not be_nil
113
+ end
110
114
  end
111
115
 
112
116
  context "actions" do
@@ -268,12 +272,21 @@ module Trello
268
272
  card.errors.should be_empty
269
273
  end
270
274
 
271
- it "can list the existing attachments" do
275
+ it "can list the existing attachments with correct fields" do
272
276
  client.stub(:get).with("/boards/abcdef123456789123456789").and_return JSON.generate(boards_details.first)
273
277
  client.stub(:get).with("/cards/abcdef123456789123456789/attachments").and_return attachments_payload
274
278
 
275
279
  card.board.should_not be_nil
276
280
  card.attachments.should_not be_nil
281
+ first_attachment = card.attachments.first
282
+ first_attachment.id.should == attachments_details[0]["id"]
283
+ first_attachment.name.should == attachments_details[0]["name"]
284
+ first_attachment.url.should == attachments_details[0]["url"]
285
+ first_attachment.bytes.should == attachments_details[0]["bytes"]
286
+ first_attachment.member_id.should == attachments_details[0]["idMember"]
287
+ first_attachment.date.should == Time.parse(attachments_details[0]["date"])
288
+ first_attachment.is_upload.should == attachments_details[0]["isUpload"]
289
+ first_attachment.mime_type.should == attachments_details[0]["mimeType"]
277
290
  end
278
291
 
279
292
  it "can remove an attachment" do
data/spec/spec_helper.rb CHANGED
@@ -97,16 +97,17 @@ module Helpers
97
97
 
98
98
  def cards_details
99
99
  [{
100
- "id" => "abcdef123456789123456789",
101
- "idShort" => "1",
102
- "name" => "Do something awesome",
103
- "desc" => "Awesome things are awesome.",
104
- "closed" => false,
105
- "idList" => "abcdef123456789123456789",
106
- "idBoard" => "abcdef123456789123456789",
107
- "idMembers" => ["abcdef123456789123456789"],
108
- "url" => "https://trello.com/card/board/specify-the-type-and-scope-of-the-jit-in-a-lightweight-spec/abcdef123456789123456789/abcdef123456789123456789",
109
- "pos" => 12
100
+ "id" => "abcdef123456789123456789",
101
+ "idShort" => "1",
102
+ "name" => "Do something awesome",
103
+ "desc" => "Awesome things are awesome.",
104
+ "closed" => false,
105
+ "idList" => "abcdef123456789123456789",
106
+ "idBoard" => "abcdef123456789123456789",
107
+ "idMembers" => ["abcdef123456789123456789"],
108
+ "url" => "https://trello.com/card/board/specify-the-type-and-scope-of-the-jit-in-a-lightweight-spec/abcdef123456789123456789/abcdef123456789123456789",
109
+ "pos" => 12,
110
+ "dateLastActivity" => "2012-12-07T18:40:24.314Z"
110
111
  }]
111
112
  end
112
113
 
@@ -117,9 +118,23 @@ module Helpers
117
118
 
118
119
  def attachments_details
119
120
  [{
120
- "id" => "abcdef123456789123456789",
121
- "name" => "list_spec.rb"
122
- }]
121
+ "id" => "abcdef123456789123456789",
122
+ "name" => "attachment1.png",
123
+ "url" => "http://trello-assets.domain.tld/attachment1.png",
124
+ "bytes" => 98765,
125
+ "idMember" => "abcdef123456789123456781",
126
+ "isUpload" => false,
127
+ "date" => "2013-02-28T17:12:28.497Z",
128
+ },
129
+ {
130
+ "id" => "abcdef123456789123456781",
131
+ "name" => "attachment2.png",
132
+ "url" => "http://trello-assets.domain.tld/attachment2.png",
133
+ "bytes" => 89123,
134
+ "idMember" => "abcdef123456789123456782",
135
+ "isUpload" => true,
136
+ "date" => "2013-03-01T14:01:25.212Z",
137
+ }]
123
138
  end
124
139
 
125
140
  def attachments_payload
@@ -263,4 +278,19 @@ module Helpers
263
278
  def label_payload
264
279
  JSON.generate(label_details)
265
280
  end
281
+
282
+ def label_name_details
283
+ [
284
+ {"yellow" => "bug"},
285
+ {"red" => "urgent"},
286
+ {"green" => "deploy"},
287
+ {"blue" => "on hold"},
288
+ {"orange" => "new feature"},
289
+ {"purple" => "experimental"}
290
+ ]
291
+ end
292
+
293
+ def label_name_payload
294
+ JSON.generate(label_name_details)
295
+ end
266
296
  end
metadata CHANGED
@@ -1,78 +1,106 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Jeremy Tregunna
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-03-06 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: activemodel
16
- requirement: &70290374194120 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
22
32
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70290374194120
25
- - !ruby/object:Gem::Dependency
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
26
35
  name: addressable
27
- requirement: &70290374193560 !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
28
38
  none: false
29
- requirements:
39
+ requirements:
30
40
  - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '2.3'
41
+ - !ruby/object:Gem::Version
42
+ hash: 5
43
+ segments:
44
+ - 2
45
+ - 3
46
+ version: "2.3"
33
47
  type: :runtime
34
- prerelease: false
35
- version_requirements: *70290374193560
36
- - !ruby/object:Gem::Dependency
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
37
50
  name: json
38
- requirement: &70290374193100 !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
39
53
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
44
61
  type: :runtime
45
- prerelease: false
46
- version_requirements: *70290374193100
47
- - !ruby/object:Gem::Dependency
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
48
64
  name: oauth
49
- requirement: &70290374192480 !ruby/object:Gem::Requirement
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
50
67
  none: false
51
- requirements:
68
+ requirements:
52
69
  - - ~>
53
- - !ruby/object:Gem::Version
70
+ - !ruby/object:Gem::Version
71
+ hash: 5
72
+ segments:
73
+ - 0
74
+ - 4
75
+ - 5
54
76
  version: 0.4.5
55
77
  type: :runtime
56
- prerelease: false
57
- version_requirements: *70290374192480
58
- - !ruby/object:Gem::Dependency
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
59
80
  name: rest-client
60
- requirement: &70290374191580 !ruby/object:Gem::Requirement
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
61
83
  none: false
62
- requirements:
84
+ requirements:
63
85
  - - ~>
64
- - !ruby/object:Gem::Version
86
+ - !ruby/object:Gem::Version
87
+ hash: 1
88
+ segments:
89
+ - 1
90
+ - 6
91
+ - 7
65
92
  version: 1.6.7
66
93
  type: :runtime
67
- prerelease: false
68
- version_requirements: *70290374191580
94
+ version_requirements: *id005
69
95
  description: A wrapper around the trello.com API.
70
96
  email: jeremy@tregunna.ca
71
97
  executables: []
98
+
72
99
  extensions: []
73
- extra_rdoc_files:
100
+
101
+ extra_rdoc_files:
74
102
  - README.md
75
- files:
103
+ files:
76
104
  - lib/trello/action.rb
77
105
  - lib/trello/association.rb
78
106
  - lib/trello/association_proxy.rb
@@ -88,6 +116,7 @@ files:
88
116
  - lib/trello/item.rb
89
117
  - lib/trello/item_state.rb
90
118
  - lib/trello/label.rb
119
+ - lib/trello/label_name.rb
91
120
  - lib/trello/list.rb
92
121
  - lib/trello/member.rb
93
122
  - lib/trello/multi_association.rb
@@ -121,30 +150,40 @@ files:
121
150
  - spec/trello_spec.rb
122
151
  homepage: https://github.com/jeremytregunna/ruby-trello
123
152
  licenses: []
153
+
124
154
  post_install_message:
125
- rdoc_options:
155
+ rdoc_options:
126
156
  - --charset=UTF-8
127
- require_paths:
157
+ require_paths:
128
158
  - lib
129
- required_ruby_version: !ruby/object:Gem::Requirement
159
+ required_ruby_version: !ruby/object:Gem::Requirement
130
160
  none: false
131
- requirements:
132
- - - ! '>='
133
- - !ruby/object:Gem::Version
134
- version: '0'
135
- required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ hash: 3
165
+ segments:
166
+ - 0
167
+ version: "0"
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
169
  none: false
137
- requirements:
138
- - - ! '>='
139
- - !ruby/object:Gem::Version
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ hash: 23
174
+ segments:
175
+ - 1
176
+ - 3
177
+ - 6
140
178
  version: 1.3.6
141
179
  requirements: []
180
+
142
181
  rubyforge_project: ruby-trello
143
- rubygems_version: 1.8.15
182
+ rubygems_version: 1.8.24
144
183
  signing_key:
145
184
  specification_version: 3
146
185
  summary: A wrapper around the trello.com API.
147
- test_files:
186
+ test_files:
148
187
  - spec/action_spec.rb
149
188
  - spec/basic_auth_policy_spec.rb
150
189
  - spec/board_spec.rb