fit-parser 0.0.1 → 0.0.2
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/.travis.yml +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +12 -2
- data/Rakefile +3 -0
- data/lib/fit/file/definitions.rb +17 -1
- data/lib/fit/version.rb +1 -1
- data/spec/file/data_spec.rb +53 -0
- data/spec/support/examples/record/message/data_lap.fit +0 -0
- data/spec/support/examples/record/message/data_session.fit +0 -0
- data/spec/support/examples/record/message/definition_lap.fit +0 -0
- data/spec/support/examples/record/message/definition_session.fit +0 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14a5bb162a20cb244ffd1de81be4327a5b868260
|
4
|
+
data.tar.gz: ce73ef3c0433f8eb91011800e47bac3d1a9e9056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae219e48085f9c4978118574b54dbe55c6632b6b254b2dd4539be8538613c135b5d4acb47634203fdd582bd91319be10b7452216555cb8c45c065f598e63af3b
|
7
|
+
data.tar.gz: 1f6637e143923e6b9b707a49939938fa764924f13a437e2ef0d4132523c5de556e35acf6db4ca5b7f793d39670e97271a9f5a8677f8c8045b0e6e7de9a78333f
|
data/.travis.yml
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
# fit
|
1
|
+
# fit [](https://travis-ci.org/tjwallace/fit)
|
2
2
|
|
3
3
|
A ruby gem for parsing [fit files](http://www.thisisant.com/pages/products/fit-sdk). It makes heavy use of the [bindata gem](http://bindata.rubyforge.org/).
|
4
4
|
|
5
|
+
It is published on RubyGems.org as [fit-parser](https://rubygems.org/gems/fit-parser).
|
6
|
+
|
5
7
|
## Example usage
|
6
8
|
|
7
9
|
```ruby
|
@@ -12,6 +14,14 @@ fit_file = Fit.load_file(ARGV[0])
|
|
12
14
|
records = fit_file.records.select{ |r| r.content.record_type != :definition }.map{ |r| r.content }
|
13
15
|
```
|
14
16
|
|
17
|
+
## Supported files
|
18
|
+
|
19
|
+
This library has been tested with files coming from the following devices:
|
20
|
+
- Garmin Swim
|
21
|
+
|
22
|
+
|
23
|
+
Please let me know if you have any success with files coming from devices that are not listed here.
|
24
|
+
|
15
25
|
## Contributing to fit
|
16
26
|
|
17
27
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
@@ -24,4 +34,4 @@ records = fit_file.records.select{ |r| r.content.record_type != :definition }.ma
|
|
24
34
|
|
25
35
|
## Copyright
|
26
36
|
|
27
|
-
Copyright (c)
|
37
|
+
Copyright (c) 2015 Jeff Wallace. See LICENSE.txt for further details.
|
data/Rakefile
CHANGED
data/lib/fit/file/definitions.rb
CHANGED
@@ -682,7 +682,7 @@ Fit::File::Definitions.add_field 55, 5, 'activity_type', :type => :activity_type
|
|
682
682
|
Fit::File::Definitions.add_field 55, 6, 'activity_subtype', :type => :activity_subtype
|
683
683
|
Fit::File::Definitions.add_field 55, 7, 'activity_level', :type => :activity_level
|
684
684
|
Fit::File::Definitions.add_field 55, 8, 'distance_16', :type => :uint16, :unit => '100 * m'
|
685
|
-
Fit::File::Definitions.add_field 55, 9, 'cycles_16', :type => :uint16, :unit => '2 * cycles
|
685
|
+
Fit::File::Definitions.add_field 55, 9, 'cycles_16', :type => :uint16, :unit => '2 * cycles (steps)'
|
686
686
|
Fit::File::Definitions.add_field 55, 10, 'active_time_16', :type => :uint16, :unit => 's'
|
687
687
|
Fit::File::Definitions.add_field 55, 11, 'local_timestamp', :type => :local_date_time
|
688
688
|
Fit::File::Definitions.add_field 55, 12, 'temperature', :type => :sint16, :scale => 100, :unit => 'C'
|
@@ -703,3 +703,19 @@ Fit::File::Definitions.add_field 145, 250, 'part_index', :type => :uint32
|
|
703
703
|
Fit::File::Definitions.add_field 145, 0, 'memo', :type => :byte
|
704
704
|
Fit::File::Definitions.add_field 145, 1, 'message_number', :type => :uint16
|
705
705
|
Fit::File::Definitions.add_field 145, 2, 'message_index', :type => :message_index
|
706
|
+
|
707
|
+
# =============================================================================
|
708
|
+
# Warning, the definition below are not part of the official fit format
|
709
|
+
# definition. They have been obtained by deduction from Garmin Swim files
|
710
|
+
# =============================================================================
|
711
|
+
# session additions
|
712
|
+
Fit::File::Definitions.add_field 18, 33, 'length_count', :type => :uint16
|
713
|
+
Fit::File::Definitions.add_field 18, 78, 'total_swim_time', :type => :uint32, :scale => 1000
|
714
|
+
Fit::File::Definitions.add_field 18, 79, 'average_stroke', :type => :uint16, :scale => 10
|
715
|
+
Fit::File::Definitions.add_field 18, 80, 'swolf', :type => :uint16
|
716
|
+
|
717
|
+
# lap additions
|
718
|
+
Fit::File::Definitions.add_field 19, 70, 'swim_time', :type => :uint32, :scale => 1000
|
719
|
+
Fit::File::Definitions.add_field 19, 72, 'average_stroke', :type => :uint16, :scale => 10
|
720
|
+
Fit::File::Definitions.add_field 19, 73, 'swolf', :type => :uint16
|
721
|
+
|
data/lib/fit/version.rb
CHANGED
data/spec/file/data_spec.rb
CHANGED
@@ -107,5 +107,58 @@ describe Fit::File::Data do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
|
+
|
111
|
+
context 'definition with undocumented fields of garmin swim' do
|
112
|
+
|
113
|
+
context 'in lap message' do
|
114
|
+
before :each do
|
115
|
+
def_file = example_file('record/message/definition_lap.fit')
|
116
|
+
definition = described_class.generate(Fit::File::Definition.read def_file)
|
117
|
+
@res = definition.read( example_file('record/message/data_lap.fit') )
|
118
|
+
end
|
119
|
+
it 'returns the total_swim_time' do
|
120
|
+
expect(@res.raw_swim_time).to eq(234321)
|
121
|
+
expect(@res.swim_time).to eq(234.321)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'returns the average_stroke' do
|
125
|
+
expect(@res.raw_average_stroke).to eq(143)
|
126
|
+
expect(@res.average_stroke).to eq(14.3)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'returns the swolf' do
|
130
|
+
expect(@res.raw_swolf).to eq(49)
|
131
|
+
expect(@res.swolf).to eq(49)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'in session message' do
|
136
|
+
before :each do
|
137
|
+
def_file = example_file('record/message/definition_session.fit')
|
138
|
+
definition = described_class.generate(Fit::File::Definition.read def_file)
|
139
|
+
@res = definition.read( example_file('record/message/data_session.fit') )
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'returns the length_count' do
|
143
|
+
expect(@res.raw_length_count).to eq(28)
|
144
|
+
expect(@res.length_count).to eq(28)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'returns the total_swim_time' do
|
148
|
+
expect(@res.raw_total_swim_time).to eq(1346975)
|
149
|
+
expect(@res.total_swim_time).to eq(1346.975)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'returns the average_stroke' do
|
153
|
+
expect(@res.raw_average_stroke).to eq(134)
|
154
|
+
expect(@res.average_stroke).to eq(13.4)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'returns the swolf' do
|
158
|
+
expect(@res.raw_swolf).to eq(44)
|
159
|
+
expect(@res.swolf).to eq(44)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
110
163
|
end
|
111
164
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fit-parser
|
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
|
- Jeff Wallace
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
133
|
- ".rspec"
|
134
|
+
- ".travis.yml"
|
134
135
|
- Gemfile
|
135
136
|
- LICENSE.txt
|
136
137
|
- README.md
|
@@ -169,10 +170,14 @@ files:
|
|
169
170
|
- spec/support/examples/record/message/data_field_array.fit
|
170
171
|
- spec/support/examples/record/message/data_file_capabilities_activities.fit
|
171
172
|
- spec/support/examples/record/message/data_file_capabilities_settings.fit
|
173
|
+
- spec/support/examples/record/message/data_lap.fit
|
174
|
+
- spec/support/examples/record/message/data_session.fit
|
172
175
|
- spec/support/examples/record/message/definition
|
173
176
|
- spec/support/examples/record/message/definition_dynamic_fields.fit
|
174
177
|
- spec/support/examples/record/message/definition_field_array.fit
|
175
178
|
- spec/support/examples/record/message/definition_file_capabilities.fit
|
179
|
+
- spec/support/examples/record/message/definition_lap.fit
|
180
|
+
- spec/support/examples/record/message/definition_session.fit
|
176
181
|
- spec/support/examples/record/normal_header
|
177
182
|
homepage: https://github.com/tjwallace/fit
|
178
183
|
licenses:
|
@@ -194,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
199
|
version: '0'
|
195
200
|
requirements: []
|
196
201
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.2.
|
202
|
+
rubygems_version: 2.2.0
|
198
203
|
signing_key:
|
199
204
|
specification_version: 4
|
200
205
|
summary: Ruby gem for reading Garmin FIT files
|
@@ -221,8 +226,12 @@ test_files:
|
|
221
226
|
- spec/support/examples/record/message/data_field_array.fit
|
222
227
|
- spec/support/examples/record/message/data_file_capabilities_activities.fit
|
223
228
|
- spec/support/examples/record/message/data_file_capabilities_settings.fit
|
229
|
+
- spec/support/examples/record/message/data_lap.fit
|
230
|
+
- spec/support/examples/record/message/data_session.fit
|
224
231
|
- spec/support/examples/record/message/definition
|
225
232
|
- spec/support/examples/record/message/definition_dynamic_fields.fit
|
226
233
|
- spec/support/examples/record/message/definition_field_array.fit
|
227
234
|
- spec/support/examples/record/message/definition_file_capabilities.fit
|
235
|
+
- spec/support/examples/record/message/definition_lap.fit
|
236
|
+
- spec/support/examples/record/message/definition_session.fit
|
228
237
|
- spec/support/examples/record/normal_header
|