fit4ruby 0.0.12 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d92abaf5b344ec25f3c770d21b13eee0eff886e
4
- data.tar.gz: 99df97374c43548739d233b1a66f15fb59165d3a
3
+ metadata.gz: 3ba139e33bb80954cf3785eb9f73e46123a6b585
4
+ data.tar.gz: a3dc959723487d30ba8e18a4f6c32a615a74a559
5
5
  SHA512:
6
- metadata.gz: 36609441b31b1653e7b6dc391ff9d13fa5e23e09110cd975e78d375a2d01d1e6c159714fbc8a7a5c4ebac6424432505c35da6f4ddfb3dca768682dd296b54e91
7
- data.tar.gz: 0075651ab07203c2ea73949a00e118fe2881b568377f74ddc37543662836aafb4349b2e1367b2cfac3250251805d52b13f096b0064242b8c2e022be1e379c30a
6
+ metadata.gz: 711dd3bfb66971ceb48db285ba3c9a694ccc34c26a2d37c713096bb5de00c9639e144ed2633b4c3bb33bd45195a5dd143b12054e8066a3eb7b1a44768afd7493
7
+ data.tar.gz: 8e03437ad93539ea7bc00bb03e0e29db2782a214e06cfd40d3e785ca25c5d74e54f783ae3d3a59e81c9b9d6d569b7f9ddef77562d4c44390bec5b4acf908e30c
@@ -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, :file_creator, :device_infos, :data_sources,
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'
@@ -49,6 +49,15 @@ module Fit4Ruby
49
49
  end
50
50
  end
51
51
 
52
+ def secsToHM(secs)
53
+ secs = secs.to_i
54
+ s = secs % 60
55
+ mins = secs / 60
56
+ m = mins % 60
57
+ h = mins / 60
58
+ "#{h}:#{'%02d' % m}"
59
+ end
60
+
52
61
  def secsToHMS(secs)
53
62
  secs = secs.to_i
54
63
  s = secs % 60
@@ -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', 'avg_candence', :unit => 'rpm'
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', 'avg_candence', :unit => 'rpm'
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
- message 141, 'gps_ephemeris'
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(STDOUT)
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(STDERR)
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 and Fit4Ruby::Error.
55
- # code 1.
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
@@ -1,4 +1,4 @@
1
1
  module Fit4Ruby
2
2
  # The version number of the library.
3
- VERSION = '0.0.12'
3
+ VERSION = '1.0.0'
4
4
  end
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.12
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-03-02 00:00:00.000000000 Z
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.4.5.1
149
+ rubygems_version: 2.2.2
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Library to read GARMIN FIT files.