Sha256: 7b90d84384a6d22a596596ee2d86fb9fd554b97149ec49a4e0b548d094dddcfd
Contents?: true
Size: 1.25 KB
Versions: 10
Compression:
Stored size: 1.25 KB
Contents
module Fig # Configuration for the Fig program, as opposed to the configuration for a # package. class ApplicationConfiguration def initialize(remote_repository_url) @data = [] @remote_repository_url = remote_repository_url clear_cached_data end def ensure_url_whitelist_initialized() return if not @whitelist.nil? whitelist = self['url whitelist'] if whitelist.nil? @whitelist = [] else @whitelist = [@remote_repository_url, whitelist].flatten end end def [](key) @data.each do |dataset| if dataset.has_key?(key) return dataset[key] end end return nil end def push_dataset(dataset) @data.push(dataset) end def unshift_dataset(dataset) @data.unshift(dataset) end # after push_dataset or unshift_dataset, call clear_cached, and lazy initialize as far as the list of things to exclude def clear_cached_data() @whitelist = nil end 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 end end
Version data entries
10 entries across 10 versions & 2 rubygems