gooby 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +133 -341
- data/config/ballantyne.yaml +11 -0
- data/config/big_sur_marathon.yaml +11 -0
- data/config/crowders_mtn_hike.yaml +11 -0
- data/config/davidson1.yaml +16 -0
- data/config/gooby_config.yaml +28 -135
- data/cucumber.yml +1 -0
- data/features/build_gem.feature +88 -0
- data/features/gooby.feature +300 -0
- data/features/install.feature +78 -0
- data/features/steps/gooby_steps.rb +245 -0
- data/features/support/env.rb +4 -0
- data/lib/gooby.rb +24 -30
- data/lib/gooby_activity.rb +63 -0
- data/lib/gooby_base_object.rb +46 -0
- data/lib/gooby_base_sax_parser.rb +95 -0
- data/lib/gooby_configuration.rb +33 -115
- data/lib/gooby_counter_hash.rb +28 -87
- data/lib/gooby_dttm.rb +88 -66
- data/lib/gooby_environment.rb +48 -0
- data/lib/gooby_garmin_tcx_parser.rb +92 -0
- data/lib/gooby_google_kml_generator.rb +168 -0
- data/lib/gooby_google_map_generator.rb +284 -349
- data/lib/gooby_gpx_parser.rb +97 -0
- data/lib/gooby_help_producer.rb +40 -0
- data/lib/gooby_introspection.rb +25 -0
- data/lib/gooby_io.rb +30 -0
- data/lib/gooby_lap.rb +27 -18
- data/lib/gooby_process.rb +281 -0
- data/lib/gooby_sax_path_parser.rb +43 -0
- data/lib/gooby_tcx_extractor.rb +71 -0
- data/lib/gooby_track_log_parser.rb +114 -0
- data/lib/gooby_trackpoint.rb +276 -0
- data/lib/gooby_xml_object.rb +40 -0
- data/{img/gicons → out/images}/blank.png +0 -0
- data/{img/gicons → out/images}/dd-end.png +0 -0
- data/{img/gicons → out/images}/dd-start.png +0 -0
- data/{img/gicons → out/images}/marker.png +0 -0
- data/{img/gicons → out/images}/marker0.png +0 -0
- data/{img/gicons → out/images}/marker00.png +0 -0
- data/{img/gicons → out/images}/marker01.png +0 -0
- data/{img/gicons → out/images}/marker02.png +0 -0
- data/{img/gicons → out/images}/marker03.png +0 -0
- data/{img/gicons → out/images}/marker04.png +0 -0
- data/{img/gicons → out/images}/marker05.png +0 -0
- data/{img/gicons → out/images}/marker06.png +0 -0
- data/{img/gicons → out/images}/marker07.png +0 -0
- data/{img/gicons → out/images}/marker08.png +0 -0
- data/{img/gicons → out/images}/marker09.png +0 -0
- data/{img/gicons → out/images}/marker1.png +0 -0
- data/{img/gicons → out/images}/marker10.png +0 -0
- data/{img/gicons → out/images}/marker11.png +0 -0
- data/{img/gicons → out/images}/marker12.png +0 -0
- data/{img/gicons → out/images}/marker13.png +0 -0
- data/{img/gicons → out/images}/marker14.png +0 -0
- data/{img/gicons → out/images}/marker15.png +0 -0
- data/{img/gicons → out/images}/marker16.png +0 -0
- data/{img/gicons → out/images}/marker17.png +0 -0
- data/{img/gicons → out/images}/marker18.png +0 -0
- data/{img/gicons → out/images}/marker19.png +0 -0
- data/{img/gicons → out/images}/marker2.png +0 -0
- data/{img/gicons → out/images}/marker20.png +0 -0
- data/{img/gicons → out/images}/marker21.png +0 -0
- data/{img/gicons → out/images}/marker22.png +0 -0
- data/{img/gicons → out/images}/marker23.png +0 -0
- data/{img/gicons → out/images}/marker24.png +0 -0
- data/{img/gicons → out/images}/marker25.png +0 -0
- data/{img/gicons → out/images}/marker26.png +0 -0
- data/{img/gicons → out/images}/marker27.png +0 -0
- data/{img/gicons → out/images}/marker28.png +0 -0
- data/{img/gicons → out/images}/marker29.png +0 -0
- data/{img/gicons → out/images}/marker3.png +0 -0
- data/{img/gicons → out/images}/marker30.png +0 -0
- data/{img/gicons → out/images}/marker31.png +0 -0
- data/{img/gicons → out/images}/marker32.png +0 -0
- data/{img/gicons → out/images}/marker33.png +0 -0
- data/{img/gicons → out/images}/marker34.png +0 -0
- data/{img/gicons → out/images}/marker35.png +0 -0
- data/{img/gicons → out/images}/marker36.png +0 -0
- data/{img/gicons → out/images}/marker37.png +0 -0
- data/{img/gicons → out/images}/marker38.png +0 -0
- data/{img/gicons → out/images}/marker39.png +0 -0
- data/{img/gicons → out/images}/marker4.png +0 -0
- data/{img/gicons → out/images}/marker40.png +0 -0
- data/{img/gicons → out/images}/marker41.png +0 -0
- data/{img/gicons → out/images}/marker42.png +0 -0
- data/{img/gicons → out/images}/marker43.png +0 -0
- data/{img/gicons → out/images}/marker44.png +0 -0
- data/{img/gicons → out/images}/marker45.png +0 -0
- data/{img/gicons → out/images}/marker46.png +0 -0
- data/{img/gicons → out/images}/marker47.png +0 -0
- data/{img/gicons → out/images}/marker48.png +0 -0
- data/{img/gicons → out/images}/marker49.png +0 -0
- data/{img/gicons → out/images}/marker5.png +0 -0
- data/{img/gicons → out/images}/marker50.png +0 -0
- data/{img/gicons → out/images}/marker51.png +0 -0
- data/{img/gicons → out/images}/marker52.png +0 -0
- data/{img/gicons → out/images}/marker53.png +0 -0
- data/{img/gicons → out/images}/marker54.png +0 -0
- data/{img/gicons → out/images}/marker55.png +0 -0
- data/{img/gicons → out/images}/marker56.png +0 -0
- data/{img/gicons → out/images}/marker57.png +0 -0
- data/{img/gicons → out/images}/marker58.png +0 -0
- data/{img/gicons → out/images}/marker59.png +0 -0
- data/{img/gicons → out/images}/marker6.png +0 -0
- data/{img/gicons → out/images}/marker60.png +0 -0
- data/{img/gicons → out/images}/marker61.png +0 -0
- data/{img/gicons → out/images}/marker62.png +0 -0
- data/{img/gicons → out/images}/marker63.png +0 -0
- data/{img/gicons → out/images}/marker64.png +0 -0
- data/{img/gicons → out/images}/marker65.png +0 -0
- data/{img/gicons → out/images}/marker66.png +0 -0
- data/{img/gicons → out/images}/marker67.png +0 -0
- data/{img/gicons → out/images}/marker68.png +0 -0
- data/{img/gicons → out/images}/marker69.png +0 -0
- data/{img/gicons → out/images}/marker7.png +0 -0
- data/{img/gicons → out/images}/marker70.png +0 -0
- data/{img/gicons → out/images}/marker71.png +0 -0
- data/{img/gicons → out/images}/marker72.png +0 -0
- data/{img/gicons → out/images}/marker73.png +0 -0
- data/{img/gicons → out/images}/marker74.png +0 -0
- data/{img/gicons → out/images}/marker75.png +0 -0
- data/{img/gicons → out/images}/marker76.png +0 -0
- data/{img/gicons → out/images}/marker77.png +0 -0
- data/{img/gicons → out/images}/marker78.png +0 -0
- data/{img/gicons → out/images}/marker79.png +0 -0
- data/{img/gicons → out/images}/marker8.png +0 -0
- data/{img/gicons → out/images}/marker80.png +0 -0
- data/{img/gicons → out/images}/marker81.png +0 -0
- data/{img/gicons → out/images}/marker82.png +0 -0
- data/{img/gicons → out/images}/marker83.png +0 -0
- data/{img/gicons → out/images}/marker84.png +0 -0
- data/{img/gicons → out/images}/marker85.png +0 -0
- data/{img/gicons → out/images}/marker86.png +0 -0
- data/{img/gicons → out/images}/marker87.png +0 -0
- data/{img/gicons → out/images}/marker88.png +0 -0
- data/{img/gicons → out/images}/marker89.png +0 -0
- data/{img/gicons → out/images}/marker9.png +0 -0
- data/{img/gicons → out/images}/marker90.png +0 -0
- data/{img/gicons → out/images}/marker91.png +0 -0
- data/{img/gicons → out/images}/marker92.png +0 -0
- data/{img/gicons → out/images}/marker93.png +0 -0
- data/{img/gicons → out/images}/marker94.png +0 -0
- data/{img/gicons → out/images}/marker95.png +0 -0
- data/{img/gicons → out/images}/marker96.png +0 -0
- data/{img/gicons → out/images}/marker97.png +0 -0
- data/{img/gicons → out/images}/marker98.png +0 -0
- data/{img/gicons → out/images}/marker99.png +0 -0
- data/{img/gicons → out/images}/markerA.png +0 -0
- data/{img/gicons → out/images}/markerB.png +0 -0
- data/{img/gicons → out/images}/markerC.png +0 -0
- data/{img/gicons → out/images}/markerD.png +0 -0
- data/{img/gicons → out/images}/markerE.png +0 -0
- data/{img/gicons → out/images}/markerF.png +0 -0
- data/{img/gicons → out/images}/markerG.png +0 -0
- data/{img/gicons → out/images}/markerH.png +0 -0
- data/{img/gicons → out/images}/markerI.png +0 -0
- data/{img/gicons → out/images}/markerJ.png +0 -0
- data/{img/gicons → out/images}/mm_20_red.png +0 -0
- data/{img/gicons → out/images}/mm_20_shadow.png +0 -0
- data/{img/gicons → out/images}/shadow50.png +0 -0
- data/rakefile.rb +79 -0
- data/samples.sh +21 -0
- data/samples/2008_04_27_13_49_50_tcx.csv +2449 -0
- data/samples/2008_04_27_13_49_50_tcx.xml +24560 -0
- data/samples/2009_01_01_14_45_00_tcx.xml +10630 -0
- data/samples/ballantyne.csv +27 -0
- data/samples/ballantyne.gpx +117 -0
- data/samples/ballantyne.kml +91 -0
- data/samples/big_sur_marathon.html +2766 -0
- data/samples/big_sur_marathon.kml +685 -0
- data/samples/build_gem_test_results.txt +6 -0
- data/samples/crowders_mtn_hike.csv +1065 -0
- data/samples/crowders_mtn_hike.html +1283 -0
- data/samples/crowders_mtn_hike.log +1 -0
- data/samples/cucumber_test_results.txt +302 -0
- data/samples/davidson1.csv +1 -0
- data/samples/davidson1.html +75 -0
- data/samples/davidson_1_point_tcx.csv +0 -0
- data/samples/doc.kml +49 -0
- data/samples/gps_track_log_asheville_mt_pisgah.txt +1 -0
- data/samples/gps_track_logs.txt +1 -0
- data/samples/install_test_results.txt +81 -0
- data/samples/mt_pisgah.txt +1 -0
- data/samples/rspec_test_results.txt +5 -0
- data/setup.rb +66 -0
- data/spec/gooby_base_object_spec.rb +116 -0
- data/spec/gooby_counter_hash_spec.rb +34 -0
- data/spec/gooby_dttm_spec.rb +40 -0
- data/spec/gooby_spec_helper.rb +9 -0
- data/spec/gooby_xml_object_spec.rb +32 -0
- metadata +225 -226
- data/bin/code_scan.rb +0 -16
- data/bin/gooby_been_there.rb +0 -33
- data/bin/gooby_config.rb +0 -24
- data/bin/gooby_csv_validation.rb +0 -50
- data/bin/gooby_first_trackpoints_as_poi.rb +0 -31
- data/bin/gooby_gen_gmap.rb +0 -20
- data/bin/gooby_parser.rb +0 -21
- data/bin/gooby_splitter.rb +0 -21
- data/bin/gooby_version.rb +0 -20
- data/bin/run_all.sh +0 -33
- data/bin/run_been_there.sh +0 -19
- data/bin/run_config.sh +0 -12
- data/bin/run_csv_validation.sh +0 -15
- data/bin/run_db_gen.sh +0 -11
- data/bin/run_db_load.sh +0 -11
- data/bin/run_first_trackpoints_as_poi.sh +0 -16
- data/bin/run_gen_gmaps.sh +0 -21
- data/bin/run_parse_full.sh +0 -45
- data/bin/run_parse_samples.sh +0 -21
- data/bin/run_split.sh +0 -24
- data/bin/run_version.sh +0 -12
- data/data/20050305_corporate_cup_hm.csv +0 -251
- data/data/20050305_corporate_cup_hm.xml +0 -2208
- data/data/20050430_nashville_marathon.xml +0 -10043
- data/data/20050430_nashville_marathon_km.csv +0 -1208
- data/data/20060115_phoenix_marathon.csv +0 -1280
- data/data/20060115_phoenix_marathon.xml +0 -10620
- data/data/20070101_davidson_11m.csv +0 -251
- data/data/20070101_davidson_11m.xml +0 -2020
- data/data/20070505_davidson_5k.xml +0 -2875
- data/data/20070505_davidson_5k_km.csv +0 -286
- data/data/hrm1.csv +0 -5
- data/img/gicons/readme.txt +0 -14
- data/lib/gooby_code_scanner.rb +0 -288
- data/lib/gooby_command.rb +0 -210
- data/lib/gooby_course.rb +0 -117
- data/lib/gooby_csv_point.rb +0 -71
- data/lib/gooby_csv_reader.rb +0 -71
- data/lib/gooby_csv_run.rb +0 -28
- data/lib/gooby_delim_line.rb +0 -42
- data/lib/gooby_duration.rb +0 -86
- data/lib/gooby_forerunner_xml_parser.rb +0 -191
- data/lib/gooby_forerunner_xml_splitter.rb +0 -115
- data/lib/gooby_history.rb +0 -41
- data/lib/gooby_kernel.rb +0 -163
- data/lib/gooby_line.rb +0 -80
- data/lib/gooby_object.rb +0 -22
- data/lib/gooby_point.rb +0 -172
- data/lib/gooby_run.rb +0 -213
- data/lib/gooby_simple_xml_parser.rb +0 -50
- data/lib/gooby_test_helper.rb +0 -23
- data/lib/gooby_track.rb +0 -47
- data/lib/gooby_track_point.rb +0 -229
- data/lib/gooby_training_center_xml_parser.rb +0 -224
- data/lib/gooby_training_center_xml_splitter.rb +0 -116
- data/lib/split_code.sh +0 -29
- data/samples/20050305_corporate_cup_hm.html +0 -450
- data/samples/20050430_nashville_marathon.html +0 -1668
- data/samples/20060115_phoenix_marathon.html +0 -1596
- data/samples/20070101_davidson_11m.html +0 -432
- data/samples/20070505_davidson_5k.html +0 -413
- data/samples/been_there.txt +0 -92
- data/samples/hrm1.html +0 -87
- data/sql/gooby.ddl +0 -60
- data/sql/gooby_load.dml +0 -62
@@ -0,0 +1,78 @@
|
|
1
|
+
Feature: Install Gooby
|
2
|
+
Gem file 'gooby-2.0.0.gem' has been created and downloaded
|
3
|
+
now we install it, run setup.rb, and ensure that certain files are present
|
4
|
+
|
5
|
+
Scenario: Execute the install process
|
6
|
+
Given file 'install.sh' exists
|
7
|
+
And the gem we are installing is named 'gooby-2.0.0.gem'
|
8
|
+
And file '/temp/gooby-2.0.0.gem' exists
|
9
|
+
And file 'gem_list_after_uninstall.txt' is removed if present
|
10
|
+
And file 'gem_list_after_install.txt' is removed if present
|
11
|
+
And GOOBY_HOME is set to '/Users/cjoakim/gooby'
|
12
|
+
And the GOOBY_HOME directory is recreated
|
13
|
+
|
14
|
+
Then we execute the shell script './install.sh'
|
15
|
+
And my garmin training center export file 'current.tcx' file is restored
|
16
|
+
And these unpacked files exist within directory '/Users/cjoakim/gooby':
|
17
|
+
| file | type |
|
18
|
+
| config | directory |
|
19
|
+
| csv | directory |
|
20
|
+
| data | directory |
|
21
|
+
| features/steps | directory |
|
22
|
+
| features/support | directory |
|
23
|
+
| out/images | directory |
|
24
|
+
| samples | directory |
|
25
|
+
| splits | directory |
|
26
|
+
| tmp | directory |
|
27
|
+
| cucumber.yml | regular |
|
28
|
+
| README | regular |
|
29
|
+
| rakefile.rb | regular |
|
30
|
+
| samples.sh | regular |
|
31
|
+
| setup.rb | regular |
|
32
|
+
| config/ballantyne.yaml | regular |
|
33
|
+
| config/big_sur_marathon.yaml | regular |
|
34
|
+
| config/crowders_mtn_hike.yaml | regular |
|
35
|
+
| config/davidson1.yaml | regular |
|
36
|
+
| config/gooby_config.yaml | regular |
|
37
|
+
| csv/2008_04_27_13_49_50_tcx.csv | regular |
|
38
|
+
| data/current.tcx | regular |
|
39
|
+
| features/build_gem.feature | regular |
|
40
|
+
| features/gooby.feature | regular |
|
41
|
+
| features/install.feature | regular |
|
42
|
+
| features/steps/gooby_steps.rb | regular |
|
43
|
+
| features/support/env.rb | regular |
|
44
|
+
| out/images/dd-end.png | regular |
|
45
|
+
| out/images/dd-end.png | regular |
|
46
|
+
| out/images/marker1.png | regular |
|
47
|
+
| out/images/marker26.png | regular |
|
48
|
+
| out/images/shadow50.png | regular |
|
49
|
+
| samples/2008_04_27_13_49_50_tcx.csv | regular |
|
50
|
+
| samples/2008_04_27_13_49_50_tcx.xml | regular |
|
51
|
+
| samples/2009_01_01_14_45_00_tcx.xml | regular |
|
52
|
+
| samples/ballantyne.csv | regular |
|
53
|
+
| samples/ballantyne.gpx | regular |
|
54
|
+
| samples/ballantyne.kml | regular |
|
55
|
+
| samples/big_sur_marathon.html | regular |
|
56
|
+
| samples/big_sur_marathon.kml | regular |
|
57
|
+
| samples/build_gem_test_results.txt | regular |
|
58
|
+
| samples/crowders_mtn_hike.csv | regular |
|
59
|
+
| samples/crowders_mtn_hike.html | regular |
|
60
|
+
| samples/crowders_mtn_hike.log | regular |
|
61
|
+
| samples/cucumber_test_results.txt | regular |
|
62
|
+
| samples/davidson1.csv | regular |
|
63
|
+
| samples/davidson1.html | regular |
|
64
|
+
| samples/doc.kml | regular |
|
65
|
+
| samples/gps_track_log_asheville_mt_pisgah.txt | regular |
|
66
|
+
| samples/gps_track_logs.txt | regular |
|
67
|
+
| samples/install_test_results.txt | regular |
|
68
|
+
| samples/mt_pisgah.txt | regular |
|
69
|
+
| samples/rspec_test_results.txt | regular |
|
70
|
+
|
71
|
+
And these generated files exist within directory '/Users/cjoakim/gooby':
|
72
|
+
| file | type |
|
73
|
+
| out/ballantyne.html | regular |
|
74
|
+
| out/ballantyne.kml | regular |
|
75
|
+
| out/big_sur_marathon.html | regular |
|
76
|
+
| out/big_sur_marathon.kml | regular |
|
77
|
+
| out/crowders_mtn_hike.html | regular |
|
78
|
+
| out/crowders_mtn_hike.kml | regular |
|
@@ -0,0 +1,245 @@
|
|
1
|
+
|
2
|
+
def gooby_home
|
3
|
+
ENV['GOOBY_HOME']
|
4
|
+
end
|
5
|
+
|
6
|
+
def directory?(word)
|
7
|
+
return false if word.nil?
|
8
|
+
return true if word.downcase == 'directory'
|
9
|
+
return true if word.downcase == 'dir'
|
10
|
+
return true if word.downcase == 'folder'
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^GOOBY_HOME is set to '(.*)'$/ do | dir_name |
|
15
|
+
ENV['GOOBY_HOME'] = dir_name
|
16
|
+
`env > tmp/cuke_env.txt`
|
17
|
+
gooby_home.should == dir_name
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^the config file we use is '(.*)'$/ do | file |
|
21
|
+
@config_file = file
|
22
|
+
end
|
23
|
+
|
24
|
+
Then /^we imported the data from our Garmin GPS device model 305 into Garmin Training Center$/ do
|
25
|
+
# This step is for documentation purposes only
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^exported the data from Garmin Training Center to a TCX file$/ do
|
29
|
+
# This step is for documentation purposes only
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^the TCX file is named '(.*)'$/ do | filename |
|
33
|
+
@tcx_filename = filename
|
34
|
+
end
|
35
|
+
|
36
|
+
Then /^an empty (.*) directory within GOOBY_HOME$/ do | dir |
|
37
|
+
pattern = "#{gooby_home}/#{dir}/*.*"
|
38
|
+
FileUtils.rm Dir.glob(pattern)
|
39
|
+
Dir.glob(pattern).size.should == 0
|
40
|
+
end
|
41
|
+
|
42
|
+
Then /^file '(.*)' does not exist within GOOBY_HOME$/ do | file |
|
43
|
+
full_name = "#{gooby_home}/#{file}"
|
44
|
+
if File.exist?(full_name)
|
45
|
+
FileUtils.rm(full_name)
|
46
|
+
end
|
47
|
+
File.exist?(full_name).should == false
|
48
|
+
end
|
49
|
+
|
50
|
+
Then /^rake task '(.*)' is executed$/ do | task_name |
|
51
|
+
@gooby_task = task_name.split(':')[1]
|
52
|
+
@redirect_file = "tmp/#{@gooby_task}.txt"
|
53
|
+
params = ''
|
54
|
+
if task_name == 'gooby:extract_activities_from_tcx'
|
55
|
+
params = "tcx_file=#{@tcx_filename}"
|
56
|
+
end
|
57
|
+
if @config_file
|
58
|
+
params << "config_file=#{@config_file}"
|
59
|
+
end
|
60
|
+
command = "rake #{task_name} #{params} > #{@redirect_file}"
|
61
|
+
`#{command}`
|
62
|
+
end
|
63
|
+
|
64
|
+
Then /^the (.*) file '(.*)' is created$/ do | type, file |
|
65
|
+
File.exists?(file).should == true
|
66
|
+
lines = IO.readlines(file)
|
67
|
+
if type == 'CSV'
|
68
|
+
@csv_filename, @csv_lines = file, lines
|
69
|
+
elsif type == 'HTML'
|
70
|
+
@html_filename, @html_lines = file, lines
|
71
|
+
elsif type == 'KML'
|
72
|
+
@kml_filename, @kml_lines = file, lines
|
73
|
+
elsif type == 'KMZ'
|
74
|
+
@kmz_filename = file
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
Then /^the following lines are expected$/ do
|
79
|
+
@expected_lines = []
|
80
|
+
end
|
81
|
+
|
82
|
+
Then "line: $to_eol" do | to_eol |
|
83
|
+
@expected_lines << to_eol.strip
|
84
|
+
end
|
85
|
+
|
86
|
+
Then /^the CSV file contains (.*) trackpoints$/ do | count |
|
87
|
+
trackpoints = []
|
88
|
+
FasterCSV.foreach(@csv_filename) do | row |
|
89
|
+
tkpt = GoobyTrackpoint.new
|
90
|
+
tkpt.from_csv(row)
|
91
|
+
trackpoints << tkpt
|
92
|
+
end
|
93
|
+
trackpoints.size.should == count.to_i
|
94
|
+
end
|
95
|
+
|
96
|
+
Then /^the HTML file contains (.*) lines$/ do | count |
|
97
|
+
@html_lines.size.should == count.to_i
|
98
|
+
end
|
99
|
+
|
100
|
+
Then /^the KML file contains (.*) lines$/ do | count |
|
101
|
+
@kml_lines.size.should == count.to_i
|
102
|
+
end
|
103
|
+
|
104
|
+
Then /^the splits directory contains at least (.*) files matching name '(.*)'$/ do | count, p |
|
105
|
+
pattern = "#{gooby_home}/splits/#{p}*"
|
106
|
+
list = Dir.glob(pattern)
|
107
|
+
list.size.should >= count.to_i
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /^these activity xml files exist:$/ do | table |
|
111
|
+
table.hashes.each do | hash |
|
112
|
+
lines = IO.readlines(hash['file'])
|
113
|
+
lines.size.should == hash['lines'].to_i
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
Then /^the output contains (.*) lines, within a tolerance of (.*)$/ do | count, tolerance |
|
118
|
+
@redirect_file_lines = IO.readlines(@redirect_file)
|
119
|
+
@redirect_file_lines.size.should >= count.to_i - tolerance.to_i
|
120
|
+
@redirect_file_lines.size.should <= count.to_i + tolerance.to_i
|
121
|
+
end
|
122
|
+
|
123
|
+
Then /^the (.*) contains the expected lines$/ do | type |
|
124
|
+
content_lines = @csv_lines if type == 'CSV'
|
125
|
+
content_lines = @html_lines if type == 'HTML'
|
126
|
+
content_lines = @kml_lines if type == 'KML'
|
127
|
+
content_lines = @redirect_file_lines if type == 'output'
|
128
|
+
prev_match_idx = -1
|
129
|
+
@expected_lines.each { | expected_line |
|
130
|
+
matched = false
|
131
|
+
content_lines.each_with_index { | content_line, content_line_idx |
|
132
|
+
if content_line_idx > prev_match_idx
|
133
|
+
pos_idx = content_line.strip.index(expected_line)
|
134
|
+
if (pos_idx) && (pos_idx >= 0)
|
135
|
+
matched, prev_match_idx = true, content_line_idx
|
136
|
+
end
|
137
|
+
end
|
138
|
+
}
|
139
|
+
matched.should == true
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
Then /^we edit CSV file '(.*)' to contain only point number (.*)$/ do | file, point_number |
|
144
|
+
lines = IO.readlines(file)
|
145
|
+
out = File.new file, 'w+'
|
146
|
+
out.write lines[point_number.to_i]
|
147
|
+
out.flush
|
148
|
+
out.close
|
149
|
+
end
|
150
|
+
|
151
|
+
Then /^the CSV file contains these trackpoints:$/ do | table |
|
152
|
+
trackpoints = []
|
153
|
+
FasterCSV.foreach(@csv_filename) do | row |
|
154
|
+
tkpt = GoobyTrackpoint.new
|
155
|
+
tkpt.from_csv(row)
|
156
|
+
trackpoints << tkpt
|
157
|
+
end
|
158
|
+
table.hashes.each do | hash |
|
159
|
+
seq = hash['seq'].to_i
|
160
|
+
seq.should > 0
|
161
|
+
seq.should <= trackpoints.size
|
162
|
+
tkpt = trackpoints[seq - 1]
|
163
|
+
tkpt.latitude.to_s.should == hash['latitude']
|
164
|
+
tkpt.longitude.to_s.should == hash['longitude']
|
165
|
+
tkpt.distance.to_s.should == hash['distance']
|
166
|
+
tkpt.elapsed_time.to_s.should == hash['elapsed']
|
167
|
+
tkpt.mph.to_s.should == hash['mph']
|
168
|
+
tkpt.pace.to_s.should == hash['pace']
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
Then /^copy the generated files to the samples directory$/ do
|
173
|
+
list = []
|
174
|
+
list << 'csv/2008_04_27_13_49_50_tcx.csv'
|
175
|
+
list << 'csv/ballantyne.csv'
|
176
|
+
list << 'csv/crowders_mtn_hike.csv'
|
177
|
+
list << 'csv/davidson1.csv'
|
178
|
+
list << 'out/ballantyne.kml'
|
179
|
+
list << 'out/big_sur_marathon.html'
|
180
|
+
list << 'out/big_sur_marathon.kml'
|
181
|
+
list << 'out/crowders_mtn_hike.html'
|
182
|
+
list << 'out/davidson1.html'
|
183
|
+
list << 'out/doc.kml'
|
184
|
+
FileUtils.cp list, "samples"
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^(.*) '(.*)' exists$/ do | word , name |
|
188
|
+
if directory?(word)
|
189
|
+
if File.exist?(name) && File.directory?(name)
|
190
|
+
# ok, the directory exists
|
191
|
+
else
|
192
|
+
FileUtils.mkdir_p(name)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
File.exist?(name).should == true
|
196
|
+
end
|
197
|
+
|
198
|
+
Then /^the GOOBY_HOME directory is recreated$/ do
|
199
|
+
if File.exist?(gooby_home) && File.directory?(gooby_home)
|
200
|
+
FileUtils.rm_rf(gooby_home)
|
201
|
+
end
|
202
|
+
FileUtils.mkdir_p(gooby_home)
|
203
|
+
end
|
204
|
+
|
205
|
+
Then /^my garmin training center export file 'current.tcx' file is restored$/ do
|
206
|
+
FileUtils.cp '/data/gooby/garmin/current.tcx', "#{gooby_home}/data/current.tcx"
|
207
|
+
end
|
208
|
+
|
209
|
+
Then /^the gem we are (.*) is named '(.*)'$/ do | word, name |
|
210
|
+
@gem_name = name
|
211
|
+
end
|
212
|
+
|
213
|
+
Then /^(.*) '(.*)' is removed if present$/ do | word , name |
|
214
|
+
if (word.downcase == 'directory') || (word.downcase == 'dir')
|
215
|
+
if File.exist?(name) && File.directory?(name)
|
216
|
+
FileUtils.rm_rf(name)
|
217
|
+
end
|
218
|
+
else
|
219
|
+
if File.exist?(name)
|
220
|
+
FileUtils.rm(name)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
File.exist?(name).should == false
|
224
|
+
end
|
225
|
+
|
226
|
+
Then /^we execute the shell script '(.*)'$/ do | name |
|
227
|
+
@shell_script_name = name
|
228
|
+
result = `#{@shell_script_name}`
|
229
|
+
end
|
230
|
+
|
231
|
+
Then /^these (.*) files exist within directory '(.*)':$/ do | word, dir, table |
|
232
|
+
table.hashes.each do | hash |
|
233
|
+
filename, type = "#{dir}/#{hash['file']}".strip, hash['type'].to_s.strip
|
234
|
+
# puts "verifying: #{dir} #{type} #{filename}"
|
235
|
+
if directory?(type)
|
236
|
+
File.exist?(filename).should == true
|
237
|
+
File.directory?(filename).should == true
|
238
|
+
else
|
239
|
+
File.exist?(filename).should == true
|
240
|
+
File.directory?(filename).should == false
|
241
|
+
IO.readlines(filename).size.should > 0
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
data/lib/gooby.rb
CHANGED
@@ -1,44 +1,38 @@
|
|
1
1
|
=begin
|
2
2
|
|
3
|
-
Gooby = Google APIs + Ruby
|
4
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
5
4
|
Gooby is available under GNU General Public License (GPL) license.
|
6
5
|
|
7
6
|
=end
|
8
7
|
|
8
|
+
require 'rubygems'
|
9
|
+
require 'rbconfig'
|
9
10
|
require 'date'
|
11
|
+
require 'erb'
|
12
|
+
require 'fastercsv'
|
10
13
|
require 'find'
|
11
|
-
require '
|
12
|
-
require 'rexml/document'
|
13
|
-
require 'rexml/streamlistener'
|
14
|
-
require 'singleton'
|
14
|
+
require 'libxml'
|
15
15
|
require 'time'
|
16
16
|
require 'yaml'
|
17
17
|
|
18
|
-
require '
|
19
|
-
require '
|
20
|
-
require '
|
18
|
+
require 'gooby_environment'
|
19
|
+
require 'gooby_introspection'
|
20
|
+
require 'gooby_io'
|
21
|
+
require 'gooby_help_producer'
|
22
|
+
require 'gooby_base_object'
|
23
|
+
require 'gooby_configuration'
|
21
24
|
require 'gooby_counter_hash'
|
22
|
-
require 'gooby_delim_line'
|
23
25
|
require 'gooby_dttm'
|
24
|
-
require '
|
25
|
-
require 'gooby_forerunner_xml_parser'
|
26
|
-
require 'gooby_forerunner_xml_splitter'
|
27
|
-
require 'gooby_training_center_xml_parser'
|
28
|
-
require 'gooby_training_center_xml_splitter'
|
29
|
-
require 'gooby_google_map_generator'
|
30
|
-
require 'gooby_history'
|
26
|
+
require 'gooby_xml_object'
|
31
27
|
require 'gooby_lap'
|
32
|
-
require '
|
33
|
-
require '
|
34
|
-
require '
|
35
|
-
require '
|
36
|
-
require '
|
37
|
-
require '
|
38
|
-
require '
|
39
|
-
require '
|
40
|
-
require '
|
41
|
-
require '
|
42
|
-
require '
|
43
|
-
require 'gooby_code_scanner'
|
44
|
-
require 'gooby_command'
|
28
|
+
require 'gooby_trackpoint'
|
29
|
+
require 'gooby_activity'
|
30
|
+
require 'gooby_tcx_extractor'
|
31
|
+
require 'gooby_track_log_parser'
|
32
|
+
require 'gooby_base_sax_parser'
|
33
|
+
require 'gooby_sax_path_parser'
|
34
|
+
require 'gooby_garmin_tcx_parser'
|
35
|
+
require 'gooby_gpx_parser'
|
36
|
+
require 'gooby_google_kml_generator'
|
37
|
+
require 'gooby_google_map_generator'
|
38
|
+
require 'gooby_process'
|
@@ -0,0 +1,63 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
4
|
+
Gooby is available under GNU General Public License (GPL) license.
|
5
|
+
|
6
|
+
=end
|
7
|
+
|
8
|
+
class GoobyActivity < GoobyXmlObject
|
9
|
+
|
10
|
+
attr_reader :sport, :laps, :trackpoints
|
11
|
+
|
12
|
+
def initialize(attrs=nil)
|
13
|
+
base_initialize
|
14
|
+
@laps, @trackpoints, @current_lap = [], [], nil
|
15
|
+
if attrs
|
16
|
+
attrs.keys.each { | name | set(name, attrs[name]) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def sport
|
21
|
+
get('Sport')
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_lap(lap)
|
25
|
+
if lap
|
26
|
+
lap.set('Seq', @laps.size + 1)
|
27
|
+
@laps << lap
|
28
|
+
@current_lap = lap
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_trackpoint(trackpoint)
|
33
|
+
if trackpoint
|
34
|
+
trackpoint.set('Seq', @trackpoints.size + 1)
|
35
|
+
@trackpoints << trackpoint
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Coumpute the elapsed time and distance of each Trackpoint within the Activity.
|
40
|
+
def post_process
|
41
|
+
cumulative_distance, first_tkpt_dttm, prev_tkpt = 0.0, nil, nil
|
42
|
+
@trackpoints.each { | tkpt |
|
43
|
+
if prev_tkpt
|
44
|
+
incremental_distance = tkpt.proximity(prev_tkpt)
|
45
|
+
cumulative_distance = cumulative_distance + incremental_distance
|
46
|
+
tkpt.set('Distance', cumulative_distance)
|
47
|
+
else
|
48
|
+
first_tkpt_dttm = tkpt.dttm
|
49
|
+
tkpt.set('Distance', 0.0)
|
50
|
+
end
|
51
|
+
tkpt.compute_elapsed_time(first_tkpt_dttm)
|
52
|
+
tkpt.compute_cumulative_pace_and_mph(first_tkpt_dttm)
|
53
|
+
prev_tkpt = tkpt
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def trackpoints_csv
|
58
|
+
lines = []
|
59
|
+
@trackpoints.each { | trackpoint | lines << trackpoint.to_csv }
|
60
|
+
lines
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|