Sha256: 5fd324cb460a3bbc3f9bbb3de5faf845c65ce8f61221695b9fd3f2f0d3097a8e

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

# coding: utf-8

module Fig; end

# Configuration for the Fig program, as opposed to a config in a package.
class Fig::ApplicationConfiguration
  attr_accessor :base_whitelisted_url
  attr_accessor :remote_repository_url

  def initialize()
    @data = []
    clear_cached_data
  end

  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

  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

  # After push_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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fig-1.27.10 lib/fig/application_configuration.rb
fig-1.27.8 lib/fig/application_configuration.rb
fig-1.27.5 lib/fig/application_configuration.rb
fig-1.27.4 lib/fig/application_configuration.rb
fig-1.27.3 lib/fig/application_configuration.rb
fig-1.27.0 lib/fig/application_configuration.rb
fig-1.26.1.beta.1 lib/fig/application_configuration.rb
fig-1.26.0 lib/fig/application_configuration.rb
fig-1.25.1.beta.1 lib/fig/application_configuration.rb
fig-1.25.0 lib/fig/application_configuration.rb
fig-1.24.1.beta.3 lib/fig/application_configuration.rb
fig-1.24.1.beta.2 lib/fig/application_configuration.rb
fig-1.24.1.beta.1 lib/fig/application_configuration.rb
fig-1.24.0 lib/fig/application_configuration.rb
fig-1.23.1.beta.1 lib/fig/application_configuration.rb