Skip to content

Commit

Permalink
Added functionality to get the simulator model (thanks @Caseyc585)
Browse files Browse the repository at this point in the history
added functions that make it easier to determine whether or not the current device is in a specific group or family of devices
changed the battery level type from Double to Int since UIDevice itself only returns a double with 2 digit precision (i.e. 0.34 for 34%)
modified tests for the new functionality
  • Loading branch information
Dennis Weissmann committed Dec 22, 2015
1 parent ed19138 commit 99cee4c
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 170 deletions.
2 changes: 1 addition & 1 deletion DeviceKit-iOS/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.0</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
17 changes: 8 additions & 9 deletions DeviceKit-iOSTests/DeviceKit_iOSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@ import XCTest
@testable import DeviceKit

class DeviceKitTests: XCTestCase {

func testDeviceSimulator() {
let device = Device()
XCTAssert(device == Device.Simulator)
XCTAssert(Device().isOneOf(Device.allSimulators))
}

func testDeviceDescription() {
XCTAssert(Device().description == "Simulator")
XCTAssert(Device().description.hasPrefix("Simulator"))
}

func testOperator1() {
XCTAssert(Device.BatteryState.Full > Device.BatteryState.Charging(100))
}

func testOperator2() {
XCTAssert(Device.BatteryState.Charging(75) != Device.BatteryState.Unplugged(75))
}

func testOperator3() {
XCTAssert(Device.BatteryState.Unplugged(2) > Device.BatteryState.Charging(1))
}

}
2 changes: 1 addition & 1 deletion DeviceKit-tvOS/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.0</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
10 changes: 5 additions & 5 deletions DeviceKit-tvOSTests/DeviceKit_tvOSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import XCTest
@testable import DeviceKit

class DeviceKitTests: XCTestCase {

func testDeviceSimulator() {
let device = Device()
XCTAssert(device == .Simulator)
XCTAssert(device.isOneOf(Device.allSimulatorTVs))
}

func testDeviceDescription() {
XCTAssert(Device().description == "Simulator")
XCTAssert(Device().description.hasPrefix("Simulator"))
}

}
8 changes: 5 additions & 3 deletions DeviceKit.podspec
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
Pod::Spec.new do |s|
s.name = 'DeviceKit'
s.version = '0.0.1'
s.version = '0.1.0'
s.summary = 'DeviceKit is a µ-framework that provides a value-type wrapper of UIDevice.'

s.description = <<-DESC
`DeviceKit` is a value-type wrapper and extension of [`UIDevice`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/).
DESC

s.homepage = 'https://github.com/dennisweissmann/DeviceKit'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.license = 'MIT'
s.author = 'Dennis Weissmann'
s.social_media_url = 'https://twitter.com/dennis_weissman'

s.requires_arc = true
s.ios.deployment_target = '8.0'
s.tvos.deployment_target = '9.0'

s.source = { :git => 'https://github.com/dennisweissmann/DeviceKit.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/dennisweissmann/DeviceKit.git', :tag => s.version }
s.source_files = 'DeviceKit-iOS', 'DeviceKit-tvOS', 'SharedCode'

s.requires_arc = true
end
10 changes: 10 additions & 0 deletions DeviceKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
957D18251C28C1E90067D203 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
957D18261C28C1F30067D203 /* DeviceKit.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = DeviceKit.podspec; sourceTree = "<group>"; };
957D18271C28C1FC0067D203 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = "<group>"; };
95CBDB6F1BFD2B5F0065FC66 /* DeviceKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DeviceKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
95CBDB721BFD2B5F0065FC66 /* DeviceKit-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DeviceKit-iOS.h"; sourceTree = "<group>"; };
95CBDB741BFD2B5F0065FC66 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -87,6 +90,9 @@
95CBDB631BFD2B440065FC66 = {
isa = PBXGroup;
children = (
957D18251C28C1E90067D203 /* README.md */,
957D18261C28C1F30067D203 /* DeviceKit.podspec */,
957D18271C28C1FC0067D203 /* .travis.yml */,
95CBDBA31BFD2BB80065FC66 /* Shared Code */,
95CBDB711BFD2B5F0065FC66 /* DeviceKit-iOS */,
95CBDB7D1BFD2B5F0065FC66 /* DeviceKit-iOSTests */,
Expand Down Expand Up @@ -795,6 +801,7 @@
95CBDB831BFD2B5F0065FC66 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
95CBDB841BFD2B5F0065FC66 /* Build configuration list for PBXNativeTarget "DeviceKit-iOSTests" */ = {
isa = XCConfigurationList;
Expand All @@ -803,6 +810,7 @@
95CBDB861BFD2B5F0065FC66 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
95CBDB9D1BFD2B720065FC66 /* Build configuration list for PBXNativeTarget "DeviceKit-tvOS" */ = {
isa = XCConfigurationList;
Expand All @@ -811,6 +819,7 @@
95CBDB9F1BFD2B720065FC66 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
95CBDBA01BFD2B720065FC66 /* Build configuration list for PBXNativeTarget "DeviceKit-tvOSTests" */ = {
isa = XCConfigurationList;
Expand All @@ -819,6 +828,7 @@
95CBDBA21BFD2B720065FC66 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Loading

0 comments on commit 99cee4c

Please sign in to comment.