Class: Inspec::InputRegistry
  
  
  
  
  
    - Inherits:
- 
      Object
      
        
          - Object
- Inspec::InputRegistry
 show all
      - Extended by:
- Forwardable
      - Includes:
- Singleton
    - Defined in:
- lib/inspec/errors.rb,
 lib/inspec/input_registry.rb
 
Defined Under Namespace
  
    
  
    
      Classes: Error, InputLookupError, ProfileLookupError
    
  
  Instance Attribute Summary collapse
  
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  Constructor Details
  
    
  
  
    
Returns a new instance of InputRegistry.
   
 
  
  
    | 
34
35
36
37
38
39
40 | # File 'lib/inspec/input_registry.rb', line 34
def initialize
    @list = {}
    @profile_aliases = {}
end | 
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #list  ⇒ Object  
  
  
  
  
    
Returns the value of attribute list.
   
 
  
  
    | 
10
11
12 | # File 'lib/inspec/input_registry.rb', line 10
def list
  @list
end | 
 
    
   
  
    Class Method Details
    
      
  
  
    
These self methods are convenience methods so you dont always have to specify instance when calling the registry
   
 
  
  
    | 
18
19
20 | # File 'lib/inspec/input_registry.rb', line 18
def self.find_input(name, profile)
  instance.find_input(name, profile)
end | 
 
    
      
  
  
    | 
30
31
32 | # File 'lib/inspec/input_registry.rb', line 30
def self.list_inputs_for_profile(profile)
  instance.list_inputs_for_profile(profile)
end | 
 
    
      
  
  
    | 
22
23
24 | # File 'lib/inspec/input_registry.rb', line 22
def self.register_input(name, profile, options = {})
  instance.register_input(name, profile, options)
end | 
 
    
      
  
  
    .register_profile_alias(name, alias_name)  ⇒ Object 
  
  
  
  
    | 
26
27
28 | # File 'lib/inspec/input_registry.rb', line 26
def self.register_profile_alias(name, alias_name)
  instance.register_profile_alias(name, alias_name)
end | 
 
    
   
  
    Instance Method Details
    
      
  
  
    #__reset  ⇒ Object 
  
  
  
  
    | 
78
79
80
81 | # File 'lib/inspec/input_registry.rb', line 78
def __reset
  @list = {}
  @profile_aliases = {}
end | 
 
    
      
  
  
    | 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 | # File 'lib/inspec/input_registry.rb', line 42
def find_input(name, profile)
  profile = @profile_aliases[profile] if !profile_exist?(profile) && @profile_aliases[profile]
  unless profile_exist?(profile)
    error = Inspec::InputRegistry::ProfileLookupError.new
    error.profile_name = profile
    raise error, "Profile '#{error.profile_name}' does not have any inputs"
  end
  unless list[profile].key?(name)
    error = Inspec::InputRegistry::InputLookupError.new
    error.input_name = name
    error.profile_name = profile
    raise error, "Profile '#{error.profile_name}' does not have an input with name '#{error.input_name}'"
  end
  list[profile][name]
end | 
 
    
      
  
  
    | 
73
74
75
76 | # File 'lib/inspec/input_registry.rb', line 73
def list_inputs_for_profile(profile)
  list[profile] = {} unless profile_exist?(profile)
  list[profile]
end | 
 
    
      
  
  
    | 
59
60
61
62
63
64
65
66
67 | # File 'lib/inspec/input_registry.rb', line 59
def register_input(name, profile, options = {})
    if profile_exist?(profile) && list[profile][name] && options.empty?
    list[profile][name]
  else
    list[profile] = {} unless profile_exist?(profile)
    list[profile][name] = Inspec::Input.new(name, options)
  end
end | 
 
    
      
  
  
    #register_profile_alias(name, alias_name)  ⇒ Object 
  
  
  
  
    | 
69
70
71 | # File 'lib/inspec/input_registry.rb', line 69
def register_profile_alias(name, alias_name)
  @profile_aliases[name] = alias_name
end |