Class: CycleTimeConfig

Inherits:
Object show all
Includes:
SelfOrIssueDispatcher
Defined in:
lib/jirametrics/cycletime_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SelfOrIssueDispatcher

#method_missing, #respond_to_missing?

Constructor Details

#initialize(parent_config:, label:, block:, today: Date.today) ⇒ CycleTimeConfig

Returns a new instance of CycleTimeConfig.



11
12
13
14
15
16
# File 'lib/jirametrics/cycletime_config.rb', line 11

def initialize parent_config:, label:, block:, today: Date.today
  @parent_config = parent_config
  @label = label
  @today = today
  instance_eval(&block) unless block.nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SelfOrIssueDispatcher

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



9
10
11
# File 'lib/jirametrics/cycletime_config.rb', line 9

def label
  @label
end

#parent_configObject (readonly)

Returns the value of attribute parent_config.



9
10
11
# File 'lib/jirametrics/cycletime_config.rb', line 9

def parent_config
  @parent_config
end

Instance Method Details

#age(issue, today: nil) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/jirametrics/cycletime_config.rb', line 52

def age issue, today: nil
  start = started_time(issue)
  stop = today || @today || Date.today
  return nil if start.nil? || stop.nil?

  (stop.to_date - start.to_date).to_i + 1
end

#cycletime(issue) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/jirametrics/cycletime_config.rb', line 44

def cycletime issue
  start = started_time(issue)
  stop = stopped_time(issue)
  return nil if start.nil? || stop.nil?

  (stop.to_date - start.to_date).to_i + 1
end

#done?(issue) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/jirametrics/cycletime_config.rb', line 32

def done? issue
  stopped_time(issue)
end

#in_progress?(issue) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/jirametrics/cycletime_config.rb', line 28

def in_progress? issue
  started_time(issue) && stopped_time(issue).nil?
end

#possible_statusesObject



60
61
62
63
64
65
66
67
68
# File 'lib/jirametrics/cycletime_config.rb', line 60

def possible_statuses
  if parent_config.is_a? BoardConfig
    project_config = parent_config.project_config
  else
    # TODO: This will go away when cycletimes are no longer supported inside html_reports
    project_config = parent_config.file_config.project_config
  end
  project_config.possible_statuses
end

#start_at(block = nil) ⇒ Object



18
19
20
21
# File 'lib/jirametrics/cycletime_config.rb', line 18

def start_at block = nil
  @start_at = block unless block.nil?
  @start_at
end

#started_time(issue) ⇒ Object



36
37
38
# File 'lib/jirametrics/cycletime_config.rb', line 36

def started_time issue
  @start_at.call(issue)
end

#stop_at(block = nil) ⇒ Object



23
24
25
26
# File 'lib/jirametrics/cycletime_config.rb', line 23

def stop_at block = nil
  @stop_at = block unless block.nil?
  @stop_at
end

#stopped_time(issue) ⇒ Object



40
41
42
# File 'lib/jirametrics/cycletime_config.rb', line 40

def stopped_time issue
  @stop_at.call(issue)
end