postrunner 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,9 @@ describe PostRunner::ActivitySummary do
17
17
 
18
18
  before(:each) do
19
19
  @as = PostRunner::ActivitySummary.new(
20
- create_fit_activity('2014-08-26-19:00', 30), 'test', :metric)
20
+ create_fit_activity('2014-08-26-19:00', 30), :metric,
21
+ { :name => 'test', :type => 'Running',
22
+ :sub_type => 'Street' })
21
23
  end
22
24
 
23
25
  it 'should create a metric summary' do
@@ -83,6 +83,13 @@ describe PostRunner::Main do
83
83
  list.index('FILE2.FIT').should be_a(Fixnum)
84
84
  rc = YAML::load_file(File.join(@db_dir, 'config.yml'))
85
85
  rc[:import_dir].should == '.'
86
+
87
+ template = "<a href=\"%s.html\"><img src=\"icons/%s.png\" " +
88
+ "class=\"active_button\">"
89
+ html1 = File.read(File.join(@db_dir, 'html', 'FILE1.html'))
90
+ html1.include?(template % ['FILE2', 'forward']).should be_true
91
+ html2 = File.read(File.join(@db_dir, 'html', 'FILE2.html'))
92
+ html2.include?(template % ['FILE1', 'back']).should be_true
86
93
  end
87
94
 
88
95
  it 'should delete the first file' do
@@ -106,6 +113,39 @@ describe PostRunner::Main do
106
113
  list.index('foobar').should be_a(Fixnum)
107
114
  end
108
115
 
116
+ it 'should fail when setting bad attribute' do
117
+ lambda { postrunner(%w( set foo bar :1)) }.should raise_error SystemExit
118
+ end
119
+
120
+ it 'should set name for FILE2.FIT activity' do
121
+ postrunner(%w( set name foobar :1 ))
122
+ list = postrunner(%w( list ))
123
+ list.index('FILE2.FIT').should be_nil
124
+ list.index('foobar').should be_a(Fixnum)
125
+ end
126
+
127
+ it 'should set activity type for FILE2.FIT activity' do
128
+ postrunner(%w( set type Cycling :1 ))
129
+ list = postrunner(%w( summary :1 ))
130
+ list.index('Running').should be_nil
131
+ list.index('Cycling').should be_a(Fixnum)
132
+ end
133
+
134
+ it 'should fail when setting bad activity type' do
135
+ lambda { postrunner(%w( set type foobar :1)) }.should raise_error SystemExit
136
+ end
137
+
138
+ it 'should set activity subtype for FILE2.FIT activity' do
139
+ postrunner(%w( set subtype Road :1 ))
140
+ list = postrunner(%w( summary :1 ))
141
+ list.index('Generic').should be_nil
142
+ list.index('Road').should be_a(Fixnum)
143
+ end
144
+
145
+ it 'should fail when setting bad activity subtype' do
146
+ lambda { postrunner(%w( set subtype foobar :1)) }.should raise_error SystemExit
147
+ end
148
+
109
149
  it 'should dump an activity from the archive' do
110
150
  postrunner(%w( dump :1 ))
111
151
  end
@@ -130,6 +170,11 @@ describe PostRunner::Main do
130
170
  rc = PostRunner::RuntimeConfig.new(@db_dir)
131
171
  rc.get_option(:version).should == '0.0.0'
132
172
 
173
+ archive_file = File.join(@db_dir, 'archive.yml')
174
+ archive = YAML.load_file(archive_file)
175
+ archive.each { |a| a.remove_instance_variable:@sport }
176
+ File.write(archive_file, archive.to_yaml)
177
+
133
178
  # Run some command.
134
179
  postrunner(%w( list ))
135
180
 
data/spec/View_spec.rb ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby -w
2
+ # encoding: UTF-8
3
+ #
4
+ # = View_spec.rb -- PostRunner - Manage the data from your Garmin sport devices.
5
+ #
6
+ # Copyright (c) 2015 by Chris Schlaeger <cs@taskjuggler.org>
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of version 2 of the GNU General Public License as
10
+ # published by the Free Software Foundation.
11
+ #
12
+
13
+ require 'postrunner/View'
14
+ require 'postrunner/ViewButtons'
15
+ require 'postrunner/PagingButtons'
16
+
17
+ module PostRunner
18
+
19
+ describe PostRunner::View do
20
+
21
+ before(:all) do
22
+ @view_names = %w( activities record )
23
+ delete_files
24
+ end
25
+
26
+ after(:all) do
27
+ delete_files
28
+ end
29
+
30
+ def delete_files
31
+ @view_names.each do |vn|
32
+ page_files(vn).each do |pf|
33
+ File.delete(pf) if File.exists?(pf)
34
+ end
35
+ end
36
+ end
37
+
38
+ def page_files(vn)
39
+ 1.upto(vn == 'record' ? 5 : 3).map { |i| "#{vn}-page#{i}.html" }
40
+ end
41
+
42
+ it 'should generate view files with multiple pages' do
43
+ views = ViewButtons.new(
44
+ @view_names.map{ |vn| NavButtonDef.
45
+ new("#{vn}.png", "#{vn}-page1.html") }
46
+ )
47
+ @view_names.each do |vn|
48
+ views.current_page = vn + '-page1.html'
49
+ pages = PagingButtons.new(page_files(vn))
50
+ page_files(vn).each do |file|
51
+ pages.current_page = file
52
+ PostRunner::View.new("Test File: #{file}", views, pages).body.
53
+ write(file)
54
+ File.exists?(file).should be true
55
+ end
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,15 @@
1
+ #!/usr/bin/env ruby -w
2
+ # encoding: UTF-8
3
+ #
4
+ # = spec_helper.rb -- PostRunner - Manage the data from your Garmin sport devices.
5
+ #
6
+ # Copyright (c) 2014, 2015 by Chris Schlaeger <cs@taskjuggler.org>
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of version 2 of the GNU General Public License as
10
+ # published by the Free Software Foundation.
11
+ #
12
+
1
13
  def create_fit_file(name, date, duration_minutes = 30)
2
14
  Fit4Ruby.write(name, create_fit_activity(date, duration_minutes))
3
15
  end
@@ -13,9 +25,10 @@ def create_fit_activity(date, duration_minutes)
13
25
 
14
26
  a.new_event({ :timestamp => ts, :event => 'timer',
15
27
  :event_type => 'start_time' })
16
- a.new_device_info({ :timestamp => ts, :device_index => 0 })
17
- a.new_device_info({ :timestamp => ts, :device_index => 1,
18
- :battery_status => 'ok' })
28
+ a.new_device_info({ :timestamp => ts, :manufacturer => 'garmin',
29
+ :device_index => 0 })
30
+ a.new_device_info({ :timestamp => ts, :manufacturer => 'garmin',
31
+ :device_index => 1, :battery_status => 'ok' })
19
32
  0.upto((a.total_timer_time / 60) - 1) do |mins|
20
33
  a.new_record({
21
34
  :timestamp => ts,
@@ -34,7 +47,7 @@ def create_fit_activity(date, duration_minutes)
34
47
  })
35
48
 
36
49
  if mins > 0 && mins % 5 == 0
37
- a.new_lap({ :timestamp => ts })
50
+ a.new_lap({ :timestamp => ts, :sport => 'running' })
38
51
  end
39
52
  ts += 60
40
53
  end
@@ -46,10 +59,11 @@ def create_fit_activity(date, duration_minutes)
46
59
  :event_type => 'marker', :data => 52 })
47
60
  a.new_event({ :timestamp => ts, :event => 'timer',
48
61
  :event_type => 'stop_all' })
49
- a.new_device_info({ :timestamp => ts, :device_index => 0 })
62
+ a.new_device_info({ :timestamp => ts, :manufacturer => 'garmin',
63
+ :device_index => 0 })
50
64
  ts += 1
51
- a.new_device_info({ :timestamp => ts, :device_index => 1,
52
- :battery_status => 'low' })
65
+ a.new_device_info({ :timestamp => ts, :manufacturer => 'garmin',
66
+ :device_index => 1, :battery_status => 'low' })
53
67
  ts += 120
54
68
  a.new_event({ :timestamp => ts, :event => 'recovery_hr',
55
69
  :event_type => 'marker', :data => 132 })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schlaeger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-03 00:00:00.000000000 Z
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fit4ruby
@@ -114,19 +114,28 @@ files:
114
114
  - lib/postrunner.rb
115
115
  - lib/postrunner/ActivitiesDB.rb
116
116
  - lib/postrunner/Activity.rb
117
+ - lib/postrunner/ActivityLink.rb
117
118
  - lib/postrunner/ActivityListView.rb
118
119
  - lib/postrunner/ActivitySummary.rb
119
120
  - lib/postrunner/ActivityView.rb
121
+ - lib/postrunner/BackedUpFile.rb
120
122
  - lib/postrunner/ChartView.rb
121
123
  - lib/postrunner/DeviceList.rb
122
124
  - lib/postrunner/FlexiTable.rb
123
125
  - lib/postrunner/HTMLBuilder.rb
124
126
  - lib/postrunner/Main.rb
127
+ - lib/postrunner/NavButtonRow.rb
128
+ - lib/postrunner/PagingButtons.rb
125
129
  - lib/postrunner/PersonalRecords.rb
130
+ - lib/postrunner/RecordListPageView.rb
126
131
  - lib/postrunner/RuntimeConfig.rb
127
132
  - lib/postrunner/TrackView.rb
128
133
  - lib/postrunner/UserProfileView.rb
129
- - lib/postrunner/ViewWidgets.rb
134
+ - lib/postrunner/View.rb
135
+ - lib/postrunner/ViewBottom.rb
136
+ - lib/postrunner/ViewButtons.rb
137
+ - lib/postrunner/ViewFrame.rb
138
+ - lib/postrunner/ViewTop.rb
130
139
  - lib/postrunner/version.rb
131
140
  - misc/flot/API.md
132
141
  - misc/flot/CONTRIBUTING.md
@@ -238,6 +247,8 @@ files:
238
247
  - misc/flot/jquery.flot.time.min.js
239
248
  - misc/flot/jquery.js
240
249
  - misc/flot/jquery.min.js
250
+ - misc/icons/activities.png
251
+ - misc/icons/activities.svg
241
252
  - misc/icons/back.png
242
253
  - misc/icons/back.svg
243
254
  - misc/icons/first.png
@@ -249,6 +260,9 @@ files:
249
260
  - misc/icons/last.png
250
261
  - misc/icons/last.svg
251
262
  - misc/icons/lgpl-3.0.txt
263
+ - misc/icons/record-small.png
264
+ - misc/icons/record.png
265
+ - misc/icons/record.svg
252
266
  - misc/jquery/jquery-2.1.1.min.js
253
267
  - misc/openlayers/.gitignore
254
268
  - misc/openlayers/OpenLayers.debug.js
@@ -1461,6 +1475,7 @@ files:
1461
1475
  - spec/ActivitySummary_spec.rb
1462
1476
  - spec/FlexiTable_spec.rb
1463
1477
  - spec/PostRunner_spec.rb
1478
+ - spec/View_spec.rb
1464
1479
  - spec/spec_helper.rb
1465
1480
  homepage: https://github.com/scrapper/postrunner
1466
1481
  licenses:
@@ -1490,5 +1505,6 @@ test_files:
1490
1505
  - spec/ActivitySummary_spec.rb
1491
1506
  - spec/FlexiTable_spec.rb
1492
1507
  - spec/PostRunner_spec.rb
1508
+ - spec/View_spec.rb
1493
1509
  - spec/spec_helper.rb
1494
1510
  has_rdoc:
@@ -1,153 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
- # encoding: UTF-8
3
- #
4
- # = ViewWidgets.rb -- PostRunner - Manage the data from your Garmin sport devices.
5
- #
6
- # Copyright (c) 2014 by Chris Schlaeger <cs@taskjuggler.org>
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of version 2 of the GNU General Public License as
10
- # published by the Free Software Foundation.
11
- #
12
-
13
- module PostRunner
14
-
15
- module ViewWidgets
16
-
17
- def view_widgets_style(doc)
18
- doc.style(<<EOT
19
- .titlebar {
20
- width: 100%;
21
- height: 50px;
22
- margin: 0px;
23
- background: linear-gradient(#7FA1FF 0, #002EAC 50px);
24
- }
25
- .title {
26
- float: left;
27
- font-size: 24pt;
28
- font-style: italic;
29
- font-weight: bold;
30
- color: #F8F8F8;
31
- text-shadow: -1px -1px 0 #5C5C5C,
32
- 1px -1px 0 #5C5C5C,
33
- -1px 1px 0 #5C5C5C,
34
- 1px 1px 0 #5C5C5C;
35
- padding: 3px 30px;
36
- }
37
- .navigator {
38
- float: right;
39
- padding: 3px 30px;
40
- }
41
- .active_button {
42
- padding: 5px;
43
- }
44
- .inactive_button {
45
- padding: 5px;
46
- opacity: 0.4;
47
- }
48
- .widget_frame {
49
- box-sizing: border-box;
50
- width: 600px;
51
- padding: 10px 15px 15px 15px;
52
- margin: 15px auto 15px auto;
53
- border: 1px solid #ddd;
54
- background: #fff;
55
- background: linear-gradient(#f6f6f6 0, #fff 50px);
56
- background: -o-linear-gradient(#f6f6f6 0, #fff 50px);
57
- background: -ms-linear-gradient(#f6f6f6 0, #fff 50px);
58
- background: -moz-linear-gradient(#f6f6f6 0, #fff 50px);
59
- background: -webkit-linear-gradient(#f6f6f6 0, #fff 50px);
60
- box-shadow: 0 3px 10px rgba(0,0,0,0.15);
61
- -o-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
62
- -ms-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
63
- -moz-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
64
- -webkit-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
65
- }
66
- .widget_frame_title {
67
- font-size:13pt;
68
- padding-bottom: 5px;
69
- text-align: left;
70
- }
71
- .flexitable {
72
- width: 100%;
73
- border: 2px solid #545454;
74
- border-collapse: collapse;
75
- font-size:11pt;
76
- }
77
- .ft_head_row {
78
- background-color: #DEDEDE
79
- }
80
- .ft_even_row {
81
- background-color: #FCFCFC
82
- }
83
- .ft_odd_row {
84
- background-color: #F1F1F1
85
- }
86
- .ft_cell {
87
- border: 1px solid #CCCCCC;
88
- padding: 1px 3px;
89
- }
90
- .footer {
91
- clear: both;
92
- width: 100%;
93
- height: 30px;
94
- padding: 15px;
95
- text-align: center;
96
- font-size: 9pt;
97
- }
98
- EOT
99
- )
100
- end
101
-
102
- def frame(doc, title)
103
- doc.div({ 'class' => 'widget_frame' }) {
104
- doc.div({ 'class' => 'widget_frame_title' }) {
105
- doc.b(title)
106
- }
107
- doc.div {
108
- yield if block_given?
109
- }
110
- }
111
- end
112
-
113
- def titlebar(doc, first_page = nil, prev_page = nil, home_page = nil,
114
- next_page = nil, last_page = nil)
115
- # The top title bar.
116
- doc.div({ :class => 'titlebar' }) {
117
- doc.div('PostRunner', { :class => 'title' })
118
- doc.div({ :class => 'navigator' }) {
119
- button(doc, first_page, 'first.png')
120
- button(doc, prev_page, 'back.png')
121
- button(doc, home_page, 'home.png')
122
- button(doc, next_page, 'forward.png')
123
- button(doc, last_page, 'last.png')
124
- }
125
- }
126
- end
127
-
128
- def button(doc, link, icon)
129
- if link
130
- doc.a({ :href => link }) {
131
- doc.img({ :src => "icons/#{icon}", :class => 'active_button' })
132
- }
133
- else
134
- doc.img({ :src => "icons/#{icon}", :class => 'inactive_button' })
135
- end
136
- end
137
-
138
- def footer(doc)
139
- doc.div({ :class => 'footer' }){
140
- doc.hr
141
- doc.div({ :class => 'copyright' }) {
142
- doc.text("Generated by ")
143
- doc.a('PostRunner',
144
- { :href => 'https://github.com/scrapper/postrunner' })
145
- doc.text(" #{VERSION} on #{Time.now}")
146
- }
147
- }
148
- end
149
-
150
- end
151
-
152
- end
153
-