ruby-trello 1.1.3 → 1.2.0

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.
@@ -1,10 +1,31 @@
1
1
  module Trello
2
2
  # A Checklist holds items which are like a "task" list. Checklists are linked to a card.
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [rw] name
7
+ # @return [String]
8
+ # @!attribute [r] description
9
+ # @return [String]
10
+ # @!attribute [r] closed
11
+ # @return [Boolean]
12
+ # @!attribute [rw] position
13
+ # @return [Object]
14
+ # @!attribute [r] url
15
+ # @return [String]
16
+ # @!attribute [r] check_items
17
+ # @return [Object]
18
+ # @!attribute [r] board_id
19
+ # @return [String] A 24-character hex string
20
+ # @!attribute [r] list_id
21
+ # @return [String] A 24-character hex string
22
+ # @!attribute [r] member_ids
23
+ # @return [Array<String>] An array of 24-character hex strings
3
24
  class Checklist < BasicData
4
25
  register_attributes :id, :name, :description, :closed, :position, :url, :check_items, :board_id, :list_id, :member_ids,
5
- :readonly => [:id, :description, :closed, :url, :check_items, :board_id, :list_id, :member_ids]
26
+ readonly: [:id, :description, :closed, :url, :check_items, :board_id, :list_id, :member_ids]
6
27
  validates_presence_of :id, :board_id, :list_id
7
- validates_length_of :name, :in => 1..16384
28
+ validates_length_of :name, in: 1..16384
8
29
 
9
30
  class << self
10
31
  # Locate a specific checklist by its id.
@@ -47,13 +68,13 @@ module Trello
47
68
  return update! if id
48
69
 
49
70
  client.post("/checklists", {
50
- :name => name,
51
- :idBoard => board_id
71
+ name: name,
72
+ idBoard: board_id
52
73
  }).json_into(self)
53
74
  end
54
75
 
55
76
  def update!
56
- client.put("/checklists/#{id}", {:name => name, :pos => position}).json_into(self)
77
+ client.put("/checklists/#{id}", {name: name, pos: position}).json_into(self)
57
78
  end
58
79
 
59
80
  # Return a list of items on the checklist.
@@ -64,10 +85,10 @@ module Trello
64
85
  end
65
86
 
66
87
  # Return a reference to the board the checklist is on.
67
- one :board, :path => :checklists, :using => :board_id
88
+ one :board, path: :checklists, using: :board_id
68
89
 
69
90
  # Return a reference to the list the checklist is on.
70
- one :list, :path => :lists, :using => :list_id
91
+ one :list, path: :lists, using: :list_id
71
92
 
72
93
  # Return a list of members active in this checklist.
73
94
  def members
@@ -79,7 +100,7 @@ module Trello
79
100
 
80
101
  # Add an item to the checklist
81
102
  def add_item(name, checked=false, position='bottom')
82
- client.post("/checklists/#{id}/checkItems", {:name => name, :checked => checked, :pos => position})
103
+ client.post("/checklists/#{id}/checkItems", {name: name, checked: checked, pos: position})
83
104
  end
84
105
 
85
106
  # Delete a checklist item
@@ -48,19 +48,19 @@ module Trello
48
48
 
49
49
  def oauth_credentials
50
50
  {
51
- :consumer_key => consumer_key,
52
- :consumer_secret => consumer_secret,
53
- :oauth_token => oauth_token,
54
- :oauth_token_secret => oauth_token_secret,
55
- :return_url => return_url,
56
- :callback => callback,
51
+ consumer_key: consumer_key,
52
+ consumer_secret: consumer_secret,
53
+ oauth_token: oauth_token,
54
+ oauth_token_secret: oauth_token_secret,
55
+ return_url: return_url,
56
+ callback: callback,
57
57
  }.delete_if { |key, value| value.nil? }
58
58
  end
59
59
 
60
60
  def basic_credentials
61
61
  {
62
- :developer_public_key => developer_public_key,
63
- :member_token => member_token
62
+ developer_public_key: developer_public_key,
63
+ member_token: member_token
64
64
  }
65
65
  end
66
66
 
@@ -2,7 +2,7 @@ module Trello
2
2
  module HasActions
3
3
  # Returns a list of the actions associated with this object.
4
4
  def actions(options = {})
5
- actions = client.get("#{request_prefix}/actions", { :filter => :all }.merge(options)).json_into(Action)
5
+ actions = client.get("#{request_prefix}/actions", { filter: :all }.merge(options)).json_into(Action)
6
6
  MultiAssociation.new(self, actions).proxy
7
7
  end
8
8
  end
data/lib/trello/item.rb CHANGED
@@ -1,7 +1,18 @@
1
1
  module Trello
2
2
  # An Item is a basic task that can be checked off and marked as completed.
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [r] name
7
+ # @return [String]
8
+ # @!attribute [r] type
9
+ # @return [Object]
10
+ # @!attribute [r] state
11
+ # @return [Object]
12
+ # @!attribute [r] pos
13
+ # @return [Object]
3
14
  class Item < BasicData
4
- register_attributes :id, :name, :type, :state, :pos, :readonly => [ :id, :name, :type, :state, :pos ]
15
+ register_attributes :id, :name, :type, :state, :pos, readonly: [ :id, :name, :type, :state, :pos ]
5
16
  validates_presence_of :id, :type
6
17
 
7
18
  # Updates the fields of an item.
@@ -17,4 +28,4 @@ module Trello
17
28
  self
18
29
  end
19
30
  end
20
- end
31
+ end
@@ -1,7 +1,14 @@
1
1
  module Trello
2
2
  # Represents the state of an item.
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [r] state
7
+ # @return [Object]
8
+ # @!attribute [r] item_id
9
+ # @return [String]
3
10
  class CheckItemState < BasicData
4
- register_attributes :id, :state, :item_id, :readonly => [ :id, :state, :item_id ]
11
+ register_attributes :id, :state, :item_id, readonly: [ :id, :state, :item_id ]
5
12
  validates_presence_of :id, :item_id
6
13
 
7
14
  # Update the fields of an item state.
data/lib/trello/label.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  module Trello
2
2
 
3
3
  # A colored Label attached to a card
4
+ #
5
+ # @!attribute [rw] id
6
+ # @return [String]
7
+ # @!attribute [rw] color
8
+ # @return [String]
4
9
  class Label < BasicData
5
10
  register_attributes :name, :color
6
11
 
@@ -2,7 +2,7 @@ module Trello
2
2
 
3
3
  # A colored Label attached to a card
4
4
  class LabelName < BasicData
5
- register_attributes :yellow, :red, :orange, :green, :purple, :blue
5
+ register_attributes :yellow, :red, :orange, :green, :purple, :blue, :sky, :pink, :lime, :black
6
6
 
7
7
  # Update the fields of a label.
8
8
  #
@@ -15,12 +15,17 @@ module Trello
15
15
  attributes[:green] = fields['green']
16
16
  attributes[:purple] = fields['purple']
17
17
  attributes[:blue] = fields['blue']
18
+ attributes[:sky] = fields['sky']
19
+ attributes[:pink] = fields['pink']
20
+ attributes[:lime] = fields['lime']
21
+ attributes[:black] = fields['black']
22
+
18
23
  self
19
24
  end
20
25
 
21
- one :board, :path => :boards, :using => :board_id
26
+ one :board, path: :boards, using: :board_id
22
27
 
23
- many :cards, :filter => :all
28
+ many :cards, filter: :all
24
29
 
25
30
  end
26
31
  end
data/lib/trello/list.rb CHANGED
@@ -1,14 +1,28 @@
1
1
  module Trello
2
2
  # A List is a container which holds cards. Lists are items on a board.
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [rw] name
7
+ # @return [String]
8
+ # @!attribute [rw] closed
9
+ # @return [Boolean]
10
+ # @!attribute [r] board_id
11
+ # @return [String] A 24-character hex string
12
+ # @!attribute [rw] pos
13
+ # @return [Object]
3
14
  class List < BasicData
4
- register_attributes :id, :name, :closed, :board_id, :pos, :readonly => [ :id, :board_id ]
15
+ register_attributes :id, :name, :closed, :board_id, :pos, readonly: [ :id, :board_id ]
5
16
  validates_presence_of :id, :name, :board_id
6
- validates_length_of :name, :in => 1..16384
17
+ validates_length_of :name, in: 1..16384
7
18
 
8
19
  include HasActions
9
20
 
10
21
  class << self
11
22
  # Finds a specific list, given an id.
23
+ #
24
+ # @param [id] id the list's ID on Trello (24-character hex string).
25
+ # @param [Hash] params
12
26
  def find(id, params = {})
13
27
  client.find(:list, id, params)
14
28
  end
@@ -37,16 +51,16 @@ module Trello
37
51
  return update! if id
38
52
 
39
53
  client.post("/lists", {
40
- :name => name,
41
- :closed => closed || false,
42
- :idBoard => board_id
54
+ name: name,
55
+ closed: closed || false,
56
+ idBoard: board_id
43
57
  }).json_into(self)
44
58
  end
45
59
 
46
60
  def update!
47
61
  client.put("/lists/#{id}", {
48
- :name => name,
49
- :closed => closed
62
+ name: name,
63
+ closed: closed
50
64
  })
51
65
  end
52
66
 
@@ -65,14 +79,14 @@ module Trello
65
79
  end
66
80
 
67
81
  # Return the board the list is connected to.
68
- one :board, :path => :boards, :using => :board_id
82
+ one :board, path: :boards, using: :board_id
69
83
 
70
84
  # Returns all the cards on this list.
71
85
  #
72
86
  # The options hash may have a filter key which can have its value set as any
73
87
  # of the following values:
74
88
  # :filter => [ :none, :open, :closed, :all ] # default :open
75
- many :cards, :filter => :open
89
+ many :cards, filter: :open
76
90
 
77
91
  # :nodoc:
78
92
  def request_prefix
data/lib/trello/member.rb CHANGED
@@ -1,10 +1,27 @@
1
1
  module Trello
2
2
  # A Member is a user of the Trello service.
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [r] username
7
+ # @return [String]
8
+ # @!attribute [rw] email
9
+ # @return [String]
10
+ # @!attribute [rw] full_name
11
+ # @return [String]
12
+ # @!attribute [rw] initials
13
+ # @return [String]
14
+ # @!attribute [r] avatar_id
15
+ # @return [String]
16
+ # @!attribute [rw] bio
17
+ # @return [String]
18
+ # @!attribute [r] url
19
+ # @return [String]
3
20
  class Member < BasicData
4
- register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, :readonly => [ :id, :username, :avatar_id, :url ]
21
+ register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
5
22
  validates_presence_of :id, :username
6
- validates_length_of :full_name, :minimum => 4
7
- validates_length_of :bio, :maximum => 16384
23
+ validates_length_of :full_name, minimum: 4
24
+ validates_length_of :bio, maximum: 16384
8
25
 
9
26
  include HasActions
10
27
 
@@ -38,7 +55,7 @@ module Trello
38
55
  # Valid values for options are:
39
56
  # :large (170x170)
40
57
  # :small (30x30)
41
- def avatar_url(options = { :size => :large })
58
+ def avatar_url(options = { size: :large })
42
59
  size = options[:size] == :small ? 30 : 170
43
60
  "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
44
61
  end
@@ -50,7 +67,7 @@ module Trello
50
67
  # :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
51
68
  # i.e.,
52
69
  # me.boards(:filter => :closed) # retrieves all closed boards
53
- many :boards, :filter => :all
70
+ many :boards, filter: :all
54
71
 
55
72
  # Returns a list of cards the member is assigned to.
56
73
  #
@@ -59,7 +76,7 @@ module Trello
59
76
  # :filter => [ :none, :open, :closed, :all ] # default :open
60
77
  # i.e.,
61
78
  # me.cards(:filter => :closed) # retrieves all closed cards
62
- many :cards, :filter => :open
79
+ many :cards, filter: :open
63
80
 
64
81
  # Returns a list of the organizations this member is a part of.
65
82
  #
@@ -68,7 +85,7 @@ module Trello
68
85
  # :filter => [ :none, :members, :public, :all ] # default: all
69
86
  # i.e.,
70
87
  # me.organizations(:filter => :public) # retrieves all public organizations
71
- many :organizations, :filter => :all
88
+ many :organizations, filter: :all
72
89
 
73
90
  # Returns a list of notifications for the user
74
91
  many :notifications
@@ -82,8 +99,8 @@ module Trello
82
99
 
83
100
  def update!
84
101
  client.put(request_prefix, {
85
- :fullName => full_name,
86
- :bio => bio
102
+ fullName: full_name,
103
+ bio: bio
87
104
  }).json_into(self)
88
105
  end
89
106
 
data/lib/trello/net.rb CHANGED
@@ -26,11 +26,11 @@ module Trello
26
26
  def execute_core(request)
27
27
  RestClient.proxy = ENV['HTTP_PROXY'] if ENV['HTTP_PROXY']
28
28
  RestClient::Request.execute(
29
- :method => request.verb,
30
- :url => request.uri.to_s,
31
- :headers => request.headers,
32
- :payload => request.body,
33
- :timeout => 10
29
+ method: request.verb,
30
+ url: request.uri.to_s,
31
+ headers: request.headers,
32
+ payload: request.body,
33
+ timeout: 10
34
34
  )
35
35
  end
36
36
  end
@@ -1,7 +1,20 @@
1
1
  module Trello
2
+
3
+ # @!attribute [r] id
4
+ # @return [String]
5
+ # @!attribute [rw] unread
6
+ # @return [Boolean]
7
+ # @!attribute [r] type
8
+ # @return [Object]
9
+ # @!attribute [r] date
10
+ # @return [Datetime]
11
+ # @!attribute [rw] data
12
+ # @return [Object]
13
+ # @!attribute [r] member_creator_id,
14
+ # @return [String]
2
15
  class Notification < BasicData
3
16
  register_attributes :id, :unread, :type, :date, :data, :member_creator_id,
4
- :read_only => [ :id, :unread, :type, :date, :member_creator_id ]
17
+ read_only: [ :id, :unread, :type, :date, :member_creator_id ]
5
18
  validates_presence_of :id, :type, :date, :member_creator_id
6
19
 
7
20
  class << self
@@ -23,7 +36,7 @@ module Trello
23
36
 
24
37
  alias :unread? :unread
25
38
 
26
- one :member_creator, :path => :members, :via => Member, :using => :member_creator_id
39
+ one :member_creator, path: :members, via: Member, using: :member_creator_id
27
40
 
28
41
  def board
29
42
  client.get("/notifications/#{id}/board").json_into(Board)
@@ -1,8 +1,19 @@
1
1
  module Trello
2
2
  # Organizations are useful for linking members together.
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [r] name
7
+ # @return [String]
8
+ # @!attribute [r] display_name
9
+ # @return [String]
10
+ # @!attribute [r] description
11
+ # @return [String]
12
+ # @!attribute [r] url
13
+ # @return [String]
3
14
  class Organization < BasicData
4
15
  register_attributes :id, :name, :display_name, :description, :url,
5
- :readonly => [ :id, :name, :display_name, :description, :url ]
16
+ readonly: [ :id, :name, :display_name, :description, :url ]
6
17
  validates_presence_of :id, :name
7
18
 
8
19
  include HasActions
data/lib/trello/token.rb CHANGED
@@ -1,7 +1,18 @@
1
1
  module Trello
2
+
3
+ # @!attribute [r] id
4
+ # @return [String]
5
+ # @!attribute [r] member_id
6
+ # @return [String]
7
+ # @!attribute [r] created_at
8
+ # @return [Datetime]
9
+ # @!attribute [r] permissions
10
+ # @return [Object]
11
+ # @!attribute [r] webhooks
12
+ # @return [Object]
2
13
  class Token < BasicData
3
14
  register_attributes :id, :member_id, :created_at, :permissions, :webhooks,
4
- :readonly => [ :id, :member_id, :created_at, :permissions, :webhooks ]
15
+ readonly: [ :id, :member_id, :created_at, :permissions, :webhooks ]
5
16
 
6
17
  class << self
7
18
  # Finds a token
@@ -20,6 +31,6 @@ module Trello
20
31
  end
21
32
 
22
33
  # Returns a reference to the user who authorized the token.
23
- one :member, :path => :members, :using => :member_id
34
+ one :member, path: :members, using: :member_id
24
35
  end
25
36
  end
@@ -1,10 +1,21 @@
1
1
  module Trello
2
- # A webhook is an url called each time a specified idModel is updated
2
+ # A webhook is a URL called each time a specified model is updated
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [r] description
7
+ # @return [String]
8
+ # @!attribute [r] id_model
9
+ # @return [String] A 24-character hex string
10
+ # @!attribute [r] callback_url
11
+ # @return [String]
12
+ # @!attribute [r] active
13
+ # @return [Boolean]
3
14
  class Webhook < BasicData
4
15
  register_attributes :id, :description, :id_model, :callback_url, :active,
5
- :readonly => [ :id ]
16
+ readonly: [ :id ]
6
17
  validates_presence_of :id, :id_model, :callback_url
7
- validates_length_of :description, :in => 1..16384
18
+ validates_length_of :description, in: 1..16384
8
19
 
9
20
  class << self
10
21
  # Find a specific webhook by its ID.
@@ -18,9 +29,14 @@ module Trello
18
29
  # Create a new webhook and save it to Trello.
19
30
  #
20
31
  # @param [Hash] options
32
+ #
21
33
  # @option options [String] :description (optional) A string with a length from 0 to 16384
22
- # @option options [String] :callback_url (required) A valid URL that is reachable with a HEAD request
34
+ # @option options [String] :callback_url (required) A valid URL that is
35
+ # reachable with a HEAD request
23
36
  # @option options [String] :id_model (required) id of the model that should be hooked
37
+ #
38
+ # @raise [Trello::Error] if the Webhook could not be created.
39
+ #
24
40
  # @return [Trello::Webhook]
25
41
  def create(options)
26
42
  client.create(:webhook,
@@ -30,7 +46,7 @@ module Trello
30
46
  end
31
47
  end
32
48
 
33
- # return [Trello::Webhook] self
49
+ # @return [Trello::Webhook] self
34
50
  def update_fields(fields)
35
51
  attributes[:id] = fields['id']
36
52
  attributes[:description] = fields['description']
@@ -40,27 +56,39 @@ module Trello
40
56
  self
41
57
  end
42
58
 
59
+ # Save the webhook.
60
+ #
61
+ # @raise [Trello::Error] if the Webhook could not be saved.
62
+ #
63
+ # @return [String] the JSON representation of the saved webhook.
43
64
  def save
44
65
  # If we have an id, just update our fields.
45
66
  return update! if id
46
67
 
47
68
  client.post("/webhooks", {
48
- :description => description,
49
- :idModel => id_model,
50
- :callbackURL => callback_url
69
+ description: description,
70
+ idModel: id_model,
71
+ callbackURL: callback_url
51
72
  }).json_into(self)
52
73
  end
53
74
 
75
+ # Update the webhook.
76
+ #
77
+ # @raise [Trello::Error] if the Webhook could not be saved.
78
+ #
79
+ # @return [String] the JSON representation of the updated webhook.
54
80
  def update!
55
81
  client.put("/webhooks/#{id}", {
56
- :description => description,
57
- :idModel => id_model,
58
- :callbackURL => callback_url,
59
- :active => active
82
+ description: description,
83
+ idModel: id_model,
84
+ callbackURL: callback_url,
85
+ active: active
60
86
  })
61
87
  end
62
88
 
63
89
  # Delete this webhook
90
+ #
91
+ # @return [String] the JSON response from the Trello API
64
92
  def delete
65
93
  client.delete("/webhooks/#{id}")
66
94
  end