Created
February 20, 2016 16:22
-
-
Save afomi/3c086c048300b3b3dcb0 to your computer and use it in GitHub Desktop.
Create Cards from one Trello Card's Activities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ruby-trello' | |
# Also requires your Trello Keys (see the .gem docs) | |
board_id = "ENTER-YOUR-OWN-BOARD-ID" | |
# Getting actions from one Card | |
@board = Trello::Board.find(board_id) | |
@lists = @board.lists | |
@list = @lists.first | |
@cards = @list.cards | |
@card = @cards.first | |
actions = @card.actions | |
# Creating an array from the Actions | |
array = [] | |
actions.each do |a| | |
array << a.attributes[:data]["text"] | |
end | |
array.compact! | |
array | |
# Writing Actions from the Array | |
@board = Trello::Board.find(board_id) | |
@list = @board.lists.select { |l| l.name == "NAME-OF-YOUR-LIST" }.first | |
# reversed, because Actions are sorted DESC | |
# Newly created Cards go on top | |
array.reverse.each do |za| | |
Trello::Card.create(list_id: @list.id, name: za) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment