Class: Fastlane::ToolSwiftFunction
Instance Attribute Summary
#default_values_to_ignore, #function_description, #function_details, #function_name, #param_default_values, #param_descriptions, #param_is_strings, #param_names, #param_optionality_values, #param_type_overrides, #reserved_words, #return_type, #return_value, #sample_return_value
Instance Method Summary
collapse
#build_argument_list, #camel_case_lower, #determine_type_from_override, #fix_documentation_indentation, #get_type, #implementation, #initialize, #non_empty, #override_default_value_if_not_correct_type, #return_declaration, #return_statement, #sanitize_reserved_word, #swift_code, #swift_documentation, #swift_parameter_documentation, #swift_return_value_documentation, #swift_type_for_return_type
Instance Method Details
#class_name ⇒ Object
323
324
325
326
|
# File 'fastlane/lib/fastlane/swift_fastlane_function.rb', line 323
def class_name
function_name = camel_case_lower(string: self.function_name)
return function_name.capitalize + "file"
end
|
#parameters ⇒ Object
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
# File 'fastlane/lib/fastlane/swift_fastlane_function.rb', line 401
def parameters
unless @param_names
return ""
end
param_names_and_types = @param_names.zip(param_default_values, param_optionality_values, param_type_overrides).map do |param, default_value, optional, param_type_override, is_string|
type = get_type(param: param, default_value: default_value, optional: optional, param_type_override: param_type_override, is_string: is_string)
param = camel_case_lower(string: param)
param = sanitize_reserved_word(word: param)
static_var_for_parameter_name = param
"#{param}: #{type} = #{self.class_name.downcase}.#{static_var_for_parameter_name}"
end
return param_names_and_types
end
|
#protocol_name ⇒ Object
318
319
320
321
|
# File 'fastlane/lib/fastlane/swift_fastlane_function.rb', line 318
def protocol_name
function_name = camel_case_lower(string: self.function_name)
return function_name.capitalize + "fileProtocol"
end
|
#swift_default_implementations ⇒ Object
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
# File 'fastlane/lib/fastlane/swift_fastlane_function.rb', line 350
def swift_default_implementations
unless @param_names
return []
end
swift_implementations = @param_names.zip(param_default_values, param_optionality_values, param_type_overrides).map do |param, default_value, optional, param_type_override|
type = get_type(param: param, default_value: default_value, optional: optional, param_type_override: param_type_override)
param = camel_case_lower(string: param)
param = sanitize_reserved_word(word: param)
var_for_parameter_name = param
unless default_value.nil?
if type == "Bool" || type == "[String]" || type == "Int" || default_value.kind_of?(Array)
default_value = default_value.to_s
elsif default_value.kind_of?(Hash)
default_value = "[:]"
else
default_value = "\"#{default_value}\""
end
end
if optional && default_value.nil?
default_value = "nil"
end
if type == "String"
default_value ||= "\"\""
end
if type == "Bool"
default_value ||= "false"
end
if type == "[String]"
default_value ||= "[]"
end
if type == "[String : Any]"
default_value ||= "[:]"
end
" var #{var_for_parameter_name}: #{type} { return #{default_value} }"
end
return swift_implementations
end
|
#swift_vars ⇒ Object
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
# File 'fastlane/lib/fastlane/swift_fastlane_function.rb', line 328
def swift_vars
unless @param_names
return []
end
swift_vars = @param_names.zip(param_default_values, param_optionality_values, param_type_overrides, param_descriptions).map do |param, default_value, optional, param_type_override, param_description|
type = get_type(param: param, default_value: default_value, optional: optional, param_type_override: param_type_override)
param = camel_case_lower(string: param)
param = sanitize_reserved_word(word: param)
static_var_for_parameter_name = param
if param_description
documentation = " /// #{param_description}\n"
end
"\n#{documentation}"\
" var #{static_var_for_parameter_name}: #{type} { get }"
end
return swift_vars
end
|