Skip to content

Commit

Permalink
issue-143: Renamed JSON class to GraphJSON to avoid framework collisi…
Browse files Browse the repository at this point in the history
…ons.
  • Loading branch information
Daniel Dahan committed Jul 12, 2018
1 parent be1ce03 commit 1604998
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 107 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.2.2

* [issue-143](https://github.com/CosmicMind/Graph/issues/143): Renamed JSON class to GraphJSON to avoid framework collisions.

## 2.2.1

* Updated for Swift 4.1.
2 changes: 1 addition & 1 deletion Graph.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Graph'
s.version = '2.2.1'
s.version = '2.2.2'
s.swift_version = '4.0'
s.license = 'BSD-3-Clause'
s.summary = 'Graph is a semantic database that is used to create data-driven applications.'
Expand Down
20 changes: 10 additions & 10 deletions Graph.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
962EB9D01D9E9E6800DFA8C4 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* JSON.swift */; };
962EB9D11D9E9E6800DFA8C4 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* JSON.swift */; };
962EB9D01D9E9E6800DFA8C4 /* GraphJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* GraphJSON.swift */; };
962EB9D11D9E9E6800DFA8C4 /* GraphJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* GraphJSON.swift */; };
965BBDCF208B96CF00AC4ED5 /* ActionPropertyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965BBDC8208B96CF00AC4ED5 /* ActionPropertyTests.swift */; };
965BBDD0208B96CF00AC4ED5 /* ActionPropertyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965BBDC8208B96CF00AC4ED5 /* ActionPropertyTests.swift */; };
965BBDD1208B96CF00AC4ED5 /* ActionPropertyStressTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965BBDC9208B96CF00AC4ED5 /* ActionPropertyStressTests.swift */; };
Expand Down Expand Up @@ -61,8 +61,8 @@
9686720E1D3BEA50000CD904 /* ManagedRelationshipGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9686720C1D3BEA50000CD904 /* ManagedRelationshipGroup.swift */; };
968672101D3BEA8F000CD904 /* ManagedActionGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9686720F1D3BEA8F000CD904 /* ManagedActionGroup.swift */; };
968672111D3BEA8F000CD904 /* ManagedActionGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9686720F1D3BEA8F000CD904 /* ManagedActionGroup.swift */; };
968B3EA81DA89EC40099F8E5 /* JSON.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* JSON.swift */; settings = {ATTRIBUTES = (Public, ); }; };
968B3EA91DA89ED40099F8E5 /* JSON.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* JSON.swift */; settings = {ATTRIBUTES = (Public, ); }; };
968B3EA81DA89EC40099F8E5 /* GraphJSON.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* GraphJSON.swift */; settings = {ATTRIBUTES = (Public, ); }; };
968B3EA91DA89ED40099F8E5 /* GraphJSON.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962EB9CF1D9E9E6800DFA8C4 /* GraphJSON.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96E3C3B41D3AB41F0086A024 /* Graph.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96E3C3A91D3AB41F0086A024 /* Graph.framework */; };
96E3C3C81D3AB4860086A024 /* Graph.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E3C3C61D3AB4860086A024 /* Graph.h */; settings = {ATTRIBUTES = (Public, ); }; };
96E3C3DE1D3AB5280086A024 /* Graph.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96E3C3D41D3AB5280086A024 /* Graph.framework */; };
Expand Down Expand Up @@ -198,7 +198,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
962EB9CF1D9E9E6800DFA8C4 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
962EB9CF1D9E9E6800DFA8C4 /* GraphJSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphJSON.swift; sourceTree = "<group>"; };
965BBDC8208B96CF00AC4ED5 /* ActionPropertyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ActionPropertyTests.swift; path = Tests/ActionPropertyTests.swift; sourceTree = SOURCE_ROOT; };
965BBDC9208B96CF00AC4ED5 /* ActionPropertyStressTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ActionPropertyStressTests.swift; path = Tests/ActionPropertyStressTests.swift; sourceTree = SOURCE_ROOT; };
965BBDCA208B96CF00AC4ED5 /* ActionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ActionTests.swift; path = Tests/ActionTests.swift; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -299,7 +299,7 @@
962EB9CE1D9E9E5600DFA8C4 /* JSON */ = {
isa = PBXGroup;
children = (
962EB9CF1D9E9E6800DFA8C4 /* JSON.swift */,
962EB9CF1D9E9E6800DFA8C4 /* GraphJSON.swift */,
);
name = JSON;
sourceTree = "<group>";
Expand Down Expand Up @@ -518,7 +518,7 @@
96F1DC5A1D64DDBC0025F925 /* ManagedActionProperty.swift in Headers */,
96F1DC5B1D64DDBC0025F925 /* ManagedActionTag.swift in Headers */,
96F1DC5C1D64DDBC0025F925 /* ManagedActionGroup.swift in Headers */,
968B3EA81DA89EC40099F8E5 /* JSON.swift in Headers */,
968B3EA81DA89EC40099F8E5 /* GraphJSON.swift in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -556,7 +556,7 @@
96F1DC781D64DDCF0025F925 /* ManagedActionProperty.swift in Headers */,
96F1DC791D64DDCF0025F925 /* ManagedActionTag.swift in Headers */,
96F1DC7A1D64DDCF0025F925 /* ManagedActionGroup.swift in Headers */,
968B3EA91DA89ED40099F8E5 /* JSON.swift in Headers */,
968B3EA91DA89ED40099F8E5 /* GraphJSON.swift in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -736,7 +736,7 @@
96E3C42C1D3AC6B60086A024 /* Entity.swift in Sources */,
96E3C4361D3AC6F20086A024 /* ManagedObject.swift in Sources */,
96E3C4441D3AC7E40086A024 /* ManagedRelationshipTag.swift in Sources */,
962EB9D01D9E9E6800DFA8C4 /* JSON.swift in Sources */,
962EB9D01D9E9E6800DFA8C4 /* GraphJSON.swift in Sources */,
96E3C3F41D3AB8B00086A024 /* Model.swift in Sources */,
968672101D3BEA8F000CD904 /* ManagedActionGroup.swift in Sources */,
96E3C4451D3AC7E40086A024 /* ManagedRelationshipProperty.swift in Sources */,
Expand Down Expand Up @@ -803,7 +803,7 @@
96E3C42D1D3AC6B70086A024 /* Entity.swift in Sources */,
96E3C4391D3AC6F30086A024 /* ManagedObject.swift in Sources */,
96E3C44C1D3AC7E50086A024 /* ManagedRelationshipTag.swift in Sources */,
962EB9D11D9E9E6800DFA8C4 /* JSON.swift in Sources */,
962EB9D11D9E9E6800DFA8C4 /* GraphJSON.swift in Sources */,
96E3C3F51D3AB8B00086A024 /* Model.swift in Sources */,
968672111D3BEA8F000CD904 /* ManagedActionGroup.swift in Sources */,
96E3C44D1D3AC7E50086A024 /* ManagedRelationshipProperty.swift in Sources */,
Expand Down
41 changes: 22 additions & 19 deletions Sources/JSON.swift → Sources/GraphJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import Foundation

open class JSON: Equatable, CustomStringConvertible {
open class GraphJSON: Equatable, CustomStringConvertible {
/// A desiption of the object, used when printing.
open var description: String {
return JSON.stringify(object: object) ?? "{}"
return GraphJSON.stringify(object: object) ?? "{}"
}

/// A reference to the core object.
Expand Down Expand Up @@ -76,30 +76,30 @@ open class JSON: Equatable, CustomStringConvertible {

/// A Data representation of the object.
open var asNSData: Data? {
return JSON.serialize(object: object)
return GraphJSON.serialize(object: object)
}

/**
Parses a given Data object.
- Parameter _ data: A Data object.
- Parameter options: JSONSerialization.ReadingOptions.
- Returns: A JSON object on success, nil otherwise.
- Returns: A GraphJSON object on success, nil otherwise.
*/
open class func parse(_ data: Data, options: JSONSerialization.ReadingOptions = .allowFragments) -> JSON? {
open class func parse(_ data: Data, options: JSONSerialization.ReadingOptions = .allowFragments) -> GraphJSON? {
guard let object = try? JSONSerialization.jsonObject(with: data, options: options) else {
return nil
}

return JSON(object)
return GraphJSON(object)
}

/**
Parses a given String object.
- Parameter _ string: A Data object.
- Parameter options: JSONSerialization.ReadingOptions.
- Returns: A JSON object on success, nil otherwise.
- Returns: A GraphJSON object on success, nil otherwise.
*/
open class func parse(_ string: String, options: JSONSerialization.ReadingOptions = .allowFragments) -> JSON? {
open class func parse(_ string: String, options: JSONSerialization.ReadingOptions = .allowFragments) -> GraphJSON? {
guard let data = string.data(using: String.Encoding.utf8) else {
return nil
}
Expand All @@ -122,20 +122,23 @@ open class JSON: Equatable, CustomStringConvertible {
- Returns: A String object if successful, nil otherwise.
*/
open class func stringify(object: Any) -> String? {
if let o = object as? JSON {
if let o = object as? GraphJSON {
return stringify(object: o.object)
} else if let data = JSON.serialize(object: object) {

} else if let data = GraphJSON.serialize(object: object) {
if let o = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as String? {
return o
}
}

return nil
}

/// An initializer that accepts a given Any object.
public required init(_ object: Any) {
if let o = object as? JSON {
if let o = object as? GraphJSON {
self.object = o.object

} else {
self.object = object
}
Expand All @@ -144,22 +147,22 @@ open class JSON: Equatable, CustomStringConvertible {
/**
A subscript operator for Array style access.
- Parameter index: An Int.
- Returns: A JSON object if successful, nil otherwise.
- Returns: A GraphJSON object if successful, nil otherwise.
*/
open subscript(index: Int) -> JSON? {
open subscript(index: Int) -> GraphJSON? {
guard let item = asArray else {
return nil
}

return JSON(item[index])
return GraphJSON(item[index])
}

/**
A subscript operator for Dictionary style access.
- Parameter key: A String.
- Returns: A JSON object if successful, nil otherwise.
- Returns: A GraphJSON object if successful, nil otherwise.
*/
open subscript(key: String) -> JSON? {
open subscript(key: String) -> GraphJSON? {
guard let item = asDictionary else {
return nil
}
Expand All @@ -168,10 +171,10 @@ open class JSON: Equatable, CustomStringConvertible {
return nil
}

return JSON(item[key]!)
return GraphJSON(item[key]!)
}
}

public func ==(lhs: JSON, rhs: JSON) -> Bool {
return JSON.stringify(object: lhs.object) == JSON.stringify(object: rhs.object)
public func ==(lhs: GraphJSON, rhs: GraphJSON) -> Bool {
return GraphJSON.stringify(object: lhs.object) == GraphJSON.stringify(object: rhs.object)
}
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2.1</string>
<string>2.2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions Tests/ActionGroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class ActionGroupTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, addedTo group: String, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("G1", group)
XCTAssertTrue(action.member(of: group))
XCTAssertEqual(1, action.groups.count)
Expand All @@ -155,7 +155,7 @@ class ActionGroupTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, removedFrom group: String, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("G2", group)
XCTAssertFalse(action.member(of: group))

Expand Down
10 changes: 5 additions & 5 deletions Tests/ActionPropertyStressTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,37 +140,37 @@ class ActionPropertyStressTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, inserted action: Action, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual(0, action.properties.count)

actionInsertExpectation?.fulfill()
}

func watch(graph: Graph, deleted action: Action, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual(0, action.properties.count)

actionDeleteExpectation?.fulfill()
}

func watch(graph: Graph, action: Action, added property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)

propertyInsertExpception?.fulfill()
}

func watch(graph: Graph, action: Action, updated property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)

propertyUpdateExpception?.fulfill()
}

func watch(graph: Graph, action: Action, removed property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)

propertyDeleteExpception?.fulfill()
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/ActionPropertyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ActionPropertyTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, added property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)

XCTAssertEqual("P1", property)
XCTAssertEqual("V1", value as? String)
Expand All @@ -151,7 +151,7 @@ class ActionPropertyTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, updated property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)

XCTAssertEqual("P1", property)
XCTAssertEqual("V2", value as? String)
Expand All @@ -162,7 +162,7 @@ class ActionPropertyTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, removed property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)

XCTAssertEqual("P1", property)
XCTAssertEqual("V1", value as? String)
Expand Down
4 changes: 2 additions & 2 deletions Tests/ActionTagTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ActionTagTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, added tag: String, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("G1", tag)
XCTAssertTrue(action.has(tags: tag))
XCTAssertEqual(1, action.tags.count)
Expand All @@ -156,7 +156,7 @@ class ActionTagTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, removed tag: String, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("G2", tag)
XCTAssertFalse(action.has(tags: tag))

Expand Down
14 changes: 7 additions & 7 deletions Tests/ActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class ActionTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, inserted action: Action, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("V", action["P"] as? String)
XCTAssertTrue(action.has(tags: "G"))

Expand All @@ -282,7 +282,7 @@ class ActionTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, deleted action: Action, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertNil(action["P"])
XCTAssertFalse(action.has(tags: "G"))
XCTAssertEqual(2, action.subjects.count)
Expand All @@ -297,7 +297,7 @@ class ActionTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, added tag: String, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("G", tag)
XCTAssertTrue(action.has(tags: tag))

Expand All @@ -306,7 +306,7 @@ class ActionTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, removed tag: String, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("G", tag)
XCTAssertFalse(action.has(tags: tag))

Expand All @@ -315,7 +315,7 @@ class ActionTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, added property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("P", property)
XCTAssertEqual("V", value as? String)
XCTAssertEqual(value as? String, action[property] as? String)
Expand All @@ -325,7 +325,7 @@ class ActionTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, updated property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("P", property)
XCTAssertEqual("V", value as? String)
XCTAssertEqual(value as? String, action[property] as? String)
Expand All @@ -335,7 +335,7 @@ class ActionTests: XCTestCase, WatchActionDelegate {

func watch(graph: Graph, action: Action, removed property: String, with value: Any, source: GraphSource) {
XCTAssertTrue("T" == action.type)
XCTAssertTrue(0 < action.id.characters.count)
XCTAssertTrue(0 < action.id.count)
XCTAssertEqual("P", property)
XCTAssertEqual("V", value as? String)
XCTAssertNil(action["P"])
Expand Down
Loading

0 comments on commit 1604998

Please sign in to comment.