From acfacc52b95128390af0b20004ab4960a2951009 Mon Sep 17 00:00:00 2001 From: Benoit BRIATTE Date: Wed, 12 Apr 2017 17:21:39 +0200 Subject: [PATCH 1/3] remove unused methods add builder pattern --- .../project.pbxproj | 5 ++-- Sources/DependencyInjector.swift | 29 ++----------------- Sources/DependencyModule.swift | 11 +------ 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/DGDependencyInjector.xcodeproj/project.pbxproj b/DGDependencyInjector.xcodeproj/project.pbxproj index d25eb51..9503573 100644 --- a/DGDependencyInjector.xcodeproj/project.pbxproj +++ b/DGDependencyInjector.xcodeproj/project.pbxproj @@ -256,14 +256,14 @@ A3169DCF1DE062A000BABAFD /* Tests */ = { isa = PBXGroup; children = ( - A37058D61E5DE4ED009D0739 /* Domains */, + A37058D61E5DE4ED009D0739 /* Domain */, A38EF2C61DECF97000637484 /* DGDependencyInjectorTests */, A3169DD11DE062A000BABAFD /* Info.plist */, ); path = Tests; sourceTree = ""; }; - A37058D61E5DE4ED009D0739 /* Domains */ = { + A37058D61E5DE4ED009D0739 /* Domain */ = { isa = PBXGroup; children = ( A37058D71E5DE4ED009D0739 /* Cat.swift */, @@ -271,6 +271,7 @@ A37058D91E5DE4ED009D0739 /* IAnimal.swift */, A37058DA1E5DE4ED009D0739 /* PetOwner.swift */, ); + name = Domain; path = Domains; sourceTree = ""; }; diff --git a/Sources/DependencyInjector.swift b/Sources/DependencyInjector.swift index 4e61087..9ecc791 100644 --- a/Sources/DependencyInjector.swift +++ b/Sources/DependencyInjector.swift @@ -23,12 +23,11 @@ open class DependencyInjector { * @return True on success, otherwise false */ @discardableResult - open func register(module: DependencyModule) -> Bool { + open func register(module: DependencyModule) -> Self { if self.modules.index(of: module) == nil { self.modules.insert(module, at: 0) - return true } - return false + return self } /** @@ -51,28 +50,6 @@ open class DependencyInjector { return self.inject(type: type, scope: nil, arguments: nil) } - /** - * Creates a new instance conforming the input Type - * The injector search the first module that can provide the injection (The default scope is used) - * @param type The given Type you want to inject - * @param arguments Used by the provider (Such as nonnull parameters for initializers) - * @return An injected object, nil if an error occurred - */ - open func inject(type: T.Type, arguments: [String: Any]?) -> T? { - return self.inject(type: type, scope: nil, arguments: arguments) - } - - /** - * Creates a new instance conforming the input Type - * The injector search the first module that can provide the injection - * @param type The given Type you want to inject - * @param scope Custom scope, give nil to use default scope - * @return An injected object, nil if an error occurred - */ - open func inject(type: T.Type, scope: String?) -> T? { - return self.inject(type: type, scope: scope, arguments: nil) - } - /** * Creates a new instance conforming the input Type * The injector search the first module that can provide the injection @@ -81,7 +58,7 @@ open class DependencyInjector { * @param arguments Used by the provider (Such as nonnull parameters for initializers) * @return An injected object, nil if an error occurred */ - open func inject(type: T.Type, scope: String?, arguments: [String: Any]?) -> T? { + open func inject(type: T.Type, scope: String? = nil, arguments: [String: Any]? = nil) -> T? { for module in self.modules { if let provider = module.provider(type: type, scope: scope) { return provider(self, arguments) diff --git a/Sources/DependencyModule.swift b/Sources/DependencyModule.swift index e9ccad6..1ec84e1 100644 --- a/Sources/DependencyModule.swift +++ b/Sources/DependencyModule.swift @@ -29,22 +29,13 @@ open class DependencyModule { self.records = [:] } - /** - * Registers a provider for the given Type and for the default scope - * @param type The Type used for injection - * @param provider The provider used to inject an object of Type T - */ - open func register(type: T.Type, provider: @escaping (DependencyInjector, [String: Any]?) -> T?) { - self.register(type: type, scope: nil, provider: provider) - } - /** * Registers a provider for the given Type * @param type The Type used for injection * @param scope The custom scope, give nil to use default scope * @param provider The provider used to inject an object of Type T */ - open func register(type: T.Type, scope: String?, provider: @escaping (DependencyInjector, [String: Any]?) -> T?) { + open func register(type: T.Type, scope: String? = nil, provider: @escaping (DependencyInjector, [String: Any]?) -> T?) { let reference = String(describing: type) var record = self.records[reference] ?? [:] record[scope ?? DependencyModule.defaultScope] = provider From 4b4c8d05593bc52839d4e195fe8a195e93e281d1 Mon Sep 17 00:00:00 2001 From: Benoit BRIATTE Date: Wed, 12 Apr 2017 17:22:18 +0200 Subject: [PATCH 2/3] Bumped release version '1.1.1' build #1 --- DGDependencyInjector.podspec | 2 +- Sources/Info.plist | 2 +- Tests/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DGDependencyInjector.podspec b/DGDependencyInjector.podspec index 876f21d..47c489f 100644 --- a/DGDependencyInjector.podspec +++ b/DGDependencyInjector.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "DGDependencyInjector" -s.version = "1.1.0" +s.version = "1.1.1" s.summary = "Dependency injector made in pure swift" s.homepage = "https://github.com/Digipolitan/dependency-injector-swift" s.license = { :type => "BSD", :file => "LICENSE" } diff --git a/Sources/Info.plist b/Sources/Info.plist index a73f15e..046057c 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.0 + 1.1.1 CFBundleVersion 1 NSPrincipalClass diff --git a/Tests/Info.plist b/Tests/Info.plist index f7ffdc0..3d05b61 100644 --- a/Tests/Info.plist +++ b/Tests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.0.0 + 1.1.1 CFBundleVersion 1 From d72d497f52f5c70e6d492ac8199f65e79eceadd2 Mon Sep 17 00:00:00 2001 From: Benoit BRIATTE Date: Wed, 12 Apr 2017 17:23:12 +0200 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c611e41..4801c26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. --- +## [1.1.1](https://github.com/Digipolitan/dependency-injector-swift/releases/tag/v1.1.1) + +remove unused methods +add builder pattern + +--- + ## [1.1.0](https://github.com/Digipolitan/dependency-injector-swift/releases/tag/v1.1.0) Moving project from dependencies-injector-pure-swift