Skip to content

Commit 8204b59

Browse files
committed
Rename from_xxx methods with a bang !
Per ruby conventions, as they might raise on invalid/unknown values
1 parent 682acd6 commit 8204b59

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/models/locales.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def all
8989
# @raise [RuntimeException] if at least one of the locale codes was unknown
9090
#
9191
%i[glotpress android google_play ios app_store].each do |key|
92-
define_method("from_#{key}") { |args| search!(key, args) }
92+
define_method("from_#{key}!") { |args| search!(key, args) }
9393
end
9494

9595
# Return an Array<Locale> based on glotpress locale codes
@@ -104,14 +104,14 @@ def [](*list)
104104
# If we passed a variadic list of Strings, `*list` will make it a single `Array<String>` and we were already good to go.
105105
# But if we passed an Array, `*list` will make it an Array<Array<String>> of one item; taking `list.first` will go back to Array<String>.
106106
list = list.first if list.count == 1 && list.first.is_a?(Array)
107-
from_glotpress(list)
107+
from_glotpress!(list)
108108
end
109109

110110
# Return the subset of the 16 locales most of our apps are localized 100% (the ones we call the "Magnificent 16")
111111
#
112112
# @return [Array<Locale>] List of the Mag16 locales
113113
def mag16
114-
from_glotpress(MAG16_GP_CODES)
114+
from_glotpress!(MAG16_GP_CODES)
115115
end
116116

117117
###################

spec/locales_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe Fastlane::Locales do
44
shared_examples 'from_xxx' do |key, fr_code, pt_code|
5-
let(:method_sym) { "from_#{key}".to_sym }
5+
let(:method_sym) { "from_#{key}!".to_sym }
66

77
it 'can find a locale from a single code' do
88
fr_locale = described_class.send(method_sym, fr_code)
@@ -30,23 +30,23 @@
3030
end
3131
end
3232

33-
describe 'from_glotpress' do
33+
describe 'from_glotpress!' do
3434
include_examples 'from_xxx', :glotpress, 'fr', 'pt-br'
3535
end
3636

37-
describe 'from_android' do
37+
describe 'from_android!' do
3838
include_examples 'from_xxx', :android, 'fr', 'pt-rBR'
3939
end
4040

41-
describe 'from_google_play' do
41+
describe 'from_google_play!' do
4242
include_examples 'from_xxx', :google_play, 'fr-FR', 'pt-BR'
4343
end
4444

45-
describe 'from_ios' do
45+
describe 'from_ios!' do
4646
include_examples 'from_xxx', :ios, 'fr-FR', 'pt-BR'
4747
end
4848

49-
describe 'from_app_store' do
49+
describe 'from_app_store!' do
5050
include_examples 'from_xxx', :app_store, 'fr-FR', 'pt-BR'
5151
end
5252

0 commit comments

Comments
 (0)