class Objc2swiftAssistant::FileHierarchicalConfig

Attributes

all_valid_keys[RW]
config_hash[RW]
configs_by_path[RW]
failure_reason[RW]
node_class[RW]

Public Class Methods

new( config_hash, config_keys ) click to toggle source
# File lib/objc2swift_assistant/file_hierarchical_config.rb, line 18
def initialize( config_hash, config_keys )
  @node_class = FileHierarchicalConfigNode
  @all_valid_keys = config_keys + [ SUBDIR_KEY, PATH_KEY ]
  @config_hash = config_hash
  @configs_by_path = {}
end

Public Instance Methods

add_config_node( config_node ) click to toggle source
# File lib/objc2swift_assistant/file_hierarchical_config.rb, line 41
def add_config_node( config_node )
  if @configs_by_path.has_key?( config_node.path_from_root.to_s )
    return false, "A configuration node already exists for #{config_node.path_from_root.to_s}"
  end

  @configs_by_path[ config_node.path_from_root.to_s ] = config_node
  return true, nil
end
config_value( path_str, key ) click to toggle source
# File lib/objc2swift_assistant/file_hierarchical_config.rb, line 50
def config_value( path_str, key )
  pathname = Pathname.new( path_str )
  value = nil
  config = nil
  while config.nil?
    config = @configs_by_path[ pathname.to_s ]
    break if pathname.to_s == "." && config.nil?    # This should not happen, but just in case
    pathname = pathname.parent
  end

  value = config.config_value_for_key( key, path_str ) unless config.nil?
  value
end
config_value_defaulted( path_str, key, default ) click to toggle source
# File lib/objc2swift_assistant/file_hierarchical_config.rb, line 64
def config_value_defaulted( path_str, key, default )
  value = config_value( path_str, key )
  value.nil? ? default : value
end
load_configuration() click to toggle source
# File lib/objc2swift_assistant/file_hierarchical_config.rb, line 25
def load_configuration
  # path test
  # p = Pathname.new( "/a/b/c/d")
  # done = false
  # until done
  #   puts( "path= #{p.to_s}")
  #   p = p.parent
  # end

  # @failure_reason = 'No Root configuration specified' unless root_hash.path.to_s == '' TODO: Fail is path specified
  root_node = node_class.new( self, @config_hash, '.' )
  add_config_node( root_node )

  # root_node.apply_wildcards
end