lib/totrello.rb in totrello-0.1.13 vs lib/totrello.rb in totrello-0.1.14
- old
+ new
@@ -31,42 +31,42 @@
todo = ToDoFind.new
todos = todo.search(@directory)
puts "Woot! We've got'em"
puts 'Generating your board'
+
board_name = todos[:directory].nil? ? todos[:directory] : @directory.split('/').last
puts "Creating the board: #{board_name}"
- board = @trello.find_board(board_name)
- board ||= @trello.create_board(board_name, 'Auto Generated by ToTrello Gem')
- return -1 if board.nil?
- puts "Created or found a board with the ID: #{board.name}"
+ board = create_or_gen_board(board_name)
+ return -1 if board.nil?
+ puts "Created or found a board with the ID: #{board.name}"
+
puts 'Talking to Trello, this is the longest part...'
todos[:todo_list].each do |tdl|
tdl[:todos].each do |td|
puts gen_description(tdl[:file], td)
- @trello.create_card(board,td, gen_description(tdl[:file],td),'To Do') unless td == ''
+ #@trello.create_card(board,td, gen_description(tdl[:file],td),'To Do') unless td == ''
+ unless td == ''
+ create_trello_card(board, 'To Do', td, tdl[:file])
+ end
end
end
puts "And you're ready to go!"
end
+ def create_or_gen_board(board_name)
+ board = @trello.find_board(board_name)
+ board ||= @trello.create_board(board_name, 'Auto Generated by ToTrello Gem')
+ end
- def test_find_todo_items
-
- todo = ToDoFind.new
- todos = todo.search(@directory)
-
- todos[:todo_list].each do |tdl|
- tdl[:todos].each do |td|
- puts gen_description(tdl[:file], td)
- end
- end
-
+ def create_trello_card(board, list, todo, filename)
+ @trello.create_card(board, todo, gen_description(filename,todo),list)
end
+
def gen_description(file, todo)
out = "TODO item found by ToTrello\n"
out += "Filename: #{file}\n"
out += "Action item: #{todo[:todo]}\n"