summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-07-30 21:50:09 +0200
committerChris Schlaeger <chris@linux.com>2014-07-30 21:50:09 +0200
commit6418648bcae08129ad89b65601f7ac86f9d9e950 (patch)
treed358eac156c2d006a5907d2976ca797dadd82b17
parent0e6e0f98cd89f136fdb5f098ca4e829f5f8af97a (diff)
downloadpostrunner-6418648bcae08129ad89b65601f7ac86f9d9e950.zip
Adding lap information to summary report
-rw-r--r--lib/postrunner/ActivityReport.rb44
-rw-r--r--lib/postrunner/FlexiTable.rb9
-rw-r--r--test/.PostRunner_spec.rb.swpbin12288 -> 0 bytes
3 files changed, 35 insertions, 18 deletions
diff --git a/lib/postrunner/ActivityReport.rb b/lib/postrunner/ActivityReport.rb
index 971ed3c..84075d5 100644
--- a/lib/postrunner/ActivityReport.rb
+++ b/lib/postrunner/ActivityReport.rb
@@ -23,24 +23,32 @@ module PostRunner
t = FlexiTable.new
t.enable_frame(false)
t.body
- t.row([ 'Date:', session.start_time ])
- t.row([ 'Distance:', "#{'%.2f' % (session.distance / 1000.0)} km" ])
- t.row([ 'Time:', secsToHMS(session.duration) ])
+ t.row([ 'Date:', session.start_time])
+ t.row([ 'Distance:', "#{'%.2f' % (session.total_distance / 1000.0)} km" ])
+ t.row([ 'Time:', secsToHMS(session.total_timer_time) ])
t.row([ 'Avg. Pace:',
"#{speedToPace(session.avg_speed)} min/km" ])
- t.row([ 'Total Ascend:', "#{session.ascend} m" ])
- t.row([ 'Total Descend:', "#{session.descent} m" ])
- t.row([ 'Calories:', "#{session.calories} m" ])
- t.row([ 'Avg. HR:', "#{session.avg_heart_rate} bpm" ])
- t.row([ 'Max. HR:', "#{session.max_heart_rate} bpm" ])
- t.row([ 'Training Effect:', session.training_effect ])
- t.row([ 'Avg. Run Cadence:', "#{session.avg_running_cadence.round} spm" ])
+ t.row([ 'Total Ascend:', "#{session.total_ascend} m" ])
+ t.row([ 'Total Descend:', "#{session.total_descent} m" ])
+ t.row([ 'Calories:', "#{session.total_calories} kCal" ])
+ t.row([ 'Avg. HR:', session.avg_heart_rate ?
+ "#{session.avg_heart_rate} bpm" : '-' ])
+ t.row([ 'Max. HR:', session.max_heart_rate ?
+ "#{session.max_heart_rate} bpm" : '-' ])
+ t.row([ 'Training Effect:', session.total_training_effect ?
+ session.total_training_effect : '-' ])
+ t.row([ 'Avg. Run Cadence:',
+ session.avg_running_cadence ?
+ "#{session.avg_running_cadence.round} spm" : '-' ])
t.row([ 'Avg. Vertical Oscillation:',
- "#{'%.1f' % (session.avg_vertical_oscillation / 10)} cm" ])
+ session.avg_vertical_oscillation ?
+ "#{'%.1f' % (session.avg_vertical_oscillation / 10)} cm" : '-' ])
t.row([ 'Avg. Ground Contact Time:',
- "#{session.avg_stance_time.round} ms" ])
+ session.avg_stance_time ?
+ "#{session.avg_stance_time.round} ms" : '-' ])
t.row([ 'Avg. Stride Length:',
- "#{'%.2f' % (session.avg_stride_length / 2)} m" ])
+ session.avg_stride_length ?
+ "#{'%.2f' % (session.avg_stride_length / 2)} m" : '-' ])
t.to_s
end
@@ -48,11 +56,19 @@ module PostRunner
def laps
t = FlexiTable.new
t.head
- t.row([ 'Duration', 'Avg. Pace', 'Avg. HR', 'Max. HR' ])
+ t.row([ 'Duration', 'Distance', 'Avg. Pace', 'Stride', 'Cadence',
+ 'Avg. HR', 'Max. HR' ])
+ t.set_column_attributes(Array.new(7, { :halign => :right }))
t.body
@activity.laps.each do |lap|
t.cell(secsToHMS(lap.total_timer_time))
+ t.cell('%.2f' % (lap.total_distance / 1000.0))
t.cell(speedToPace(lap.avg_speed))
+ t.cell(lap.total_strides ?
+ '%.2f' % (lap.total_distance / (2 * lap.total_strides)) : '')
+ t.cell(lap.avg_running_cadence && lap.avg_fractional_cadence ?
+ '%.1f' % (2 * lap.avg_running_cadence +
+ (2 * lap.avg_fractional_cadence) / 100.0) : '')
t.cell(lap.avg_heart_rate.to_s)
t.cell(lap.max_heart_rate.to_s)
t.new_row
diff --git a/lib/postrunner/FlexiTable.rb b/lib/postrunner/FlexiTable.rb
index 9655f2e..2fa45c4 100644
--- a/lib/postrunner/FlexiTable.rb
+++ b/lib/postrunner/FlexiTable.rb
@@ -73,7 +73,8 @@ module PostRunner
private
def get_attribute(name)
- @attributes[name] || @row.attributes[name] ||
+ @attributes[name] ||
+ @row.attributes[name] ||
@table.column_attributes[@column_index][name]
end
@@ -85,7 +86,7 @@ module PostRunner
def initialize(table)
@table = table
- @attributes = nil
+ @attributes = Attributes.new
super()
end
@@ -108,7 +109,7 @@ module PostRunner
frame = @table.frame
s << '|' if frame
- s << join(@table.frame ? '|' : ' ')
+ s << join(frame ? '|' : ' ')
s << '|' if frame
s
@@ -259,7 +260,7 @@ module PostRunner
end
def frame_line_to_s
- return '' unless @enable_frame
+ return '' unless @frame
s = '+'
@column_attributes.each do |c|
s += '-' * c.min_terminal_width + '+'
diff --git a/test/.PostRunner_spec.rb.swp b/test/.PostRunner_spec.rb.swp
deleted file mode 100644
index cfe7b69..0000000
--- a/test/.PostRunner_spec.rb.swp
+++ /dev/null
Binary files differ