ruby-trello 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c17175318e69e1e208b7627f0615eb57c51bf390
4
- data.tar.gz: c1a06d5f619a2c87be2e97b138af7b0f8c6507c3
3
+ metadata.gz: eff2182d04d8c17e2f7978adac83a17b053e77c2
4
+ data.tar.gz: 98a0c4853b9033260ee8b7095dddcf2b65899d42
5
5
  SHA512:
6
- metadata.gz: ad4b9c49036f29e88b67482ac536f1a76add9db97390724449b7d7de8c9fb23421f00e401486ed99ee6a18ed96d816db40d64dc583a4132a81911dea4baffdd0
7
- data.tar.gz: 1f629c2acef4cfa18b60503b7c16799d89dd64193d1e72a3ec9abaee1950d12ba414104d6e4d3ccf48bedac2214fcf3a9e63eb51cf3cdb0fb7fe26805927d7dd
6
+ metadata.gz: 8e50b332a4d61974e2c27dd2d2e9d110bb54971d668ea659cca4f06762d0d42b155da98c00e391eb151451983e95405e44545425841692647e9ca17b3bdbe7c0
7
+ data.tar.gz: 2b3526b6a11edee0d6ba2357f4fda861bc2c2c0c376f8df945fe4dd412ed2e86589a4be66892765e8de581314fb265172fd0c009e38636f65bde74abceb36fa4
@@ -38,6 +38,7 @@ require 'addressable/uri'
38
38
  # Feel free to {peruse and participate in our Trello board}[https://trello.com/board/ruby-trello/4f092b2ee23cb6fe6d1aaabd]. It's completely open to the public.
39
39
  module Trello
40
40
  autoload :Action, 'trello/action'
41
+ autoload :Comment, 'trello/comment'
41
42
  autoload :Association, 'trello/association'
42
43
  autoload :AssociationProxy, 'trello/association_proxy'
43
44
  autoload :Attachment, 'trello/attachment'
@@ -128,7 +129,7 @@ module Trello
128
129
  params[:key] ||= configuration.developer_public_key or
129
130
  raise ArgumentError, 'Please configure your Trello public key'
130
131
  params[:name] ||= 'Ruby Trello'
131
- params[:scope] = 'read,write,account'
132
+ params[:scope] ||= 'read,write,account'
132
133
  params[:expiration] ||= 'never'
133
134
  params[:response_type] ||= 'token'
134
135
  uri = Addressable::URI.parse 'https://trello.com/1/authorize'
@@ -35,13 +35,18 @@ module Trello
35
35
  # @return [Hash]
36
36
  # @!attribute [r] card_members
37
37
  # @return [Object]
38
+ # @!attribute [rw] source_card_id
39
+ # @return [String] A 24-character hex string
40
+ # @!attribute [rw] source_card_properties
41
+ # @return [Array<String>] Array of strings
42
+
38
43
  class Card < BasicData
39
44
  register_attributes :id, :short_id, :name, :desc, :due, :closed, :url, :short_url,
40
45
  :board_id, :member_ids, :list_id, :pos, :last_activity_date, :card_labels,
41
- :cover_image_id, :badges, :card_members,
46
+ :cover_image_id, :badges, :card_members, :source_card_id, :source_card_properties,
42
47
  readonly: [ :id, :short_id, :url, :short_url, :last_activity_date, :badges, :card_members ]
43
48
  validates_presence_of :id, :name, :list_id
44
- validates_length_of :name, in: 1..16384
49
+ validates_length_of :name, in: 1..16384
45
50
  validates_length_of :desc, in: 0..16384
46
51
 
47
52
  include HasActions
@@ -61,9 +66,11 @@ module Trello
61
66
  list_id: 'idList',
62
67
  pos: 'pos',
63
68
  last_activity_date: 'dateLastActivity',
64
- card_labels: 'labels',
69
+ card_labels: 'idLabels',
65
70
  badges: 'badges',
66
- card_members: 'members'
71
+ card_members: 'members',
72
+ source_card_id: "idCardSource",
73
+ source_card_properties: "keepFromSource"
67
74
  }
68
75
 
69
76
  class << self
@@ -78,6 +85,10 @@ module Trello
78
85
 
79
86
  # Create a new card and save it on Trello.
80
87
  #
88
+ # If using source_card_id to duplicate a card, make sure to save
89
+ # the source card to Trello before calling this method to assure
90
+ # the correct data is used in the duplication.
91
+ #
81
92
  # @param [Hash] options
82
93
  # @option options [String] :name The name of the new card.
83
94
  # @option options [String] :list_id ID of the list that the card should
@@ -91,6 +102,11 @@ module Trello
91
102
  # @option options [Date] :due A date, or `nil`.
92
103
  # @option options [String] :pos A position. `"top"`, `"bottom"`, or a
93
104
  # positive number. Defaults to `"bottom"`.
105
+ # @option options [String] :source_card_id ID of the card to copy
106
+ # @option options [String] :source_card_properties A single, or array of,
107
+ # string properties to copy from source card.
108
+ # `"all"`, `"checklists"`, `"due"`, `"members"`, or `nil`.
109
+ # Defaults to `"all"`.
94
110
  #
95
111
  # @raise [Trello::Error] if the card could not be created.
96
112
  #
@@ -101,9 +117,11 @@ module Trello
101
117
  'idList' => options[:list_id],
102
118
  'desc' => options[:desc],
103
119
  'idMembers' => options[:member_ids],
104
- 'labels' => options[:card_labels],
120
+ 'idLabels' => options[:card_labels],
105
121
  'due' => options[:due],
106
- 'pos' => options[:pos]
122
+ 'pos' => options[:pos],
123
+ 'idCardSource' => options[:source_card_id],
124
+ 'keepFromSource' => options.key?(:source_card_properties) ? options[:source_card_properties] : 'all'
107
125
  )
108
126
  end
109
127
  end
@@ -138,27 +156,30 @@ module Trello
138
156
  # @option fields [Object] :cover_image_id
139
157
  # @option fields [Object] :badges
140
158
  # @option fields [Object] :card_members
159
+ # @option fields [String] :source_card_id
160
+ # @option fields [Array] :source_card_properties
141
161
  #
142
162
  # @return [Trello::Card] self
143
163
  def update_fields(fields)
144
- attributes[:id] = fields[SYMBOL_TO_STRING[:id]]
145
- attributes[:short_id] = fields[SYMBOL_TO_STRING[:short_id]]
146
- attributes[:name] = fields[SYMBOL_TO_STRING[:name]]
147
- attributes[:desc] = fields[SYMBOL_TO_STRING[:desc]]
148
- attributes[:due] = Time.iso8601(fields[SYMBOL_TO_STRING[:due]]) rescue nil
149
- attributes[:closed] = fields[SYMBOL_TO_STRING[:closed]]
150
- attributes[:url] = fields[SYMBOL_TO_STRING[:url]]
151
- attributes[:short_url] = fields[SYMBOL_TO_STRING[:short_url]]
152
- attributes[:board_id] = fields[SYMBOL_TO_STRING[:board_id]]
153
- attributes[:member_ids] = fields[SYMBOL_TO_STRING[:member_ids]]
154
- attributes[:list_id] = fields[SYMBOL_TO_STRING[:list_id]]
155
- attributes[:pos] = fields[SYMBOL_TO_STRING[:pos]]
156
- attributes[:card_labels] = fields[SYMBOL_TO_STRING[:card_labels]]
157
- attributes[:last_activity_date] = Time.iso8601(fields[SYMBOL_TO_STRING[:last_activity_date]]) rescue nil
158
- attributes[:cover_image_id] = fields[SYMBOL_TO_STRING[:cover_image_id]]
159
- attributes[:badges] = fields[SYMBOL_TO_STRING[:badges]]
160
- attributes[:card_members] = fields[SYMBOL_TO_STRING[:card_members]]
161
-
164
+ attributes[:id] = fields[SYMBOL_TO_STRING[:id]]
165
+ attributes[:short_id] = fields[SYMBOL_TO_STRING[:short_id]]
166
+ attributes[:name] = fields[SYMBOL_TO_STRING[:name]]
167
+ attributes[:desc] = fields[SYMBOL_TO_STRING[:desc]]
168
+ attributes[:due] = Time.iso8601(fields[SYMBOL_TO_STRING[:due]]) rescue nil
169
+ attributes[:closed] = fields[SYMBOL_TO_STRING[:closed]]
170
+ attributes[:url] = fields[SYMBOL_TO_STRING[:url]]
171
+ attributes[:short_url] = fields[SYMBOL_TO_STRING[:short_url]]
172
+ attributes[:board_id] = fields[SYMBOL_TO_STRING[:board_id]]
173
+ attributes[:member_ids] = fields[SYMBOL_TO_STRING[:member_ids]]
174
+ attributes[:list_id] = fields[SYMBOL_TO_STRING[:list_id]]
175
+ attributes[:pos] = fields[SYMBOL_TO_STRING[:pos]]
176
+ attributes[:card_labels] = fields[SYMBOL_TO_STRING[:card_labels]]
177
+ attributes[:last_activity_date] = Time.iso8601(fields[SYMBOL_TO_STRING[:last_activity_date]]) rescue nil
178
+ attributes[:cover_image_id] = fields[SYMBOL_TO_STRING[:cover_image_id]]
179
+ attributes[:badges] = fields[SYMBOL_TO_STRING[:badges]]
180
+ attributes[:card_members] = fields[SYMBOL_TO_STRING[:card_members]]
181
+ attributes[:source_card_id] = fields[SYMBOL_TO_STRING[:source_card_id]]
182
+ attributes[:source_card_properties] = fields[SYMBOL_TO_STRING[:source_card_properties]]
162
183
  self
163
184
  end
164
185
 
@@ -211,7 +232,9 @@ module Trello
211
232
  idMembers: member_ids,
212
233
  idLabels: card_labels,
213
234
  pos: pos,
214
- due: due
235
+ due: due,
236
+ idCardSource: source_card_id,
237
+ keepFromSource: source_card_properties
215
238
  })
216
239
  end
217
240
 
@@ -365,5 +388,10 @@ module Trello
365
388
  def request_prefix
366
389
  "/cards/#{id}"
367
390
  end
391
+
392
+ # Retrieve a list of comments
393
+ def comments
394
+ comments = Comment.from_response client.get("/cards/#{id}/actions", filter: "commentCard")
395
+ end
368
396
  end
369
397
  end
@@ -0,0 +1,62 @@
1
+ module Trello
2
+ # A Comment is a string with a creation date; it resides inside a Card and belongs to a User.
3
+ #
4
+ # @!attribute [r] action_id
5
+ # @return [String]
6
+ # @!attribute [r] text
7
+ # @return [String]
8
+ # @!attribute [r] date
9
+ # @return [Datetime]
10
+ # @!attribute [r] member_creator_id
11
+ # @return [String]
12
+ class Comment < BasicData
13
+ register_attributes :action_id, :text, :date, :member_creator_id,
14
+ readonly: [ :action_id, :text, :date, :member_creator_id ]
15
+ validates_presence_of :action_id, :text, :date, :member_creator_id
16
+ validates_length_of :text, in: 1..16384
17
+
18
+ class << self
19
+ # Locate a specific action and return a new Comment object.
20
+ def find(action_id)
21
+ client.find(:action, action_id, filter: commentCard)
22
+ end
23
+ end
24
+
25
+ # Update the attributes of a Comment
26
+ #
27
+ # Supply a hash of string keyed data retrieved from the Trello API representing
28
+ # a Comment.
29
+ def update_fields(fields)
30
+ attributes[:action_id] = fields['id']
31
+ attributes[:text] = fields['data']['text']
32
+ attributes[:date] = Time.iso8601(fields['date'])
33
+ attributes[:member_creator_id] = fields['idMemberCreator']
34
+ self
35
+ end
36
+
37
+ # Returns the board this comment is located
38
+ def board
39
+ Board.from_response client.get("/actions/#{action_id}/board")
40
+ end
41
+
42
+ # Returns the card the comment is located
43
+ def card
44
+ Card.from_response client.get("/actions/#{action_id}/card")
45
+ end
46
+
47
+ # Returns the list the comment is located
48
+ def list
49
+ List.from_response client.get("/actions/#{action_id}/list")
50
+ end
51
+
52
+ # Deletes the comment from the card
53
+ def delete
54
+ ruta = "/actions/#{action_id}"
55
+ client.delete(ruta)
56
+ end
57
+
58
+
59
+ # Returns the member who created the comment.
60
+ one :member_creator, via: Member, path: :members, using: :member_creator_id
61
+ end
62
+ end
@@ -63,7 +63,7 @@ module Trello
63
63
  result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
64
64
 
65
65
  expected_payload = {name: "Test Card", desc: nil, idList: "abcdef123456789123456789",
66
- idMembers: nil, idLabels: "abcdef123456789123456789", pos: nil, due: nil}
66
+ idMembers: nil, idLabels: "abcdef123456789123456789", pos: nil, due: nil, idCardSource: nil, keepFromSource: 'all'}
67
67
 
68
68
  expect(client)
69
69
  .to receive(:post)
@@ -74,6 +74,69 @@ module Trello
74
74
 
75
75
  expect(card).to be_a Card
76
76
  end
77
+
78
+ it 'creates a duplicate card with all source properties and saves it on Trello', refactor: true do
79
+ payload = {
80
+ source_card_id: cards_details.first['id']
81
+ }
82
+
83
+ result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
84
+
85
+ expected_payload = {name: nil, desc: nil, idList: "abcdef123456789123456789",
86
+ idMembers: nil, idLabels: nil, pos: nil, due: nil, idCardSource: cards_details.first['id'], keepFromSource: 'all'}
87
+
88
+ expect(client)
89
+ .to receive(:post)
90
+ .with("/cards", expected_payload)
91
+ .and_return result
92
+
93
+ card = Card.create(cards_details.first.merge(payload.merge(list_id: lists_details.first['id'])))
94
+
95
+ expect(card).to be_a Card
96
+ end
97
+
98
+ it 'creates a duplicate card with source due date and checklists and saves it on Trello', refactor: true do
99
+ payload = {
100
+ source_card_id: cards_details.first['id'],
101
+ source_card_properties: ['due','checklists']
102
+ }
103
+
104
+ result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
105
+
106
+ expected_payload = {name: nil, desc: nil, idList: "abcdef123456789123456789",
107
+ idMembers: nil, idLabels: nil, pos: nil, due: nil, idCardSource: cards_details.first['id'], keepFromSource: ['due','checklists']}
108
+
109
+ expect(client)
110
+ .to receive(:post)
111
+ .with("/cards", expected_payload)
112
+ .and_return result
113
+
114
+ card = Card.create(cards_details.first.merge(payload.merge(list_id: lists_details.first['id'])))
115
+
116
+ expect(card).to be_a Card
117
+ end
118
+
119
+ it 'creates a duplicate card with no source properties and saves it on Trello', refactor: true do
120
+ payload = {
121
+ source_card_id: cards_details.first['id'],
122
+ source_card_properties: nil
123
+ }
124
+
125
+ result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
126
+
127
+ expected_payload = {name: nil, desc: nil, idList: "abcdef123456789123456789",
128
+ idMembers: nil, idLabels: nil, pos: nil, due: nil, idCardSource: cards_details.first['id'], keepFromSource: nil}
129
+
130
+ expect(client)
131
+ .to receive(:post)
132
+ .with("/cards", expected_payload)
133
+ .and_return result
134
+
135
+ card = Card.create(cards_details.first.merge(payload.merge(list_id: lists_details.first['id'])))
136
+
137
+ expect(card).to be_a Card
138
+ end
139
+
77
140
  end
78
141
 
79
142
  context "updating" do
@@ -86,6 +86,12 @@ describe Trello do
86
86
  it { expect(Trello.public_key_url).to eq('https://trello.com/app-key') }
87
87
  it { expect(Trello.authorize_url(key: 'foo')).to match(%r{^https://trello.com/1/authorize}) }
88
88
 
89
+ describe '.authorize_url' do
90
+ it 'allows the scope to be set' do
91
+ expect(Trello.authorize_url(key: 'foo', scope: 'read')).to match(%r{scope=read$})
92
+ end
93
+ end
94
+
89
95
  describe '.open_public_key_url' do
90
96
  it 'launches app key endpoint' do
91
97
  expect(Launchy).to receive(:open).with('https://trello.com/app-key')
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Tregunna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-01 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: oauth
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.4.5
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.4.5
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rest-client
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.8.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.8.0
83
83
  description: A wrapper around the trello.com API.
@@ -87,6 +87,8 @@ extensions: []
87
87
  extra_rdoc_files:
88
88
  - README.md
89
89
  files:
90
+ - README.md
91
+ - lib/trello.rb
90
92
  - lib/trello/action.rb
91
93
  - lib/trello/association.rb
92
94
  - lib/trello/association_proxy.rb
@@ -97,6 +99,7 @@ files:
97
99
  - lib/trello/card.rb
98
100
  - lib/trello/checklist.rb
99
101
  - lib/trello/client.rb
102
+ - lib/trello/comment.rb
100
103
  - lib/trello/configuration.rb
101
104
  - lib/trello/core_ext/array.rb
102
105
  - lib/trello/core_ext/hash.rb
@@ -116,8 +119,6 @@ files:
116
119
  - lib/trello/organization.rb
117
120
  - lib/trello/token.rb
118
121
  - lib/trello/webhook.rb
119
- - lib/trello.rb
120
- - README.md
121
122
  - spec/action_spec.rb
122
123
  - spec/array_spec.rb
123
124
  - spec/association_spec.rb
@@ -150,22 +151,22 @@ licenses:
150
151
  metadata: {}
151
152
  post_install_message:
152
153
  rdoc_options:
153
- - --charset=UTF-8
154
+ - "--charset=UTF-8"
154
155
  require_paths:
155
156
  - lib
156
157
  required_ruby_version: !ruby/object:Gem::Requirement
157
158
  requirements:
158
- - - '>='
159
+ - - ">="
159
160
  - !ruby/object:Gem::Version
160
161
  version: 2.0.0
161
162
  required_rubygems_version: !ruby/object:Gem::Requirement
162
163
  requirements:
163
- - - '>='
164
+ - - ">="
164
165
  - !ruby/object:Gem::Version
165
166
  version: '0'
166
167
  requirements: []
167
168
  rubyforge_project: ruby-trello
168
- rubygems_version: 2.0.14
169
+ rubygems_version: 2.5.1
169
170
  signing_key:
170
171
  specification_version: 4
171
172
  summary: A wrapper around the trello.com API.