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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f422b15043676a7b0404bdf5ab6c632bf51fe142d28700953fa8c84516f0ae1
4
- data.tar.gz: ff789be11d0c34fdfd4cd218540b5ec3d489b965ac228fbc21836ad15044ee50
3
+ metadata.gz: 2a6f4bc89fcaa0b13753ab758e0c6f4dd5083c1c6509136c941d07a7f712dd6f
4
+ data.tar.gz: 7916aa6ccba90cc9898b5ad06080cf02bb2761b0f48697f5514e5fea18482049
5
5
  SHA512:
6
- metadata.gz: 79765878d4d9e6d259223857a506c7c2e29c702456be764fc9b4c6cf09e3b7fc0cbad4be7b244d1c3e62d80b07c9204bf46eb2d6ad2507111b01d70030175ec8
7
- data.tar.gz: a3657b3f2c129067ba22946691c138d5248dfd9d2b62fcb17b9bb3d3ddb56cd2a0c7d1a6d1ce9e9a66c22855b7569ccd4f38120f6636474a85591ed76796ec9a
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(output_to)
68
+ Logger.log_to = output_to
69
69
  end
70
70
  end
71
71
 
@@ -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(file = $stdout)
17
- @out_file ||= 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)
@@ -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}", default_value)
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
@@ -7,5 +7,7 @@ loader.push_dir(__dir__)
7
7
  loader.setup
8
8
 
9
9
  module Confiner
10
- VERSION = '0.1.1'
10
+ VERSION = '0.2.0'
11
+
12
+ module Plugins; end
11
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confiner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality