ruby-trello 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/trello.rb +2 -0
- data/lib/trello/basic_data.rb +25 -0
- data/lib/trello/board.rb +7 -11
- data/lib/trello/card.rb +9 -14
- data/lib/trello/list.rb +39 -0
- data/lib/trello/member.rb +2 -3
- data/lib/trello/organization.rb +2 -3
- data/spec/list_spec.rb +47 -0
- data/spec/member_spec.rb +9 -6
- data/spec/spec_helper.rb +14 -6
- metadata +13 -9
data/lib/trello.rb
CHANGED
@@ -6,9 +6,11 @@ require 'oauth'
|
|
6
6
|
require 'yajl'
|
7
7
|
|
8
8
|
module Trello
|
9
|
+
autoload :BasicData, 'trello/basic_data'
|
9
10
|
autoload :Board, 'trello/board'
|
10
11
|
autoload :Card, 'trello/card'
|
11
12
|
autoload :Client, 'trello/client'
|
13
|
+
autoload :List, 'trello/list'
|
12
14
|
autoload :Member, 'trello/member'
|
13
15
|
autoload :Organization, 'trello/organization'
|
14
16
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Ruby wrapper around the Trello API
|
2
|
+
# Copyright (c) 2012, Jeremy Tregunna
|
3
|
+
# Use and distribution terms may be found in the file LICENSE included in this distribution.
|
4
|
+
|
5
|
+
module Trello
|
6
|
+
class BasicData
|
7
|
+
attr_reader :fields
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def find(path, id)
|
11
|
+
response = Client.query("/1/#{path}/#{id}")
|
12
|
+
new(Yajl::Parser.parse(response.read_body))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Fields
|
17
|
+
def initialize(fields = {})
|
18
|
+
@fields = fields
|
19
|
+
end
|
20
|
+
|
21
|
+
def ==(other)
|
22
|
+
@fields == other.fields
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/trello/board.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Use and distribution terms may be found in the file LICENSE included in this distribution.
|
4
4
|
|
5
5
|
module Trello
|
6
|
-
class Board
|
6
|
+
class Board < BasicData
|
7
7
|
class << self
|
8
8
|
def find(id)
|
9
9
|
response = Client.query("/1/boards/#{id}")
|
@@ -11,30 +11,26 @@ module Trello
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(fields = {})
|
15
|
-
@fields = fields
|
16
|
-
end
|
17
|
-
|
18
14
|
# Fields
|
19
15
|
|
20
16
|
def id
|
21
|
-
|
17
|
+
fields['id']
|
22
18
|
end
|
23
19
|
|
24
20
|
def name
|
25
|
-
|
21
|
+
fields['name']
|
26
22
|
end
|
27
23
|
|
28
24
|
def description
|
29
|
-
|
25
|
+
fields['desc']
|
30
26
|
end
|
31
27
|
|
32
28
|
def closed
|
33
|
-
|
29
|
+
fields['closed']
|
34
30
|
end
|
35
31
|
|
36
32
|
def url
|
37
|
-
|
33
|
+
fields['url']
|
38
34
|
end
|
39
35
|
|
40
36
|
# Links to other data structures
|
@@ -48,7 +44,7 @@ module Trello
|
|
48
44
|
end
|
49
45
|
|
50
46
|
def organization
|
51
|
-
Organization.find(
|
47
|
+
Organization.find(fields['idOrganization'])
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
data/lib/trello/card.rb
CHANGED
@@ -3,48 +3,43 @@
|
|
3
3
|
# Use and distribution terms may be found in the file LICENSE included in this distribution.
|
4
4
|
|
5
5
|
module Trello
|
6
|
-
class Card
|
6
|
+
class Card < BasicData
|
7
7
|
class << self
|
8
8
|
def find(id)
|
9
|
-
|
10
|
-
new(Yajl::Parser.parse(response.read_body))
|
9
|
+
super(:cards, id)
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
|
-
def initialize(fields = {})
|
15
|
-
@fields = fields
|
16
|
-
end
|
17
|
-
|
18
13
|
# Fields
|
19
14
|
|
20
15
|
def id
|
21
|
-
|
16
|
+
fields['id']
|
22
17
|
end
|
23
18
|
|
24
19
|
def name
|
25
|
-
|
20
|
+
fields['name']
|
26
21
|
end
|
27
22
|
|
28
23
|
def description
|
29
|
-
|
24
|
+
fields['desc']
|
30
25
|
end
|
31
26
|
|
32
27
|
def closed
|
33
|
-
|
28
|
+
fields['closed']
|
34
29
|
end
|
35
30
|
|
36
31
|
def url
|
37
|
-
|
32
|
+
fields['url']
|
38
33
|
end
|
39
34
|
|
40
35
|
# Links to other data structures
|
41
36
|
|
42
37
|
def board
|
43
|
-
Board.find(
|
38
|
+
Board.find(fields['idBoard'])
|
44
39
|
end
|
45
40
|
|
46
41
|
def members
|
47
|
-
|
42
|
+
fields['idMembers'].map do |member_id|
|
48
43
|
response = Client.query("/1/members/#{member_id}")
|
49
44
|
Member.new(Yajl::Parser.parse(response.read_body))
|
50
45
|
end
|
data/lib/trello/list.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Ruby wrapper around the Trello API
|
2
|
+
# Copyright (c) 2012, Jeremy Tregunna
|
3
|
+
# Use and distribution terms may be found in the file LICENSE included in this distribution.
|
4
|
+
|
5
|
+
module Trello
|
6
|
+
class List < BasicData
|
7
|
+
class << self
|
8
|
+
def find(id)
|
9
|
+
super(:lists, id)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Fields
|
14
|
+
|
15
|
+
def id
|
16
|
+
fields['id']
|
17
|
+
end
|
18
|
+
|
19
|
+
def name
|
20
|
+
fields['name']
|
21
|
+
end
|
22
|
+
|
23
|
+
def closed
|
24
|
+
fields['closed']
|
25
|
+
end
|
26
|
+
|
27
|
+
# Links to other data structures
|
28
|
+
|
29
|
+
def board
|
30
|
+
Board.find(fields['idBoard'])
|
31
|
+
end
|
32
|
+
|
33
|
+
def cards
|
34
|
+
fields['cards'].map do |c|
|
35
|
+
Card.new(c)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/trello/member.rb
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
# Use and distribution terms may be found in the file LICENSE included in this distribution.
|
4
4
|
|
5
5
|
module Trello
|
6
|
-
class Member
|
6
|
+
class Member < BasicData
|
7
7
|
class << self
|
8
8
|
def find(id_or_username)
|
9
|
-
|
10
|
-
new(Yajl::Parser.parse(response.read_body))
|
9
|
+
super(:members, id_or_username)
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
data/lib/trello/organization.rb
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
# Use and distribution terms may be found in the file LICENSE included in this distribution.
|
4
4
|
|
5
5
|
module Trello
|
6
|
-
class Organization
|
6
|
+
class Organization < BasicData
|
7
7
|
class << self
|
8
8
|
def find(id)
|
9
|
-
|
10
|
-
new(Yajl::Parser.parse(response.read_body))
|
9
|
+
super(:organizations, id)
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
data/spec/list_spec.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Trello
|
4
|
+
describe List do
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
Client.public_key = 'dummy'
|
9
|
+
Client.secret = 'dummy'
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
stub_request(:get, "https://api.trello.com/1/lists/abcdef123456789123456789?").
|
14
|
+
with(:headers => {'Accept'=>'*/*', 'Authorization'=>/.*/, 'User-Agent' => /.*/}).
|
15
|
+
to_return(:status => 200, :headers => {}, :body => Yajl::Encoder.encode(lists_details.first))
|
16
|
+
stub_request(:get, "https://api.trello.com/1/boards/abcdef123456789123456789?").
|
17
|
+
with(:headers => {'Accept'=>'*/*', 'Authorization'=>/.*/, 'User-Agent' => /.*/}).
|
18
|
+
to_return(:status => 200, :headers => {}, :body => Yajl::Encoder.encode(boards_details.first))
|
19
|
+
|
20
|
+
@list = List.find("abcdef123456789123456789")
|
21
|
+
end
|
22
|
+
|
23
|
+
context "fields" do
|
24
|
+
it "gets its id" do
|
25
|
+
@list.id.should == lists_details.first['id']
|
26
|
+
end
|
27
|
+
|
28
|
+
it "gets its name" do
|
29
|
+
@list.name.should == lists_details.first['name']
|
30
|
+
end
|
31
|
+
|
32
|
+
it "knows if it is open or closed" do
|
33
|
+
@list.closed.should == lists_details.first['closed']
|
34
|
+
end
|
35
|
+
|
36
|
+
it "has a board" do
|
37
|
+
@list.board.should == Board.new(boards_details.first)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "cards" do
|
42
|
+
it "has a list of cards" do
|
43
|
+
@list.cards.count.should be > 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/member_spec.rb
CHANGED
@@ -12,7 +12,10 @@ module Trello
|
|
12
12
|
end
|
13
13
|
|
14
14
|
before(:each) do
|
15
|
-
|
15
|
+
stub_request(:get, "https://api.trello.com/1/members/me?").
|
16
|
+
with(:headers => {'Accept'=>'*/*', 'Authorization'=>/.*/, 'User-Agent' => /.*/}).
|
17
|
+
to_return(:status => 200, :headers => {}, :body => user_payload)
|
18
|
+
|
16
19
|
@member = Member.find('me')
|
17
20
|
end
|
18
21
|
|
@@ -45,23 +48,23 @@ module Trello
|
|
45
48
|
|
46
49
|
context "personal" do
|
47
50
|
it "gets the members bio" do
|
48
|
-
@member.bio.
|
51
|
+
@member.bio.should == user_details['bio']
|
49
52
|
end
|
50
53
|
|
51
54
|
it "gets the full name" do
|
52
|
-
@member.full_name.
|
55
|
+
@member.full_name.should == user_details['fullName']
|
53
56
|
end
|
54
57
|
|
55
58
|
it "gets the gravatar id" do
|
56
|
-
@member.gravatar_id.
|
59
|
+
@member.gravatar_id.should == user_details['gravatar']
|
57
60
|
end
|
58
61
|
|
59
62
|
it "gets the url" do
|
60
|
-
@member.url.
|
63
|
+
@member.url.should == user_details['url']
|
61
64
|
end
|
62
65
|
|
63
66
|
it "gets the username" do
|
64
|
-
@member.username.
|
67
|
+
@member.username.should == user_details['username']
|
65
68
|
end
|
66
69
|
end
|
67
70
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -47,6 +47,20 @@ module Helpers
|
|
47
47
|
Yajl::Encoder.encode(boards_details)
|
48
48
|
end
|
49
49
|
|
50
|
+
def lists_details
|
51
|
+
[{
|
52
|
+
"id" => "abcdef123456789123456789",
|
53
|
+
"name" => "To Do",
|
54
|
+
"closed" => false,
|
55
|
+
"idBoard" => "abcdef123456789123456789",
|
56
|
+
"cards" => cards_details
|
57
|
+
}]
|
58
|
+
end
|
59
|
+
|
60
|
+
def lists_payload
|
61
|
+
Yajl::Encoder.encode(lists_details)
|
62
|
+
end
|
63
|
+
|
50
64
|
def cards_details
|
51
65
|
[{
|
52
66
|
"id" => "abcdef123456789123456789",
|
@@ -77,10 +91,4 @@ module Helpers
|
|
77
91
|
def orgs_payload
|
78
92
|
Yajl::Encoder.encode(orgs_details)
|
79
93
|
end
|
80
|
-
|
81
|
-
def stub_oauth!
|
82
|
-
stub_request(:get, "https://api.trello.com/1/members/me?").
|
83
|
-
with(:headers => {'Accept'=>'*/*', 'Authorization'=>/.*/, 'User-Agent' => /.*/}).
|
84
|
-
to_return(:status => 200, :headers => {}, :body => user_payload)
|
85
|
-
end
|
86
94
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-07 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &70325350827020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70325350827020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &70325350826560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.5
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70325350826560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: addressable
|
38
|
-
requirement: &
|
38
|
+
requirement: &70325350826100 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.2.6
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70325350826100
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70325350825640 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70325350825640
|
58
58
|
description: A wrapper around the trello.com API.
|
59
59
|
email: jeremy@tregunna.ca
|
60
60
|
executables: []
|
@@ -62,9 +62,11 @@ extensions: []
|
|
62
62
|
extra_rdoc_files:
|
63
63
|
- README.md
|
64
64
|
files:
|
65
|
+
- lib/trello/basic_data.rb
|
65
66
|
- lib/trello/board.rb
|
66
67
|
- lib/trello/card.rb
|
67
68
|
- lib/trello/client.rb
|
69
|
+
- lib/trello/list.rb
|
68
70
|
- lib/trello/member.rb
|
69
71
|
- lib/trello/organization.rb
|
70
72
|
- lib/trello.rb
|
@@ -72,6 +74,7 @@ files:
|
|
72
74
|
- spec/board_spec.rb
|
73
75
|
- spec/card_spec.rb
|
74
76
|
- spec/client_spec.rb
|
77
|
+
- spec/list_spec.rb
|
75
78
|
- spec/member_spec.rb
|
76
79
|
- spec/organization_spec.rb
|
77
80
|
- spec/spec_helper.rb
|
@@ -104,6 +107,7 @@ test_files:
|
|
104
107
|
- spec/board_spec.rb
|
105
108
|
- spec/card_spec.rb
|
106
109
|
- spec/client_spec.rb
|
110
|
+
- spec/list_spec.rb
|
107
111
|
- spec/member_spec.rb
|
108
112
|
- spec/organization_spec.rb
|
109
113
|
- spec/spec_helper.rb
|