class Speedflow::Configuration
Used to manage configuration in Speedflow
core
Constants
- DEFAULTS
Default options. Overridden by values in .speedflow.yml.
- DEFAULT_FILENAME
Default configuration filename
Public Class Methods
Get all configuration.
override - Hash
of configuration.
Returns the full configuration.
# File lib/speedflow/configuration.rb, line 102 def self.get(override = {}) config = self[self::DEFAULTS] override = self[override].stringify_keys config = config.read_config_files(config.config_files(override)) config.deep_merge(override).stringify_keys config end
Public Instance Methods
Public: Generate list of configuration files from the override
override - the command-line options hash
Returns an Array of config files
# File lib/speedflow/configuration.rb, line 55 def config_files(override) files = [] if override.stringify_keys.key?('config') files = override.stringify_keys.delete('config') override.delete('config') else files << source(override) + File::SEPARATOR + DEFAULT_FILENAME end files = [files] unless files.is_a? Array files end
Public: Check trigger in flow
trigger - Trigger name.
Returns if trigger exists in flow.
# File lib/speedflow/configuration.rb, line 27 def flow_trigger?(trigger) key?('flow') && self['flow'].key?(trigger.to_s) end
Public: Check triggers in flow
Returns if flow has triggers.
# File lib/speedflow/configuration.rb, line 18 def flow_triggers? key?('flow') && !self['flow'].keys.empty? end
Public: Get config value with override
config_key - Configuration
key. override - An Hash
of override values.
Returns the value of config key or override.
# File lib/speedflow/configuration.rb, line 46 def get_config_value_with_override(config_key, override) override[config_key] || self[config_key] || DEFAULTS[config_key] end
Public: Read config file
file - File to read.
Returns a Hash
.
# File lib/speedflow/configuration.rb, line 91 def read_config_file(file) SafeYAML.load_file(file) || {} rescue raise ConfigurationFileFormat, "This file is not a valid YAML: #{file}" end
Public: Read all files content
files - the list of configuration file
Returns the full configuration.
# File lib/speedflow/configuration.rb, line 72 def read_config_files(files) config = clone files.each do |file| unless File.exist?(file) raise ConfigurationFileNotFound, "Unable to load config file: #{file}" end config = config.deep_merge(read_config_file(file)) end config.replace_values_from_env end