Skip to content

Commit

Permalink
Renaming all elements from CloudEnvironment to CloudFoundryEnv.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolivieri committed Jun 9, 2016
1 parent d848624 commit d208a9e
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
.build/*
Packages/*
CloudEnvironment.xcodeproj/xcuserdata/*
CloudEnvironment.xcodeproj/project.xcworkspace/xcuserdata/*
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import PackageDescription

let package = Package(
name: "CloudEnvironment",
name: "CloudFoundryEnv",
targets: [
Target(
name: "CloudEnvironment",
name: "CloudFoundryEnv",
dependencies: []
),
],
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ To leverage the Swift-cfenv package in your Swift application, you should specif
])
```

Once the Package.swift file of your application has been updated accordingly, you can import the `CloudEnvironment` module in your code:
Once the Package.swift file of your application has been updated accordingly, you can import the `CloudFoundryEnv` module in your code:

```swift
import CloudEnvironment
import CloudFoundryEnv

...

do {
let appEnv = try CloudEnvironment.getAppEnv()
let appEnv = try CloudFoundryEnv.getAppEnv()
// Use the given port and binding host values to create a socket for our server...
let ip: String = appEnv.bind
let port: Int = appEnv.port
Expand All @@ -48,7 +48,7 @@ do {

...

} catch CloudEnvironmentError.InvalidValue {
} catch CloudFoundryEnvError.InvalidValue {
print("Oops, something went wrong... Server did not start!")
}
```
Expand All @@ -67,8 +67,8 @@ The following environment variables, which are set when your application is runn
If the `VCAP_APPLICATION` isn't set, it is then assumed that your application is running locally. For such cases, the [`AppEnv`](#appenv) instance returns values that are still useful for starting your application. Therefore, this Swift package can be used when running in Cloud Foundry and when running locally.

## API
### `CloudEnvironment`
To get an instance of the [`AppEnv`](#appenv) structure, you can use one of the following methods of the `CloudEnvironment` structure:
### `CloudFoundryEnv`
To get an instance of the [`AppEnv`](#appenv) structure, you can use one of the following methods of the `CloudFoundryEnv` structure:

- `getAppEnv(options: JSON)`
- `getAppEnv()`
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public struct AppEnv {
if let json = JSONUtils.convertStringToJSON(text: environmentVars[variableName]) {
return json
}
throw CloudEnvironmentError.InvalidValue("Environment variable \(variableName) is not a valid JSON string!")
throw CloudFoundryEnvError.InvalidValue("Environment variable \(variableName) is not a valid JSON string!")
}
}

Expand All @@ -275,7 +275,7 @@ public struct AppEnv {
if let number = Int(portString) {
return number
} else {
throw CloudEnvironmentError.InvalidValue("Invalid PORT value: \(portString)")
throw CloudFoundryEnvError.InvalidValue("Invalid PORT value: \(portString)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import SwiftyJSON
/**
* Functions as a factory to create instances of the AppEnv structure.
*/
public struct CloudEnvironment {
public struct CloudFoundryEnv {

public static func getAppEnv(options: JSON = [:]) throws -> AppEnv {
return try AppEnv(options: options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
**/

public enum CloudEnvironmentError: ErrorProtocol {
public enum CloudFoundryEnvError: ErrorProtocol {
case InvalidValue(String)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import XCTest
import Foundation
import SwiftyJSON

@testable import CloudEnvironment
@testable import CloudFoundryEnv

/**
* Online tool for escaping JSON: http://www.freeformatter.com/javascript-escape.html
Expand Down Expand Up @@ -59,7 +59,7 @@ class MainTests : XCTestCase {

func testGetApp() {
do {
let appEnv = try CloudEnvironment.getAppEnv(options: jsonOptions)
let appEnv = try CloudFoundryEnv.getAppEnv(options: jsonOptions)
if let app = appEnv.getApp() {
XCTAssertNotNil(app)
XCTAssertEqual(app.port, 61263, "Application port number should match.")
Expand Down Expand Up @@ -100,7 +100,7 @@ class MainTests : XCTestCase {
func testGetServices() {
do {
//print("json \(json)")
let appEnv = try CloudEnvironment.getAppEnv(options: jsonOptions)
let appEnv = try CloudFoundryEnv.getAppEnv(options: jsonOptions)
//let servs = appEnv.services
//print("servs \(servs)")
let services = appEnv.getServices()
Expand All @@ -122,7 +122,7 @@ class MainTests : XCTestCase {

func testGetService() {
do {
let appEnv = try CloudEnvironment.getAppEnv(options: jsonOptions)
let appEnv = try CloudFoundryEnv.getAppEnv(options: jsonOptions)
let checkService = { (name: String) in
if let service = appEnv.getService(spec: name) {
self.verifyService(service: service)
Expand All @@ -148,7 +148,7 @@ class MainTests : XCTestCase {
func testGetAppEnv() {
do {
// Case #1 - Running locally, no options
var appEnv = try CloudEnvironment.getAppEnv()
var appEnv = try CloudFoundryEnv.getAppEnv()
XCTAssertEqual(appEnv.isLocal, true, "AppEnv's isLocal should be true.")
XCTAssertEqual(appEnv.port, 8090, "AppEnv's port should be 8090.")
XCTAssertNil(appEnv.name, "AppEnv's name should be nil.")
Expand All @@ -159,7 +159,7 @@ class MainTests : XCTestCase {
XCTAssertEqual(appEnv.services.count, 0, "AppEnv's services array should contain 0 elements.")

// Case #2 - Running locally with options
appEnv = try CloudEnvironment.getAppEnv(options: jsonOptions)
appEnv = try CloudFoundryEnv.getAppEnv(options: jsonOptions)
XCTAssertEqual(appEnv.isLocal, true, "AppEnv's isLocal should be true.")
XCTAssertEqual(appEnv.port, 8090, "AppEnv's port should be 8090.")
XCTAssertEqual(appEnv.name, "swift-test")
Expand All @@ -181,7 +181,7 @@ class MainTests : XCTestCase {
let name = "Cloudant NoSQL DB-kd"

// Case #1 - Running locally, no options
let appEnv = try CloudEnvironment.getAppEnv()
let appEnv = try CloudFoundryEnv.getAppEnv()
let serviceURL = appEnv.getServiceURL(spec: name, replacements: nil)
XCTAssertNil(serviceURL, "The serviceURL should be nil.")

Expand All @@ -208,7 +208,7 @@ class MainTests : XCTestCase {

func testGetServiceCreds() {
do {
let appEnv = try CloudEnvironment.getAppEnv(options: jsonOptions)
let appEnv = try CloudFoundryEnv.getAppEnv(options: jsonOptions)
let checkServiceCreds = { (name: String) in
if let serviceCreds = appEnv.getServiceCreds(spec: name) {
self.verifyServiceCreds(serviceCreds: serviceCreds)
Expand Down Expand Up @@ -238,7 +238,7 @@ class MainTests : XCTestCase {
}

private func verifyServiceURLWithOptions(name: String, replacements: String?, expectedServiceURL: String) throws {
let appEnv = try CloudEnvironment.getAppEnv(options: jsonOptions)
let appEnv = try CloudFoundryEnv.getAppEnv(options: jsonOptions)
let substitutions = JSONUtils.convertStringToJSON(text: replacements)
if let serviceURL = appEnv.getServiceURL(spec: name, replacements: substitutions) {
XCTAssertEqual(serviceURL, expectedServiceURL, "ServiceURL should match '\(expectedServiceURL)'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import XCTest
import Foundation
import SwiftyJSON

@testable import CloudEnvironment
@testable import CloudFoundryEnv

/**
* Online tool for escaping JSON: http://www.freeformatter.com/javascript-escape.html
Expand Down
2 changes: 1 addition & 1 deletion Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import XCTest

@testable import CloudEnvironmentTestSuite
@testable import CloudFoundryEnvTestSuite

XCTMain([
testCase(MainTests.allTests),
Expand Down

0 comments on commit d208a9e

Please sign in to comment.