Skip to content

Commit

Permalink
Merge pull request #46 from uber/foundation-remove_module_name-master
Browse files Browse the repository at this point in the history
Remove module name from component path
  • Loading branch information
Rudro Samanta authored May 8, 2018
2 parents 7cd8729 + 2ac8692 commit fb676a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Foundation/Sources/NeedleFoundation/Component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ open class Component<DependencyType>: ComponentType {
// Use `lazy var` to avoid computing the path repeatedly. Internally, this is always
// accessed with the `__DependencyProviderRegistry`'s lock acquired.
public lazy var path: String = {
return parent.path + "->\(self)"
let fullyQualifiedSelfName = String(describing: self)
let parts = fullyQualifiedSelfName.components(separatedBy: ".")
let name = parts.last ?? fullyQualifiedSelfName
return parent.path + "->\(name)"
}()

/// The dependency of this component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ComponentTests: XCTestCase {
override func setUp() {
super.setUp()

let path = "^->NeedleFoundationTests.TestComponent"
let path = "^->TestComponent"
__DependencyProviderRegistry.instance.registerDependencyProviderFactory(for: path) {_ in
return EmptyDependencyProvider()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DependencyProviderRegistryTests: XCTestCase {
override func setUp() {
super.setUp()

let path = "^->NeedleFoundationTests.MockAppComponent"
let path = "^->MockAppComponent"
__DependencyProviderRegistry.instance.registerDependencyProviderFactory(for: path) {_ in
return EmptyDependencyProvider()
}
Expand All @@ -35,7 +35,7 @@ class DependencyProviderRegistryTests: XCTestCase {
func test_registerProviderFactory_verifyRetrievingProvider_verifyDependencyReference() {
let expectedProvider = MockRootDependencyProvider()

let path = "^->NeedleFoundationTests.MockAppComponent->NeedleFoundationTests.MockRootComponent"
let path = "^->MockAppComponent->MockRootComponent"
__DependencyProviderRegistry.instance.registerDependencyProviderFactory(for: path) { (component: ComponentType) -> AnyObject in
return expectedProvider
}
Expand Down

0 comments on commit fb676a6

Please sign in to comment.