Sha256: 04209ade0f0c31494d535a4431a7a303f16e2668731d01798c2b067e3e9e7095

Contents?: true

Size: 1.02 KB

Versions: 28

Compression:

Stored size: 1.02 KB

Contents

module LitmusPaper
  class ConfigurationFile
    def initialize(config_file_path)
      @config_file_path = config_file_path
      @services = {}
      @port = 9292
      @data_directory = "/etc/litmus"
    end

    def evaluate(file = @config_file_path)
      LitmusPaper.logger.info "Loading file #{file}"
      config_contents = File.read(file)
      instance_eval(config_contents)
      LitmusPaper::Configuration.new(@port, @data_directory, @services)
    end

    def include_files(glob_pattern)
      full_glob_pattern = File.expand_path(glob_pattern, File.dirname(@config_file_path))
      LitmusPaper.logger.info "Searching for files matching: #{full_glob_pattern}"

      Dir.glob(full_glob_pattern).each do |file|
        evaluate(file)
      end
    end

    def port(port)
      @port = port
    end

    def data_directory(directory)
      @data_directory = directory
    end

    def service(name, &block)
      service = Service.new(name.to_s)
      block.call(service)
      @services[name.to_s] = service
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
litmus_paper-1.0.0 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.9 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.7 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.6 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.5 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.4 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.3 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.2 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.1 lib/litmus_paper/configuration_file.rb
litmus_paper-0.9.0 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.9 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.8 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.7 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.6 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.5 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.4 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.3 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.2 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.1 lib/litmus_paper/configuration_file.rb
litmus_paper-0.8.0 lib/litmus_paper/configuration_file.rb