confiner 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/confiner/cli.rb +2 -2
- data/lib/confiner/logger.rb +8 -3
- data/lib/confiner/plugin.rb +6 -1
- data/lib/confiner.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a6f4bc89fcaa0b13753ab758e0c6f4dd5083c1c6509136c941d07a7f712dd6f
|
4
|
+
data.tar.gz: 7916aa6ccba90cc9898b5ad06080cf02bb2761b0f48697f5514e5fea18482049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac49213f58a6378ced0bf2ecfb1a82e91a2e6252083efaefe6936d1bf6db7a9b5bb61a9d5e78f95e4a79247b17d0eee67877497921a3bd10bc45bf601d3af961
|
7
|
+
data.tar.gz: eb2a4a4ebd927e4a885dc1105adfecf3e383666b238fe531795b59a718176602bdc19ce3c198c44c6e252eb39fa04ed2a256dde3531648ba8f321a546b721f16
|
data/lib/confiner/cli.rb
CHANGED
@@ -17,7 +17,7 @@ module Confiner
|
|
17
17
|
@rules = []
|
18
18
|
|
19
19
|
# default logging to standard out
|
20
|
-
Logger.log_to $stdout
|
20
|
+
Logger.log_to = $stdout
|
21
21
|
|
22
22
|
if options.include?('--')
|
23
23
|
@plugin_options = options[options.index('--')..]
|
@@ -65,7 +65,7 @@ module Confiner
|
|
65
65
|
end
|
66
66
|
|
67
67
|
opts.on('-o OUTPUT', '--output-to OUTPUT', 'File to output the log to') do |output_to|
|
68
|
-
log_to
|
68
|
+
Logger.log_to = output_to
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
data/lib/confiner/logger.rb
CHANGED
@@ -8,13 +8,18 @@ module Confiner
|
|
8
8
|
|
9
9
|
output = "(#{Time.now.strftime('%F %H:%M:%S')})\t\e[0;35m#{level.to_s.upcase}#{' ' * (12 - level.size)}\e[m#{"\t" * indentation}#{message}"
|
10
10
|
|
11
|
-
Logger.log_to(File.open(Logger.log_to.strip, 'a+t')) if Logger.log_to.is_a?(String)
|
12
11
|
Logger.log_to.puts(output)
|
13
12
|
end
|
14
13
|
|
15
14
|
# Where to output the log
|
16
|
-
def self.log_to
|
17
|
-
@out_file
|
15
|
+
def self.log_to
|
16
|
+
@out_file
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.log_to=(file)
|
20
|
+
file = File.open(file.strip, 'a+t') if file.is_a?(String)
|
21
|
+
|
22
|
+
@out_file = file
|
18
23
|
end
|
19
24
|
|
20
25
|
def run(action)
|
data/lib/confiner/plugin.rb
CHANGED
@@ -21,8 +21,11 @@ module Confiner
|
|
21
21
|
arg.each do |a, default_value|
|
22
22
|
attr_writer a
|
23
23
|
|
24
|
+
default = default_value
|
25
|
+
default = ENV[default_value[1..]] if default_value[0] == '$'
|
26
|
+
|
24
27
|
define_method(a) do
|
25
|
-
instance_variable_get("@#{a}") || instance_variable_set("@#{a}",
|
28
|
+
instance_variable_get("@#{a}") || instance_variable_set("@#{a}", default)
|
26
29
|
end
|
27
30
|
end
|
28
31
|
else
|
@@ -34,6 +37,8 @@ module Confiner
|
|
34
37
|
|
35
38
|
def initialize(**args)
|
36
39
|
args.each do |k, v|
|
40
|
+
v = ENV[v[1..]] if v[0] == '$' # get environment variable
|
41
|
+
|
37
42
|
self.public_send(:"#{k}=", v)
|
38
43
|
end
|
39
44
|
end
|
data/lib/confiner.rb
CHANGED