From b5267c1a8fda1784e5a4892ee227f5e4fb57e804 Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Sat, 12 Sep 2015 21:54:53 +0200 Subject: Adding plumbing to have PEROBS as additional dependency. --- Rakefile | 10 ---------- lib/postrunner.rb | 6 +++++- lib/postrunner/Main.rb | 5 +++++ lib/postrunner/MonitoringDB.rb | 23 +++++++++++++++++++++++ lib/postrunner/RuntimeConfig.rb | 1 + spec/ActivitySummary_spec.rb | 2 +- spec/FlexiTable_spec.rb | 1 + spec/PostRunner_spec.rb | 3 ++- spec/View_spec.rb | 1 + spec/spec_helper.rb | 7 +++++++ 10 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 lib/postrunner/MonitoringDB.rb diff --git a/Rakefile b/Rakefile index a2728e4..7053a89 100644 --- a/Rakefile +++ b/Rakefile @@ -1,16 +1,6 @@ require "bundler/gem_tasks" require "rspec/core/rake_task" -# Add the include path for the fit4ruby library. We assume it is located in -# the same directory as the postrunner directory. -fit4ruby = File.realpath(File.join(File.dirname(__FILE__), '..', - 'fit4ruby', 'lib')) -if ENV['RUBYLIB'] - ENV['RUBYLIB'] += ":#{fit4ruby}" -else - ENV['RUBYLIB'] = fit4ruby -end - RSpec::Core::RakeTask.new task :default => :spec diff --git a/lib/postrunner.rb b/lib/postrunner.rb index 8e79a74..3aeff83 100644 --- a/lib/postrunner.rb +++ b/lib/postrunner.rb @@ -10,7 +10,11 @@ # published by the Free Software Foundation. # -$:.unshift(File.join(File.dirname(__FILE__), '..', '..', 'fit4ruby', 'lib')) +# Some dependencies may not be installed as Ruby Gems but as local sources. +# Add them to the LOAD_PATH. +%w( fit4ruby perobs ).each do |lib_dir| + $:.unshift(File.join(File.dirname(__FILE__), '..', '..', lib_dir, 'lib')) +end $:.unshift(File.dirname(__FILE__)) require 'postrunner/Main' diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb index 17ffe71..71bda49 100644 --- a/lib/postrunner/Main.rb +++ b/lib/postrunner/Main.rb @@ -13,10 +13,12 @@ require 'optparse' require 'logger' require 'fit4ruby' +require 'perobs' require 'postrunner/version' require 'postrunner/RuntimeConfig' require 'postrunner/ActivitiesDB' +require 'postrunner/MonitoringDB' require 'postrunner/EPO_Downloader' module PostRunner @@ -36,11 +38,13 @@ module PostRunner @attribute = nil @value = nil @activities = nil + @monitoring = nil @db_dir = File.join(ENV['HOME'], '.postrunner') return if (args = parse_options(args)).nil? @cfg = RuntimeConfig.new(@db_dir) + @db = PEROBS::Store.new(File.join(@db_dir, 'database')) execute_command(args) end @@ -188,6 +192,7 @@ EOT def execute_command(args) @activities = ActivitiesDB.new(@db_dir, @cfg) + @monitoring = MonitoringDB.new(@db, @cfg) handle_version_update case (cmd = args.shift) diff --git a/lib/postrunner/MonitoringDB.rb b/lib/postrunner/MonitoringDB.rb new file mode 100644 index 0000000..28d8322 --- /dev/null +++ b/lib/postrunner/MonitoringDB.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby -w +# encoding: UTF-8 +# +# = MonitoringDB.rb -- PostRunner - Manage the data from your Garmin sport devices. +# +# Copyright (c) 2014, 2015 by Chris Schlaeger +# +# 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 +# published by the Free Software Foundation. +# + +module PostRunner + + class MonitoringDB + + def initialize(db, cfg) + db.sync + end + + end + +end diff --git a/lib/postrunner/RuntimeConfig.rb b/lib/postrunner/RuntimeConfig.rb index a090683..16115aa 100644 --- a/lib/postrunner/RuntimeConfig.rb +++ b/lib/postrunner/RuntimeConfig.rb @@ -23,6 +23,7 @@ module PostRunner # Create a new RC object. # @param dir [String] the directory to hold the config.yml file. def initialize(dir) + create_directory(dir, 'application data') @options = { :version => '0.0.0', :unit_system => :metric, diff --git a/spec/ActivitySummary_spec.rb b/spec/ActivitySummary_spec.rb index 08e2b15..b3d77b0 100644 --- a/spec/ActivitySummary_spec.rb +++ b/spec/ActivitySummary_spec.rb @@ -10,8 +10,8 @@ # published by the Free Software Foundation. # -require 'postrunner/ActivitySummary' require 'spec_helper' +require 'postrunner/ActivitySummary' class Activity < Struct.new(:fit_activity, :sport) end diff --git a/spec/FlexiTable_spec.rb b/spec/FlexiTable_spec.rb index 5a03c56..c3357cd 100644 --- a/spec/FlexiTable_spec.rb +++ b/spec/FlexiTable_spec.rb @@ -10,6 +10,7 @@ # published by the Free Software Foundation. # +require 'spec_helper' require 'postrunner/FlexiTable' describe PostRunner::FlexiTable do diff --git a/spec/PostRunner_spec.rb b/spec/PostRunner_spec.rb index e146e3f..4ca5a4a 100644 --- a/spec/PostRunner_spec.rb +++ b/spec/PostRunner_spec.rb @@ -12,8 +12,8 @@ require 'fileutils' -require 'postrunner/Main' require 'spec_helper' +require 'postrunner/Main' describe PostRunner::Main do @@ -38,6 +38,7 @@ describe PostRunner::Main do FileUtils.rm_rf(@db_dir) FileUtils.rm_rf('FILE1.FIT') FileUtils.rm_rf('FILE2.FIT') + FileUtils::rm_rf('icons') end it 'should abort without arguments' do diff --git a/spec/View_spec.rb b/spec/View_spec.rb index 7a90a01..538b71f 100644 --- a/spec/View_spec.rb +++ b/spec/View_spec.rb @@ -10,6 +10,7 @@ # published by the Free Software Foundation. # +require 'spec_helper' require 'postrunner/View' require 'postrunner/ViewButtons' require 'postrunner/PagingButtons' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7c15dbb..691f097 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,6 +10,13 @@ # published by the Free Software Foundation. # +# Some dependencies may not be installed as Ruby Gems but as local sources. +# Add them and the postrunner dir to the LOAD_PATH. +%w( postrunner fit4ruby perobs ).each do |lib_dir| + $:.unshift(File.join(File.dirname(__FILE__), '..', '..', lib_dir, 'lib')) +end +puts $: + def create_fit_file(name, date, duration_minutes = 30) Fit4Ruby.write(name, create_fit_activity(date, duration_minutes)) end -- cgit v1.2.3