Skip to content

Commit

Permalink
Merge branch 'pr/71'
Browse files Browse the repository at this point in the history
Partial solve object type mismatch issue from PR #71

# Conflicts:
#	EVReflection/EVReflectionTestApp/ViewController.swift
#	EVReflection/pod/EVObject.swift
  • Loading branch information
evermeer committed Apr 26, 2016
2 parents 90f6583 + e91b5fa commit 8be217d
Show file tree
Hide file tree
Showing 31 changed files with 665 additions and 563 deletions.
2 changes: 1 addition & 1 deletion EVReflection.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |s|
#

s.name = "EVReflection"
s.version = "2.24.0"
s.version = "2.25.0"
s.summary = "iOS: Swift helper library with reflection functions"
s.description = "Swift helper library with reflection functions including support for NSCoding, Printable, Hashable, Equatable and JSON"
s.homepage = "https://github.com/evermeer/EVReflection"
Expand Down
68 changes: 68 additions & 0 deletions EVReflection/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
disabled_rules:
- trailing_whitespace
- variable_name
- type_name

#- opening_brace
#- comma
#- colon
#- control_statement
#- statement_position

#opt_in_rules:
#- empty_count
#- missing_docs


excluded:
- Pods/
- Sparen/Common/Generated/
- Sparen/Resources
- GlobalAPIKey
- _name

force_cast: warning

force_try: warning

function_parameter_count:
- 5
- 12

function_body_length:
- 50
- 120

cyclomatic_complexity:
- 20
- 60

line_length:
- 200
- 800

type_body_length:
- 500
- 1000

file_length:
- 500
- 2000

type_name:
min_length:
warning: 5
error: 2
max_length:
warning: 40
error: 60

variable_name:
min_length:
warning: 5
error: 2
max_length:
warning: 80
error: 50

#reporter: "csv" # reporter type (xcode, json, csv, checkstyle)
4 changes: 2 additions & 2 deletions EVReflection/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: objective-c
osx_image: xcode7
osx_image: xcode7.3

before_install:
- export LANG=en_US.UTF-8
- brew update
- if brew outdated | grep -qx xctool; then brew upgrade xctool; fi

script:
- xctool clean build -project EVReflection/EVReflection.xcodeproj -scheme 'EVReflection iOS Tests' -sdk iphonesimulator9.0 ONLY_ACTIVE_ARCH=NO
- xctool clean build -project EVReflection/EVReflection.xcodeproj -scheme 'EVReflection iOS Tests' -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO

36 changes: 36 additions & 0 deletions EVReflection/EVReflection.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
7F159DFB1BA2FA2F00247CB1 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
7F1BA5261B971CBF009F9DB8 /* EVExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVExtensions.swift; sourceTree = "<group>"; };
7F29762A1BB913910074C85A /* osx-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "osx-Info.plist"; sourceTree = "<group>"; };
7F36405C1CC9F2E600D7F055 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = "<group>"; };
7F3E19291B8526CA00A6E6C6 /* EVObjectDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVObjectDescription.swift; sourceTree = "<group>"; };
7F41ECA41B91F2E0003A2236 /* TestObjects.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestObjects.swift; sourceTree = "<group>"; };
7F41ECA61B91F306003A2236 /* EVObjectDescriptionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVObjectDescriptionTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -278,6 +279,7 @@
7F07C5541AF101A9000DF1F3 = {
isa = PBXGroup;
children = (
7F36405C1CC9F2E600D7F055 /* .swiftlint.yml */,
7F159DFB1BA2FA2F00247CB1 /* .gitignore */,
7F0636B31AFF413900595461 /* .travis.yml */,
7F07C5861AF10296000DF1F3 /* README.md */,
Expand Down Expand Up @@ -483,6 +485,7 @@
7F07C56E1AF101A9000DF1F3 /* Sources */,
7F07C56F1AF101A9000DF1F3 /* Frameworks */,
7F07C5701AF101A9000DF1F3 /* Resources */,
7F36405E1CC9F37A00D7F055 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -520,6 +523,7 @@
7F6C9FAD1CB90E6D00F19811 /* Frameworks */,
7F6C9FAE1CB90E6D00F19811 /* Resources */,
7F6C9FC91CB92D3C00F19811 /* Embed Frameworks */,
7F36405D1CC9F30100D7F055 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -709,6 +713,37 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
7F36405D1CC9F30100D7F055 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = SwiftLint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n echo \"Start SwiftLint\"\n swiftlint\nelse\n echo \"WARNING: installing SwiftLint not installed (start dowload using brew)\"\n brew install swiftlint\n if which swiftlint >/dev/null; then\n echo \"Start SwiftLint\"\n swiftlint\n else\n echo \"WARNING: SwiftLint could not be installed. Download it from https://github.com/realm/SwiftLint\"\nfi\nfi\n";
};
7F36405E1CC9F37A00D7F055 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = SwiftLint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#SwiftLint only enabled\nif which swiftlint >/dev/null; then\n echo \"Start SwiftLint\"\n #swiftlint\nelse\n echo \"WARNING: installing SwiftLint not installed (start dowload using brew)\"\n #brew install swiftlint\n if which swiftlint >/dev/null; then\n echo \"Start SwiftLint\"\n #swiftlint\n else\n echo \"WARNING: SwiftLint could not be installed. Download it from https://github.com/realm/SwiftLint\"\n fi\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
2DC8AA381C24215500FA6B8E /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -1329,6 +1364,7 @@
7F6C9FC11CB90E6D00F19811 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
7F9336BF1C28227400AF7076 /* Build configuration list for PBXNativeTarget "EVReflection TVOS" */ = {
isa = XCConfigurationList;
Expand Down
30 changes: 0 additions & 30 deletions EVReflection/EVReflectionTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

12 changes: 3 additions & 9 deletions EVReflection/EVReflectionTestApp/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ViewController: UIViewController {
@IBOutlet weak var curenMemoryUsage: UILabel!
@IBOutlet weak var changedMemoryUsage: UILabel!

var usage:UInt = 0
var usage: UInt = 0

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
Expand Down Expand Up @@ -48,15 +48,14 @@ class ViewController: UIViewController {
if kerr == KERN_SUCCESS {
print("Memory in use (in bytes): \(NSNumber(int: Int32(info.resident_size)).descriptionWithLocale(NSLocale.currentLocale()))")
return UInt(info.resident_size)
}
else {
} else {
print("Error with task_info(): " +
(String.fromCString(mach_error_string(kerr)) ?? "unknown error"))
return 0
}
}

func doTest(test : ()-> ()){
func doTest(test : ()-> ()) {
let startTime = NSDate()
let usageAtBegin = usage

Expand Down Expand Up @@ -111,9 +110,4 @@ class TestObject2: EVObject {
required init() {
super.init()
}


}



34 changes: 13 additions & 21 deletions EVReflection/EVReflectionTests/EVObjectDescriptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Testing EVObjectDescription
*/
class EVObjectDescriptionTests: XCTestCase {

var bundle:String = ""
var bundle: String = ""

/**
For now nothing to setUp
Expand Down Expand Up @@ -42,26 +42,27 @@ class EVObjectDescriptionTests: XCTestCase {
let c = EVObjectDescription(forObject: EVObjectDescriptionTests.SubTest.SubSubTest())
XCTAssert(c.classPath == [bundle, "EVObjectDescriptionTests", "SubTest", "SubSubTest"], "Pass")

class FuncSubTest:NSObject {
class FuncSubSubTest:NSObject {

class FuncSubTest: NSObject {
class FuncSubSubTest: NSObject {
var name: String?
}
}
//TODO: For now these only succeed because we assume a function name will have an aditional string containing FS0_FT_T_L_ in the description. I have to reverse engineer the parameter notation for Functions.
//Because in a bug of Xcode code coverage whe using an inline class definition, the 2 XCAsserts below will not be registered as covered
//TODO: For now these only succeed because we assume a function name will have an aditional string
// containing FS0_FT_T_L_ in the description. I have to reverse engineer the parameter notation for Functions.
// Because in a bug of Xcode code coverage whe using an inline class definition, the 2 XCAsserts below will not be registered as covered
let d = EVObjectDescription(forObject: FuncSubTest())
XCTAssert(d.classPath == [bundle, "EVObjectDescriptionTests", "testEVObjectDescription", "FuncSubTest"], "Pass")
let e = EVObjectDescription(forObject: FuncSubTest.FuncSubSubTest())
XCTAssert(e.classPath == [bundle, "EVObjectDescriptionTests", "testEVObjectDescription", "FuncSubTest", "FuncSubSubTest"], "Pass")
}

func testIncorrectDescription() {
let (_ , a) = testDescription("", paramb:1, paramc: "")
let (_, a) = testDescription("", paramb:1, paramc: "")
XCTAssert(a.classPath == [bundle, "EVObjectDescriptionTests", "testDescription", ""], "OK... Something has changed. Or did we fixed this? Then remove this test")
}

func testDescription(param: String, paramb:Int, paramc:String) -> (a:String, b:EVObjectDescription) {
class FuncSubTest:NSObject {
func testDescription(param: String, paramb: Int, paramc: String) -> (a: String, b: EVObjectDescription) {
class FuncSubTest: NSObject {
var param: Any?
}
let o = FuncSubTest()
Expand All @@ -70,19 +71,10 @@ class EVObjectDescriptionTests: XCTestCase {
return ("", p)
}

class SubTest:NSObject {
class SubSubTest:NSObject {

class SubTest: NSObject {
class SubSubTest: NSObject {
var name: String?
}
}

}









Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class EVReflectionAssociatedTests: XCTestCase {


func testEnumAssociatedValues() {
let parameters:[usersParameters] = [.number(19), .authors_only(false)]
let parameters: [usersParameters] = [.number(19), .authors_only(false)]
let y = WordPressRequestConvertible.MeLikes("XX", Dictionary(associated: parameters))
// Now just extract the label and associated values from this enum
let label = y.associated.label
let (token, param) = y.associated.value as! (String, [String:Any]?)
let (token, param) = (y.associated.value as? (String, [String:Any]?))!

XCTAssertEqual("MeLikes", label, "The label of the enum should be MeLikes")
XCTAssertEqual("XX", token, "The token associated value of the enum should be XX")
Expand Down Expand Up @@ -76,4 +76,4 @@ public enum usersParameters: EVAssociated {
case order_by(String)
case authors_only(Bool)
case type(String)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,3 @@ public class CustomPropertyClass: EVObject {
super.init()
}
}




Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,3 @@ public class TestRootObject: TestBaseObject {

public class TestInnerObject: TestBaseObject {
}



Loading

0 comments on commit 8be217d

Please sign in to comment.