Class: AggregateConfig
- Inherits:
-
Object
- Object
- AggregateConfig
- Defined in:
- lib/jirametrics/aggregate_config.rb
Instance Attribute Summary collapse
-
#included_projects ⇒ Object
readonly
Returns the value of attribute included_projects.
-
#project_config ⇒ Object
readonly
Returns the value of attribute project_config.
Instance Method Summary collapse
-
#adjust_issue_links(issues:) ⇒ Object
IssueLinks just have a reference to the key.
- #evaluate_next_level ⇒ Object
- #find_time_range(projects:) ⇒ Object
- #include_issues_from(project_name) ⇒ Object
-
#initialize(project_config:, block:) ⇒ AggregateConfig
constructor
A new instance of AggregateConfig.
Constructor Details
#initialize(project_config:, block:) ⇒ AggregateConfig
Returns a new instance of AggregateConfig.
8 9 10 11 12 13 |
# File 'lib/jirametrics/aggregate_config.rb', line 8 def initialize project_config:, block: @project_config = project_config @block = block @included_projects = [] end |
Instance Attribute Details
#included_projects ⇒ Object (readonly)
Returns the value of attribute included_projects.
6 7 8 |
# File 'lib/jirametrics/aggregate_config.rb', line 6 def included_projects @included_projects end |
#project_config ⇒ Object (readonly)
Returns the value of attribute project_config.
6 7 8 |
# File 'lib/jirametrics/aggregate_config.rb', line 6 def project_config @project_config end |
Instance Method Details
#adjust_issue_links(issues:) ⇒ Object
IssueLinks just have a reference to the key. Walk through all of them to see if we have a full issue that we'd already loaded. If we do, then replace it.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jirametrics/aggregate_config.rb', line 30 def adjust_issue_links issues: issues.each do |issue| issue.issue_links.each do |link| other_issue_key = link.other_issue.key other_issue = issues.find { |i| i.key == other_issue_key } link.other_issue = other_issue if other_issue end end end |
#evaluate_next_level ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jirametrics/aggregate_config.rb', line 15 def evaluate_next_level instance_eval(&@block) if @included_projects.empty? raise "#{@project_config.name}: When aggregating, you must include at least one other project" end # If the time range wasn't set then calculate it now @project_config.time_range = find_time_range projects: @included_projects if @project_config.time_range.nil? adjust_issue_links issues: @project_config.issues end |
#find_time_range(projects:) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jirametrics/aggregate_config.rb', line 56 def find_time_range projects: raise "Can't calculate aggregated range as no projects were included." if projects.empty? earliest = nil latest = nil projects.each do |project| range = project.time_range earliest = range.begin if earliest.nil? || range.begin < earliest latest = range.end if latest.nil? || range.end > latest end earliest..latest end |
#include_issues_from(project_name) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/jirametrics/aggregate_config.rb', line 41 def include_issues_from project_name project = find_included_project project_name return if project.nil? @included_projects << project issues = issues_for project if issues.nil? file_system.warning "No issues found for #{project_name}" return end @project_config.add_issues issues merge_fix_versions_from project end |