Commit the pile of initial work. Largely taken from company internal
repos, allowed to be newly released. Portions already in production, coverage still needs to be boosted. Enjoy. FossilOrigin-Name: 0f17fa483f55467bdf9e8f99dace58e6a90f5a8a7e595bdd79dfda5c92d16b7f
This commit is contained in:
commit
b18647f6a5
23 changed files with 2639 additions and 0 deletions
79
lib/symphony/metronome.rb
Normal file
79
lib/symphony/metronome.rb
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#!/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.1.0'
|
||||
|
||||
# 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue