class Fig::ApplicationConfiguration

Configuration for the Fig program, as opposed to a config in a package.

Attributes

base_whitelisted_url[RW]
remote_repository_url[RW]

Public Class Methods

new() click to toggle source
# File lib/fig/application_configuration.rb, line 10
def initialize()
  @data = []
  clear_cached_data
end

Public Instance Methods

[](key) click to toggle source
# File lib/fig/application_configuration.rb, line 29
def [](key)
  @data.each do |dataset|
    if dataset.has_key?(key)
      return dataset[key]
    end
  end
  return nil
end
clear_cached_data() click to toggle source

After push_dataset, call clear_cached, and lazy initialize as far as the list of things to exclude

# File lib/fig/application_configuration.rb, line 44
def clear_cached_data()
  @whitelist = nil
end
ensure_url_whitelist_initialized() click to toggle source
# File lib/fig/application_configuration.rb, line 15
def ensure_url_whitelist_initialized()
  return if not @whitelist.nil?
  whitelist = self['url whitelist']
  if whitelist.nil?
    @whitelist = []
  elsif @base_whitelisted_url
    @whitelist = [@base_whitelisted_url, whitelist].flatten
  elsif whitelist.is_a? Array
    @whitelist = whitelist
  else
    @whitelist = [whitelist]
  end
end
push_dataset(dataset) click to toggle source
# File lib/fig/application_configuration.rb, line 38
def push_dataset(dataset)
  @data.push(dataset)
end
url_access_allowed?(url) click to toggle source
# File lib/fig/application_configuration.rb, line 48
def url_access_allowed?(url)
  ensure_url_whitelist_initialized
  return true if @whitelist.empty?
  @whitelist.each do |allowed_url|
    return true if url.match(/\A#{Regexp.quote(allowed_url)}\b/)
  end
  return false
end