ruby-trello 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f46b5d3c7a3289b56568b9be4ccff37cdb218806
4
+ data.tar.gz: b67d2acd6cbd716a7bf013efc961c78c9bd117d0
5
+ SHA512:
6
+ metadata.gz: 33d759205434832b33b63ce91b052cbe0e8f621bd4783eb159f704bfe6be9ca7fd3271bdd34ea896bcf581c8d8b0ed51bdf40f43dcc649cc438252f8a7829c91
7
+ data.tar.gz: 2ad17d8f86890622fbf9503abda767bec8a1afcce6ce5151eac9b0c1a7f6feff85b2c80b43bf26ec38d5208dcd752ff9f39b2ff0d1f3dcbd9c40499adc58278c
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Ruby Trello API
2
2
 
3
+ [![Stories in Ready](http://badge.waffle.io/jeremytregunna/ruby-trello.png)](http://waffle.io/jeremytregunna/ruby-trello)
3
4
  [![Build Status](https://secure.travis-ci.org/jeremytregunna/ruby-trello.png)](http://travis-ci.org/jeremytregunna/ruby-trello) [![Dependency Status](https://gemnasium.com/jeremytregunna/ruby-trello.png)](https://gemnasium.com/jeremytregunna/ruby-trello.png)
4
5
 
5
6
  This library implements the [Trello](http://www.trello.com/) [API](http://trello.com/api).
@@ -16,6 +17,9 @@ Seriously, [check it out](http://www.trello.com/).
16
17
  Full Disclosure: This library is mostly complete, if you do find anything missing or not functioning as you expect it
17
18
  to, please [let us know](https://trello.com/card/spot-a-bug-report-it/4f092b2ee23cb6fe6d1aaabd/17).
18
19
 
20
+ While this library still does function on ruby 1.8 as of version 1.0.2 with activemodel < 4.0, this notice services to
21
+ illustrate that future versions may include ruby 1.9+ specific features.
22
+
19
23
  ## Configuration
20
24
 
21
25
  Basic authorization
data/lib/trello.rb CHANGED
@@ -71,9 +71,13 @@ module Trello
71
71
  API_VERSION = 1
72
72
 
73
73
  # Raise this when we hit a Trello error.
74
- class Error < StandardError; end
74
+ Error = Class.new(StandardError)
75
+
75
76
  # This specific error is thrown when your access token is invalid. You should get a new one.
76
- class InvalidAccessToken < StandardError; end
77
+ InvalidAccessToken = Class.new(Error)
78
+
79
+ # This error is thrown when your client has not been configured
80
+ ConfigurationError = Class.new(Error)
77
81
 
78
82
  def self.logger
79
83
  @logger ||= Logger.new(STDOUT)
@@ -6,6 +6,10 @@ module Trello
6
6
 
7
7
  AuthPolicy = Class.new do
8
8
  def initialize(attrs = {}); end
9
+
10
+ def authorize(*args)
11
+ raise Trello::ConfigurationError, "Trello has not been configured to make authorized requests."
12
+ end
9
13
  end
10
14
 
11
15
  class BasicAuthPolicy
data/lib/trello/card.rb CHANGED
@@ -1,11 +1,11 @@
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, :last_activity_date,
4
+ register_attributes :id, :short_id, :name, :desc, :due, :closed, :url, :board_id, :member_ids, :list_id, :pos, :last_activity_date,
5
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
- validates_length_of :description, :in => 0..16384
8
+ validates_length_of :desc, :in => 0..16384
9
9
 
10
10
  include HasActions
11
11
 
@@ -20,7 +20,7 @@ module Trello
20
20
  client.create(:card,
21
21
  'name' => options[:name],
22
22
  'idList' => options[:list_id],
23
- 'desc' => options[:description])
23
+ 'desc' => options[:desc])
24
24
  end
25
25
  end
26
26
 
@@ -32,7 +32,7 @@ module Trello
32
32
  attributes[:id] = fields['id']
33
33
  attributes[:short_id] = fields['idShort']
34
34
  attributes[:name] = fields['name']
35
- attributes[:description] = fields['desc']
35
+ attributes[:desc] = fields['desc']
36
36
  attributes[:due] = Time.iso8601(fields['due']) rescue nil
37
37
  attributes[:closed] = fields['closed']
38
38
  attributes[:url] = fields['url']
@@ -78,7 +78,7 @@ module Trello
78
78
 
79
79
  client.post("/cards", {
80
80
  :name => name,
81
- :desc => description,
81
+ :desc => desc,
82
82
  :idList => list_id
83
83
  }).json_into(self)
84
84
  end
@@ -77,8 +77,8 @@ module Trello
77
77
  end
78
78
 
79
79
  # Add an item to the checklist
80
- def add_item(name)
81
- client.post("/checklists/#{id}/checkItems", {:name => name})
80
+ def add_item(name, checked=false, position='bottom')
81
+ client.post("/checklists/#{id}/checkItems", {:name => name, :checked => checked, :pos => position})
82
82
  end
83
83
 
84
84
  # Delete a checklist item
data/lib/trello/item.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Trello
2
2
  # An Item is a basic task that can be checked off and marked as completed.
3
3
  class Item < BasicData
4
- register_attributes :id, :name, :type, :readonly => [ :id, :name, :type ]
4
+ register_attributes :id, :name, :type, :state, :pos, :readonly => [ :id, :name, :type, :state, :pos ]
5
5
  validates_presence_of :id, :type
6
6
 
7
7
  # Updates the fields of an item.
@@ -9,9 +9,11 @@ module Trello
9
9
  # Supply a hash of string keyed data retrieved from the Trello API representing
10
10
  # an item.
11
11
  def update_fields(fields)
12
- attributes[:id] = fields['id']
13
- attributes[:name] = fields['name']
14
- attributes[:type] = fields['type']
12
+ attributes[:id] = fields['id']
13
+ attributes[:name] = fields['name']
14
+ attributes[:type] = fields['type']
15
+ attributes[:state] = fields['state']
16
+ attributes[:pos] = fields['pos']
15
17
  self
16
18
  end
17
19
  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, :email, :full_name, :avatar_id, :bio, :url, :readonly => [ :id, :username, :avatar_id, :url ]
4
+ register_attributes :id, :username, :email, :full_name, :initials, :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
@@ -26,6 +26,7 @@ module Trello
26
26
  attributes[:full_name] = fields['fullName']
27
27
  attributes[:email] = fields['email']
28
28
  attributes[:username] = fields['username']
29
+ attributes[:initials] = fields['initials']
29
30
  attributes[:avatar_id] = fields['avatarHash']
30
31
  attributes[:bio] = fields['bio']
31
32
  attributes[:url] = fields['url']
data/spec/card_spec.rb CHANGED
@@ -46,7 +46,7 @@ module Trello
46
46
  it 'creates a new record and saves it on Trello', :refactor => true do
47
47
  payload = {
48
48
  :name => 'Test Card',
49
- :desc => '',
49
+ :desc => nil,
50
50
  }
51
51
 
52
52
  result = JSON.generate(cards_details.first.merge(payload.merge(:idList => lists_details.first['id'])))
@@ -97,7 +97,7 @@ module Trello
97
97
  end
98
98
 
99
99
  it "gets its description" do
100
- card.description.should_not be_nil
100
+ card.desc.should_not be_nil
101
101
  end
102
102
 
103
103
  it "knows if it is open or closed" do
@@ -75,6 +75,27 @@ module Trello
75
75
  checklist.name = expected_new_name
76
76
  checklist.save
77
77
  end
78
+
79
+ it "adds an item" do
80
+ expected_item_name = "item1"
81
+ expected_checked = true
82
+ expected_pos = 9999
83
+ expected_resource = "/checklists/abcdef123456789123456789"
84
+ payload = {
85
+ :name => expected_item_name,
86
+ :checked => expected_checked,
87
+ :pos => expected_pos
88
+ }
89
+ result_hash = {
90
+ :name => expected_item_name,
91
+ :state => expected_checked ? 'complete' : 'incomplete',
92
+ :pos => expected_pos
93
+ }
94
+ result = JSON.generate(result_hash)
95
+ client.should_receive(:post).once.with("/checklists/abcdef123456789123456789/checkItems", payload).and_return result
96
+
97
+ checklist.add_item(expected_item_name, expected_checked, expected_pos)
98
+ end
78
99
  end
79
100
 
80
101
  context "board" do
data/spec/item_spec.rb CHANGED
@@ -6,7 +6,9 @@ module Trello
6
6
  @detail = {
7
7
  'id' => "abcdef123456789123456789",
8
8
  'name' => "test item",
9
- 'type' => "check"
9
+ 'type' => "check",
10
+ 'state' => "complete",
11
+ 'pos' => 0
10
12
  }
11
13
 
12
14
  @item = Item.new(@detail)
@@ -23,5 +25,13 @@ module Trello
23
25
  it "knows its type" do
24
26
  @item.type.should == @detail['type']
25
27
  end
28
+
29
+ it "knows its state" do
30
+ @item.state.should == @detail['state']
31
+ end
32
+
33
+ it "knows its pos" do
34
+ @item.pos.should == @detail['pos']
35
+ end
26
36
  end
27
37
  end
data/spec/member_spec.rb CHANGED
@@ -93,6 +93,10 @@ module Trello
93
93
  it "gets the email" do
94
94
  member.email.should == user_details['email']
95
95
  end
96
+
97
+ it "gets the initials" do
98
+ member.initials.should == user_details['initials']
99
+ end
96
100
  end
97
101
 
98
102
  context "modification" do
data/spec/spec_helper.rb CHANGED
@@ -38,6 +38,7 @@ module Helpers
38
38
  "id" => "abcdef123456789012345678",
39
39
  "fullName" => "Test User",
40
40
  "username" => "me",
41
+ "intials" => "TU",
41
42
  "avatarHash" => "abcdef1234567890abcdef1234567890",
42
43
  "bio" => "a rather dumb user",
43
44
  "url" => "https://trello.com/me",
data/spec/trello_spec.rb CHANGED
@@ -69,5 +69,15 @@ describe Trello do
69
69
  auth_policy.oauth_token_secret.should be_nil
70
70
  end
71
71
  end
72
+
73
+ context "not configured" do
74
+ before do
75
+ Trello.configure
76
+ end
77
+
78
+ it { Trello.auth_policy.should be_a(AuthPolicy) }
79
+ it { expect { Trello.client.get(:member) }.to raise_error(Trello::ConfigurationError) }
80
+ end
81
+
72
82
  end
73
83
  end
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeremy Tregunna
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-01 00:00:00.000000000 Z
11
+ date: 2013-08-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activemodel
16
- requirement: &70094496121360 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70094496121360
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: addressable
27
- requirement: &70094496120820 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: '2.3'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70094496120820
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.3'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: json
38
- requirement: &70094496120400 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - '>='
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *70094496120400
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: oauth
49
- requirement: &70094496119860 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: 0.4.5
55
62
  type: :runtime
56
63
  prerelease: false
57
- version_requirements: *70094496119860
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.5
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rest-client
60
- requirement: &70094483304140 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
73
  - - ~>
64
74
  - !ruby/object:Gem::Version
65
75
  version: 1.6.7
66
76
  type: :runtime
67
77
  prerelease: false
68
- version_requirements: *70094483304140
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.6.7
69
83
  description: A wrapper around the trello.com API.
70
84
  email: jeremy@tregunna.ca
71
85
  executables: []
@@ -122,28 +136,27 @@ files:
122
136
  - spec/trello_spec.rb
123
137
  homepage: https://github.com/jeremytregunna/ruby-trello
124
138
  licenses: []
139
+ metadata: {}
125
140
  post_install_message:
126
141
  rdoc_options:
127
142
  - --charset=UTF-8
128
143
  require_paths:
129
144
  - lib
130
145
  required_ruby_version: !ruby/object:Gem::Requirement
131
- none: false
132
146
  requirements:
133
- - - ! '>='
147
+ - - '>='
134
148
  - !ruby/object:Gem::Version
135
149
  version: '0'
136
150
  required_rubygems_version: !ruby/object:Gem::Requirement
137
- none: false
138
151
  requirements:
139
- - - ! '>='
152
+ - - '>='
140
153
  - !ruby/object:Gem::Version
141
154
  version: 1.3.6
142
155
  requirements: []
143
156
  rubyforge_project: ruby-trello
144
- rubygems_version: 1.8.15
157
+ rubygems_version: 2.0.3
145
158
  signing_key:
146
- specification_version: 3
159
+ specification_version: 4
147
160
  summary: A wrapper around the trello.com API.
148
161
  test_files:
149
162
  - spec/action_spec.rb