Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Commit 5fa8462

Browse files
committed
Merge branch 'release/1.0.0'
Conflicts: README.md
2 parents 65b58cc + 758d36d commit 5fa8462

67 files changed

Lines changed: 786 additions & 1042 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Example/OrangeFramework.xcodeproj/project.pbxproj

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
B73EA13C1C20923800681710 /* OFDependencySpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B73EA1391C20923800681710 /* OFDependencySpec.m */; };
11-
B73EA13D1C20923800681710 /* OFDependencySpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = B73EA13A1C20923800681710 /* OFDependencySpec.swift */; };
12-
B73EA1471C218F8C00681710 /* OFLogSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B73EA1461C218F8C00681710 /* OFLogSpec.m */; };
13-
B73EA1491C218FA500681710 /* OFLogSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = B73EA1481C218FA500681710 /* OFLogSpec.swift */; };
11+
B73EA13D1C20923800681710 /* DependencySpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = B73EA13A1C20923800681710 /* DependencySpec.swift */; };
1412
B7A2D82C1C23064100080093 /* OFExtensionSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B7A2D82B1C23064100080093 /* OFExtensionSpec.m */; };
1513
B7B9C9C51C2AAA77006FC8AF /* OrangeFrameworkObjC.podspec in Resources */ = {isa = PBXBuildFile; fileRef = B7B9C9C41C2AAA77006FC8AF /* OrangeFrameworkObjC.podspec */; };
1614
BDE7A31337913D25FBC75722 /* Pods_OrangeFramework_Specs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DCBB1CDA75E36449C1C2D5D /* Pods_OrangeFramework_Specs.framework */; };
@@ -24,9 +22,7 @@
2422
90233076878E7EA11B771E9A /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
2523
B73EA1381C20923800681710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2624
B73EA1391C20923800681710 /* OFDependencySpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OFDependencySpec.m; sourceTree = "<group>"; };
27-
B73EA13A1C20923800681710 /* OFDependencySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OFDependencySpec.swift; sourceTree = "<group>"; };
28-
B73EA1461C218F8C00681710 /* OFLogSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OFLogSpec.m; sourceTree = "<group>"; };
29-
B73EA1481C218FA500681710 /* OFLogSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OFLogSpec.swift; sourceTree = "<group>"; };
25+
B73EA13A1C20923800681710 /* DependencySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DependencySpec.swift; sourceTree = "<group>"; };
3026
B7A2D82B1C23064100080093 /* OFExtensionSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OFExtensionSpec.m; sourceTree = "<group>"; };
3127
B7B9C9C41C2AAA77006FC8AF /* OrangeFrameworkObjC.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OrangeFrameworkObjC.podspec; path = ../OrangeFrameworkObjC.podspec; sourceTree = "<group>"; };
3228
F37C9518BA8F4C03FE1D26EC /* OrangeFramework.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = OrangeFramework.podspec; path = ../OrangeFramework.podspec; sourceTree = "<group>"; };
@@ -95,11 +91,9 @@
9591
B73EA1371C20923800681710 /* Specs */ = {
9692
isa = PBXGroup;
9793
children = (
94+
B73EA13A1C20923800681710 /* DependencySpec.swift */,
9895
B73EA1391C20923800681710 /* OFDependencySpec.m */,
99-
B73EA13A1C20923800681710 /* OFDependencySpec.swift */,
10096
B7A2D82B1C23064100080093 /* OFExtensionSpec.m */,
101-
B73EA1461C218F8C00681710 /* OFLogSpec.m */,
102-
B73EA1481C218FA500681710 /* OFLogSpec.swift */,
10397
B73EA13E1C20924300681710 /* Supporting Files */,
10498
);
10599
path = Specs;
@@ -234,10 +228,8 @@
234228
isa = PBXSourcesBuildPhase;
235229
buildActionMask = 2147483647;
236230
files = (
237-
B73EA1491C218FA500681710 /* OFLogSpec.swift in Sources */,
238-
B73EA13D1C20923800681710 /* OFDependencySpec.swift in Sources */,
231+
B73EA13D1C20923800681710 /* DependencySpec.swift in Sources */,
239232
B73EA13C1C20923800681710 /* OFDependencySpec.m in Sources */,
240-
B73EA1471C218F8C00681710 /* OFLogSpec.m in Sources */,
241233
B7A2D82C1C23064100080093 /* OFExtensionSpec.m in Sources */,
242234
);
243235
runOnlyForDeploymentPostprocessing = 0;

Example/Podfile.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
PODS:
22
- Nimble (3.0.0)
3-
- OrangeFramework (0.1.0):
4-
- OrangeFramework/Dependency (= 0.1.0)
5-
- OrangeFramework/Extensions (= 0.1.0)
6-
- OrangeFramework/Log (= 0.1.0)
7-
- OrangeFramework/Segues (= 0.1.0)
8-
- OrangeFramework/SystemInfo (= 0.1.0)
9-
- OrangeFramework/Dependency (0.1.0)
10-
- OrangeFramework/Extensions (0.1.0)
11-
- OrangeFramework/Log (0.1.0)
12-
- OrangeFramework/Segues (0.1.0)
13-
- OrangeFramework/SystemInfo (0.1.0)
3+
- OrangeFramework (1.0.0):
4+
- OrangeFramework/Dependency (= 1.0.0)
5+
- OrangeFramework/Device (= 1.0.0)
6+
- OrangeFramework/Extensions (= 1.0.0)
7+
- OrangeFramework/Log (= 1.0.0)
8+
- OrangeFramework/Segues (= 1.0.0)
9+
- OrangeFramework/Dependency (1.0.0)
10+
- OrangeFramework/Device (1.0.0)
11+
- OrangeFramework/Extensions (1.0.0)
12+
- OrangeFramework/Log (1.0.0)
13+
- OrangeFramework/Segues (1.0.0)
1414
- Quick (0.8.0)
1515

1616
DEPENDENCIES:
@@ -24,7 +24,7 @@ EXTERNAL SOURCES:
2424

2525
SPEC CHECKSUMS:
2626
Nimble: 4c353d43735b38b545cbb4cb91504588eb5de926
27-
OrangeFramework: 74be818e2371656a4b4e9b80bb76b0aa7a61c369
27+
OrangeFramework: db3daeec6900fc9156506dfe78a8f76d0c2a3197
2828
Quick: 563d0f6ec5f72e394645adb377708639b7dd38ab
2929

3030
COCOAPODS: 0.39.0

Example/Specs/DependencySpec.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Quick
2+
import Nimble
3+
import OrangeFramework
4+
5+
protocol TestProtocol {}
6+
class TestClass: TestProtocol {}
7+
struct TestStruct {}
8+
9+
class DependencySpec: QuickSpec {
10+
override func spec() {
11+
12+
describe("dependency by class type") {
13+
it("resolve after register") {
14+
Dependency.register(TestClass.self, lifetime: .Transient, constructor: {
15+
return TestClass()
16+
})
17+
expect(Dependency.resolve(TestClass.self)).toNot(raiseException())
18+
}
19+
it("resolve with exception after remove") {
20+
Dependency.remove(TestClass.self)
21+
expect(Dependency.resolve(TestClass.self)).to(raiseException())
22+
}
23+
}
24+
25+
describe("dependency by protocol type") {
26+
it("resolve after register") {
27+
Dependency.register(TestProtocol.self, lifetime: .Transient, constructor: {
28+
return TestClass()
29+
})
30+
expect(Dependency.resolve(TestProtocol.self)).toNot(raiseException())
31+
}
32+
}
33+
34+
describe("dependency by value type") {
35+
it("resolve after register") {
36+
Dependency.register(TestStruct.self, lifetime: .Transient, constructor: {
37+
return TestStruct()
38+
})
39+
expect(Dependency.resolve(TestStruct.self)).toNot(raiseException())
40+
}
41+
}
42+
43+
}
44+
}

Example/Specs/OFDependencySpec.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ @implementation TestClass @end
1313
describe(@"by key", ^{
1414
NSString *dependencyKey = @"some_key";
1515
context(@"when registered", ^{
16-
context(@"on factory mode", ^{
16+
context(@"with transient lifetime", ^{
1717
beforeEach(^{
18-
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeFactory constructor:^id _Nonnull{
18+
[OFDependency registerWithKey:dependencyKey lifetime:OFDependencyLifetimeTransient constructor:^id _Nonnull{
1919
return [NSObject new];
2020
}];
2121
});
@@ -28,9 +28,9 @@ @implementation TestClass @end
2828
expect(instance1).toNot(beIdenticalTo(instance2));
2929
});
3030
});
31-
context(@"on singleton mode", ^{
31+
context(@"with singleton lifetime", ^{
3232
beforeEach(^{
33-
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeSingleton constructor:^id _Nonnull{
33+
[OFDependency registerWithKey:dependencyKey lifetime:OFDependencyLifetimeSingleton constructor:^id _Nonnull{
3434
return [NSObject new];
3535
}];
3636
});
@@ -43,9 +43,9 @@ @implementation TestClass @end
4343
expect(instance1).to(beIdenticalTo(instance2));
4444
});
4545
});
46-
context(@"on weak singleton mode", ^{
46+
context(@"with weak singleton lifetime", ^{
4747
beforeEach(^{
48-
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeWeakSingleton constructor:^id _Nonnull{
48+
[OFDependency registerWithKey:dependencyKey lifetime:OFDependencyLifetimeWeakSingleton constructor:^id _Nonnull{
4949
return [NSObject new];
5050
}];
5151
});
@@ -70,7 +70,7 @@ @implementation TestClass @end
7070
});
7171
context(@"when removed", ^{
7272
beforeEach(^{
73-
[OFDependency registerWithKey:dependencyKey mode:OFDependencyModeFactory constructor:^id _Nonnull{
73+
[OFDependency registerWithKey:dependencyKey lifetime:OFDependencyLifetimeTransient constructor:^id _Nonnull{
7474
return [NSObject new];
7575
}];
7676
[OFDependency removeForKey:dependencyKey];
@@ -87,15 +87,15 @@ @implementation TestClass @end
8787
describe(@"by class", ^{
8888
context(@"when constructor result is kind of registered class", ^{
8989
it(@"resolve", ^{
90-
[OFDependency registerWithClass:[TestClass class] mode:OFDependencyModeFactory constructor:^id _Nonnull{
90+
[OFDependency registerWithClass:[TestClass class] lifetime:OFDependencyLifetimeTransient constructor:^id _Nonnull{
9191
return [TestClass new];
9292
}];
9393
expect([OFDependency resolveByClass:[TestClass class]]).to(beAKindOf([TestClass class]));
9494
});
9595
});
9696
context(@"when constructor result is NOT kind of registered class", ^{
9797
it(@"resolve with exception", ^{
98-
[OFDependency registerWithClass:[TestClass class] mode:OFDependencyModeFactory constructor:^id _Nonnull{
98+
[OFDependency registerWithClass:[TestClass class] lifetime:OFDependencyLifetimeTransient constructor:^id _Nonnull{
9999
return [NSString new];
100100
}];
101101
expect([OFDependency resolveByClass:[TestClass class]]).to(raiseException());
@@ -106,15 +106,15 @@ @implementation TestClass @end
106106
describe(@"by protocol", ^{
107107
context(@"when constructor result class conformed to registered protocol", ^{
108108
it(@"resolve", ^{
109-
[OFDependency registerWithProtocol:@protocol(TestProtocol) mode:OFDependencyModeFactory constructor:^id _Nonnull{
109+
[OFDependency registerWithProtocol:@protocol(TestProtocol) lifetime:OFDependencyLifetimeTransient constructor:^id _Nonnull{
110110
return [TestClass new];
111111
}];
112112
expect(@([[OFDependency resolveByProtocol:@protocol(TestProtocol)] conformsToProtocol:@protocol(TestProtocol)])).to(beTrue());
113113
});
114114
});
115115
context(@"when constructor result class NOT conformed to registered protocol", ^{
116116
it(@"resolve with exception", ^{
117-
[OFDependency registerWithProtocol:@protocol(TestProtocol) mode:OFDependencyModeFactory constructor:^id _Nonnull{
117+
[OFDependency registerWithProtocol:@protocol(TestProtocol) lifetime:OFDependencyLifetimeTransient constructor:^id _Nonnull{
118118
return [NSString new];
119119
}];
120120
expect([OFDependency resolveByProtocol:@protocol(TestProtocol)]).to(raiseException());

Example/Specs/OFDependencySpec.swift

Lines changed: 0 additions & 44 deletions
This file was deleted.

Example/Specs/OFExtensionSpec.m

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
context(@"when use serial queue", ^{
99
it(@"run async operation in series", ^{
1010
__block NSString *testString = @"";
11-
NSOperationQueue *testOperationQueue = [[NSOperationQueue alloc]init];
11+
NSOperationQueue *testOperationQueue = [NSOperationQueue new];
1212
testOperationQueue.maxConcurrentOperationCount = 1;
13-
[testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
13+
[testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
1414
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
1515
testString = [testString stringByAppendingString:@"1"];
1616
finish();
1717
});
1818
}];
19-
[testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
19+
[testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
2020
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
2121
testString = [testString stringByAppendingString:@"2"];
2222
finish();
2323
});
2424
}];
25-
[testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
25+
[testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
2626
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
2727
testString = [testString stringByAppendingString:@"3"];
2828
finish();
@@ -34,21 +34,21 @@
3434
context(@"when use parallel queue", ^{
3535
it(@"run async operation in parallel", ^{
3636
__block NSString *testString = @"";
37-
NSOperationQueue *testOperationQueue = [[NSOperationQueue alloc]init];
37+
NSOperationQueue *testOperationQueue = [NSOperationQueue new];
3838
testOperationQueue.maxConcurrentOperationCount = 3;
39-
[testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
39+
[testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
4040
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
4141
testString = [testString stringByAppendingString:@"1"];
4242
finish();
4343
});
4444
}];
45-
[testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
45+
[testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
4646
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
4747
testString = [testString stringByAppendingString:@"2"];
4848
finish();
4949
});
5050
}];
51-
[testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
51+
[testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) {
5252
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
5353
testString = [testString stringByAppendingString:@"3"];
5454
finish();
@@ -64,44 +64,44 @@
6464
NSString *testString = @"This is test string.";
6565
it(@"match regex", ^{
6666
NSString *testRegex = @".*";
67-
expect(@([testString matchRegex:testRegex])).to(beTrue());
67+
expect(@([testString of_matchRegex:testRegex])).to(beTrue());
6868
});
6969

7070
it(@"has first match of regex", ^{
7171
NSString *testRegex = @"is";
72-
expect([testString firstMatchOfRegex:testRegex]).toNot(beNil());
72+
expect([testString of_firstMatchOfRegex:testRegex]).toNot(beNil());
7373
});
7474

7575
it(@"has all matches of regex", ^{
7676
NSString *testRegex = @"is";
7777
NSInteger resultCount = 2;
78-
expect(@([testString allMatchesOfRegex:testRegex].count)).to(equal(@(resultCount)));
78+
expect(@([testString of_allMatchesOfRegex:testRegex].count)).to(equal(@(resultCount)));
7979
});
8080

8181
it(@"has match email", ^{
8282
NSString *testEmail = @"test@mail.com";
83-
expect(@([testEmail matchEmailString])).to(beTrue());
83+
expect(@([testEmail of_matchEmailString])).to(beTrue());
8484
});
8585
});
8686
context(@"when the string NOT contains regex pattern", ^{
8787
NSString *testString = @"This is test string.";
8888
it(@"not match regex", ^{
8989
NSString *testRegex = @"This";
90-
expect(@([testString matchRegex:testRegex])).toNot(beTrue());
90+
expect(@([testString of_matchRegex:testRegex])).toNot(beTrue());
9191
});
9292
it(@"has not first match of regex", ^{
9393
NSString *testRegex = @"testing";
94-
expect([testString firstMatchOfRegex:testRegex]).to(beNil());
94+
expect([testString of_firstMatchOfRegex:testRegex]).to(beNil());
9595
});
9696

9797
it(@"has not all matches of regex", ^{
9898
NSString *testRegex = @"testing";
99-
expect([testString firstMatchOfRegex:testRegex]).to(beNil());
99+
expect([testString of_firstMatchOfRegex:testRegex]).to(beNil());
100100
});
101101

102102
it(@"has not match email", ^{
103103
NSString *testEmail = @"testmail.com";
104-
expect(@([testEmail matchEmailString])).toNot(beTrue());
104+
expect(@([testEmail of_matchEmailString])).toNot(beTrue());
105105
});
106106
});
107107
});
@@ -111,7 +111,7 @@
111111
it(@"create color", ^{
112112
NSString *testStringColor = @"#e74c3c";
113113
CGFloat testR = 231/256.0f, testG = 76/256.0f, testB = 60/256.0f;
114-
UIColor *testColor = [UIColor colorWithHexString:testStringColor];
114+
UIColor *testColor = [UIColor of_colorWithHexString:testStringColor];
115115
CGFloat r, g, b;
116116
[testColor getRed:&r green:&g blue:&b alpha:NULL];
117117
expect(@(r)).to(equal(@(testR)));
@@ -121,7 +121,7 @@
121121
context(@"when NOT valid hex string", ^{
122122
it(@"create NIL color", ^{
123123
NSString *testStringColor = @"888e74c3c";
124-
expect([UIColor colorWithHexString:testStringColor]).to(beNil());
124+
expect([UIColor of_colorWithHexString:testStringColor]).to(beNil());
125125
});
126126
});
127127

0 commit comments

Comments
 (0)