Class: Facter::OptionStore

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/framework/core/options/option_store.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.allow_external_loggersObject

Returns the value of attribute allow_external_loggers.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def allow_external_loggers
  @allow_external_loggers
end

.blockObject

Returns the value of attribute block.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def block
  @block
end

.block_listObject

Returns the value of attribute block_list.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def block_list
  @block_list
end

.blocked_factsObject

Returns the value of attribute blocked_facts.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def blocked_facts
  @blocked_facts
end

.cacheObject

Returns the value of attribute cache.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def cache
  @cache
end

.cliObject

Returns the value of attribute cli.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def cli
  @cli
end

.colorObject

Returns the value of attribute color.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def color
  @color
end

.configObject

Returns the value of attribute config.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def config
  @config
end

.config_file_custom_dirObject

Returns the value of attribute config_file_custom_dir.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def config_file_custom_dir
  @config_file_custom_dir
end

.config_file_external_dirObject

Returns the value of attribute config_file_external_dir.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def config_file_external_dir
  @config_file_external_dir
end

.custom_factsObject (readonly)

Returns the value of attribute custom_facts.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def custom_facts
  @custom_facts
end

.debugObject

Returns the value of attribute debug.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def debug
  @debug
end

.default_external_dirObject

Returns the value of attribute default_external_dir.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def default_external_dir
  @default_external_dir
end

.external_dirObject



82
83
84
85
86
# File 'lib/facter/framework/core/options/option_store.rb', line 82

def external_dir
  return fallback_external_dir if @external_dir.empty? && @external_facts

  @external_dir
end

.external_factsObject (readonly)

Returns the value of attribute external_facts.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def external_facts
  @external_facts
end

.fact_groupsObject

Returns the value of attribute fact_groups.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def fact_groups
  @fact_groups
end

.hoconObject

Returns the value of attribute hocon.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def hocon
  @hocon
end

.jsonObject

Returns the value of attribute json.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def json
  @json
end

.log_levelObject

Returns the value of attribute log_level.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def log_level
  @log_level
end

.puppetObject

Returns the value of attribute puppet.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def puppet
  @puppet
end

.rubyObject (readonly)

Returns the value of attribute ruby.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def ruby
  @ruby
end

.sequentialObject

Returns the value of attribute sequential.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def sequential
  @sequential
end

.show_legacyObject

Returns the value of attribute show_legacy.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def show_legacy
  @show_legacy
end

.strictObject

Returns the value of attribute strict.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def strict
  @strict
end

.timingObject

Returns the value of attribute timing.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def timing
  @timing
end

.traceObject

Returns the value of attribute trace.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def trace
  @trace
end

.ttlsObject

Returns the value of attribute ttls.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def ttls
  @ttls
end

.user_queryObject

Returns the value of attribute user_query.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def user_query
  @user_query
end

.verboseObject

Returns the value of attribute verbose.



41
42
43
# File 'lib/facter/framework/core/options/option_store.rb', line 41

def verbose
  @verbose
end

.yamlObject

Returns the value of attribute yaml.



44
45
46
# File 'lib/facter/framework/core/options/option_store.rb', line 44

def yaml
  @yaml
end

Class Method Details

.allObject



51
52
53
54
55
56
57
58
# File 'lib/facter/framework/core/options/option_store.rb', line 51

def all
  options = {}
  instance_variables.each do |iv|
    variable_name = iv.to_s.delete('@')
    options[variable_name.to_sym] = OptionStore.send(variable_name.to_sym)
  end
  options
end

.custom_dirObject



94
95
96
97
98
# File 'lib/facter/framework/core/options/option_store.rb', line 94

def custom_dir
  return @config_file_custom_dir unless @custom_dir.any?

  @custom_dir
end

.custom_dir=(*dirs) ⇒ Object



100
101
102
103
104
105
# File 'lib/facter/framework/core/options/option_store.rb', line 100

def custom_dir=(*dirs)
  @ruby = true

  @custom_dir = [*dirs]
  @custom_dir.flatten!
end

.fallback_external_dirObject



211
212
213
214
215
# File 'lib/facter/framework/core/options/option_store.rb', line 211

def fallback_external_dir
  return @config_file_external_dir if @config_file_external_dir.any?

  @default_external_dir
end

.no_block=(bool) ⇒ Object



70
71
72
# File 'lib/facter/framework/core/options/option_store.rb', line 70

def no_block=(bool)
  @block = !bool
end

.no_cache=(bool) ⇒ Object



74
75
76
# File 'lib/facter/framework/core/options/option_store.rb', line 74

def no_cache=(bool)
  @cache = !bool
end

.no_color=(bool) ⇒ Object



78
79
80
# File 'lib/facter/framework/core/options/option_store.rb', line 78

def no_color=(bool)
  @color = !bool
end

.no_custom_facts=(bool) ⇒ Object



126
127
128
129
130
131
132
133
# File 'lib/facter/framework/core/options/option_store.rb', line 126

def no_custom_facts=(bool)
  if bool == false
    @custom_facts = true
    @ruby = true
  else
    @custom_facts = false
  end
end

.no_external_facts=(bool) ⇒ Object



135
136
137
# File 'lib/facter/framework/core/options/option_store.rb', line 135

def no_external_facts=(bool)
  @external_facts = !bool
end

.no_ruby=(bool) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/facter/framework/core/options/option_store.rb', line 60

def no_ruby=(bool)
  if bool
    @ruby = false
    @custom_facts = false
    @blocked_facts << 'ruby'
  else
    @ruby = true
  end
end

.resetObject



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/facter/framework/core/options/option_store.rb', line 167

def reset
  @debug = false
  @verbose = false
  # TODO: constant is not yet available when running puppet facts
  @log_level = :warn
  @show_legacy = true
  @ruby = true
  @user_query = []
  @json = false
  @hocon = false
  @cache = true
  @yaml = false
  @puppet = false
  @ttls = []
  @block = true
  @cli = nil
  reset_config
end

.reset_configObject



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/facter/framework/core/options/option_store.rb', line 186

def reset_config
  @blocked_facts = []
  @external_facts = true
  @config = nil
  @strict = false
  @config_file_custom_dir = []
  @config_file_external_dir = []
  @default_external_dir = []
  @fact_groups = {}
  @block_list = {}
  @color = true
  @sequential = true
  @ttls = []
  @trace = false
  @timing = false
  @allow_external_loggers = true
  reset_facts
end

.reset_factsObject



205
206
207
208
209
# File 'lib/facter/framework/core/options/option_store.rb', line 205

def reset_facts
  @custom_facts = true
  @external_dir = []
  @custom_dir = []
end

.set(key, value) ⇒ Object



163
164
165
# File 'lib/facter/framework/core/options/option_store.rb', line 163

def set(key, value)
  send("#{key}=".to_sym, value)
end