Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AppEnvironment/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
products: [
.library(
name: "AppEnvironment",
targets: ["AppEnvironment"]),
targets: ["AppEnvironment"])
],
dependencies: [
],
Expand All @@ -18,6 +18,6 @@ let package = Package(
dependencies: []),
.testTarget(
name: "AppEnvironmentTests",
dependencies: ["AppEnvironment"]),
dependencies: ["AppEnvironment"])
]
)
10 changes: 5 additions & 5 deletions AppEnvironment/Sources/AppEnvironment/Bundle+Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public extension Bundle {
}

/// String value for CFBundleShortVersionString.
var version: String { return infoDictionaryValue(for: BundleKey.shortVersionString.rawValue) }
var version: String { infoDictionaryValue(for: BundleKey.shortVersionString.rawValue) }

/// String value for CFBundleVersion.
var build: String { return infoDictionaryValue(for: BundleKey.bundleVersion.rawValue) }
var build: String { infoDictionaryValue(for: BundleKey.bundleVersion.rawValue) }

/// String value for CFBundleIdentifier.
var buildIdentifier: String { return infoDictionaryValue(for: BundleKey.bundleIdentifier.rawValue) }
var buildIdentifier: String { infoDictionaryValue(for: BundleKey.bundleIdentifier.rawValue) }

func infoDictionaryValue(for key: String) -> String {
return (Bundle.main.infoDictionary?[key] as? String) ?? ""
(Bundle.main.infoDictionary?[key] as? String) ?? ""
}

var environmentSetting: NSDictionary { return (Bundle.main.infoDictionary?[PlistKey.appSettings.rawValue] as? NSDictionary) ?? NSDictionary() }
var environmentSetting: NSDictionary { (Bundle.main.infoDictionary?[PlistKey.appSettings.rawValue] as? NSDictionary) ?? NSDictionary() }
}
14 changes: 7 additions & 7 deletions AppEnvironment/Sources/AppEnvironment/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum EnvironmentSettings: EnvironmentSettingType, AutoCaseName {
/// sourcery: asString = "Install Owner"
case developerName

public var key: String { return caseName.rawValue }
public var key: String { caseName.rawValue }
}

// MARK: -
Expand Down Expand Up @@ -57,26 +57,26 @@ public extension Environment {
/// - Parameter key: Dictionary key for an env specific setting.
/// - Returns: Value for env setting.
func environmentSetting(for key: EnvironmentSettingType) -> String {
return provider.environmentSetting(for: key)
provider.environmentSetting(for: key)
}

var environment: Environment.Name? {
return provider.environment
provider.environment
}

var name: String {
return provider.name
provider.name
}

var rootURL: String {
return provider.rootURL
provider.rootURL
}

var isTesting: Bool {
return provider.isTesting
provider.isTesting
}

var isRelease: Bool {
return provider.isRelease
provider.isRelease
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public protocol EnvironmentProvider {
public extension EnvironmentProvider {

var environment: Environment.Name? {
return Environment.Name(rawValue: environmentSetting(for: EnvironmentSettings.environment))
Environment.Name(rawValue: environmentSetting(for: EnvironmentSettings.environment))
}

var name: String {
return environment.map { $0.rawValue } ?? Environment.Name.release.rawValue
environment.map { $0.rawValue } ?? Environment.Name.release.rawValue
}

var rootURL: String {
return environmentSetting(for: EnvironmentSettings.rootURL)
environmentSetting(for: EnvironmentSettings.rootURL)
}

var isTesting: Bool {
Expand All @@ -50,14 +50,14 @@ public extension EnvironmentProvider {
return UIApplication.shared.isDebugEnvironment
}

var isRelease: Bool { return environment == .release }
var isRelease: Bool { environment == .release }

/// Access to the info.plist dictionary values for the app specific settings.
///
/// - Parameter type: Dictionary key for the app setting.
/// - Returns: Value for the app specific setting.
func environmentSetting(for type: EnvironmentSettingType) -> String {
return Bundle.main.environmentSetting[type.key] as? String ?? ""
Bundle.main.environmentSetting[type.key] as? String ?? ""
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public struct ServiceEnvironment {
// MARK: -

extension ServiceEnvironment: CustomStringConvertible, CustomDebugStringConvertible {
public var description: String { return debugDescription }
public var description: String { debugDescription }

public var debugDescription: String {
return [
[
"rootURLString: \(self.environmentProvider.rootURLString)",
"env : \(String(describing: self.environmentProvider.environment.self))"
].joined(separator: "\n")
Expand All @@ -49,10 +49,10 @@ public struct DefaultServiceEnvironment: ServiceEnvironmentInterface {
public init() {}

public var environment: Environment.Name {
return Environment.shared.environment ?? Environment.Name.release
Environment.shared.environment ?? Environment.Name.release
}

public var rootURLString: String {
return Environment.shared.rootURL
Environment.shared.rootURL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ final class AppEnvironmentTests: XCTestCase {
}

static var allTests = [
("testExample", testExample),
("testExample", testExample)
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import XCTest

#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(AppEnvironmentTests.allTests),
[
testCase(AppEnvironmentTests.allTests)
]
}
#endif