Skip to content

Commit baa0500

Browse files
committed
Use symbols as level instead of strings
1 parent 90abfe6 commit baa0500

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/bundled_gems.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,24 @@ def self.warning?(name, specs: nil)
124124
return if WARNED[name]
125125
WARNED[name] = true
126126

127-
level = RUBY_VERSION < SINCE[name] ? "warning" : "error"
127+
level = RUBY_VERSION < SINCE[name] ? :warning : :error
128128

129129
if subfeature
130130
"#{feature} is found in #{name}, which"
131131
else
132-
"#{feature} #{level == "warning" ? "was loaded" : "used to be loaded"} from the standard library, but"
132+
"#{feature} #{level == :warning ? "was loaded" : "used to be loaded"} from the standard library, but"
133133
end + build_message(name, level)
134134
end
135135

136136
def self.build_message(name, level)
137-
msg = if level == "warning"
137+
msg = if level == :warning
138138
" will no longer be part of the default gems starting from Ruby #{SINCE[name]}"
139139
else
140140
" is not part of the default gems since Ruby #{SINCE[name]}."
141141
end
142142

143143
if defined?(Bundler)
144-
motivation = level == "warning" ? "silence this warning" : "fix this error"
144+
motivation = level == :warning ? "silence this warning" : "fix this error"
145145
msg += "\nYou can add #{name} to your Gemfile or gemspec to #{motivation}."
146146

147147
# We detect the gem name from caller_locations. First we walk until we find `require`
@@ -236,7 +236,7 @@ def message # :nodoc:
236236

237237
name = path.tr("/", "-")
238238
if !defined?(Bundler) && Gem::BUNDLED_GEMS::SINCE[name] && !Gem::BUNDLED_GEMS::WARNED[name]
239-
warn name + Gem::BUNDLED_GEMS.build_message(name, "error"), uplevel: Gem::BUNDLED_GEMS.uplevel
239+
warn name + Gem::BUNDLED_GEMS.build_message(name, :error), uplevel: Gem::BUNDLED_GEMS.uplevel
240240
end
241241
super
242242
end

0 commit comments

Comments
 (0)