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. --- lib/postrunner.rb | 6 +++++- lib/postrunner/Main.rb | 5 +++++ lib/postrunner/MonitoringDB.rb | 23 +++++++++++++++++++++++ lib/postrunner/RuntimeConfig.rb | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 lib/postrunner/MonitoringDB.rb (limited to 'lib') 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, -- cgit v1.2.3