Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 110450d

Browse files
committed
fix settings env var priority
1 parent 522d2b8 commit 110450d

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

‎.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
4141
RSpec/ExampleLength:
4242
Exclude:
4343
- 'spec/bashly/integration/**/*'
4444
- 'spec/bashly/libraries/render*'
45+
- 'spec/bashly/script/command_spec.rb'

‎lib/bashly/settings.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff 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

‎spec/bashly/settings_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
end
9696
end
9797
end
98-
9998
end
10099

101100
describe '::env' do

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /