symphony-metronome/lib/symphony/metronome.rb
mahlon@martini.nu 3c487706ff Update dependencies.
FossilOrigin-Name: 473831d28501a6a72d7400c23df1cd83ad6dc38a2136d3694997da0c56fe5acb
2018-04-12 18:18:34 +00:00

78 lines
2 KiB
Ruby

#!/usr/bin/env ruby
# vim: set nosta noet ts=4 sw=4:
require 'pathname'
require 'symphony' unless defined?( Symphony )
module Symphony::Metronome
extend Loggability,
Configurability
# Library version constant
VERSION = '0.2.2'
# Version-control revision constant
REVISION = %q$Revision$
# The name of the environment variable to check for config file overrides
CONFIG_ENV = 'METRONOME_CONFIG'
# The path to the default config file
DEFAULT_CONFIG_FILE = 'etc/config.yml'
# The data directory that contains migration files.
#
DATADIR = if ENV['METRONOME_DATADIR']
Pathname.new( ENV['METRONOME_DATADIR'] )
elsif Gem.datadir( 'symphony-metronome' )
Pathname.new( Gem.datadir('symphony-metronome') )
else
Pathname.new( __FILE__ ).dirname.parent.parent + 'data/symphony-metronome'
end
# Loggability API -- use symphony's logger
log_to :symphony
# Configurability API
config_key :metronome
### Get the loaded config (a Configurability::Config object)
def self::config
Configurability.loaded_config
end
### Load the specified +config_file+, install the config in all objects with
### Configurability, and call any callbacks registered via #after_configure.
def self::load_config( config_file=nil, defaults=nil )
config_file ||= ENV[ CONFIG_ENV ] || DEFAULT_CONFIG_FILE
defaults ||= Configurability.gather_defaults
config = Configurability::Config.load( config_file, defaults )
config.install
end
# The generic parse exception class.
class TimeParseError < ArgumentError; end
require 'symphony/metronome/scheduler'
require 'symphony/metronome/intervalexpression'
require 'symphony/metronome/scheduledevent'
require 'symphony/tasks/scheduletask'
###############
module_function
###############
### Convenience method for running the scheduler.
###
def run( &block )
raise LocalJumpError, "No block provided." unless block_given?
return Symphony::Metronome::Scheduler.run( &block )
end
end # Symphony::Metronome