knife-santoku 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/knife_santoku/application.rb +17 -15
- data/lib/knife_santoku/version.rb +1 -1
- metadata +1 -1
@@ -4,7 +4,8 @@ require 'chef/knife'
|
|
4
4
|
module KnifeSantoku
|
5
5
|
class Application
|
6
6
|
def initialize(argv)
|
7
|
-
|
7
|
+
@active = false
|
8
|
+
|
8
9
|
chef_conf_dir = ::Chef::Knife.chef_config_dir
|
9
10
|
|
10
11
|
config_file = "#{chef_conf_dir}/../config/santoku-config.yml"
|
@@ -12,27 +13,28 @@ module KnifeSantoku
|
|
12
13
|
after_file = "#{chef_conf_dir}/../config/santoku-after.rb"
|
13
14
|
lib_folder = Pathname.new("#{chef_conf_dir}/../lib/santoku/")
|
14
15
|
|
16
|
+
if File.exists?(config_file) and (File.exists?(before_file) or File.exists?(after_file))
|
17
|
+
@active = true
|
18
|
+
|
19
|
+
config = AppConf.new
|
20
|
+
config.load(config_file)
|
15
21
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# load up callbacks
|
26
|
-
@before_callbacks = Callback.new(before_file, notifier, argv)
|
27
|
-
@after_callbacks = Callback.new(after_file, notifier, argv)
|
22
|
+
# load up notifiers & custom code out of lib
|
23
|
+
#notifier = Notifier.new(config,lib_folder)
|
24
|
+
notifier = ::KnifeSantoku::Notifier.new(config)
|
25
|
+
|
26
|
+
# load up callbacks
|
27
|
+
@before_callbacks = Callback.new(before_file, notifier, argv)
|
28
|
+
@after_callbacks = Callback.new(after_file, notifier, argv)
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
32
|
def run_before_callbacks
|
31
|
-
@before_callbacks.run
|
33
|
+
@before_callbacks.run if @active
|
32
34
|
end
|
33
35
|
|
34
36
|
def run_after_callbacks
|
35
|
-
@after_callbacks.run
|
37
|
+
@after_callbacks.run if @active
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|