require "totrello/version" require 'trello_creator' require 'to_do_find' require 'totrello_config' module Totrello class Trelloize @trello @directory @config def initialize(directory) @trello = TrelloCreator.new @directory = directory totrello_config = TotrelloConfig.new(directory) @config = totrello_config.build_hash end def create_or_gen_board board = @trello.find_board(@config[:board_name].to_s) board ||= @trello.create_board(@config[:board_name].to_s, 'Auto Generated by ToTrello Gem') end def create_trello_card(board, list, todo, filename) description = gen_description(filename,todo, @config[:project_name].to_s) card = @trello.create_card(board, todo[:todo], description ,list) end def gen_description(file, todo, project_name) out = "TODO item found by the [ToTrello](https://rubygems.org/gems/totrello) gem\n" out += "**Project name:** #{project_name}\n" out += "**Filename**: #{file}\n" out += "**Action item**: #{todo[:todo]}\n" out += "**Location (at or near) line**: #{todo[:location]}\n" end def create_cards(board, todos) todos[:todo_list].each do |tdl| tdl[:todos].each do |td| unless td == '' create_trello_card(board, @config[:default_list], td, tdl[:file]) end end end end def get_todos todo = ToDoFind.new todos = todo.search(@directory, Array( @config[:excludes]), Array( @config[:todo_types]), Array( @config[:file_types]), Array( @config[:comment_style])) todos end end end