Class: Board
Instance Attribute Summary collapse
-
#backlog_statuses ⇒ Object
readonly
Returns the value of attribute backlog_statuses.
-
#cycletime ⇒ Object
Returns the value of attribute cycletime.
-
#expedited_priority_names ⇒ Object
Returns the value of attribute expedited_priority_names.
-
#possible_statuses ⇒ Object
readonly
Returns the value of attribute possible_statuses.
-
#project_config ⇒ Object
Returns the value of attribute project_config.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#sprints ⇒ Object
readonly
Returns the value of attribute sprints.
-
#visible_columns ⇒ Object
readonly
Returns the value of attribute visible_columns.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(raw:, possible_statuses: StatusCollection.new) ⇒ Board
constructor
A new instance of Board.
- #kanban? ⇒ Boolean
- #name ⇒ Object
- #scrum? ⇒ Boolean
- #status_ids_from_column(column) ⇒ Object
- #status_ids_in_or_right_of_column(column_name) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(raw:, possible_statuses: StatusCollection.new) ⇒ Board
Returns a new instance of Board.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jirametrics/board.rb', line 7 def initialize raw:, possible_statuses: StatusCollection.new @raw = raw @board_type = raw['type'] @possible_statuses = possible_statuses @sprints = [] @expedited_priority_names = [] columns = raw['columnConfig']['columns'] # For a Kanban board, the first column here will always be called 'Backlog' and will NOT be # visible on the board. If the board is configured to have a kanban backlog then it will have # statuses matched to it and otherwise, there will be no statuses. if kanban? assert_jira_behaviour_true(columns[0]['name'] == 'Backlog') do "Expected first column to be called Backlog: #{raw}" end @backlog_statuses = @possible_statuses.(status_ids_from_column columns[0]) do |unknown_status| # Yet another "theoretically impossible and yet we've seen it in production" moment puts "Status #{unknown_status.inspect} is defined as being in the backlog for board #{name.inspect}:#{id} " \ 'and yet it\'s not defined in the list of possible statuses available to the project. Check your Jira ' \ 'configuration' end columns = columns[1..] else # We currently don't know how to get the backlog status for a Scrum board @backlog_statuses = [] end @visible_columns = columns.collect do |column| # It's possible for a column to be defined without any statuses and in this case, it won't be visible. BoardColumn.new column unless status_ids_from_column(column).empty? end.compact end |
Instance Attribute Details
#backlog_statuses ⇒ Object (readonly)
Returns the value of attribute backlog_statuses.
4 5 6 |
# File 'lib/jirametrics/board.rb', line 4 def backlog_statuses @backlog_statuses end |
#cycletime ⇒ Object
Returns the value of attribute cycletime.
5 6 7 |
# File 'lib/jirametrics/board.rb', line 5 def cycletime @cycletime end |
#expedited_priority_names ⇒ Object
Returns the value of attribute expedited_priority_names.
5 6 7 |
# File 'lib/jirametrics/board.rb', line 5 def expedited_priority_names @expedited_priority_names end |
#possible_statuses ⇒ Object (readonly)
Returns the value of attribute possible_statuses.
4 5 6 |
# File 'lib/jirametrics/board.rb', line 4 def possible_statuses @possible_statuses end |
#project_config ⇒ Object
Returns the value of attribute project_config.
5 6 7 |
# File 'lib/jirametrics/board.rb', line 5 def project_config @project_config end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/jirametrics/board.rb', line 4 def raw @raw end |
#sprints ⇒ Object (readonly)
Returns the value of attribute sprints.
4 5 6 |
# File 'lib/jirametrics/board.rb', line 4 def sprints @sprints end |
#visible_columns ⇒ Object (readonly)
Returns the value of attribute visible_columns.
4 5 6 |
# File 'lib/jirametrics/board.rb', line 4 def visible_columns @visible_columns end |
Instance Method Details
#id ⇒ Object
78 79 80 |
# File 'lib/jirametrics/board.rb', line 78 def id @raw['id'].to_i end |
#kanban? ⇒ Boolean
70 71 72 |
# File 'lib/jirametrics/board.rb', line 70 def kanban? @board_type == 'kanban' end |
#name ⇒ Object
82 83 84 |
# File 'lib/jirametrics/board.rb', line 82 def name @raw['name'] end |
#scrum? ⇒ Boolean
74 75 76 |
# File 'lib/jirametrics/board.rb', line 74 def scrum? @board_type == 'scrum' end |
#status_ids_from_column(column) ⇒ Object
49 50 51 |
# File 'lib/jirametrics/board.rb', line 49 def status_ids_from_column column column['statuses'].collect { |status| status['id'].to_i } end |
#status_ids_in_or_right_of_column(column_name) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jirametrics/board.rb', line 53 def status_ids_in_or_right_of_column column_name status_ids = [] found_it = false @visible_columns.each do |column| # Check both the current name and also the original raw name in case anonymization has happened. found_it = true if column.name == column_name || column.raw['name'] == column_name status_ids += column.status_ids if found_it end unless found_it column_names = @visible_columns.collect(&:name).collect(&:inspect).join(', ') raise "No visible column with name: #{column_name.inspect} Possible options are: #{column_names}" end status_ids end |
#url ⇒ Object
42 43 44 45 46 47 |
# File 'lib/jirametrics/board.rb', line 42 def url # Strangely, the URL isn't anywhere in the returned data so we have to fabricate it. raise "Cannot parse self: #{@raw['self']}" unless @raw['self'] =~ /^(https?:\/\/[^\/]+)\// "#{$1}/secure/RapidBoard.jspa?rapidView=#{id}" end |