postrunner 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -11
- data/lib/postrunner/ActivitiesDB.rb +19 -8
- data/lib/postrunner/Main.rb +68 -4
- data/lib/postrunner/version.rb +1 -1
- data/postrunner.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f3d16409dd73ebb5ece8d55497b5e7fcfdc1449
|
4
|
+
data.tar.gz: 7263f602002f1d64b13dd0c1dbaeeeb6fe1637fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bd644e7c8d478cd0782e0dabf92f7eafe6f25f1043fb1af1ae7932b8cdfa67011fccd950d37c68f4eeac531117576215423f20940fec38484ea7306ec45088b
|
7
|
+
data.tar.gz: b44bcc85946e726fd6b5ebbf9ba6b85c96a36c40c5962e5d12b25476094373891f2e1a10d0e4881797eb40ef28264c50021127094e463dc41f5fc1e489ed9967
|
data/README.md
CHANGED
@@ -1,28 +1,48 @@
|
|
1
|
-
#
|
1
|
+
# PostRunner
|
2
2
|
|
3
|
-
|
3
|
+
PostRunner is an application to manage FIT files such as those produced by Garmin products like the Forerunner 620. It allows you to import the files from the device and inspect them.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
PostRunner is a Ruby application. You need to have a Ruby 2.0 or later runtime environment installed.
|
8
8
|
|
9
|
-
gem
|
9
|
+
$ gem install postrunner
|
10
10
|
|
11
|
-
|
11
|
+
## Usage
|
12
12
|
|
13
|
-
|
13
|
+
To get started you need to connect your device to your computer and mount it as a drive. Only devices that expose their data as FAT file system are supported. Older devices use proprietary drivers and are not supported by postrunner. Once the device is mounted find out the full path to the directory that contains your FIT files. You can then import all files on the device.
|
14
14
|
|
15
|
-
|
15
|
+
$ postrunner import /var/run/media/user/GARMIN/GARMIN/ACTIVITY/
|
16
|
+
|
17
|
+
The above command assumes that your device is mounted as /var/run/media/user. Please replace this with the path to your device. Files that have been imported previously will not be imported again.
|
16
18
|
|
17
|
-
|
19
|
+
Now you can list all the FIT files in your data base.
|
18
20
|
|
19
|
-
|
21
|
+
$ postrunner list
|
22
|
+
|
23
|
+
The first column is the index you can use to reference FIT files. To get a summary of the most recent activity use the following command.
|
20
24
|
|
21
|
-
|
25
|
+
$ postrunner summary :1
|
26
|
+
|
27
|
+
To get a summary of the oldest activity you can use
|
28
|
+
|
29
|
+
$ postrunner summary :-1
|
30
|
+
|
31
|
+
You can also get a full dump of the content of a FIT file.
|
32
|
+
|
33
|
+
$ postrunner dump 1234568.FIT
|
34
|
+
|
35
|
+
If the file is already in the data base you can also use the reference notation.
|
36
|
+
|
37
|
+
$ postrunner dump :1
|
38
|
+
|
39
|
+
This will provide you with a lot more information contained in the FIT files that is not available through Garmin Connect or most other tools.
|
22
40
|
|
23
41
|
## Contributing
|
24
42
|
|
25
|
-
|
43
|
+
PostRunner is currently work in progress. It does some things I want with files from my Garmin FR620. It's certainly possible to do more things and support more devices. Patches are welcome!
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/scrapper/postrunner/fork )
|
26
46
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
47
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
48
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -42,6 +42,11 @@ module PostRunner
|
|
42
42
|
return false
|
43
43
|
end
|
44
44
|
|
45
|
+
if File.exists(File.join(@fit_dir, base_fit_file))
|
46
|
+
Log.debug "Activity #{fit_file} has been deleted before"
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
|
45
50
|
begin
|
46
51
|
fit_activity = Fit4Ruby.read(fit_file)
|
47
52
|
rescue Fit4Ruby::Error
|
@@ -65,6 +70,12 @@ module PostRunner
|
|
65
70
|
true
|
66
71
|
end
|
67
72
|
|
73
|
+
def delete(fit_file)
|
74
|
+
base_fit_file = File.basename(fit_file)
|
75
|
+
index = @activities.index { |a| a.fit_file == base_fit_file }
|
76
|
+
@activities.delete_at(index)
|
77
|
+
sync
|
78
|
+
end
|
68
79
|
|
69
80
|
def rename(fit_file, name)
|
70
81
|
base_fit_file = File.basename(fit_file)
|
@@ -129,16 +140,16 @@ module PostRunner
|
|
129
140
|
end
|
130
141
|
|
131
142
|
def create_directories
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
143
|
+
create_directory(@db_dir, 'data')
|
144
|
+
create_directory(@fit_dir, 'fit')
|
145
|
+
end
|
146
|
+
|
147
|
+
def create_directory(dir, name)
|
148
|
+
Log.info "Creating #{name} directory #{dir}"
|
138
149
|
begin
|
139
|
-
Dir.mkdir(
|
150
|
+
Dir.mkdir(dir)
|
140
151
|
rescue
|
141
|
-
Log.fatal "Cannot create
|
152
|
+
Log.fatal "Cannot create #{name} directory #{dir}: #{$!}"
|
142
153
|
end
|
143
154
|
end
|
144
155
|
|
data/lib/postrunner/Main.rb
CHANGED
@@ -6,7 +6,11 @@ require 'postrunner/ActivitiesDB'
|
|
6
6
|
|
7
7
|
module PostRunner
|
8
8
|
|
9
|
+
# Use the Logger provided by Fit4Ruby for all console output.
|
9
10
|
Log = Fit4Ruby::ILogger.new(STDOUT)
|
11
|
+
Log.formatter = proc { |severity, datetime, progname, msg|
|
12
|
+
"#{severity == Logger::INFO ? '' : "#{severity}:"} #{msg}\n"
|
13
|
+
}
|
10
14
|
|
11
15
|
class Main
|
12
16
|
|
@@ -23,9 +27,18 @@ module PostRunner
|
|
23
27
|
def parse_options(args)
|
24
28
|
parser = OptionParser.new do |opts|
|
25
29
|
opts.banner = "Usage postrunner <command> [options]"
|
30
|
+
|
31
|
+
opts.separator <<"EOT"
|
32
|
+
|
33
|
+
Copyright (c) 2014 by Chris Schlaeger
|
34
|
+
|
35
|
+
This program is free software; you can redistribute it and/or modify it under
|
36
|
+
the terms of version 2 of the GNU General Public License as published by the
|
37
|
+
Free Software Foundation.
|
38
|
+
EOT
|
39
|
+
|
26
40
|
opts.separator ""
|
27
41
|
opts.separator "Options for the 'dump' command:"
|
28
|
-
|
29
42
|
opts.on('--filter-msg N', Integer,
|
30
43
|
'Only dump messages of type number N') do |n|
|
31
44
|
@filter = Fit4Ruby::FitFilter.new unless @filter
|
@@ -50,21 +63,66 @@ module PostRunner
|
|
50
63
|
@filter.ignore_undef = true
|
51
64
|
end
|
52
65
|
|
66
|
+
opts.separator ""
|
53
67
|
opts.separator "Options for the 'import' and 'rename' command:"
|
54
|
-
|
55
68
|
opts.on('--name name', String,
|
56
69
|
'Name or rename the activity to the specified name') do |n|
|
57
70
|
@name = n
|
58
71
|
end
|
72
|
+
|
73
|
+
opts.separator ""
|
74
|
+
opts.separator "General options:"
|
75
|
+
opts.on('-v', '--verbose',
|
76
|
+
'Show internal messages helpful for debugging problems') do
|
77
|
+
Log.level = Logger::DEBUG
|
78
|
+
end
|
79
|
+
opts.on('-h', '--help', 'Show this message') do
|
80
|
+
$stderr.puts opts
|
81
|
+
exit
|
82
|
+
end
|
83
|
+
opts.on('--version', 'Show version number') do
|
84
|
+
$stderr.puts VERSION
|
85
|
+
exit
|
86
|
+
end
|
87
|
+
|
88
|
+
opts.separator <<"EOT"
|
89
|
+
|
90
|
+
Commands:
|
91
|
+
|
92
|
+
check <fit file> ...
|
93
|
+
Check the provided FIT file(s) for structural errors.
|
94
|
+
|
95
|
+
dump <fit file> | <ref>
|
96
|
+
Dump the content of the FIT file.
|
97
|
+
|
98
|
+
import <fit file> | <directory>
|
99
|
+
Import the provided FIT file(s) into the postrunner database.
|
100
|
+
|
101
|
+
delete <ref>
|
102
|
+
Delete the activity from the archive.
|
103
|
+
|
104
|
+
list
|
105
|
+
List all FIT files stored in the data base.
|
106
|
+
|
107
|
+
rename <ref>
|
108
|
+
Replace the FIT file name with a more meaningful name that describes
|
109
|
+
the activity.
|
110
|
+
|
111
|
+
summary <fit file> | <ref>
|
112
|
+
Display the summary information for the FIT file.
|
113
|
+
EOT
|
114
|
+
|
59
115
|
end
|
60
116
|
|
61
117
|
parser.parse!(args)
|
62
118
|
end
|
63
119
|
|
64
120
|
def execute_command(args)
|
65
|
-
case args.shift
|
121
|
+
case (cmd = args.shift)
|
66
122
|
when 'check'
|
67
123
|
process_files_or_activities(args, :check)
|
124
|
+
when 'delete'
|
125
|
+
process_activities(args, :delete)
|
68
126
|
when 'dump'
|
69
127
|
@filter = Fit4Ruby::FitFilter.new unless @filter
|
70
128
|
process_files_or_activities(args, :dump)
|
@@ -76,8 +134,12 @@ module PostRunner
|
|
76
134
|
process_activities(args, :rename)
|
77
135
|
when 'summary'
|
78
136
|
process_files_or_activities(args, :summary)
|
137
|
+
when nil
|
138
|
+
Log.fatal("No command provided. " +
|
139
|
+
"See 'postrunner -h' for more information.")
|
79
140
|
else
|
80
|
-
Log.fatal("
|
141
|
+
Log.fatal("Unknown command '#{cmd}'. " +
|
142
|
+
"See 'postrunner -h' for more information.")
|
81
143
|
end
|
82
144
|
end
|
83
145
|
|
@@ -131,6 +193,8 @@ module PostRunner
|
|
131
193
|
|
132
194
|
def process_file(file, command)
|
133
195
|
case command
|
196
|
+
when :delete
|
197
|
+
@activities.delete(file)
|
134
198
|
when :import
|
135
199
|
@activities.add(file)
|
136
200
|
when :rename
|
data/lib/postrunner/version.rb
CHANGED
data/postrunner.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["chris@linux.com"]
|
11
11
|
spec.summary = %q{Application to manage and analyze Garmin FIT files.}
|
12
12
|
spec.description = %q{This application will allow you to manage and analyze .FIT files as generated by Garmin GPS devices. The application was developed for the Garmin Forerunner 620. Other devices may or may not work. Only devices that expose themselves as USB Mass Storage devices are supported.}
|
13
|
-
spec.homepage = 'https://github.com/scrapper/
|
13
|
+
spec.homepage = 'https://github.com/scrapper/postrunner'
|
14
14
|
spec.license = "GNU GPL version 2"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
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.
|
4
|
+
version: 0.0.2
|
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-07-
|
11
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,7 +62,7 @@ files:
|
|
62
62
|
- lib/postrunner/RuntimeConfig.rb
|
63
63
|
- lib/postrunner/version.rb
|
64
64
|
- postrunner.gemspec
|
65
|
-
homepage: https://github.com/scrapper/
|
65
|
+
homepage: https://github.com/scrapper/postrunner
|
66
66
|
licenses:
|
67
67
|
- GNU GPL version 2
|
68
68
|
metadata: {}
|