kafo 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da8bfdbd9cb9a67ef04b7bf185ddc714e543701f
4
- data.tar.gz: bcb53dc3da0576cf70a52d943236d0c60171e844
3
+ metadata.gz: a0891988265b632e07a6cc18c78d1675cdce70ff
4
+ data.tar.gz: 6225f461595283a292a6c9ed9ccad6ae1cc3ca04
5
5
  SHA512:
6
- metadata.gz: 0c63f286d4f0dc36c7b1d8578eda27c4c56f274b212da4213dcd1380b5a0ba31e75fc3e1764b21395912ef176c5734e5e2f7ed8cf27c1f32f8f21b0998384d18
7
- data.tar.gz: c473170d70a63030d004a9d7fbdd777ea8d692c9dca8627e708735910cbe9db6afe391a2969a928cc9ad398920b3d5add2912c12026d1b611405d0650a817e96
6
+ metadata.gz: 58caffa69d462436a789a1a23a5cc238872e39393ebe5216f94f69e3ff44ddea5c94debf3642ef646799bc69e19d1c62ebc197a310cdad688c08e096881e757b
7
+ data.tar.gz: 7d89c58aac9b309531cbb7ebe3666a08fca3c41d9b59ef7de899c333befbc8af333496b0db50875fd1b50fd89f3f5191f229a685be7d44c35fc1cf80eeb81357
data/README.md CHANGED
@@ -762,15 +762,21 @@ KafoConfigure.hooking.register_pre(:reset_db) do
762
762
  end
763
763
  ```
764
764
 
765
- Note that the hook is evaluated in HookContext object which provides some DSL. We can create a
766
- new installer option using ```app_option```. These option values can be accessed by using
767
- ```app_value(:reset_foreman_db)```. You can modify parameters (if they are already defined)
768
- using ```param('module name', 'parameter name')``` accessor. You can register your own module
769
- that is not specified in the answer file using ```add_module```. Custom mapping is also supported.
770
- This is useful if you need to add some module to the existing installer based on kafo but you don't
771
- have control over its source code. You can use a custom config storage which persists among
772
- kafo runs using ```get_custom_config``` and ```store_custom_config```.
773
- Last but not least you have access to logger. For more details, see
765
+ Note that the hook is evaluated in HookContext object which provides a DSL:
766
+
767
+ * ```app_option``` creates a new installer option
768
+ * ```app_value(:reset_foreman_db)``` accesses values of installer options
769
+ * ```param('module name', 'parameter name')``` accessor allows parameters to be modified if already
770
+ defined
771
+ * ```add_module``` registers your own module not specified in the answer file (custom mapping is also
772
+ supported), useful if you need to add some module to the existing installer based on kafo but you
773
+ don't have control over its source code
774
+ * ```module_enabled?('module_name')``` indicates whether a module is currently enabled
775
+ * ```get_custom_config``` and ```store_custom_config``` access custom config storage which persists
776
+ among kafo runs
777
+ * ```logger``` is also available for writing log messages
778
+
779
+ For more details, see
774
780
  [hook_context.rb](https://github.com/theforeman/kafo/blob/master/lib/kafo/hook_context.rb).
775
781
 
776
782
  If you don't want to modify your installer script you can place your hooks into the
@@ -88,6 +88,10 @@ module Kafo
88
88
  @modules ||= @data.keys.map { |mod| PuppetModule.new(mod, PuppetModule.find_parser, self).parse }.sort
89
89
  end
90
90
 
91
+ def module(name)
92
+ modules.find { |m| m.name == name }
93
+ end
94
+
91
95
  def root_dir
92
96
  File.expand_path(app[:installer_dir])
93
97
  end
@@ -184,8 +188,9 @@ module Kafo
184
188
  @params ||= modules.map(&:params).flatten
185
189
  end
186
190
 
187
- def param(mod, name)
188
- params.detect { |p| p.name == name && p.module.name == mod }
191
+ def param(mod_name, param_name)
192
+ mod = self.module(mod_name)
193
+ mod.nil? ? nil : mod.params.find { |p| p.name == param_name }
189
194
  end
190
195
 
191
196
  def preset_defaults_from_puppet
@@ -264,7 +269,7 @@ module Kafo
264
269
 
265
270
  def parser_cache
266
271
  if app[:parser_cache_path]
267
- @parser_cache ||= Kafo::ParserCacheReader.new_from_file(File.expand_path(app[:parser_cache_path]))
272
+ @parser_cache ||= Kafo::ParserCacheReader.new_from_file(app[:parser_cache_path])
268
273
  end
269
274
  end
270
275
 
@@ -61,6 +61,13 @@ module Kafo
61
61
  self.kafo.add_module(module_name)
62
62
  end
63
63
 
64
+ # Check if a module is enabled in the current configuration.
65
+ # examples:
66
+ # module_enabled?('example')
67
+ def module_enabled?(module_name)
68
+ self.kafo.module(module_name).enabled?
69
+ end
70
+
64
71
  # You can trigger installer exit by this method. You must specify exit code as a first
65
72
  # argument. You can also specify a symbol alias which is built-in (see exit_handler.rb
66
73
  # for more details).
@@ -15,7 +15,7 @@ module Kafo
15
15
  return nil
16
16
  end
17
17
 
18
- parsed = cache_paths.map { |path| YAML.load(File.read(path)) }
18
+ parsed = cache_paths.map { |path| YAML.load(File.read(File.expand_path(path))) }
19
19
 
20
20
  parsed.each_with_index do |cache, i|
21
21
  if !cache.is_a?(Hash) || cache[:version] != PARSER_CACHE_VERSION || !cache[:files].is_a?(Hash)
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
3
  PARSER_CACHE_VERSION = 1
4
- VERSION = "0.9.4"
4
+ VERSION = "0.9.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Hulan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-24 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler