Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Electrode-iOS/ELRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
bsneed committed Jun 22, 2016
2 parents 30807d2 + 497f5e8 commit f8a41c3
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 37 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [1.0.1](https://github.com/Electrode-iOS/ELRouter/releases/tag/v1.0.1)

## Fixes

- Added missing call to `injectRouterSwizzles()` in Router init, fixing stuck locked routes

# [1.0.0](https://github.com/Electrode-iOS/ELRouter/releases/tag/v1.0.0)
1 change: 0 additions & 1 deletion ELRouter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion ELRouter/AssociatedData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
The AssociatedData protocol is used for conformance on passing data
through a chain of routes.
*/
//@objc
@objc
public protocol AssociatedData { }

/**
Expand Down
2 changes: 1 addition & 1 deletion ELRouter/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>0.0.0</string>
<string>1.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
16 changes: 12 additions & 4 deletions ELRouter/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public class Router: NSObject {

private let masterRoute: Route = Route("MASTER", type: .Other)
private var translation = [String : String]()

public override init() {
super.init()
injectRouterSwizzles()
}
}

// MARK: - Translation API
Expand Down Expand Up @@ -124,7 +129,6 @@ extension Router {
}

// MARK: - Evaluating Routes

extension Router {
/**
Can be used to determine if Routes are currently be processed.
Expand Down Expand Up @@ -154,11 +158,15 @@ extension Router {

- parameter url: The URL to evaluate.
*/
public func evaluateURL(url: NSURL, animated: Bool = false, completion: RouteCompletion? = nil) -> Bool {
public func evaluateURL(url: NSURL, associatedData: AssociatedData? = nil, animated: Bool = false, completion: RouteCompletion? = nil) -> Bool {
guard let components = url.deepLinkComponents else { return false }
return evaluate(components, associatedData: url, animated: animated, completion: completion)
var passedData: AssociatedData = url
if let validAssociatedData = associatedData {
passedData = validAssociatedData
}
return evaluate(components, associatedData: passedData, animated: animated, completion: completion)
}

/**
Evaluate an array of RouteSpecs. Routes matching the specs will be executed.

Expand Down
12 changes: 6 additions & 6 deletions ELRouterTests/RouteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RouteTests: XCTestCase {
}

func test_initialization_withNameAndAction() {
let route = Route("testName", type: .Other) { _ in
let route = Route("testName", type: .Other) { _, _ in
return nil
}

Expand Down Expand Up @@ -56,7 +56,7 @@ class RouteTests: XCTestCase {

func test_initialization_withTypeAndAction() {
let parentRoute = Route("parent", type: .Other)
let route = Route(type: .Other, parentRoute: parentRoute) { _ in
let route = Route(type: .Other, parentRoute: parentRoute) { _, _ in
return nil
}

Expand All @@ -72,7 +72,7 @@ class RouteTests: XCTestCase {

func test_initialization_withNamedAndParentRoute() {
let parentRoute = Route("parent", type: .Other)
let route = Route("sub", type: .Other, parentRoute: parentRoute) { _ in
let route = Route("sub", type: .Other, parentRoute: parentRoute) { _, _ in
return nil
}

Expand Down Expand Up @@ -223,7 +223,7 @@ extension RouteTests {
// }

func test_execute_returnsStaticValue() {
let route = Route("executeTest", type: .Static) { variable in
let route = Route("executeTest", type: .Static) { _, _ in
let vc = UIViewController(nibName: nil, bundle: nil)
vc.title = "Static Test"
return vc
Expand All @@ -244,7 +244,7 @@ extension RouteTests {
let navVC = UINavigationController(rootViewController: vc)
navigator.setViewControllers([navVC], animated: false)
navigator.selectedViewController = navVC
let route = Route("segueTest", type: .Segue) { variable in
let route = Route("segueTest", type: .Segue) { _, _ in
return "fooSegue"
}
route.parentRouter = router
Expand All @@ -259,7 +259,7 @@ extension RouteTests {
let navigator = MockNavigator()
router.navigator = navigator
let vc = UIViewController(nibName: nil, bundle: nil)
let route = Route("selectTest", type: .Static) { _ in
let route = Route("selectTest", type: .Static) { _, _ in
return vc
}
route.parentRouter = router
Expand Down
24 changes: 12 additions & 12 deletions ELRouterTests/RouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class RouterTests: XCTestCase {
let tabBarController = UITabBarController(nibName: nil, bundle: nil)
router.navigator = tabBarController

router.register(Route("tabOne", type: .Static) { (variable) in
router.register(Route("tabOne", type: .Static) { _, _ in
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabTwo", type: .Static) { (variable) in
router.register(Route("tabTwo", type: .Static) { _, _ in
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabThree", type: .Static) { (variable) in
router.register(Route("tabThree", type: .Static) { _, _ in
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})
Expand All @@ -44,15 +44,15 @@ class RouterTests: XCTestCase {
let tabBarController = UITabBarController(nibName: nil, bundle: nil)
router.navigator = tabBarController

router.register(Route("tabOne", type: .Static) { (variable) in
router.register(Route("tabOne", type: .Static) { _, _ in
return nil
})

router.register(Route("tabTwo", type: .Static) { (variable) in
router.register(Route("tabTwo", type: .Static) { _, _ in
return nil
})

router.register(Route("tabThree", type: .Static) { (variable) in
router.register(Route("tabThree", type: .Static) { _, _ in
return nil
})

Expand Down Expand Up @@ -84,19 +84,19 @@ class RouterTests: XCTestCase {
let tabTwoExpectation = expectationWithDescription("tabTwo static route executes")
let tabThreeExpectation = expectationWithDescription("tabThree static route executes")

router.register(Route("tabOne", type: .Static) { (variable) in
router.register(Route("tabOne", type: .Static) { _, _ in
tabOneExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabTwo", type: .Static) { (variable) in
router.register(Route("tabTwo", type: .Static) { _, _ in
tabTwoExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabThree", type: .Static) { (variable) in
router.register(Route("tabThree", type: .Static) { _, _ in
tabThreeExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
Expand All @@ -110,19 +110,19 @@ class RouterTests: XCTestCase {
func test_updateNavigator_doesNotExecuteStaticRoutesWithNilNavigator() {
let router = Router()

router.register(Route("tabOne", type: .Static) { (variable) in
router.register(Route("tabOne", type: .Static) { _, _ in
XCTAssertTrue(false)
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabTwo", type: .Static) { (variable) in
router.register(Route("tabTwo", type: .Static) { _, _ in
XCTAssertTrue(false)
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabThree", type: .Static) { (variable) in
router.register(Route("tabThree", type: .Static) { _, _ in
XCTAssertTrue(false)
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
Expand Down
16 changes: 8 additions & 8 deletions ELRouterTests/TabBarControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class TabBarControllerTests: XCTestCase {
let tabOneExpectation = expectationWithDescription("tab one created")
let tabTwoExpectation = expectationWithDescription("tab two created")

router.register(Route("tabOne", type: .Static) { (variable) in
router.register(Route("tabOne", type: .Static) { _, _ in
tabOneExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabTwo", type: .Static) { (variable) in
router.register(Route("tabTwo", type: .Static) { _, _ in
tabTwoExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
Expand Down Expand Up @@ -64,19 +64,19 @@ class TabBarControllerTests: XCTestCase {
let tabTwoExpectation = expectationWithDescription("tab two created")
let tabThreeExpectation = expectationWithDescription("tab three created")

router.register(Route("tabOne", type: .Static) { (variable) in
router.register(Route("tabOne", type: .Static) { _, _ in
tabOneExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabTwo", type: .Static) { (variable) in
router.register(Route("tabTwo", type: .Static) { _, _ in
tabTwoExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabThree", type: .Static) { (variable) in
router.register(Route("tabThree", type: .Static) { _, _ in
tabThreeExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
Expand Down Expand Up @@ -108,19 +108,19 @@ class TabBarControllerTests: XCTestCase {

let tabTwoExpectation = expectationWithDescription("route handler should run")

router.register(Route("tabOne", type: .Static) { (variable) in
router.register(Route("tabOne", type: .Static) { _, _ in
XCTAssertTrue(true, "Tab one handler should not be run when evaluating tab two")
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabTwo", type: .Static) { (variable) in
router.register(Route("tabTwo", type: .Static) { _, _ in
tabTwoExpectation.fulfill()
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
})

router.register(Route("tabThree", type: .Static) { (variable) in
router.register(Route("tabThree", type: .Static) { _, _ in
XCTAssertTrue(true, "Tab two handler should not be run when evaluating tab three")
let vc = UIViewController(nibName: nil, bundle: nil)
return UINavigationController(rootViewController: vc)
Expand Down
5 changes: 4 additions & 1 deletion ELRouterTests/TypedRouteExecution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import XCTest
import ELRouter


public struct WMListItemSpec: AssociatedData {
public class WMListItemSpec: AssociatedData {
init(blah argBlah: Int) {
blah = argBlah
}
var blah: Int = 1
}

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# ELRouter [![Build Status](https://travis-ci.org/Electrode-iOS/ELRouter.svg)](https://travis-ci.org/Electrode-iOS/ELRouter)
# ELRouter

ELRouter.framework. A **work in progress** of a URL router for UIKit.
[![Version](https://img.shields.io/badge/version-v1.0.1-blue.svg)](https://github.com/Electrode-iOS/ELRouter/releases/latest)
[![Build Status](https://travis-ci.org/Electrode-iOS/ELRouter.svg)](https://travis-ci.org/Electrode-iOS/ELRouter)

ELRouter.framework. A URL router for UIKit.

## Requirements

Expand Down

0 comments on commit f8a41c3

Please sign in to comment.