class Nginxtra::Config::SimpleConfig
A class for encapsulating simple configuration.
Public Class Methods
new(config, options = {}, &block)
click to toggle source
# File lib/nginxtra/config.rb, line 580 def initialize(config, options = {}, &block) @config = config @options = options @block = block end
Public Instance Methods
find_config_files!(path)
click to toggle source
Find all the config files at the given path directory. The result will be a hash of hashes. The key on the outer hash is the output config file name, while the value is a hash of :path to the original file path, and :config_file to the output config file name.
# File lib/nginxtra/config.rb, line 606 def find_config_files!(path) files_hash = {} Dir["#{path}/**/*.rb"].each do |x| next unless File.file? x file_name = x.sub %r{^#{Regexp.quote path.to_s}/(.*)\.rb$}, "\\1" files_hash[file_name] = { path: x, config_file: file_name } end files_hash end
process!()
click to toggle source
Process the simple config.
# File lib/nginxtra/config.rb, line 587 def process! file_options = @config.file_paths.map do |path| find_config_files! path end config_files = file_options.map(&:keys).inject([], &:+).uniq.map do |x| file_options.find do |option| option.include? x end[x] end process_files! config_files end
process_files!(files)
click to toggle source
Process all config files passed in, where each is a hash with :path to the original path of the file, and :config_file to the output config file name.
# File lib/nginxtra/config.rb, line 621 def process_files!(files) files.each do |x| path = x[:path] filename = x[:config_file] options = @options block = @block @config.file filename do process_template! path, options, block end end end