class CarthageCacheRes::Configuration

Attributes

hash_object[R]

Public Class Methods

config_key(name) click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 11
def self.config_key(name)
  supported_keys << name
end
default() click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 27
def self.default
  @default ||= Configuration.new({
    prune_on_publish: false,
    platforms: nil,
    prune_white_list: nil,
    aws_s3_client_options: {
      region: ENV['AWS_REGION'],
      access_key_id: ENV['AWS_ACCESS_KEY_ID'],
      secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
      profile: ENV['AWS_PROFILE'],
      session_token: ENV['AWS_SESSION_TOKEN']
      
    },
    tmpdir: File.join(Dir.home, 'Library', 'Caches'),
    archive_base_path: nil
  })
end
new(hash_object = {}) click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 59
def initialize(hash_object = {})
  @hash_object = hash_object
end
parse(str) click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 23
def self.parse(str)
  new(YAML.load(str))
end
read_only?(config) click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 19
def self.read_only?(config)
  ConfigurationValidator.new(config).read_only?
end
supported_keys() click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 7
def self.supported_keys
  @supported_keys ||= []
end
valid?(config) click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 15
def self.valid?(config)
  ConfigurationValidator.new(config).valid?
end

Public Instance Methods

merge(c) click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 75
def merge(c)
  other_hash = nil
  if c.is_a?(Hash)
    other_hash = c
  else
    other_hash = c.hash_object
  end

  @hash_object = hash_object.merge(other_hash) do |key, oldval, newval|
    oldval.is_a?(Hash) ? oldval.merge(newval) : newval
  end
  self
end
method_missing(method_sym, *arguments, &block) click to toggle source
Calls superclass method
# File lib/carthage_cache_res/configuration.rb, line 89
def method_missing(method_sym, *arguments, &block)
  method_name = method_sym.to_s
  key = method_name.chomp("=")
  return super if !self.class.supported_keys.include?(key.to_sym)
  config, key = extract_config_and_key(key)

  if method_name.end_with?("=")
    config[key] = arguments.first
  else
    config[key]
  end
end
read_only?() click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 71
def read_only?
  self.class.read_only?(self)
end
respond_to?(method_sym, include_private = false) click to toggle source
Calls superclass method
# File lib/carthage_cache_res/configuration.rb, line 102
def respond_to?(method_sym, include_private = false)
  if self.class.supported_keys.include?(method_sym)
    true
  else
    super
  end
end
to_yaml() click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 63
def to_yaml
  hash_object.to_yaml
end
valid?() click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 67
def valid?
  self.class.valid?(self)
end

Private Instance Methods

extract_config_and_key(method_name) click to toggle source
# File lib/carthage_cache_res/configuration.rb, line 112
def extract_config_and_key(method_name)
  if method_name =~ /^aws_(.*)$/
    [hash_object[:aws_s3_client_options] ||= {}, $1.to_sym]
  else
    [hash_object, method_name.to_sym]
  end
end