File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,6 @@ Metrics/PerceivedComplexity:
21
21
Max : 10
22
22
Metrics/AbcSize :
23
23
Max : 29
24
+ Style/MethodMissing :
25
+ Exclude :
26
+ - ' libraries/process_env_var.rb'
Original file line number Diff line number Diff line change 210
210
throw :stop
211
211
end
212
212
213
- if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . split ( '=' ) . last )
213
+ if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . to_s . split ( '=' , 2 ) . last . to_s )
214
214
throw :stop
215
215
end
216
216
end
245
245
throw :stop
246
246
end
247
247
248
- if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . split ( '=' ) . last )
248
+ if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . to_s . split ( '=' , 2 ) . last . to_s )
249
249
throw :stop
250
250
end
251
251
end
Original file line number Diff line number Diff line change @@ -29,25 +29,25 @@ def initialize(process)
29
29
end
30
30
31
31
def method_missing ( name )
32
- read_params [ name . to_s ]
32
+ read_params [ name . to_s ] || ''
33
33
end
34
34
35
35
def read_params
36
36
return @params if defined? ( @params )
37
37
38
- proc_environ = inspec . file ( "/proc/#{ @process . pids . first } /environ" )
39
- unless file . file?
38
+ @file = inspec . file ( "/proc/#{ @process . pids . first } /environ" )
39
+ unless @ file. file?
40
40
skip_resource "Can't find environ file for #{ @process } "
41
41
return @params = { }
42
42
end
43
43
44
- environ_content = proc_environ . content
45
- if content . empty? && !file . empty?
44
+ @content = @file . content
45
+ if @ content. empty? && !@ file. empty?
46
46
skip_resource "Can't read environ file for #{ @process } "
47
47
return @params = { }
48
48
end
49
49
50
- @params = environ_content . split ( "\0 " ) . map { |i | i . split ( '=' ) } . to_h
50
+ @params = @content . split ( "\0 " ) . map { |i | i . split ( '=' , 2 ) } . to_h
51
51
end
52
52
53
53
def to_s
You can’t perform that action at this time.
0 commit comments