fit4ruby 1.2.0 → 1.3.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/fit4ruby.gemspec +3 -2
- data/lib/fit4ruby/DumpedField.rb +50 -0
- data/lib/fit4ruby/FitFile.rb +7 -1
- data/lib/fit4ruby/FitMessageRecord.rb +7 -2
- data/lib/fit4ruby/FitRecord.rb +6 -3
- data/lib/fit4ruby/GlobalFitMessages.rb +4 -4
- data/lib/fit4ruby/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7421c4ad0cf94e98f1ee6eece22948d8fc2f6b4
|
4
|
+
data.tar.gz: 394e28074fea568b49142c6e5548226046241a82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8e86bad757aec6cc33c0030d6fc17cdad765ba661c9e48ae09d643bb4497c902e79207fbc2a57549da136d5f7a5d7c616532d8f564c4e8bbdf9fb343b9117bb
|
7
|
+
data.tar.gz: 8b262ae977668501bb9cedb8982e17065f5ba997da36bb8e790c0b8faa98a724a8ae74d70e7cef24ff48c9eef4efc8a5f734fe00d0549a64c79fb20826b3a087
|
data/fit4ruby.gemspec
CHANGED
@@ -10,8 +10,9 @@ GEM_SPEC = Gem::Specification.new do |spec|
|
|
10
10
|
spec.summary = 'Library to read GARMIN FIT files.'
|
11
11
|
spec.description = <<EOT
|
12
12
|
This library can read and write FIT files and convert them into a Ruby data
|
13
|
-
structure for easy processing. This library was written for
|
14
|
-
Fit files from other devices may
|
13
|
+
structure for easy processing. This library was written for Garmin devices
|
14
|
+
like the FR620, Fenix 3 and Fenix 3 HR. Fit files from other devices may work
|
15
|
+
as well but have not been tested.
|
15
16
|
EOT
|
16
17
|
spec.authors = [ 'Chris Schlaeger' ]
|
17
18
|
spec.email = 'chris@linux.com'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# = DumpedField.rb -- Fit4Ruby - FIT file processing library for Ruby
|
5
|
+
#
|
6
|
+
# Copyright (c) 2016 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 Fit4Ruby
|
14
|
+
|
15
|
+
# If the user has requested a dump of the records, this class is used to
|
16
|
+
# capture a subset of the field related information for the later textual
|
17
|
+
# dump.
|
18
|
+
class DumpedField
|
19
|
+
|
20
|
+
attr_reader :message_number, :field_number
|
21
|
+
|
22
|
+
# Create a new field dump record.
|
23
|
+
# @param message_number [Fixnum] The global message number of the message
|
24
|
+
# this field belongs to.
|
25
|
+
# @param field_number [Fixnum] The number of the FIT message field
|
26
|
+
# @param name [String] The name of the field
|
27
|
+
# @param type [Symbol] The type of the field
|
28
|
+
# @param value [String] A human readable dump of the field value
|
29
|
+
def initialize(message_number, field_number, name, type, value)
|
30
|
+
@message_number = message_number
|
31
|
+
@field_number = field_number
|
32
|
+
@name = name
|
33
|
+
@type = type
|
34
|
+
@value = value
|
35
|
+
end
|
36
|
+
|
37
|
+
def <=>(f)
|
38
|
+
@field_number <=> f.field_number
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s(index)
|
42
|
+
"[#{'%03d' % @message_number}:#{'%03d' % index}:" +
|
43
|
+
"#{'%03d' % @field_number}:" +
|
44
|
+
"#{"%-7s" % @type}] #{@name}: " + "#{@value}"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
data/lib/fit4ruby/FitFile.rb
CHANGED
@@ -144,8 +144,14 @@ module Fit4Ruby
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def dump_records(records)
|
147
|
+
# For each message number we keep a count for how often we already had
|
148
|
+
# this kind of message.
|
149
|
+
message_counters = Hash.new(0)
|
150
|
+
|
147
151
|
records.each do |record|
|
148
|
-
record.dump
|
152
|
+
record.dump(message_counters[record.number])
|
153
|
+
# Increase the counter for this message number.
|
154
|
+
message_counters[record.number] += 1
|
149
155
|
end
|
150
156
|
end
|
151
157
|
|
@@ -14,6 +14,7 @@ require 'bindata'
|
|
14
14
|
require 'fit4ruby/Log'
|
15
15
|
require 'fit4ruby/GlobalFitMessage'
|
16
16
|
require 'fit4ruby/FitFileEntity'
|
17
|
+
require 'fit4ruby/DumpedField'
|
17
18
|
|
18
19
|
module Fit4Ruby
|
19
20
|
|
@@ -78,8 +79,12 @@ module Fit4Ruby
|
|
78
79
|
(filter.field_names.nil? ||
|
79
80
|
filter.field_names.include?(field_name)) &&
|
80
81
|
(value != field.undefined_value || !filter.ignore_undef)
|
81
|
-
fields_dump <<
|
82
|
-
|
82
|
+
fields_dump << DumpedField.new(
|
83
|
+
@global_message_number,
|
84
|
+
field.field_definition_number.snapshot,
|
85
|
+
field_name,
|
86
|
+
field.type(true),
|
87
|
+
(field_def ? field_def : field).to_s(value))
|
83
88
|
end
|
84
89
|
end
|
85
90
|
end
|
data/lib/fit4ruby/FitRecord.rb
CHANGED
@@ -16,6 +16,7 @@ require 'fit4ruby/FitDefinition'
|
|
16
16
|
require 'fit4ruby/FitMessageRecord'
|
17
17
|
require 'fit4ruby/FitFilter'
|
18
18
|
require 'fit4ruby/FitFileEntity'
|
19
|
+
require 'fit4ruby/DumpedField'
|
19
20
|
|
20
21
|
module Fit4Ruby
|
21
22
|
|
@@ -25,6 +26,8 @@ module Fit4Ruby
|
|
25
26
|
# kind of record this is.
|
26
27
|
class FitRecord
|
27
28
|
|
29
|
+
attr_reader :number
|
30
|
+
|
28
31
|
def initialize(definitions)
|
29
32
|
@definitions = definitions
|
30
33
|
@name = @number = @fields = nil
|
@@ -72,13 +75,13 @@ module Fit4Ruby
|
|
72
75
|
self
|
73
76
|
end
|
74
77
|
|
75
|
-
def dump
|
78
|
+
def dump(index)
|
76
79
|
return unless @fields
|
77
80
|
|
78
81
|
begin
|
79
82
|
puts "Message #{@number}: #{@name}" unless @fields.empty?
|
80
|
-
@fields.each do |
|
81
|
-
puts
|
83
|
+
@fields.sort.each do |field|
|
84
|
+
puts field.to_s(index)
|
82
85
|
end
|
83
86
|
rescue Errno::EPIPE
|
84
87
|
# Avoid ugly error message when aborting a less/more pipe.
|
@@ -444,7 +444,7 @@ module Fit4Ruby
|
|
444
444
|
field 8, 'uint16', 'recovery_time', :scale => 60, :unit => 'hours'
|
445
445
|
field 9, 'uint16', 'undocumented_field_9' # maybe activity measurement
|
446
446
|
field 10, 'uint8', 'undocumented_field_10'
|
447
|
-
field 11, 'uint16', '
|
447
|
+
field 11, 'uint16', 'running_lactate_threshold_heart_rate', :unit => 'bpm'
|
448
448
|
field 12, 'uint16', 'undocumented_field_12'
|
449
449
|
field 13, 'uint16', 'undocumented_field_13'
|
450
450
|
field 14, 'uint8', 'undocumented_field_14'
|
@@ -517,9 +517,9 @@ module Fit4Ruby
|
|
517
517
|
field 11, 'enum', 'undocumented_field_11'
|
518
518
|
field 12, 'enum', 'undocumented_field_12'
|
519
519
|
field 13, 'uint8', 'undocumented_field_13'
|
520
|
-
field 14, 'uint16', '
|
521
|
-
field 15, 'uint16', '
|
522
|
-
field 16, 'uint16', 'undocumented_field_16'
|
520
|
+
field 14, 'uint16', 'running_lactate_threshold_heart_rate', :unit => 'bpm'
|
521
|
+
field 15, 'uint16', 'running_lactate_threshold_speed', :scale => 100, :unit => 'm/s'
|
522
|
+
field 16, 'uint16', 'undocumented_field_16' # very correlated to 14 and 15
|
523
523
|
field 17, 'sint8', 'undocumented_field_17'
|
524
524
|
field 18, 'uint8', 'undocumented_field_18'
|
525
525
|
field 19, 'uint8', 'undocumented_field_19'
|
data/lib/fit4ruby/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.3.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-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -68,8 +68,9 @@ dependencies:
|
|
68
68
|
version: 1.6.4
|
69
69
|
description: |
|
70
70
|
This library can read and write FIT files and convert them into a Ruby data
|
71
|
-
structure for easy processing. This library was written for
|
72
|
-
Fit files from other devices may
|
71
|
+
structure for easy processing. This library was written for Garmin devices
|
72
|
+
like the FR620, Fenix 3 and Fenix 3 HR. Fit files from other devices may work
|
73
|
+
as well but have not been tested.
|
73
74
|
email: chris@linux.com
|
74
75
|
executables: []
|
75
76
|
extensions: []
|
@@ -86,6 +87,7 @@ files:
|
|
86
87
|
- lib/fit4ruby/Converters.rb
|
87
88
|
- lib/fit4ruby/DataSources.rb
|
88
89
|
- lib/fit4ruby/DeviceInfo.rb
|
90
|
+
- lib/fit4ruby/DumpedField.rb
|
89
91
|
- lib/fit4ruby/EPO_Data.rb
|
90
92
|
- lib/fit4ruby/Event.rb
|
91
93
|
- lib/fit4ruby/FileCreator.rb
|