summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2015-09-12 21:54:53 +0200
committerChris Schlaeger <chris@linux.com>2015-09-12 21:54:53 +0200
commitb5267c1a8fda1784e5a4892ee227f5e4fb57e804 (patch)
treebfd1dfea01003f6b8347119f026d31c813b10fda /lib
parent21eddca873d2912e9f5f8ab88c681ce55cbe0c6f (diff)
downloadpostrunner-b5267c1a8fda1784e5a4892ee227f5e4fb57e804.zip
Adding plumbing to have PEROBS as additional dependency.
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner.rb6
-rw-r--r--lib/postrunner/Main.rb5
-rw-r--r--lib/postrunner/MonitoringDB.rb23
-rw-r--r--lib/postrunner/RuntimeConfig.rb1
4 files changed, 34 insertions, 1 deletions
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 <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
+# 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,