Sha256: 910ac22c88d2e4d0b0c2c8ab2638f3dea0d12a4e08e260b109a986d81d38c876

Contents?: true

Size: 883 Bytes

Versions: 6

Compression:

Stored size: 883 Bytes

Contents

module Typus
  module Configuration

    # Read configuration from <tt>config/typus/*.yml</tt>.
    def self.config!
      files = Dir[File.join(Typus.config_folder, "*.yml").to_s].reject { |f| f.match(/_roles.yml/) }

      @@config = {}

      files.each do |file|
        if data = YAML::load_file(file)
          @@config.merge!(data)
        end
      end
    end

    mattr_accessor :config
    @@config = {}

    # Read roles from files <tt>config/typus/*_roles.yml</tt>.
    def self.roles!
      files = Dir[File.join(Typus.config_folder, "*_roles.yml").to_s].sort

      @@roles = {}

      files.each do |file|
        if data = YAML::load_file(file)
          data.compact.each do |key, value|
            @@roles[key] ? @@roles[key].merge!(value) : (@@roles[key] = value)
          end
        end
      end
    end

    mattr_accessor :roles
    @@roles = {}

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typus-3.1.0.rc18 lib/typus/configuration.rb
typus-3.1.0.rc17 lib/typus/configuration.rb
typus-3.1.0.rc16 lib/typus/configuration.rb
typus-3.1.0.rc15 lib/typus/configuration.rb
typus-3.1.0.rc14 lib/typus/configuration.rb
typus-3.1.0.rc13 lib/typus/configuration.rb