Sha256: 7e2983f0adb5e21f8003a6bc8b4f96bd418135d3e2bfde3aa6834845d54958da
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 KB
Contents
require 'active_record' require 'rflow/configuration/uuid_keyed' class RFlow class Configuration class Setting < ConfigurationItem include ActiveModel::Validations self.primary_key = 'name' DEFAULTS = { 'rflow.application_name' => 'rflow', 'rflow.application_directory_path' => '.', 'rflow.pid_directory_path' => 'run', # relative to rflow.application_directory_path 'rflow.log_directory_path' => 'log', # relative to rflow.application_directory_path 'rflow.log_file_path' => lambda {File.join(Setting['rflow.log_directory_path'], Setting['rflow.application_name'] + '.log')}, 'rflow.pid_file_path' => lambda {File.join(Setting['rflow.pid_directory_path'], Setting['rflow.application_name'] + '.pid')}, 'rflow.log_level' => 'INFO', } DIRECTORY_PATHS = [ 'rflow.application_directory_path', 'rflow.pid_directory_path', 'rflow.log_directory_path', ] FILE_PATHS = [ 'rflow.log_file_path', 'rflow.pid_file_path', ] # TODO: fix these validations, as they run without the # application directory path context for subdirectories #validate :valid_directory_path?, :if => :directory_path? #validate :valid_writable_path?, :if => :directory_path? # TODO: Think about making this a regex check to pull in other, # externally-defined settings def directory_path? DIRECTORY_PATHS.include? self.name end def valid_directory_path? unless File.directory? self.value errors.add :value, "setting '#{self.name}' is not a directory ('#{File.expand_path self.value}')" end end def valid_writable_path? unless File.writable? self.value errors.add :value, "setting '#{self.name}' is not writable ('#{File.expand_path self.value}')" end end def self.[](name) Setting.find(name).value rescue nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rflow-1.3.0 | lib/rflow/configuration/setting.rb |
rflow-1.3.0a1 | lib/rflow/configuration/setting.rb |