Class: Config

Inherits:
Object
  • Object
show all
Defined in:
lib/arkana/models/config.rb

Overview

Model used to hold all the configuration set up by the user (both from CLI arguments and from the config file).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml) ⇒ Config

rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/arkana/models/config.rb', line 48

def initialize(yaml)
  @environments = (yaml["environments"] || []).map(&:capitalize_first_letter)
  @environment_secrets = yaml["environment_secrets"] || []
  @global_secrets = yaml["global_secrets"] || []
  default_name = "ArkanaKeys"
  @namespace = yaml["namespace"] || default_name
  @import_name = yaml["import_name"] || default_name
  @pod_name = yaml["pod_name"] || default_name
  @result_path = yaml["result_path"] || default_name
  @kotlin_package_name = yaml["kotlin_package_name"] || "com.arkanakeys"
  @kotlin_sources_path = yaml["kotlin_sources_path"] || "kotlin"
  @flavors = yaml["flavors"] || []
  @swift_declaration_strategy = yaml["swift_declaration_strategy"] || "let"
  @should_generate_unit_tests = yaml["should_generate_unit_tests"]
  @should_generate_unit_tests = true if @should_generate_unit_tests.nil?
  @package_manager = yaml["package_manager"] || "spm"
  @should_cocoapods_cross_import_modules = yaml["should_cocoapods_cross_import_modules"]
  @should_cocoapods_cross_import_modules = true if @should_cocoapods_cross_import_modules.nil?
  @should_generate_gradle_build_file = yaml["should_generate_gradle_build_file"]
  @should_generate_gradle_build_file = true if @should_generate_gradle_build_file.nil?
  @kotlin_jvm_toolchain_version = yaml["kotlin_jvm_toolchain_version"] || 11
  @is_kotlin_multiplatform_module = yaml["is_kotlin_multiplatform_module"]
  @is_kotlin_multiplatform_module = false if @should_generate_gradle_build_file.nil?
end

Instance Attribute Details

#current_flavorObject

Returns the value of attribute current_flavor.



41
42
43
# File 'lib/arkana/models/config.rb', line 41

def current_flavor
  @current_flavor
end

#current_langObject

Returns the value of attribute current_lang.



45
46
47
# File 'lib/arkana/models/config.rb', line 45

def current_lang
  @current_lang
end

#dotenv_filepathObject

Returns the value of attribute dotenv_filepath.



43
44
45
# File 'lib/arkana/models/config.rb', line 43

def dotenv_filepath
  @dotenv_filepath
end

#environment_secretsObject (readonly)

Returns the value of attribute environment_secrets.



10
11
12
# File 'lib/arkana/models/config.rb', line 10

def environment_secrets
  @environment_secrets
end

#environmentsObject (readonly)

Returns the value of attribute environments.



6
7
8
# File 'lib/arkana/models/config.rb', line 6

def environments
  @environments
end

#flavorsObject (readonly)

Returns the value of attribute flavors.



24
25
26
# File 'lib/arkana/models/config.rb', line 24

def flavors
  @flavors
end

#global_secretsObject (readonly)

Returns the value of attribute global_secrets.



8
9
10
# File 'lib/arkana/models/config.rb', line 8

def global_secrets
  @global_secrets
end

#import_nameObject (readonly)

Returns the value of attribute import_name.



12
13
14
# File 'lib/arkana/models/config.rb', line 12

def import_name
  @import_name
end

#is_kotlin_multiplatform_moduleObject (readonly)

Returns the value of attribute is_kotlin_multiplatform_module.



38
39
40
# File 'lib/arkana/models/config.rb', line 38

def is_kotlin_multiplatform_module
  @is_kotlin_multiplatform_module
end

#kotlin_jvm_toolchain_versionObject (readonly)

Returns the value of attribute kotlin_jvm_toolchain_version.



36
37
38
# File 'lib/arkana/models/config.rb', line 36

def kotlin_jvm_toolchain_version
  @kotlin_jvm_toolchain_version
end

#kotlin_package_nameObject (readonly)

Returns the value of attribute kotlin_package_name.



20
21
22
# File 'lib/arkana/models/config.rb', line 20

def kotlin_package_name
  @kotlin_package_name
end

#kotlin_sources_pathObject (readonly)

Returns the value of attribute kotlin_sources_path.



22
23
24
# File 'lib/arkana/models/config.rb', line 22

def kotlin_sources_path
  @kotlin_sources_path
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



14
15
16
# File 'lib/arkana/models/config.rb', line 14

def namespace
  @namespace
end

#package_managerObject (readonly)

Returns the value of attribute package_manager.



30
31
32
# File 'lib/arkana/models/config.rb', line 30

def package_manager
  @package_manager
end

#pod_nameObject (readonly)

Returns the value of attribute pod_name.



16
17
18
# File 'lib/arkana/models/config.rb', line 16

def pod_name
  @pod_name
end

#result_pathObject (readonly)

Returns the value of attribute result_path.



18
19
20
# File 'lib/arkana/models/config.rb', line 18

def result_path
  @result_path
end

#should_cocoapods_cross_import_modulesObject (readonly)

Returns the value of attribute should_cocoapods_cross_import_modules.



32
33
34
# File 'lib/arkana/models/config.rb', line 32

def should_cocoapods_cross_import_modules
  @should_cocoapods_cross_import_modules
end

#should_generate_gradle_build_fileObject (readonly)

Returns the value of attribute should_generate_gradle_build_file.



34
35
36
# File 'lib/arkana/models/config.rb', line 34

def should_generate_gradle_build_file
  @should_generate_gradle_build_file
end

#should_generate_unit_testsObject (readonly)

Returns the value of attribute should_generate_unit_tests.



28
29
30
# File 'lib/arkana/models/config.rb', line 28

def should_generate_unit_tests
  @should_generate_unit_tests
end

#swift_declaration_strategyObject (readonly)

Returns the value of attribute swift_declaration_strategy.



26
27
28
# File 'lib/arkana/models/config.rb', line 26

def swift_declaration_strategy
  @swift_declaration_strategy
end

Instance Method Details

#all_keysObject



82
83
84
# File 'lib/arkana/models/config.rb', line 82

def all_keys
  global_secrets + environment_keys
end

#environment_keysObject

TODO: Consider renaming this and environment_secrets, cuz they’re confusing.



75
76
77
78
79
80
# File 'lib/arkana/models/config.rb', line 75

def environment_keys
  result = environment_secrets.map do |k|
    environments.map { |e| k + e }
  end
  result.flatten
end

#include_environments(environments) ⇒ Object



86
87
88
89
90
# File 'lib/arkana/models/config.rb', line 86

def include_environments(environments)
  return unless environments

  @environments = @environments.select { |e| environments.map(&:downcase).include?(e.downcase) }
end