Module: SecureKeys::Globals

Defined in:
lib/core/globals/globals.rb

Class Method Summary collapse

Class Method Details

.add_xcframework?Bool

Check if the SecureKeys XCFramework should be added

Returns:

  • (Bool)

    true if the SecureKeys XCFramework should be added



54
55
56
57
58
# File 'lib/core/globals/globals.rb', line 54

def add_xcframework?
  Core::Console::Argument::Handler.fetch(key: %i[xcframework add])
                                  .to_s
                                  .to_boolean
end

.ci?Bool

Returns:

  • (Bool)

    true if the current build is running on a CI



13
14
15
16
17
18
19
20
# File 'lib/core/globals/globals.rb', line 13

def ci?
  return true if circle_ci?

  # Check for Jenkins, Travis CI, ... environment variables
  %w[JENKINS_HOME JENKINS_URL TRAVIS CI APPCENTER_BUILD_ID TEAMCITY_VERSION GO_PIPELINE_NAME bamboo_buildKey GITLAB_CI XCS TF_BUILD GITHUB_ACTION GITHUB_ACTIONS BITRISE_IO BUDDY CODEBUILD_BUILD_ARN].any? do |current|
    ENV[current].to_s.to_boolean
  end || Core::Console::Argument::Handler.fetch(key: :ci).to_s.to_boolean
end

.circle_ci?Bool

Check if the current build is running on CircleCI

Returns:

  • (Bool)

    true if the current build is running on CircleCI



24
25
26
# File 'lib/core/globals/globals.rb', line 24

def circle_ci?
  ENV.key?('CIRCLECI')
end

.default_key_access_identifierString

Returns the default key access identifier

Returns:

  • (String)

    default key access identifier



112
113
114
# File 'lib/core/globals/globals.rb', line 112

def default_key_access_identifier
  'secure-keys'
end

.default_key_delimiterString

Returns the default keys delimiter

Returns:

  • (String)

    default keys delimiter



118
119
120
# File 'lib/core/globals/globals.rb', line 118

def default_key_delimiter
  ','
end

.generate_xcframework?Bool

Check if the SecureKeys XCFramework should be generated

Returns:

  • (Bool)

    true if the SecureKeys XCFramework should be generated



38
39
40
41
42
# File 'lib/core/globals/globals.rb', line 38

def generate_xcframework?
  Core::Console::Argument::Handler.fetch(key: :generate)
                                  .to_s
                                  .to_boolean
end

.ios_platformsArray

Returns the supported iOS platforms

Returns:

  • (Array)

    supported iOS platforms



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/core/globals/globals.rb', line 83

def ios_platforms
  [
    {
      name: 'iOS Simulator',
      path: 'iphonesimulator'
    },
    {
      name: 'iOS',
      path: 'iphoneos'
    }
  ]
end

.key_access_identifierString

Returns the identifier to get all the key names

Returns:

  • (String)

    key access identifier



98
99
100
101
# File 'lib/core/globals/globals.rb', line 98

def key_access_identifier
  Core::Console::Argument::Handler.fetch(key: :identifier,
                                         default: default_key_access_identifier)
end

.key_delimiterString

Returns the keys delimiter

Returns:

  • (String)

    keys delimiter



105
106
107
108
# File 'lib/core/globals/globals.rb', line 105

def key_delimiter
  Core::Console::Argument::Handler.fetch(key: :delimiter,
                                         default: default_key_delimiter)
end

.replace_xcframework?Bool

Check if the SecureKeys XCFramework should be replaced

Returns:

  • (Bool)

    true if the SecureKeys XCFramework should be replaced



46
47
48
49
50
# File 'lib/core/globals/globals.rb', line 46

def replace_xcframework?
  Core::Console::Argument::Handler.fetch(key: %i[xcframework replace])
                                  .to_s
                                  .to_boolean
end

.secret_keys_sourceObject

Determine the secret keys source based on the environment

Returns:

  • (Object)

    secret keys source



75
76
77
78
79
# File 'lib/core/globals/globals.rb', line 75

def secret_keys_source
  return SecureKeys::Core::Environment::CI.new if ci?

  SecureKeys::Core::Environment::Keychain.new
end

.secure_keys_xcframework_pathString

Returns the secure keys XCFramework path

Returns:

  • (String)

    secure keys XCFramework path



69
70
71
# File 'lib/core/globals/globals.rb', line 69

def secure_keys_xcframework_path
  Dir.glob("**/#{Swift::KEYS_DIRECTORY}/#{Swift::XCFRAMEWORK_DIRECTORY}").first
end

.verbose?Bool

Check if the current instance is verbose

Returns:

  • (Bool)

    true if the current instance is verbose



30
31
32
33
34
# File 'lib/core/globals/globals.rb', line 30

def verbose?
  Core::Console::Argument::Handler.fetch(key: :verbose)
                                  .to_s
                                  .to_boolean
end

.xcodeproj_pathString

Returns the Xcode project path

Returns:

  • (String)

    Xcode project path



62
63
64
65
# File 'lib/core/globals/globals.rb', line 62

def xcodeproj_path
  Core::Console::Argument::Handler.fetch(key: %i[xcframework xcodeproj],
                                         default: Dir.glob('**/*.xcodeproj').first)
end