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

.blockObject



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

def block
  @block
end

.block_listObject



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

def block_list
  @block_list
end

.blocked_factsObject



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def blocked_facts
  @blocked_facts
end

.cacheObject



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

def cache
  @cache
end

.cliObject



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

def cli
  @cli
end

.colorObject



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

def color
  @color
end

.configObject



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

def config
  @config
end

.config_file_custom_dirObject



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

def config_file_custom_dir
  @config_file_custom_dir
end

.config_file_external_dirObject



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

def config_file_external_dir
  @config_file_external_dir
end

.custom_factsObject (readonly)



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def custom_facts
  @custom_facts
end

.debugObject



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def debug
  @debug
end

.default_external_dirObject



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

def default_external_dir
  @default_external_dir
end

.external_dirObject



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

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

  @external_dir
end

.external_factsObject (readonly)



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def external_facts
  @external_facts
end

.fact_groupsObject



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

def fact_groups
  @fact_groups
end

.jsonObject



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

def json
  @json
end

.log_levelObject



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def log_level
  @log_level
end

.puppetObject



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

def puppet
  @puppet
end

.rubyObject (readonly)



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def ruby
  @ruby
end

.sequentialObject



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

def sequential
  @sequential
end

.show_legacyObject



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def show_legacy
  @show_legacy
end

.strictObject



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

def strict
  @strict
end

.timingObject



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

def timing
  @timing
end

.traceObject



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

def trace
  @trace
end

.ttlsObject



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

def ttls
  @ttls
end

.user_queryObject



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

def user_query
  @user_query
end

.verboseObject



39
40
41
# File 'lib/facter/framework/core/options/option_store.rb', line 39

def verbose
  @verbose
end

.yamlObject



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

def yaml
  @yaml
end

Class Method Details

.allObject



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

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



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

def custom_dir
  return @config_file_custom_dir unless @custom_dir.any?

  @custom_dir
end

.custom_dir=(*dirs) ⇒ Object



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

def custom_dir=(*dirs)
  @ruby = true

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

.fallback_external_dirObject



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

def fallback_external_dir
  return @config_file_external_dir if @config_file_external_dir.any?

  @default_external_dir
end

.no_block=(bool) ⇒ Object



68
69
70
# File 'lib/facter/framework/core/options/option_store.rb', line 68

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

.no_cache=(bool) ⇒ Object



72
73
74
# File 'lib/facter/framework/core/options/option_store.rb', line 72

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

.no_color=(bool) ⇒ Object



76
77
78
# File 'lib/facter/framework/core/options/option_store.rb', line 76

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

.no_custom_facts=(bool) ⇒ Object



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

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

.no_external_facts=(bool) ⇒ Object



133
134
135
# File 'lib/facter/framework/core/options/option_store.rb', line 133

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

.no_ruby=(bool) ⇒ Object



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

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

.resetObject



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

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
  @cache = true
  @yaml = false
  @puppet = false
  @ttls = []
  @block = true
  @cli = nil
  @custom_facts = true
  reset_config
end

.reset_configObject



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

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
  @external_dir = []
  @custom_dir = []
end

.set(key, value) ⇒ Object



161
162
163
# File 'lib/facter/framework/core/options/option_store.rb', line 161

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