class Monte::Commands::Carlo

Runs Monte Carlo Simulation to estimate how long a piece of work will take

Constants

BLURB
CERTAINTY
HEADERS
PERCENTILES
RUNS

Public Instance Methods

ask_backlog(options) click to toggle source
# File lib/monte/commands/carlo.rb, line 45
def ask_backlog(options)
  options.merge(backlog:
                prompt.ask('How many tasks/tickets do you have left to complete?',
                           required: true,
                           convert: :int))
end
ask_questions(options) click to toggle source
# File lib/monte/commands/carlo.rb, line 37
def ask_questions(options)
  q1 = ask_backlog(options)
  q2 = ask_throughput(q1)
  q3 = ask_start(q2)
  q4 = ask_split(q3)
  ask_runs(q4)
end
ask_runs(options) click to toggle source
# File lib/monte/commands/carlo.rb, line 79
def ask_runs(options)
  options.merge(
    runs: prompt.select('How many simulations would you like to run?', RUNS)
  )
end
ask_split(options) click to toggle source
# File lib/monte/commands/carlo.rb, line 52
def ask_split(options)
  options.merge(split:
                prompt.select('How certain are you with regard to the scope of the work?', CERTAINTY))
end
ask_start(options) click to toggle source
# File lib/monte/commands/carlo.rb, line 57
def ask_start(options)
  options.merge(start:
                prompt.ask('When will you start work (e.g. 28/04/2021)') do |q|
                  q.required true
                  q.default Date.today
                  q.convert ->(input) { Date.parse(input.to_s) }
                end)
end
ask_throughput(options) click to toggle source
# File lib/monte/commands/carlo.rb, line 66
def ask_throughput(options)
  data_exists = prompt.yes?('Do you have a JIRA csv export to use?', required: true)
  if data_exists
    path = prompt.ask('what is the absolute file path to the csv file', required: true)
    throughput = historic_throughput(path)
  else
    low = prompt.ask('Enter the smallest number of tasks/tickets you have finished in a week?', convert: :int)
    high = prompt.ask('Enter the largest number of tasks/tickets you have finished in a week?', convert: :int)
    throughput = (low..high).to_a
  end
  options.merge(throughput: throughput)
end
create_header() click to toggle source
# File lib/monte/commands/carlo.rb, line 33
def create_header
  large_title('Monte')
end
create_table(rows) click to toggle source
# File lib/monte/commands/carlo.rb, line 28
def create_table(rows)
  table(HEADERS, [rows.prepend('Forecast Date')])
    .render(:unicode, alignment: [:center])
end
execute() click to toggle source
# File lib/monte/commands/carlo.rb, line 21
def execute
  puts(create_header, BLURB)
  user_input = ask_questions({})
  results = percentiles(user_input)
  puts(create_table(results))
end