class Object
Constants
- APP_NAME
Public Instance Methods
_get_board_id(boards, board_name)
click to toggle source
# File trello-bulk, line 10 def _get_board_id(boards, board_name) # Get all open boards open_boards = boards.reject(&:closed) board = open_boards.select { |b| b.name == board_name } if board.empty? warn "#{APP_NAME}: failed to find a board named `#{board_name}`" exit 1 end board[0].id # Assume name is unique so take the first match end
_get_ids(user_handle, options)
click to toggle source
# File trello-bulk, line 35 def _get_ids(user_handle, options) id = OpenStruct.new id.board = _get_board_id(user_handle.boards, options[:board]) id.list = _get_list_id(id.board, options[:list]) id end
_get_list_id(board_id, list_name)
click to toggle source
# File trello-bulk, line 23 def _get_list_id(board_id, list_name) lists = Trello::Board.find(board_id).lists list = lists.select { |l| l.name == list_name } if list.empty? warn "#{APP_NAME}: failed to find a list named `#{list_name}`" exit 1 end list[0].id # Assume name is unique so take the first match end
expand_cards(cards)
click to toggle source
# File trello-bulk, line 60 def expand_cards(cards) expanded_cards = [] cards.each do |card| expanded = OpenStruct.new # Allow future due dates, relative to when this script is run if card.key? 'due' future_date = Date.today + card['due'] # set the due date in the future expanded.due_date = future_date.to_time.iso8601 # convert to ruby-trello required format end expanded.description = card['description'] expanded.title = card['title'] expanded_cards << expanded end expanded_cards end
load_cards(card_set)
click to toggle source
# File trello-bulk, line 44 def load_cards(card_set) unless File.exist? card_set warn "#{APP_NAME}: Failed to find `#{card_set}`" exit 1 end begin yaml = YAML.safe_load(File.read(card_set)) rescue Psych::SyntaxError => e warn "#{APP_NAME}: Failed to load YAML from `#{card_set}`: #{e.inspect}" exit 1 end expand_cards(yaml['cards']) end