fit4ruby 0.0.12 → 1.0.0
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.
- checksums.yaml +4 -4
- data/lib/fit4ruby/Activity.rb +6 -1
- data/lib/fit4ruby/Converters.rb +9 -0
- data/lib/fit4ruby/FitMessageRecord.rb +1 -1
- data/lib/fit4ruby/GlobalFitDictionaries.rb +2 -0
- data/lib/fit4ruby/GlobalFitMessages.rb +10 -4
- data/lib/fit4ruby/Log.rb +16 -4
- data/lib/fit4ruby/version.rb +1 -1
- data/tasks/gem.rake +1 -4
- 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: 3ba139e33bb80954cf3785eb9f73e46123a6b585
|
4
|
+
data.tar.gz: a3dc959723487d30ba8e18a4f6c32a615a74a559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 711dd3bfb66971ceb48db285ba3c9a694ccc34c26a2d37c713096bb5de00c9639e144ed2633b4c3bb33bd45195a5dd143b12054e8066a3eb7b1a44768afd7493
|
7
|
+
data.tar.gz: 8e03437ad93539ea7bc00bb03e0e29db2782a214e06cfd40d3e785ca25c5d74e54f783ae3d3a59e81c9b9d6d569b7f9ddef77562d4c44390bec5b4acf908e30c
|
data/lib/fit4ruby/Activity.rb
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
|
13
13
|
require 'fit4ruby/FitDataRecord'
|
14
14
|
require 'fit4ruby/FileId'
|
15
|
+
require 'fit4ruby/EPO_Data'
|
15
16
|
require 'fit4ruby/FileCreator'
|
16
17
|
require 'fit4ruby/DeviceInfo'
|
17
18
|
require 'fit4ruby/DataSources'
|
@@ -30,7 +31,8 @@ module Fit4Ruby
|
|
30
31
|
# equivalents of the message record structures used in the FIT file.
|
31
32
|
class Activity < FitDataRecord
|
32
33
|
|
33
|
-
attr_accessor :file_id, :
|
34
|
+
attr_accessor :file_id, :epo_data,
|
35
|
+
:file_creator, :device_infos, :data_sources,
|
34
36
|
:user_profiles, :sessions, :laps, :records, :hrv,
|
35
37
|
:events, :personal_records
|
36
38
|
|
@@ -43,6 +45,7 @@ module Fit4Ruby
|
|
43
45
|
@num_sessions = 0
|
44
46
|
|
45
47
|
@file_id = FileId.new
|
48
|
+
@epo_data = nil
|
46
49
|
@file_creator = FileCreator.new
|
47
50
|
@device_infos = []
|
48
51
|
@data_sources = []
|
@@ -365,6 +368,8 @@ module Fit4Ruby
|
|
365
368
|
case record_type
|
366
369
|
when 'file_id'
|
367
370
|
@file_id = (record = FileId.new(field_values))
|
371
|
+
when 'epo_data'
|
372
|
+
@epo_data = (record = EPO_Data.new(field_values))
|
368
373
|
when 'file_creator'
|
369
374
|
@file_creator = (record = FileCreator.new(field_values))
|
370
375
|
when 'device_info'
|
data/lib/fit4ruby/Converters.rb
CHANGED
@@ -68,7 +68,7 @@ module Fit4Ruby
|
|
68
68
|
# file, but we have to discard all bytes from the first null byte
|
69
69
|
# onwards.
|
70
70
|
if value.is_a?(String) && (null_byte = value.index("\0"))
|
71
|
-
value = value[0..(null_byte - 1)]
|
71
|
+
value = null_byte == 0 ? '' : value[0..(null_byte - 1)]
|
72
72
|
end
|
73
73
|
|
74
74
|
field_name, field_def = get_field_name_and_global_def(field, obj)
|
@@ -78,6 +78,7 @@ module Fit4Ruby
|
|
78
78
|
entry 3, 'acceleration' # Just a guess
|
79
79
|
entry 4, 'barometric_pressure' # Just a guess
|
80
80
|
entry 1, 'antfs'
|
81
|
+
entry 10, 'optical_heart_rate' # Just a guess
|
81
82
|
entry 11, 'bike_power'
|
82
83
|
entry 12, 'environment_sensor_legacy'
|
83
84
|
entry 13, 'multi_sport_speed_distance'
|
@@ -205,6 +206,7 @@ module Fit4Ruby
|
|
205
206
|
entry 2173, 'fr620_taiwan'
|
206
207
|
entry 2188, 'fenix3_china'
|
207
208
|
entry 2189, 'fenix3_twn'
|
209
|
+
entry 2413, 'fenix3_hr'
|
208
210
|
entry 10007, 'sdm4'
|
209
211
|
entry 20119, 'training_center'
|
210
212
|
entry 65532, 'android_antplus_plugin'
|
@@ -60,7 +60,7 @@ module Fit4Ruby
|
|
60
60
|
field 16, 'uint8', 'avg_heart_rate', :unit => 'bpm'
|
61
61
|
field 17, 'uint8', 'max_heart_rate', :unit => 'bpm'
|
62
62
|
alt_field 18, 'sport' do
|
63
|
-
field :default, 'uint8', '
|
63
|
+
field :default, 'uint8', 'avg_cadence', :unit => 'rpm'
|
64
64
|
field 'running', 'uint8', 'avg_running_cadence', :unit => 'strides/min'
|
65
65
|
end
|
66
66
|
alt_field 19, 'sport' do
|
@@ -160,7 +160,7 @@ module Fit4Ruby
|
|
160
160
|
field 15, 'uint8', 'avg_heart_rate', :unit => 'bpm'
|
161
161
|
field 16, 'uint8', 'max_heart_rate', :unit => 'bpm'
|
162
162
|
alt_field 17, 'sport' do
|
163
|
-
field :default, 'uint8', '
|
163
|
+
field :default, 'uint8', 'avg_cadence', :unit => 'rpm'
|
164
164
|
field 'running', 'uint8', 'avg_running_cadence', :unit => 'strides/min'
|
165
165
|
end
|
166
166
|
alt_field 18, 'sport' do
|
@@ -326,6 +326,7 @@ module Fit4Ruby
|
|
326
326
|
field 11, 'uint8', 'battery_status', :dict => 'battery_status'
|
327
327
|
field 15, 'uint32', 'rx_packets_ok' # just a guess
|
328
328
|
field 16, 'uint32', 'rx_packets_err' # just a guess
|
329
|
+
field 17, 'string', 'undocumented_field_17'
|
329
330
|
field 20, 'uint8z', 'ant_transmission_type'
|
330
331
|
field 21, 'uint16z', 'ant_device_number'
|
331
332
|
field 22, 'enum', 'ant_network', :dict => 'ant_network'
|
@@ -516,8 +517,9 @@ module Fit4Ruby
|
|
516
517
|
field 19, 'uint8', 'undocumented_field_19'
|
517
518
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
518
519
|
|
519
|
-
# Not part of the official ANT SDK doc
|
520
|
-
|
520
|
+
# Not part of the official ANT SDK doc. The message name is guessed and
|
521
|
+
# may change in the future.
|
522
|
+
message 141, 'epo_data'
|
521
523
|
field 0, 'enum', 'valid' # 0 if no data cached, 1 else
|
522
524
|
field 1, 'uint32', 'interval_start', :type => 'date_time'
|
523
525
|
field 2, 'uint32', 'interval_end', :type => 'date_time'
|
@@ -526,6 +528,10 @@ module Fit4Ruby
|
|
526
528
|
field 5, 'sint32', 'undocumented_field_5'
|
527
529
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
528
530
|
|
531
|
+
message 211, 'undocumented_211'
|
532
|
+
field 0, 'uint8', 'undocumented_field_0'
|
533
|
+
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
534
|
+
|
529
535
|
end
|
530
536
|
|
531
537
|
end
|
data/lib/fit4ruby/Log.rb
CHANGED
@@ -20,6 +20,10 @@ module Fit4Ruby
|
|
20
20
|
# errors.
|
21
21
|
class Error < StandardError ; end
|
22
22
|
|
23
|
+
# This is the Exception type that will be thrown for all program errors that
|
24
|
+
# are caused by user error rather than program logic errors.
|
25
|
+
class Abort < StandardError ; end
|
26
|
+
|
23
27
|
# The ILogger class is a singleton that provides a common logging mechanism
|
24
28
|
# to all objects. It exposes essentially the same interface as the Logger
|
25
29
|
# class, just as a singleton and with some additional methods like 'fatal'
|
@@ -28,7 +32,7 @@ module Fit4Ruby
|
|
28
32
|
|
29
33
|
include Singleton
|
30
34
|
|
31
|
-
@@logger = Logger.new(
|
35
|
+
@@logger = Logger.new($stdout)
|
32
36
|
|
33
37
|
# Redirect all log messages to the given IO.
|
34
38
|
# @param io [IO] Output file descriptor
|
@@ -36,7 +40,7 @@ module Fit4Ruby
|
|
36
40
|
begin
|
37
41
|
@@logger = Logger.new(io)
|
38
42
|
rescue => e
|
39
|
-
@@logger = Logger.new(
|
43
|
+
@@logger = Logger.new($stderr)
|
40
44
|
Log.fatal "Cannot open log file: #{e.message}"
|
41
45
|
end
|
42
46
|
end
|
@@ -51,8 +55,16 @@ module Fit4Ruby
|
|
51
55
|
@@logger.respond_to?(method)
|
52
56
|
end
|
53
57
|
|
54
|
-
# Print an error message via the Logger and raise
|
55
|
-
#
|
58
|
+
# Print an error message via the Logger and raise a Fit4Ruby::Abort.
|
59
|
+
# This method should be used to abort the program in case of user errors.
|
60
|
+
def abort(msg, &block)
|
61
|
+
@@logger.error(msg, &block)
|
62
|
+
raise Abort, msg
|
63
|
+
end
|
64
|
+
|
65
|
+
# Print an error message via the Logger and raise a Fit4Ruby::Error.
|
66
|
+
# This method should be used to abort the program in case of program logic
|
67
|
+
# errors.
|
56
68
|
def fatal(msg, &block)
|
57
69
|
@@logger.error(msg, &block)
|
58
70
|
raise Error, msg
|
data/lib/fit4ruby/version.rb
CHANGED
data/tasks/gem.rake
CHANGED
@@ -10,8 +10,6 @@ task :gem => [:clobber] do
|
|
10
10
|
Rake::Task[:changelog].invoke
|
11
11
|
Rake::Task[:permissions].invoke
|
12
12
|
|
13
|
-
load 'fit4ruby.gemspec';
|
14
|
-
|
15
13
|
# Build the gem file according to the loaded spec.
|
16
14
|
if RUBY_VERSION >= "2.0.0"
|
17
15
|
Gem::Package.build(GEM_SPEC)
|
@@ -30,8 +28,7 @@ task :permissions do
|
|
30
28
|
# Find the bin and test directories relative to this file.
|
31
29
|
baseDir = File.expand_path('..', File.dirname(__FILE__))
|
32
30
|
|
33
|
-
execs = Dir.glob("#{baseDir}/bin/*")
|
34
|
-
Dir.glob("#{baseDir}/test/**/genrefs")
|
31
|
+
execs = Dir.glob("#{baseDir}/bin/*")
|
35
32
|
|
36
33
|
Find.find(baseDir) do |f|
|
37
34
|
# Ignore the whoke pkg directory as it may contain links to the other
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fit4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schlaeger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.2.2
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Library to read GARMIN FIT files.
|