Class: TrelloToolThor
- Inherits:
-
Thor
- Object
- Thor
- TrelloToolThor
- Includes:
- TrelloTool::Util
- Defined in:
- lib/trello_tool_thor.rb
Overview
The thor class rubocop:disable Metrics/ClassLength
Class Method Summary collapse
Instance Method Summary collapse
- #archive ⇒ Object
- #archive_last(to_archive = "1") ⇒ Object
- #config ⇒ Object
- #health ⇒ Object
- #lists(url = configuration.main_board_url) ⇒ Object
- #release(version = nil) ⇒ Object
- #summarize_as_md(list_name = configuration.todo_list_name, url = configuration.main_board_url) ⇒ Object
- #summarize_as_md_long(list_name = configuration.todo_list_name, url = configuration.main_board_url) ⇒ Object
- #summarize_as_urls(list_name = configuration.todo_list_name, url = configuration.main_board_url) ⇒ Object
Class Method Details
.configuration ⇒ Object
14 15 16 |
# File 'lib/trello_tool_thor.rb', line 14 def self.configuration @configuration ||= TrelloTool::Configuration.new end |
Instance Method Details
#archive ⇒ Object
56 57 58 59 60 61 |
# File 'lib/trello_tool_thor.rb', line 56 def archive client.archiveable_list_names_with_index.each do |list, index| say "* #{list.inspect} @##{index + 1}" end archive_last(client.archiveable_list_names_with_index.length) if yes?("archive them?") end |
#archive_last(to_archive = "1") ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trello_tool_thor.rb', line 38 def archive_last(to_archive = "1") number_to_archive = to_archive.to_i say "archiving #{number_to_archive} lists:" lists_reversed = client.main_board.lists.reverse 0.upto(number_to_archive - 1).each do |index| say(format("\r%<count>2s / %<total>s", count: index + 1, total: number_to_archive), Thor::Shell::Color::GREEN, false) list = lists_reversed[index] break unless list list.move_to_board(client.archive_board) say "\r * #{list.name.inspect}#{' ' * 20}\n" end say end |
#config ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/trello_tool_thor.rb', line 26 def config if configuration.config_file_exists? say("Configuration already exists at #{configuration.config_file}") else configuration.generate say("Generated configuration at #{configuration.config_file}. You will need to specify trello urls") end end |
#health ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/trello_tool_thor.rb', line 65 def health health = TrelloTool::Health.new(client.main_board, configuration) health.symbols_and_colours.each do |symbol, colour| say(symbol, colour, false) end say health.each_issue_with_severity do |issue, severity| say(format("%-20s", "#{severity}:"), Thor::Shell::Color::RED, false) say(issue) end health.each_expected_list_with_length do |list_name, length| say(" * #{list_name} (#{length})") end end |
#lists(url = configuration.main_board_url) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/trello_tool_thor.rb', line 82 def lists(url = configuration.main_board_url) board = client.find(:boards, extract_id_from_url(url)) say board.name say url say board.lists.each do |list| say "* #{list.name}" end end |
#release(version = nil) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/trello_tool_thor.rb', line 95 def release(version = nil) version ||= File.exist?(".RELEASE_NEW_VERSION") && File.read(".RELEASE_NEW_VERSION").strip unless version say("Usage: release VERSION # or put version number in .RELEASE_NEW_VERSION") return end next_version_list = client.next_version_list next_version_list.name = version next_version_list.save client. do Trello::List.create(name: configuration.next_version_list_name, board_id: client.main_board.id, pos: find_pos_before_list(client.main_board, next_version_list)) end end |
#summarize_as_md(list_name = configuration.todo_list_name, url = configuration.main_board_url) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/trello_tool_thor.rb', line 114 def summarize_as_md(list_name = configuration.todo_list_name, url = configuration.main_board_url) board = client.find(:boards, extract_id_from_url(url)) list = find_list_by_list_name(board, list_name) return unless list cards = list.cards say "\n# #{list.name} (#{cards.length} cards)\n\n" list.cards.each do |card| say "* [#{card.name}](#{card.url})" end say "\n" end |
#summarize_as_md_long(list_name = configuration.todo_list_name, url = configuration.main_board_url) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/trello_tool_thor.rb', line 131 def summarize_as_md_long(list_name = configuration.todo_list_name, url = configuration.main_board_url) board = client.find(:boards, extract_id_from_url(url)) list = find_list_by_list_name(board, list_name) return unless list cards = list.cards say "\n# #{list.name} (#{cards.length} cards)\n\n" list.cards.each do |card| labels = card.labels.map { |label| "[#{label.name}]" }.join(" ") say "* #{card.name} #{labels}\n #{card.url}" card..each do || next unless (url = .url) next if %w[pdf png jpg].include?(url.split(".").last&.downcase) say " - #{url}" end end say "\n" end |
#summarize_as_urls(list_name = configuration.todo_list_name, url = configuration.main_board_url) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/trello_tool_thor.rb', line 152 def summarize_as_urls(list_name = configuration.todo_list_name, url = configuration.main_board_url) board = client.find(:boards, extract_id_from_url(url)) list = find_list_by_list_name(board, list_name) return unless list cards = list.cards say "\n#{list.name} (#{cards.length} cards)\n\n" list.cards.each do |card| say card.url end say "\n" end |