lib/produce/config.rb in produce-0.2.0 vs lib/produce/config.rb in produce-0.2.1
- old
+ new
@@ -24,17 +24,25 @@
# Retrieves the value for given `key`. If not found, will promt user with
# `ASK_MESSAGES[key]` till gets valid response. Thus, always returns value.
# Raises exception if given `key` is not Symbol or unknown.
def val(key)
raise "Please only pass symbols, no Strings to this method".red unless key.kind_of? Symbol
+
+ # bundle_identifier_suffix can be set to empty string, if bundle_identifier is not a wildcard id
+ # (does not end with '*'). bundle_identifier_suffix is ignored on non wildcard bundle_identifiers
+ if key == :bundle_identifier_suffix
+ unless @config[:bundle_identifier].end_with?("*")
+ @config[key] = '' # set empty string, if no wildcard bundle_indentifiier
+ end
+ end
unless @config.has_key? key
@config[key] = ask(ASK_MESSAGES[key]) do |q|
case key
when :primary_language
q.validate = lambda { |val| is_valid_language?(val) }
- q.responses[:not_valid] = "Please enter one of available languages: #{AvailableDefaultLanguages.all_langauges}"
+ q.responses[:not_valid] = "Please enter one of available languages: #{AvailableDefaultLanguages.all_languages}"
else
q.validate = lambda { |val| !val.empty? }
q.responses[:not_valid] = "#{key.to_s.gsub('_', ' ').capitalize} can't be blank"
end
end
@@ -65,24 +73,39 @@
team_id: ENV['PRODUCE_TEAM_ID'],
team_name: ENV['PRODUCE_TEAM_NAME']
}
if ENV['PRODUCE_LANGUAGE']
- language = ENV['PRODUCE_LANGUAGE'].split.map(&:capitalize).join(' ')
- if is_valid_language?(language)
- hash[:primary_language] = language
+ language = valid_language(ENV['PRODUCE_LANGUAGE'])
+
+ if language.nil?
+ unknown_language = ENV['PRODUCE_LANGUAGE']
+ Helper.log.error "PRODUCE_LANGUAGE is set to #{unknown_language} but it's not one of available languages. You'll be asked to set language again if needed."
else
- Helper.log.error "PRODUCE_LANGUAGE is set to #{language} but it's not one of available languages. You'll be asked to set language again if needed."
+ hash[:primary_language] = language
end
end
+
hash[:bundle_identifier] ||= CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
hash.delete_if { |key, value| value.nil? }
hash
end
def is_valid_language? language
- AvailableDefaultLanguages.all_langauges.include? language
+ AvailableDefaultLanguages.all_languages.include? language
+ end
+
+ def valid_language language
+ AvailableDefaultLanguages.all_languages.each do |l|
+
+ if l.casecmp(language) == 0
+ return l
+ end
+
+ end
+
+ return nil
end
# TODO: this could be moved inside fastlane_core
def is_truthy? value
%w( true t 1 yes y ).include? value.to_s.downcase
\ No newline at end of file