lib/trello_wrapper.rb in trollolo-0.1.1 vs lib/trello_wrapper.rb in trollolo-0.2.0
- old
+ new
@@ -40,27 +40,27 @@
Trello::Organization.find(org_id)
end
def add_attachment(card_id, filename)
card = Trello::Card.find(card_id)
- card.add_attachment(File.open(filename, "rb"))
+ card.add_attachment(File.open(filename, 'rb'))
end
def make_cover(card_id, image_name)
attachment_id = attachment_id_by_name(card_id, image_name)
- raise("Error: The attachment with the name '#{image_name}' was not found") if !attachment_id
+ raise("Error: The attachment with the name '#{image_name}' was not found") unless attachment_id
+ make_cover_with_id(card_id, attachment_id)
+ end
+
+ def make_cover_with_id(card_id, attachment_id)
client.put("/cards/#{card_id}/idAttachmentCover?value=#{attachment_id}")
end
def attachment_id_by_name(card_id, image_name)
json = JSON.parse(client.get("/cards/#{card_id}/attachments?fields=name"))
- attachment = json.find{ |e| e["name"] == image_name }
- if attachment
- attachment["id"]
- else
- nil
- end
+ attachment = json.find{ |e| e['name'] == image_name }
+ attachment['id'] if attachment
end
def get_description(card_id)
card = Trello::Card.find(card_id)
card.desc
@@ -77,10 +77,10 @@
def set_name(card_id, name)
client.put("/cards/#{card_id}/name?value=#{name}")
end
def get_board(board_id)
- raise TrolloloError.new("Board id cannot be blank") if board_id.blank?
+ raise TrolloloError, 'Board id cannot be blank' if board_id.blank?
client.get("/boards/#{board_id}?lists=open&cards=open&card_checklists=all")
end
end