ruby-trello 0.6.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,9 +2,9 @@ module Trello
2
2
  # A Checklist holds items which are like a "task" list. Checklists are linked to a card.
3
3
  class Checklist < BasicData
4
4
  register_attributes :id, :name, :description, :closed, :url, :check_items, :board_id, :list_id, :member_ids,
5
- :readonly => [ :id, :description, :closed, :url, :check_items, :board_id, :list_id, :member_ids ]
5
+ :readonly => [:id, :description, :closed, :url, :check_items, :board_id, :list_id, :member_ids]
6
6
  validates_presence_of :id, :board_id, :list_id
7
- validates_length_of :name, :in => 1..16384
7
+ validates_length_of :name, :in => 1..16384
8
8
 
9
9
  class << self
10
10
  # Locate a specific checklist by its id.
@@ -14,8 +14,8 @@ module Trello
14
14
 
15
15
  def create(options)
16
16
  client.create(:checklist,
17
- 'name' => options[:name],
18
- 'idBoard' => options[:board_id])
17
+ 'name' => options[:name],
18
+ 'idBoard' => options[:board_id])
19
19
  end
20
20
  end
21
21
 
@@ -24,15 +24,15 @@ module Trello
24
24
  # Supply a hash of string keyed data retrieved from the Trello API representing
25
25
  # a checklist.
26
26
  def update_fields(fields)
27
- attributes[:id] = fields['id']
28
- attributes[:name] = fields['name']
27
+ attributes[:id] = fields['id']
28
+ attributes[:name] = fields['name']
29
29
  attributes[:description] = fields['desc']
30
- attributes[:closed] = fields['closed']
31
- attributes[:url] = fields['url']
30
+ attributes[:closed] = fields['closed']
31
+ attributes[:url] = fields['url']
32
32
  attributes[:check_items] = fields['checkItems']
33
- attributes[:board_id] = fields['idBoard']
34
- attributes[:list_id] = fields['idList']
35
- attributes[:member_ids] = fields['idMembers']
33
+ attributes[:board_id] = fields['idBoard']
34
+ attributes[:list_id] = fields['idList']
35
+ attributes[:member_ids] = fields['idMembers']
36
36
  self
37
37
  end
38
38
 
@@ -46,13 +46,13 @@ module Trello
46
46
  return update! if id
47
47
 
48
48
  client.post("/checklists", {
49
- :name => name,
50
- :idBoard => board_id
49
+ :name => name,
50
+ :idBoard => board_id
51
51
  }).json_into(self)
52
52
  end
53
53
 
54
54
  def update!
55
- client.put("/checklists/#{id}", { :name => name }).json_into(self)
55
+ client.put("/checklists/#{id}", {:name => name}).json_into(self)
56
56
  end
57
57
 
58
58
  # Return a list of items on the checklist.
@@ -78,7 +78,17 @@ module Trello
78
78
 
79
79
  # Add an item to the checklist
80
80
  def add_item(name)
81
- client.post("/checklists/#{id}/checkItems", { :name => name })
81
+ client.post("/checklists/#{id}/checkItems", {:name => name})
82
+ end
83
+
84
+ # Delete a checklist item
85
+ def delete_checklist_item(item_id)
86
+ client.delete("/checklists/#{id}/checkItems/#{item_id}")
87
+ end
88
+
89
+ # Delete a checklist
90
+ def delete
91
+ client.delete("/checklists/#{id}")
82
92
  end
83
93
  end
84
94
  end
data/lib/trello/member.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Trello
2
2
  # A Member is a user of the Trello service.
3
3
  class Member < BasicData
4
- register_attributes :id, :username, :full_name, :avatar_id, :bio, :url, :readonly => [ :id, :username, :avatar_id, :url ]
4
+ register_attributes :id, :username, :email, :full_name, :avatar_id, :bio, :url, :readonly => [ :id, :username, :avatar_id, :url ]
5
5
  validates_presence_of :id, :username
6
6
  validates_length_of :full_name, :minimum => 4
7
7
  validates_length_of :bio, :maximum => 16384
@@ -24,6 +24,7 @@ module Trello
24
24
  def update_fields(fields)
25
25
  attributes[:id] = fields['id']
26
26
  attributes[:full_name] = fields['fullName']
27
+ attributes[:email] = fields['email']
27
28
  attributes[:username] = fields['username']
28
29
  attributes[:avatar_id] = fields['avatarHash']
29
30
  attributes[:bio] = fields['bio']
@@ -9,7 +9,7 @@ module Trello
9
9
 
10
10
  before(:each) do
11
11
  client.stub(:get).with("/checklists/abcdef123456789123456789").
12
- and_return JSON.generate(checklists_details.first)
12
+ and_return JSON.generate(checklists_details.first)
13
13
  end
14
14
 
15
15
  context "finding" do
@@ -30,8 +30,8 @@ module Trello
30
30
 
31
31
  it 'creates a new record and saves it on Trello', :refactor => true do
32
32
  payload = {
33
- :name => 'Test Checklist',
34
- :desc => '',
33
+ :name => 'Test Checklist',
34
+ :desc => '',
35
35
  }
36
36
 
37
37
  result = JSON.generate(checklists_details.first.merge(payload.merge(:idBoard => boards_details.first['id'])))
@@ -46,12 +46,27 @@ module Trello
46
46
  end
47
47
  end
48
48
 
49
+ context "deleting" do
50
+ let(:client) { Trello.client }
51
+
52
+ it "deletes a checklist" do
53
+ client.should_receive(:delete).with("/checklists/#{checklist.id}")
54
+ checklist.delete
55
+ end
56
+
57
+ it "deletes a checklist item" do
58
+ item_id = checklist.check_items.first.last
59
+ client.should_receive(:delete).with("/checklists/#{checklist.id}/checkItems/#{item_id}")
60
+ checklist.delete_checklist_item(item_id)
61
+ end
62
+ end
63
+
49
64
  context "updating" do
50
65
  it "updating name does a put on the correct resource with the correct value" do
51
66
  expected_new_name = "xxx"
52
67
  expected_resource = "/checklists/abcdef123456789123456789"
53
68
  payload = {
54
- :name => expected_new_name
69
+ :name => expected_new_name
55
70
  }
56
71
 
57
72
  result = JSON.generate(checklists_details.first)
data/spec/member_spec.rb CHANGED
@@ -89,6 +89,10 @@ module Trello
89
89
  it "gets the username" do
90
90
  member.username.should == user_details['username']
91
91
  end
92
+
93
+ it "gets the email" do
94
+ member.email.should == user_details['email']
95
+ end
92
96
  end
93
97
 
94
98
  context "modification" do
data/spec/spec_helper.rb CHANGED
@@ -40,7 +40,8 @@ module Helpers
40
40
  "username" => "me",
41
41
  "avatarHash" => "abcdef1234567890abcdef1234567890",
42
42
  "bio" => "a rather dumb user",
43
- "url" => "https://trello.com/me"
43
+ "url" => "https://trello.com/me",
44
+ "email" => "johnsmith@example.com"
44
45
  }
45
46
  end
46
47
 
@@ -73,7 +74,7 @@ module Helpers
73
74
  "idBoard" => "abcdef123456789123456789",
74
75
  "idList" => "abcdef123456789123456789",
75
76
  "idMembers" => ["abcdef123456789123456789"],
76
- "checkItems" => {}
77
+ "checkItems" => { "id" => "ghijk987654321" }
77
78
  }]
78
79
  end
79
80
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 6
9
9
  - 0
10
- version: 0.6.0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Tregunna
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-03-06 00:00:00 Z
18
+ date: 2013-03-23 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel