Class: Objc2swiftAssistant::FileHierarchicalConfig
- Inherits:
 - 
      Object
      
        
- Object
 - Objc2swiftAssistant::FileHierarchicalConfig
 
 
- Defined in:
 - lib/objc2swift_assistant/file_hierarchical_config.rb
 
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #all_valid_keys  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute all_valid_keys.
 - 
  
    
      #config_hash  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute config_hash.
 - 
  
    
      #configs_by_path  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute configs_by_path.
 - 
  
    
      #failure_reason  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute failure_reason.
 - 
  
    
      #node_class  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute node_class.
 
Instance Method Summary collapse
- #add_config_node(config_node) ⇒ Object
 - #config_value(path_str, key) ⇒ Object
 - #config_value_defaulted(path_str, key, default) ⇒ Object
 - 
  
    
      #initialize(config_hash, config_keys)  ⇒ FileHierarchicalConfig 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of FileHierarchicalConfig.
 - #load_configuration ⇒ Object
 
Constructor Details
#initialize(config_hash, config_keys) ⇒ FileHierarchicalConfig
Returns a new instance of FileHierarchicalConfig.
      18 19 20 21 22 23  | 
    
      # 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  | 
  
Instance Attribute Details
#all_valid_keys ⇒ Object
Returns the value of attribute all_valid_keys.
      14 15 16  | 
    
      # File 'lib/objc2swift_assistant/file_hierarchical_config.rb', line 14 def all_valid_keys @all_valid_keys end  | 
  
#config_hash ⇒ Object
Returns the value of attribute config_hash.
      11 12 13  | 
    
      # File 'lib/objc2swift_assistant/file_hierarchical_config.rb', line 11 def config_hash @config_hash end  | 
  
#configs_by_path ⇒ Object
Returns the value of attribute configs_by_path.
      12 13 14  | 
    
      # File 'lib/objc2swift_assistant/file_hierarchical_config.rb', line 12 def configs_by_path @configs_by_path end  | 
  
#failure_reason ⇒ Object
Returns the value of attribute failure_reason.
      13 14 15  | 
    
      # File 'lib/objc2swift_assistant/file_hierarchical_config.rb', line 13 def failure_reason @failure_reason end  | 
  
#node_class ⇒ Object
Returns the value of attribute node_class.
      10 11 12  | 
    
      # File 'lib/objc2swift_assistant/file_hierarchical_config.rb', line 10 def node_class @node_class end  | 
  
Instance Method Details
#add_config_node(config_node) ⇒ Object
      41 42 43 44 45 46 47 48  | 
    
      # 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) ⇒ Object
      50 51 52 53 54 55 56 57 58 59 60 61 62  | 
    
      # 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) ⇒ Object
      64 65 66 67  | 
    
      # 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 ⇒ Object
      25 26 27 28 29 30 31 32 33 34 35 36 37 38 39  | 
    
      # 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  |