Class: Jira::Auto::Tool::SprintController
- Defined in:
- lib/jira/auto/tool/sprint_controller.rb,
lib/jira/auto/tool/sprint_controller/options.rb
Defined Under Namespace
Classes: Options
Constant Summary collapse
- SUCCESSFUL_EXECUTION_EXIT_CODE =
0- UNSUCCESSFUL_EXECUTION_EXIT_CODE =
1
Instance Attribute Summary collapse
-
#board ⇒ Object
Returns the value of attribute board.
-
#tool ⇒ Object
Returns the value of attribute tool.
Instance Method Summary collapse
- #boards ⇒ Object
- #exit_with_board_warning(message, exit_code = SUCCESSFUL_EXECUTION_EXIT_CODE) ⇒ Object
- #fetch_jira_sprints(board, options) ⇒ Object
-
#initialize(tool, board) ⇒ SprintController
constructor
A new instance of SprintController.
- #jira_sprints ⇒ Object
- #list_object(object_class, object_method, title, without_board_information: false) ⇒ Object
- #list_sprint_prefixes(without_board_information: false) ⇒ Object
- #list_sprints(without_board_information: false) ⇒ Object
- #quarterly_add_one_sprint_for_each_unclosed_sprint_prefix ⇒ Object
- #quarterly_add_sprints_until(until_date) ⇒ Object
- #sprint_compatible_boards ⇒ Object
- #sprint_exist? ⇒ Boolean
- #sprints ⇒ Object
- #unclosed_sprint_exist? ⇒ Boolean
- #unclosed_sprint_prefixes ⇒ Object
- #unclosed_sprints ⇒ Object
- #unfiltered_board_sprints ⇒ Object
- #unfiltered_jira_sprints(board) ⇒ Object
Constructor Details
#initialize(tool, board) ⇒ SprintController
Returns a new instance of SprintController.
15 16 17 18 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 15 def initialize(tool, board) @tool = tool @board = board end |
Instance Attribute Details
#board ⇒ Object
Returns the value of attribute board.
13 14 15 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 13 def board @board end |
#tool ⇒ Object
Returns the value of attribute tool.
13 14 15 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 13 def tool @tool end |
Instance Method Details
#boards ⇒ Object
107 108 109 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 107 def boards tool.board_controller.boards end |
#exit_with_board_warning(message, exit_code = SUCCESSFUL_EXECUTION_EXIT_CODE) ⇒ Object
36 37 38 39 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 36 def exit_with_board_warning(, exit_code = SUCCESSFUL_EXECUTION_EXIT_CODE) log.warn { "Jira board '#{board.name}': #{message}" } exit(exit_code) end |
#fetch_jira_sprints(board, options) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 117 def fetch_jira_sprints(board, ) log.debug { "Fetching sprints from Jira (#{options.inspect})" } fetched_sprints = board.jira_board.sprints() log.debug do "Board: #{board.name}: Fetched #sprints #{fetched_sprints.size} sprints from Jira: " \ "#{fetched_sprints.map(&:name).join(", ")}" end fetched_sprints end |
#jira_sprints ⇒ Object
86 87 88 89 90 91 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 86 def jira_sprints sprint_filter_string = tool.art_sprint_regex_defined? ? tool.art_sprint_regex : "" sprint_filter_regex = Regexp.new(sprint_filter_string) unfiltered_board_sprints.find_all { |sprint| sprint.name =~ sprint_filter_regex } end |
#list_object(object_class, object_method, title, without_board_information: false) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 64 def list_object(object_class, object_method, title, without_board_information: false) table_row_header = object_class.to_table_row_header(without_board_information: without_board_information) rows = send(object_method).collect do |sprint| sprint.to_table_row(without_board_information: without_board_information) end table = Terminal::Table.new( title: title, headings: table_row_header, rows: rows ) puts table end |
#list_sprint_prefixes(without_board_information: false) ⇒ Object
53 54 55 56 57 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 53 def list_sprint_prefixes(without_board_information: false) list_object(Sprint::Prefix, :unclosed_sprint_prefixes, "Sprint Prefixes With Corresponding Last Sprints", without_board_information: without_board_information) end |
#list_sprints(without_board_information: false) ⇒ Object
59 60 61 62 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 59 def list_sprints(without_board_information: false) list_object(Sprint, :unclosed_sprints, "Matching Sprints", without_board_information: without_board_information) end |
#quarterly_add_one_sprint_for_each_unclosed_sprint_prefix ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 24 def quarterly_add_one_sprint_for_each_unclosed_sprint_prefix exit_with_board_warning "No sprint added since no reference sprint was found!" unless sprint_exist? unless unclosed_sprint_exist? exit_with_board_warning "No sprint added since no unclosed reference sprint was found!" end unclosed_sprint_prefixes.each(&:add_sprint_following_last_one) end |
#quarterly_add_sprints_until(until_date) ⇒ Object
20 21 22 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 20 def quarterly_add_sprints_until(until_date) unclosed_sprint_prefixes.each { |prefix| prefix.quarterly_add_sprints_until(until_date) } end |
#sprint_compatible_boards ⇒ Object
103 104 105 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 103 def sprint_compatible_boards boards.find_all(&:sprint_compatible?) end |
#sprint_exist? ⇒ Boolean
49 50 51 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 49 def sprint_exist? !sprints.empty? end |
#sprints ⇒ Object
80 81 82 83 84 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 80 def sprints jira_sprints.collect { |jira_sprint| Sprint.new(tool, jira_sprint) } .uniq(&:id) .sort end |
#unclosed_sprint_exist? ⇒ Boolean
45 46 47 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 45 def unclosed_sprint_exist? !unclosed_sprints.empty? end |
#unclosed_sprint_prefixes ⇒ Object
41 42 43 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 41 def unclosed_sprint_prefixes @unclosed_sprint_prefixes ||= calculate_unclosed_sprint_prefixes.sort_by(&:name) end |
#unclosed_sprints ⇒ Object
130 131 132 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 130 def unclosed_sprints sprints.find_all { |sprint| sprint.state != SprintStateController::SprintState::CLOSED } end |
#unfiltered_board_sprints ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 93 def unfiltered_board_sprints all_board_sprints = [] sprint_compatible_boards.each do |board| all_board_sprints.concat(unfiltered_jira_sprints(board)) end all_board_sprints end |
#unfiltered_jira_sprints(board) ⇒ Object
111 112 113 114 115 |
# File 'lib/jira/auto/tool/sprint_controller.rb', line 111 def unfiltered_jira_sprints(board) Helpers::Pagination.fetch_all_object_pages do || fetch_jira_sprints(board, ) end end |