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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/arkana/models/config.rb', line 34

def initialize(yaml)
  @environments = (yaml["environments"] || []).map(&:capitalize)
  @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
  @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"
end

Instance Attribute Details

#current_flavorObject

Returns the value of attribute current_flavor.



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

def current_flavor
  @current_flavor
end

#dotenv_filepathObject

Returns the value of attribute dotenv_filepath.



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

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.



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

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

#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.



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

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_generate_unit_testsObject (readonly)

Returns the value of attribute should_generate_unit_tests.



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

def should_generate_unit_tests
  @should_generate_unit_tests
end

#swift_declaration_strategyObject (readonly)

Returns the value of attribute swift_declaration_strategy.



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

def swift_declaration_strategy
  @swift_declaration_strategy
end

Instance Method Details

#all_keysObject



59
60
61
# File 'lib/arkana/models/config.rb', line 59

def all_keys
  global_secrets + environment_keys
end

#environment_keysObject

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



52
53
54
55
56
57
# File 'lib/arkana/models/config.rb', line 52

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