diff options
author | Chris Schlaeger <chris@linux.com> | 2019-01-19 09:37:39 +0100 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2019-01-19 09:37:39 +0100 |
commit | 3d7aa8f14f0c7fbad609e53e33187a7b9181a439 (patch) | |
tree | 157ea55852ac29a676000419e4dbb7e8e0a840f4 /lib | |
parent | 859f41226cef50003e8ced4345e042d1fe8a7652 (diff) | |
download | postrunner-3d7aa8f14f0c7fbad609e53e33187a7b9181a439.zip |
Enable PEROBS progress meter
Diffstat (limited to 'lib')
-rw-r--r-- | lib/postrunner/DeviceList.rb | 2 | ||||
-rw-r--r-- | lib/postrunner/FFS_Device.rb | 17 | ||||
-rw-r--r-- | lib/postrunner/FitFileStore.rb | 5 | ||||
-rw-r--r-- | lib/postrunner/Main.rb | 4 |
4 files changed, 22 insertions, 6 deletions
diff --git a/lib/postrunner/DeviceList.rb b/lib/postrunner/DeviceList.rb index 22609d5..ad82fa1 100644 --- a/lib/postrunner/DeviceList.rb +++ b/lib/postrunner/DeviceList.rb @@ -3,7 +3,7 @@ # # = DeviceList.rb -- PostRunner - Manage the data from your Garmin sport devices. # -# Copyright (c) 2014, 2015 by Chris Schlaeger <cs@taskjuggler.org> +# Copyright (c) 2014, 2015, 2018 by Chris Schlaeger <cs@taskjuggler.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as diff --git a/lib/postrunner/FFS_Device.rb b/lib/postrunner/FFS_Device.rb index 6ea6890..cd59711 100644 --- a/lib/postrunner/FFS_Device.rb +++ b/lib/postrunner/FFS_Device.rb @@ -3,7 +3,7 @@ # # = FFS_Device.rb -- PostRunner - Manage the data from your Garmin sport devices. # -# Copyright (c) 2015, 2016 by Chris Schlaeger <cs@taskjuggler.org> +# Copyright (c) 2015, 2016, 2018 by Chris Schlaeger <cs@taskjuggler.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as @@ -23,7 +23,7 @@ module PostRunner # dashes. All objects are transparently stored in the PEROBS::Store. class FFS_Device < PEROBS::Object - attr_persist :activities, :monitorings, :short_uid, :long_uid + attr_persist :activities, :monitorings, :metrics, :short_uid, :long_uid # Create a new FFS_Device object. # @param p [PEROBS::Handle] p @@ -41,6 +41,7 @@ module PostRunner def restore attr_init(:activities) { @store.new(PEROBS::Array) } attr_init(:monitorings) { @store.new(PEROBS::Array) } + attr_init(:metrics) { @store.new(PEROBS::Array) } end # Add a new FIT file for this device. @@ -61,6 +62,11 @@ module PostRunner entities = @monitorings type = 'monitoring' new_entity_class = FFS_Monitoring + elsif fit_entity.is_a?(Fit4Ruby::Metrics) + entity = metrics_by_file_name(File.basename(fit_file_name)) + entities = @metrics + type = 'metrics' + new_entity_class = FFS_Metrics else Log.fatal "Unsupported FIT entity #{fit_entity.class}" end @@ -130,6 +136,13 @@ module PostRunner @monitorings.find { |a| a.fit_file_name == file_name } end + # Return the metrics with the given file name. + # @param file_name [String] Base name of the fit file. + # @return [FFS_Activity] Corresponding FFS_Metrics or nil. + def metrics_by_file_name(file_name) + @metrics.find { |a| a.fit_file_name == file_name } + end + # Return all monitorings that overlap with the time interval given by # from_time and to_time. # @param from_time [Time] start time of the interval diff --git a/lib/postrunner/FitFileStore.rb b/lib/postrunner/FitFileStore.rb index 0b1a704..d91cd28 100644 --- a/lib/postrunner/FitFileStore.rb +++ b/lib/postrunner/FitFileStore.rb @@ -3,7 +3,7 @@ # # = FitFileStore.rb -- PostRunner - Manage the data from your Garmin sport devices. # -# Copyright (c) 2014, 2015, 2016 by Chris Schlaeger <cs@taskjuggler.org> +# Copyright (c) 2014, 2015, 2016, 2018 by Chris Schlaeger <cs@taskjuggler.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as @@ -87,7 +87,8 @@ module PostRunner end unless [ Fit4Ruby::Activity, - Fit4Ruby::Monitoring_B ].include?(fit_entity.class) + Fit4Ruby::Monitoring_B, + Fit4Ruby::Metrics ].include?(fit_entity.class) Log.fatal "Unsupported FIT file type #{fit_entity.class}" end diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb index 353bb59..2a75e02 100644 --- a/lib/postrunner/Main.rb +++ b/lib/postrunner/Main.rb @@ -57,7 +57,9 @@ module PostRunner create_directory(@db_dir, 'PostRunner data') ensure_flat_file_db @db = PEROBS::Store.new(File.join(@db_dir, 'database'), - { :engine => PEROBS::FlatFileDB }) + { :engine => PEROBS::FlatFileDB, + :progressmeter => + PEROBS::ConsoleProgressMeter.new }) # Create a hash to store configuration data in the store unless it # exists already. cfg = (@db['config'] ||= @db.new(PEROBS::Hash)) |