Skip to content

Commit 5ba9984

Browse files
committed
[Attribute] Create attribute with sorting #1
1 parent 620c45d commit 5ba9984

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

QueryKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Pod::Spec.new do |spec|
77
spec.author = { 'Kyle Fuller' => '[email protected]' }
88
spec.social_media_url = 'http://twitter.com/kylefuller'
99
spec.source = { :git => 'https://github.com/kylef/QueryKit.git', :tag => "#{spec.version}" }
10-
spec.source_files = 'QueryKit/QueryKit.{h,swift}'
10+
spec.source_files = 'QueryKit/*.{h,swift}'
1111
spec.requires_arc = true
1212
end
1313

QueryKit.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
77A9B685195374490016654E /* QueryKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77A9B679195374490016654E /* QueryKit.framework */; };
1212
77A9B68C195374490016654E /* QueryKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77A9B68B195374490016654E /* QueryKitTests.swift */; };
1313
77A9B698195374AA0016654E /* QueryKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77A9B697195374AA0016654E /* QueryKit.swift */; };
14+
77E8728119539C0900A6F13F /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77E8728019539C0900A6F13F /* Attribute.swift */; };
15+
77E8728319539C2A00A6F13F /* AttributeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77E8728219539C2A00A6F13F /* AttributeTests.swift */; };
1416
/* End PBXBuildFile section */
1517

1618
/* Begin PBXContainerItemProxy section */
@@ -45,6 +47,8 @@
4547
77A9B68A195374490016654E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4648
77A9B68B195374490016654E /* QueryKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueryKitTests.swift; sourceTree = "<group>"; };
4749
77A9B697195374AA0016654E /* QueryKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryKit.swift; sourceTree = "<group>"; };
50+
77E8728019539C0900A6F13F /* Attribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attribute.swift; sourceTree = "<group>"; };
51+
77E8728219539C2A00A6F13F /* AttributeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributeTests.swift; sourceTree = "<group>"; };
4852
/* End PBXFileReference section */
4953

5054
/* Begin PBXFrameworksBuildPhase section */
@@ -89,6 +93,7 @@
8993
children = (
9094
77A9B67E195374490016654E /* QueryKit.h */,
9195
77A9B697195374AA0016654E /* QueryKit.swift */,
96+
77E8728019539C0900A6F13F /* Attribute.swift */,
9297
77A9B67C195374490016654E /* Supporting Files */,
9398
);
9499
path = QueryKit;
@@ -106,6 +111,7 @@
106111
isa = PBXGroup;
107112
children = (
108113
77A9B68B195374490016654E /* QueryKitTests.swift */,
114+
77E8728219539C2A00A6F13F /* AttributeTests.swift */,
109115
77A9B689195374490016654E /* Supporting Files */,
110116
);
111117
path = QueryKitTests;
@@ -228,6 +234,7 @@
228234
isa = PBXSourcesBuildPhase;
229235
buildActionMask = 2147483647;
230236
files = (
237+
77E8728119539C0900A6F13F /* Attribute.swift in Sources */,
231238
77A9B698195374AA0016654E /* QueryKit.swift in Sources */,
232239
);
233240
runOnlyForDeploymentPostprocessing = 0;
@@ -236,6 +243,7 @@
236243
isa = PBXSourcesBuildPhase;
237244
buildActionMask = 2147483647;
238245
files = (
246+
77E8728319539C2A00A6F13F /* AttributeTests.swift in Sources */,
239247
77A9B68C195374490016654E /* QueryKitTests.swift in Sources */,
240248
);
241249
runOnlyForDeploymentPostprocessing = 0;

QueryKit/Attribute.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// Attribute.swift
3+
// QueryKit
4+
//
5+
// Created by Kyle Fuller on 19/06/2014.
6+
//
7+
//
8+
9+
import Foundation
10+
11+
class Attribute {
12+
let name:String
13+
14+
init(_ name:String) {
15+
self.name = name
16+
}
17+
18+
// Sorting
19+
20+
func ascending() -> NSSortDescriptor {
21+
return NSSortDescriptor(key: name, ascending: true)
22+
}
23+
24+
func descending() -> NSSortDescriptor {
25+
return NSSortDescriptor(key: name, ascending: false)
26+
}
27+
}

QueryKitTests/AttributeTests.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// AttributeTests.swift
3+
// QueryKit
4+
//
5+
// Created by Kyle Fuller on 19/06/2014.
6+
//
7+
//
8+
9+
import XCTest
10+
import QueryKit
11+
12+
class AttributeTests: XCTestCase {
13+
var attribute:Attribute?
14+
15+
override func setUp() {
16+
super.setUp()
17+
18+
attribute = Attribute("age")
19+
}
20+
21+
func testAttributeHasName() {
22+
XCTAssertEqual(attribute!.name, "age")
23+
}
24+
25+
// Sorting
26+
27+
func testAscendingSortDescriptor() {
28+
XCTAssertEqual(attribute!.ascending(), NSSortDescriptor(key: "age", ascending: true))
29+
}
30+
31+
func testDescendingSortDescriptor() {
32+
XCTAssertEqual(attribute!.descending(), NSSortDescriptor(key: "age", ascending: false))
33+
}
34+
}

0 commit comments

Comments
 (0)