File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,9 @@ RSpec/SpecFilePathFormat:
3737 - ' spec/bashly/concerns/completions_command_spec.rb'
3838 - ' spec/bashly/concerns/completions_flag_spec.rb'
3939
40- # Allow longer integration examples as they are more complex by nature
40+ # Allow longer examples in some cases
4141RSpec/ExampleLength :
4242 Exclude :
4343 - ' spec/bashly/integration/**/*'
4444 - ' spec/bashly/libraries/render*'
45+ - ' spec/bashly/script/command_spec.rb'
Original file line number Diff line number Diff line change @@ -160,29 +160,29 @@ def var_aliases
160160 private
161161
162162 def get ( key )
163- value_from_env ( key ) || value_from_config ( key )
163+ ENV . has_key? ( env_var_name ( key ) ) ? value_from_env ( key ) : value_from_config ( key )
164+ end
165+
166+ def env_var_name ( key )
167+ "BASHLY_#{ key . upcase } "
164168 end
165169
166170 def value_from_config ( key )
167- if key != :env
168- config [ "#{ key } _#{ env } " ] || config [ "#{ key } " ]
169- else
170- config [ "#{ key } " ]
171- end
171+ return config [ key . to_s ] if key == :env
172+
173+ result = config [ "#{ key } _#{ env } " ]
174+ result . nil? ? config [ key . to_s ] : result
172175 end
173176
174177 def value_from_env ( key )
175- case env_value key
176- when '0' , 'false' , 'no' then false
177- when '1' , 'true' , 'yes' then true
178- else env_value key
178+ result = ENV [ env_var_name ( key ) ]
179+ case result &.strip &.downcase
180+ when '0' , 'false' , 'no' then false
181+ when '1' , 'true' , 'yes' then true
182+ else result
179183 end
180184 end
181185
182- def env_value ( key )
183- ENV [ "BASHLY_#{ key . upcase } " ]
184- end
185-
186186 def config
187187 @config ||= default_settings . merge user_settings
188188 end
Original file line number Diff line number Diff line change 9595 end
9696 end
9797 end
98-
9998 end
10099
101100 describe '::env' do
You can’t perform that action at this time.
0 commit comments