Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbriatte committed Apr 12, 2017
2 parents 14f6fcb + d72d497 commit 725f93b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 41 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion DGDependencyInjector.podspec
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down
5 changes: 3 additions & 2 deletions DGDependencyInjector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,22 @@
A3169DCF1DE062A000BABAFD /* Tests */ = {
isa = PBXGroup;
children = (
A37058D61E5DE4ED009D0739 /* Domains */,
A37058D61E5DE4ED009D0739 /* Domain */,
A38EF2C61DECF97000637484 /* DGDependencyInjectorTests */,
A3169DD11DE062A000BABAFD /* Info.plist */,
);
path = Tests;
sourceTree = "<group>";
};
A37058D61E5DE4ED009D0739 /* Domains */ = {
A37058D61E5DE4ED009D0739 /* Domain */ = {
isa = PBXGroup;
children = (
A37058D71E5DE4ED009D0739 /* Cat.swift */,
A37058D81E5DE4ED009D0739 /* Dog.swift */,
A37058D91E5DE4ED009D0739 /* IAnimal.swift */,
A37058DA1E5DE4ED009D0739 /* PetOwner.swift */,
);
name = Domain;
path = Domains;
sourceTree = "<group>";
};
Expand Down
29 changes: 3 additions & 26 deletions Sources/DependencyInjector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand All @@ -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<T>(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<T>(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
Expand All @@ -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<T>(type: T.Type, scope: String?, arguments: [String: Any]?) -> T? {
open func inject<T>(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)
Expand Down
11 changes: 1 addition & 10 deletions Sources/DependencyModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(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<T>(type: T.Type, scope: String?, provider: @escaping (DependencyInjector, [String: Any]?) -> T?) {
open func register<T>(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
Expand Down
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>1.1.0</string>
<string>1.1.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.1.1</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down

0 comments on commit 725f93b

Please sign in to comment.