Rule ScoreAggregation
  input '*.score'.all
  input 'stat-template.erb'
  output '*_bar-graph.png'.all
  output 'histgram.png'
  output '*.html'.all
Flow
  rule PersonalStatistics
  rule PersonalPreStatistics
  rule MeanSummary
  rule HistgramGraph
  rule MD2HTML
  rule ApplyTemplate
  rule PersonalBarGraph
  rule TotalMean
  rule TotalStatistics
End

Rule PersonalStatistics
  input '*.pre-stat.md'
  input '{$*}.dev'
  output '{$*}.stat.md'
Action
  echo "| Deviaion | `cat {$I[2]}` |" | cat {$I[1]} - > {$O[1]}
End

Rule PersonalPreStatistics
  input '*.score'
  output '{$*}.pre-stat.md'
  output '{$*}.mean'
Action
  personal-pre-statistics.rb
End

Rule MeanSummary
  input '*.mean'.except('total.mean').all
  output 'total.histgram'
Action
  mean-summary.rb > {$O[1]}
End

Rule HistgramGraph
  input 'total.histgram'
  output 'histgram.png'
Action
  histgram-graph.sh
End

Rule MD2HTML
  input '*.stat.md'
  output '{$*}.html.part'
Action
  kramdown {$I[1]} > {$O[1]}
End

Rule ApplyTemplate
  input 'stat-template.erb'
  input '*.html.part'
  output '{$*}.html'
Action
  apply-template.rb > {$O[1]}
End

Rule PersonalBarGraph
  input '*.score'
  output '{$*}_bar-graph.png'
Action
  personal-bar-graph.sh
End

Rule TotalMean
  input '*.mean'.all
  output 'total.mean'
Action
  total-mean.rb > {$O[1]}
End

Rule TotalStatistics
  input '*.mean'.except('total.mean').all
  input 'total.mean'
  output '*.dev'.all
  output 'total.stat.md'
Action
  total-statistics.rb
End