├── .DS_Store ├── .gitignore ├── .travis.yml ├── CIFilterKit.podspec ├── CIFilterKit.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── jeff.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── xcshareddata │ └── xcschemes │ │ └── CIFilterKit.xcscheme └── xcuserdata │ └── jeff.xcuserdatad │ └── xcschemes │ ├── ExampleApp.xcscheme │ └── xcschememanagement.plist ├── CIFilterKit.xcworkspace └── contents.xcworkspacedata ├── CIFilterKit ├── BlurFilters.swift ├── CIFilterKit.h ├── ColorAdjustmentFilters.swift ├── ColorEffectFilters.swift ├── CompositeOperationFilters.swift ├── DistortionEffectFilters.swift ├── Filter.swift ├── Generators.swift ├── GeometryAdjustmentFilters.swift ├── Gradients.swift ├── HalftoneEffectFilters.swift ├── Info.plist ├── Options.swift ├── ReductionFilters.swift ├── SharpenFilters.swift ├── StylizeFilters.swift └── TileEffectFilters.swift ├── CIFilterKitTests ├── BlurFilterTests.swift ├── ColorAdjustmentFilterTests.swift ├── ColorEffectFilterTests.swift ├── CompositeOperationFilterTests.swift ├── DistortionEffectFilterTests.swift ├── GeneratorTests.swift ├── GeometryAdjustmentFilterTests.swift ├── GradientTests.swift ├── HalftoneEffectFilterTests.swift ├── Info.plist ├── MiscFunctionTests.swift ├── ReductionFilterTests.swift ├── SharpenFilterTests.swift ├── StylizeFilterTests.swift ├── TileEffectFilterTests.swift ├── bacon.jpg ├── banana.png ├── rhinoceros.jpg └── wutang.png ├── ExampleApp ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── kevin.imageset │ │ ├── Contents.json │ │ ├── bacon-1.jpg │ │ ├── bacon-2.jpg │ │ └── bacon.jpg ├── Info.plist ├── Oranization.swift └── ViewController.swift ├── ExampleAppTests ├── ExampleAppTests.swift └── Info.plist ├── LICENSE ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── Nimble │ ├── LICENSE.md │ ├── README.md │ └── Sources │ │ └── Nimble │ │ ├── Adapters │ │ ├── AdapterProtocols.swift │ │ ├── AssertionDispatcher.swift │ │ ├── AssertionRecorder.swift │ │ ├── NimbleEnvironment.swift │ │ ├── NimbleXCTestHandler.swift │ │ └── ObjectiveC │ │ │ ├── CurrentTestCaseTracker.m │ │ │ ├── DSL.h │ │ │ ├── DSL.m │ │ │ ├── NMBExceptionCapture.h │ │ │ ├── NMBExceptionCapture.m │ │ │ ├── NMBExpectation.swift │ │ │ ├── NMBObjCMatcher.swift │ │ │ ├── NMBStringify.h │ │ │ └── NMBStringify.m │ │ ├── DSL+Wait.swift │ │ ├── DSL.swift │ │ ├── Expectation.swift │ │ ├── Expression.swift │ │ ├── FailureMessage.swift │ │ ├── Matchers │ │ ├── AllPass.swift │ │ ├── AsyncMatcherWrapper.swift │ │ ├── BeAKindOf.swift │ │ ├── BeAnInstanceOf.swift │ │ ├── BeCloseTo.swift │ │ ├── BeEmpty.swift │ │ ├── BeGreaterThan.swift │ │ ├── BeGreaterThanOrEqualTo.swift │ │ ├── BeIdenticalTo.swift │ │ ├── BeLessThan.swift │ │ ├── BeLessThanOrEqual.swift │ │ ├── BeLogical.swift │ │ ├── BeNil.swift │ │ ├── BeVoid.swift │ │ ├── BeginWith.swift │ │ ├── Contain.swift │ │ ├── EndWith.swift │ │ ├── Equal.swift │ │ ├── HaveCount.swift │ │ ├── Match.swift │ │ ├── MatchError.swift │ │ ├── MatcherFunc.swift │ │ ├── MatcherProtocols.swift │ │ ├── PostNotification.swift │ │ ├── RaisesException.swift │ │ ├── SatisfyAnyOf.swift │ │ └── ThrowError.swift │ │ ├── Nimble.h │ │ └── Utils │ │ ├── Async.swift │ │ ├── Errors.swift │ │ ├── Functional.swift │ │ ├── SourceLocation.swift │ │ └── Stringers.swift ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── jeff.xcuserdatad │ │ └── xcschemes │ │ ├── Pods-CIFilterKitTests.xcscheme │ │ ├── Pods-ExampleAppTests.xcscheme │ │ └── xcschememanagement.plist ├── Quick │ ├── LICENSE │ ├── README.md │ └── Sources │ │ └── Quick │ │ ├── Callsite.swift │ │ ├── Configuration │ │ ├── Configuration.swift │ │ ├── QuickConfiguration.h │ │ └── QuickConfiguration.m │ │ ├── DSL │ │ ├── DSL.swift │ │ ├── QCKDSL.h │ │ ├── QCKDSL.m │ │ ├── World+DSL.h │ │ └── World+DSL.swift │ │ ├── ErrorUtility.swift │ │ ├── Example.swift │ │ ├── ExampleGroup.swift │ │ ├── ExampleMetadata.swift │ │ ├── Filter.swift │ │ ├── Hooks │ │ ├── Closures.swift │ │ ├── ExampleHooks.swift │ │ ├── HooksPhase.swift │ │ └── SuiteHooks.swift │ │ ├── NSBundle+CurrentTestBundle.swift │ │ ├── NSString+QCKSelectorName.h │ │ ├── NSString+QCKSelectorName.m │ │ ├── Quick.h │ │ ├── QuickSelectedTestSuiteBuilder.swift │ │ ├── QuickSpec.h │ │ ├── QuickSpec.m │ │ ├── QuickTestSuite.swift │ │ ├── String+FileName.swift │ │ ├── World.h │ │ ├── World.swift │ │ └── XCTestSuite+QuickTestSuiteBuilder.m └── Target Support Files │ ├── Nimble │ ├── Info.plist │ ├── Nimble-dummy.m │ ├── Nimble-prefix.pch │ ├── Nimble-umbrella.h │ ├── Nimble.modulemap │ └── Nimble.xcconfig │ ├── Pods-CIFilterKit │ ├── Info.plist │ ├── Pods-CIFilterKit-acknowledgements.markdown │ ├── Pods-CIFilterKit-acknowledgements.plist │ ├── Pods-CIFilterKit-dummy.m │ ├── Pods-CIFilterKit-frameworks.sh │ ├── Pods-CIFilterKit-resources.sh │ ├── Pods-CIFilterKit-umbrella.h │ ├── Pods-CIFilterKit.debug.xcconfig │ ├── Pods-CIFilterKit.modulemap │ └── Pods-CIFilterKit.release.xcconfig │ ├── Pods-CIFilterKitTests │ ├── Info.plist │ ├── Pods-CIFilterKitTests-acknowledgements.markdown │ ├── Pods-CIFilterKitTests-acknowledgements.plist │ ├── Pods-CIFilterKitTests-dummy.m │ ├── Pods-CIFilterKitTests-frameworks.sh │ ├── Pods-CIFilterKitTests-resources.sh │ ├── Pods-CIFilterKitTests-umbrella.h │ ├── Pods-CIFilterKitTests.debug.xcconfig │ ├── Pods-CIFilterKitTests.modulemap │ └── Pods-CIFilterKitTests.release.xcconfig │ ├── Pods-ExampleApp │ ├── Info.plist │ ├── Pods-ExampleApp-acknowledgements.markdown │ ├── Pods-ExampleApp-acknowledgements.plist │ ├── Pods-ExampleApp-dummy.m │ ├── Pods-ExampleApp-frameworks.sh │ ├── Pods-ExampleApp-resources.sh │ ├── Pods-ExampleApp-umbrella.h │ ├── Pods-ExampleApp.debug.xcconfig │ ├── Pods-ExampleApp.modulemap │ └── Pods-ExampleApp.release.xcconfig │ ├── Pods-ExampleAppTests │ ├── Info.plist │ ├── Pods-ExampleAppTests-acknowledgements.markdown │ ├── Pods-ExampleAppTests-acknowledgements.plist │ ├── Pods-ExampleAppTests-dummy.m │ ├── Pods-ExampleAppTests-frameworks.sh │ ├── Pods-ExampleAppTests-resources.sh │ ├── Pods-ExampleAppTests-umbrella.h │ ├── Pods-ExampleAppTests.debug.xcconfig │ ├── Pods-ExampleAppTests.modulemap │ └── Pods-ExampleAppTests.release.xcconfig │ └── Quick │ ├── Info.plist │ ├── Quick-dummy.m │ ├── Quick-prefix.pch │ ├── Quick-umbrella.h │ ├── Quick.modulemap │ └── Quick.xcconfig ├── README.md └── filter.png /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/.DS_Store -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: swift 2 | osx_image: xcode7.2 3 | xcode_workspace: CIFilterKit.xcworkspace 4 | xcode_scheme: CIFilterKit 5 | xcode_sdk: iphonesimulator9.3 6 | -------------------------------------------------------------------------------- /CIFilterKit.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "CIFilterKit" 4 | s.version = "0.1.0" 5 | s.summary = "A functional, composable wrapper for Core Image." 6 | 7 | s.description = <<-DESC 8 | Inspired by the "Wrapping Core Image" chapter of [Functional Programming in Swift](http://www.objc.io/books/fpinswift/). CIFilterKit makes working with Core Image filters safer and simpler. 9 | DESC 10 | 11 | s.homepage = "https://github.com/jefflovejapan/CIFilterKit.git" 12 | s.license = { :type => "MIT", :file => "LICENSE" } 13 | 14 | 15 | s.author = { "Jeffrey Blagdon" => "jeffblagdon@gmail.com" } 16 | s.social_media_url = "http://twitter.com/blagdon" 17 | s.platform = :ios, "8.0" 18 | 19 | s.source = { :git => "https://github.com/jefflovejapan/CIFilterKit.git", :tag => s.version.to_s } 20 | s.source_files = "CIFilterKit", "CIFilterKit/*" 21 | s.requires_arc = true 22 | 23 | end 24 | -------------------------------------------------------------------------------- /CIFilterKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CIFilterKit.xcodeproj/project.xcworkspace/xcuserdata/jeff.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/CIFilterKit.xcodeproj/project.xcworkspace/xcuserdata/jeff.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CIFilterKit.xcodeproj/xcuserdata/jeff.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CIFilterKit.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | ExampleApp.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 1FD8820D1B212C20000CC676 21 | 22 | primary 23 | 24 | 25 | 1FD882181B212C20000CC676 26 | 27 | primary 28 | 29 | 30 | 1FD8822D1B212C83000CC676 31 | 32 | primary 33 | 34 | 35 | 1FD882411B212C83000CC676 36 | 37 | primary 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /CIFilterKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CIFilterKit/BlurFilters.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BlurFilters.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/16/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | - parameter inputRadius: The size of the blur to be applied. Default value is 10.0. 13 | - returns: A closure of type `Filter` 14 | */ 15 | 16 | public func GaussianBlur(inputRadius: Double?) -> Filter { 17 | return { image in 18 | var parameters: Parameters = [ 19 | kCIInputImageKey: image 20 | ] 21 | if let radius = inputRadius { 22 | parameters[kCIInputRadiusKey] = radius 23 | } 24 | let filter = CIFilter(name: FilterName.GaussianBlur.rawValue, withInputParameters: parameters) 25 | return filter?.outputImage 26 | } 27 | } 28 | 29 | /** 30 | - parameter options: An instance of `MotionBlurOptions` 31 | - returns: A closure of type `Filter` 32 | */ 33 | 34 | public func MotionBlur(options: MotionBlurOptions) -> Filter { 35 | return { image in 36 | let parameters = [ 37 | kCIInputImageKey: image, 38 | kCIInputRadiusKey: options.inputRadius, 39 | kCIInputAngleKey: options.inputAngle 40 | ] 41 | let filter = CIFilter(name: FilterName.MotionBlur.rawValue, withInputParameters: parameters) 42 | return filter?.outputImage 43 | } 44 | } 45 | 46 | /** 47 | - parameter options: An instance of `ZoomBlurOptions` 48 | - returns: A closure of type `Filter` 49 | */ 50 | 51 | public func ZoomBlur(options: ZoomBlurOptions) -> Filter { 52 | return { image in 53 | let parameters = [ 54 | kCIInputImageKey: image, 55 | kCIInputCenterKey: options.inputCenter.vector(), 56 | kCIInputRadiusKey: options.inputRadius, 57 | ] 58 | let filter = CIFilter(name: FilterName.ZoomBlur.rawValue, withInputParameters: parameters) 59 | return filter?.outputImage 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /CIFilterKit/CIFilterKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // CIFilterKit.h 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 6/4/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for CIFilterKit. 12 | FOUNDATION_EXPORT double CIFilterKitVersionNumber; 13 | 14 | //! Project version string for CIFilterKit. 15 | FOUNDATION_EXPORT const unsigned char CIFilterKitVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /CIFilterKit/Gradients.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Gradients.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/28/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | - parameter options: An instance of `GaussianGradientOptions` 13 | - returns: The output `CIImage` 14 | */ 15 | 16 | public func GaussianGradient(options: GaussianGradientOptions) -> CIImage? { 17 | let parameters: Parameters = [ 18 | kCIInputCenterKey: options.inputCenter.vector(), 19 | "inputColor0": options.inputColor0, 20 | "inputColor1": options.inputColor1, 21 | kCIInputRadiusKey: options.inputRadius 22 | ] 23 | let filter = CIFilter(name:FilterName.GaussianGradient.rawValue, withInputParameters:parameters) 24 | return filter?.outputImage 25 | } 26 | 27 | /** 28 | - parameter options: An instance of `LinearGradientOptions` 29 | - returns: The output `CIImage` 30 | */ 31 | 32 | public func LinearGradient(options: LinearGradientOptions) -> CIImage? { 33 | let parameters: Parameters = [ 34 | "inputPoint0": options.inputPoint0.vector(), 35 | "inputPoint1": options.inputPoint1.vector(), 36 | "inputColor0": options.inputColor0, 37 | "inputColor1": options.inputColor1 38 | ] 39 | let filter = CIFilter(name:FilterName.LinearGradient.rawValue, withInputParameters:parameters) 40 | return filter?.outputImage 41 | } 42 | 43 | /** 44 | - parameter options: An instance of `RadialGradientOptions` 45 | - returns: The output `CIImage` 46 | */ 47 | 48 | public func RadialGradient(options: RadialGradientOptions) -> CIImage? { 49 | let parameters = [ 50 | kCIInputCenterKey: options.inputCenter.vector(), 51 | "inputRadius0": options.inputRadius0, 52 | "inputRadius1": options.inputRadius1, 53 | "inputColor0": options.inputColor0, 54 | "inputColor1": options.inputColor1 55 | ] 56 | let aFilter = CIFilter(name:FilterName.RadialGradient.rawValue, withInputParameters: parameters) 57 | return aFilter?.outputImage 58 | } 59 | 60 | /** 61 | - parameter options: An instance of `SmoothLinearGradientOptions` 62 | - returns: The output `CIImage` 63 | */ 64 | 65 | public func SmoothLinearGradient(options: SmoothLinearGradientOptions) -> CIImage? { 66 | let parameters = [ 67 | "inputPoint0": options.inputPoint0.vector(), 68 | "inputPoint1": options.inputPoint1.vector(), 69 | "inputColor0": options.inputColor0, 70 | "inputColor1": options.inputColor1 71 | ] 72 | let aFilter = CIFilter(name: FilterName.SmoothLinearGradient.rawValue, withInputParameters: parameters) 73 | return aFilter?.outputImage 74 | } -------------------------------------------------------------------------------- /CIFilterKit/HalftoneEffectFilters.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HalftoneEffectFilters.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/28/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | - parameter options: An instance of `CircularScreenOptions` 13 | - returns: A closure of type `Filter` 14 | */ 15 | 16 | public func CircularScreen(options: CircularScreenOptions) -> Filter { 17 | return { image in 18 | let parameters = [ 19 | kCIInputImageKey: image, 20 | kCIInputCenterKey: options.inputCenter.vector(), 21 | kCIInputWidthKey: options.inputWidth, 22 | kCIInputSharpnessKey: options.inputSharpness 23 | ] 24 | let filter = CIFilter(name: FilterName.CircularScreen.rawValue, withInputParameters: parameters) 25 | return filter?.outputImage 26 | } 27 | } 28 | 29 | /** 30 | - parameter options: An instance of `DotScreenOptions` 31 | - returns: A closure of type `Filter` 32 | */ 33 | 34 | public func DotScreen(options: DotScreenOptions) -> Filter { 35 | return { image in 36 | let parameters = [ 37 | kCIInputImageKey: image, 38 | kCIInputCenterKey: options.inputCenter.vector(), 39 | kCIInputAngleKey: options.inputAngle, 40 | kCIInputWidthKey: options.inputWidth, 41 | kCIInputSharpnessKey: options.inputSharpness 42 | ] 43 | let filter = CIFilter(name: FilterName.DotScreen.rawValue, withInputParameters: parameters) 44 | return filter?.outputImage 45 | } 46 | } 47 | 48 | /** 49 | - parameter options: An instance of `HatchedScreenOptions` 50 | - returns: A closure of type `Filter` 51 | */ 52 | 53 | public func HatchedScreen(options: HatchedScreenOptions) -> Filter { 54 | return { image in 55 | let parameters = [ 56 | kCIInputImageKey: image, 57 | kCIInputCenterKey: options.inputCenter.vector(), 58 | kCIInputAngleKey: options.inputAngle, 59 | kCIInputWidthKey: options.inputWidth, 60 | kCIInputSharpnessKey: options.inputSharpness 61 | ] 62 | let filter = CIFilter(name: FilterName.HatchedScreen.rawValue, withInputParameters: parameters) 63 | return filter?.outputImage 64 | } 65 | } 66 | 67 | /** 68 | - parameter options: An instance of `LineScreenOptions` 69 | - returns: A closure of type `Filter` 70 | */ 71 | 72 | public func LineScreen(options: LineScreenOptions) -> Filter { 73 | return { image in 74 | let parameters = [ 75 | kCIInputImageKey: image, 76 | kCIInputCenterKey: options.inputCenter.vector(), 77 | kCIInputAngleKey: options.inputAngle, 78 | kCIInputWidthKey: options.inputWidth, 79 | kCIInputSharpnessKey: options.inputSharpness 80 | ] 81 | let filter = CIFilter(name: FilterName.LineScreen.rawValue, withInputParameters: parameters) 82 | return filter?.outputImage 83 | } 84 | } -------------------------------------------------------------------------------- /CIFilterKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CIFilterKit/ReductionFilters.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ReductionFilters.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 6/2/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | - parameter options: An instance of `AreaHistogramOptions` 13 | - returns: A closure of type `Filter` 14 | */ 15 | 16 | public func AreaHistogram(options: AreaHistogramOptions) -> Filter { 17 | return { image in 18 | let parameters = [ 19 | kCIInputImageKey: image, 20 | kCIInputExtentKey: options.inputExtent.vector(), 21 | "inputCount": options.inputCount, 22 | kCIInputScaleKey: options.inputScale 23 | ] 24 | let filter = CIFilter(name:FilterName.AreaHistogram.rawValue, withInputParameters: parameters) 25 | return filter?.outputImage 26 | } 27 | } 28 | 29 | /** 30 | - parameter options: An instance of `HistogramDisplayOptions` 31 | - returns: A closure of type `Filter` 32 | */ 33 | 34 | public func HistogramDisplayFilter(options: HistogramDisplayOptions) -> Filter { 35 | return { image in 36 | let parameters = [ 37 | kCIInputImageKey: image, 38 | "inputHeight": options.inputHeight, 39 | "inputHighLimit": options.inputHighLimit, 40 | "inputLowLimit": options.inputLowLimit 41 | ] 42 | let filter = CIFilter(name:FilterName.HistogramDisplayFilter.rawValue, withInputParameters: parameters) 43 | return filter?.outputImage 44 | } 45 | } -------------------------------------------------------------------------------- /CIFilterKit/SharpenFilters.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SharpenFilters.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 6/2/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | - parameter inputSharpness: The amount of sharpening to apply 13 | - returns: A closure of type `Filter` 14 | */ 15 | 16 | public func SharpenLuminance(inputSharpness:Double?) -> Filter { 17 | return { image in 18 | var parameters: Parameters = [ 19 | kCIInputImageKey: image 20 | ] 21 | if let sharpness = inputSharpness { 22 | parameters[kCIInputSharpnessKey] = sharpness 23 | } 24 | let filter = CIFilter(name: FilterName.SharpenLuminance.rawValue, withInputParameters: parameters) 25 | return filter?.outputImage 26 | } 27 | } 28 | 29 | /** 30 | - parameter options: An instance of `UnsharpMaskOptions` 31 | - returns: A closure of type `Filter` 32 | */ 33 | 34 | public func UnsharpMask(options: UnsharpMaskOptions) -> Filter { 35 | return { image in 36 | let parameters = [ 37 | kCIInputImageKey: image, 38 | kCIInputRadiusKey: options.inputRadius, 39 | kCIInputIntensityKey: options.inputIntensity 40 | ] 41 | let filter = CIFilter(name: FilterName.UnsharpMask.rawValue, withInputParameters: parameters) 42 | return filter?.outputImage 43 | } 44 | } -------------------------------------------------------------------------------- /CIFilterKitTests/BlurFilterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CIFilterKitTests.swift 3 | // CIFilterKitTests 4 | // 5 | // Created by Jeffrey Blagdon on 5/16/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | class BlurFilterTests: QuickSpec { 14 | override func spec() { 15 | var kevinBaconImg : UIImage! 16 | var kevinBaconCiImage: CIImage! 17 | beforeEach { 18 | let filePath = NSBundle(forClass: self.classForCoder).pathForResource("bacon", ofType: "jpg")! 19 | let imgData = NSData(contentsOfFile: filePath)! 20 | kevinBaconImg = UIImage(data: imgData)! 21 | expect(kevinBaconImg).toNot(beNil()) 22 | kevinBaconCiImage = CIImage(CGImage: kevinBaconImg.CGImage!) 23 | expect(kevinBaconCiImage).toNot(beNil()) 24 | } 25 | describe("The GaussianBlur filter") { 26 | it("should be able to filter a picture of Kevin Bacon") { 27 | let aFilter = GaussianBlur(0.5) 28 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 29 | } 30 | } 31 | describe("The MotionBlur filter") { 32 | it("should be able to filter a picture of Kevin Bacon") { 33 | let aFilter = MotionBlur(MotionBlurOptions()) 34 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 35 | } 36 | } 37 | describe("The ZoomBlur filter") { 38 | it("should be able to filter a picture of Kevin Bacon") { 39 | let aFilter = ZoomBlur(ZoomBlurOptions()) 40 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /CIFilterKitTests/ColorAdjustmentFilterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorAdjustmentFilterTests.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/25/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | 14 | class ColorAdjustmentFilterTests: QuickSpec { 15 | override func spec() { 16 | var kevinBaconImg : UIImage! 17 | var kevinBaconCiImage: CIImage! 18 | beforeEach { 19 | let filePath = NSBundle(forClass: self.classForCoder).pathForResource("bacon", ofType: "jpg")! 20 | let imgData = NSData(contentsOfFile: filePath)! 21 | kevinBaconImg = UIImage(data: imgData)! 22 | expect(kevinBaconImg).toNot(beNil()) 23 | kevinBaconCiImage = CIImage(CGImage: kevinBaconImg.CGImage!) 24 | expect(kevinBaconCiImage).toNot(beNil()) 25 | } 26 | describe("The ColorControls filter") { 27 | it("Should be able to filter a picture of Kevin Bacon") { 28 | let aFilter = ColorControls(ColorControlsOptions()) 29 | let outImg = aFilter(kevinBaconCiImage) 30 | expect(outImg).toNot(beNil()) 31 | } 32 | } 33 | describe("The ColorMatrix filter") { 34 | it("Should be able to filter a picture of Kevin Bacon") { 35 | let aFilter = ColorMatrix(ColorMatrixOptions()) 36 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 37 | } 38 | } 39 | describe("The ExposureAdjust filter") { 40 | it("Should be able to filter a picture of Kevin Bacon") { 41 | let aFilter = ExposureAdjust(-0.2) 42 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 43 | } 44 | } 45 | describe("The GammaAdjust filter") { 46 | it("Should be able to filter a picture of Kevin Bacon") { 47 | let aFilter = GammaAdjust(0.5) 48 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 49 | } 50 | } 51 | describe("The HueAdjust filter") { 52 | it("Should be able to filter a picture of Kevin Bacon") { 53 | let aFilter = HueAdjust(-0.5) 54 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 55 | } 56 | } 57 | describe("The LinearToSRGBToneCurve filter") { 58 | it("Should be able to filter a picture of Kevin Bacon") { 59 | let aFilter = LinearToSRGBToneCurve() 60 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 61 | } 62 | } 63 | describe("The SRGBToneCurveToLinear filter") { 64 | it("Should be able to filter a picture of Kevin Bacon") { 65 | let aFilter = SRGBToneCurveToLinear() 66 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 67 | } 68 | } 69 | describe("The TemperatureAndTint filter") { 70 | it("Should be able to filter a picture of Kevin Bacon") { 71 | let aFilter = TemperatureAndTint(TemperatureAndTintOptions()) 72 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 73 | } 74 | } 75 | describe("The ToneCurve filter") { 76 | it("Should be able to filter a picture of Kevin Bacon") { 77 | let aFilter = ToneCurve(ToneCurveOptions()) 78 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 79 | } 80 | } 81 | describe("The Vibrance filter") { 82 | it("Should be able to filter a picture of Kevin Bacon") { 83 | let aFilter = Vibrance(0.5) 84 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 85 | } 86 | } 87 | describe("The WhitePointAdjust filter") { 88 | it("Should be able to filter a picture of Kevin Bacon") { 89 | let aFilter = WhitePointAdjust(nil) 90 | let outImg = aFilter(kevinBaconCiImage) 91 | expect(outImg).toNot(beNil()) 92 | } 93 | } 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /CIFilterKitTests/GeneratorTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GeneratorTests.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/27/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | class GeneratorTests: QuickSpec { 14 | override func spec() { 15 | describe("The AztecCodeGenerator filter") { 16 | it("should be able to generate an image") { 17 | let data = "o hai Leslie".dataUsingEncoding(NSUTF8StringEncoding) 18 | var outImg: CIImage? 19 | if let data = data { 20 | outImg = AztecCodeGenerator(data, options:AztecCodeGeneratorOptions()) 21 | } 22 | expect(outImg).toNot(beNil()) 23 | } 24 | } 25 | describe("The CheckerboardGenerator filter") { 26 | it("should be able to generate an image") { 27 | let options = CheckerboardGeneratorOptions(inputCenter:XYPosition(x: 150.0, y: 150.0), inputColor0:CIColor(red: 0.5, green: 0.9, blue: 0.1), inputColor1:CIColor(red: 0.0, green: 0.4, blue: 0.8), inputWidth: 300.0, inputSharpness: 1.0) 28 | let outImg = CheckerboardGenerator(options) 29 | expect(outImg).toNot(beNil()) 30 | } 31 | } 32 | describe("The Code128BarcodeGenerator filter") { 33 | it("should be able to generate an image") { 34 | let outImg = Code128BarcodeGenerator("blahblahsomemessage".dataUsingEncoding(NSASCIIStringEncoding)!, inputQuietSpace:nil) 35 | expect(outImg).toNot(beNil()) 36 | } 37 | } 38 | describe("The ConstantColorGenerator filter") { 39 | it("should be able to generate an image") { 40 | let outImg = ConstantColorGenerator(CIColor(red: 0.2, green: 0.7, blue: 0.8)) 41 | expect(outImg).toNot(beNil()) 42 | } 43 | } 44 | describe("The QRCodeGenerator filter") { 45 | it("should be able to generate an image") { 46 | let outImg = QRCodeGenerator("Good morning".dataUsingEncoding(NSUTF8StringEncoding)!, inputCorrectionLevel:.M) 47 | expect(outImg).toNot(beNil()) 48 | } 49 | } 50 | describe("The RandomGenerator filter") { 51 | it("should be able to generate an image") { 52 | let outImg = RandomGenerator() 53 | expect(outImg).toNot(beNil()) 54 | } 55 | } 56 | describe("The StarShineGenerator filter") { 57 | it("should be able to generate an image") { 58 | let options = StarShineGeneratorOptions() 59 | let outImg = StarShineGenerator(options) 60 | expect(outImg).toNot(beNil()) 61 | } 62 | } 63 | describe("The StripesGenerator filter") { 64 | it("should be able to generate an image") { 65 | let options = StripesGeneratorOptions(inputCenter:XYPosition(x: 200.0, y: 200.0), inputColor0: CIColor(red: 0.2, green: 0.2, blue: 0.6), inputColor1: CIColor(red: 0.9, green: 0.4, blue: 0.4), inputWidth: 90.0, inputSharpness: 0.6) 66 | let outImg = StripesGenerator(options) 67 | expect(outImg).toNot(beNil()) 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /CIFilterKitTests/GradientTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GradientTests.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/28/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | class GradientTests: QuickSpec { 14 | override func spec() { 15 | describe("The GaussianGradient filter") { 16 | it("should be able to generate an image") { 17 | let options = GaussianGradientOptions(inputCenter: XYPosition(x: 150.0, y: 300.0), inputColor0: CIColor(red: 0.2, green: 0.8, blue: 0.7), inputColor1: CIColor(red: 0.8, green: 0.2, blue: 0.1), inputRadius: 200.0) 18 | let outImg = GaussianGradient(options) 19 | expect(outImg).toNot(beNil()) 20 | } 21 | } 22 | describe("The LinearGradient filter") { 23 | it("should be able to generate an image") { 24 | let options = LinearGradientOptions(inputPoint0: XYPosition(x: 150.0, y: 300.0),inputPoint1: XYPosition(x: 600.0, y: 800.0), inputColor0: CIColor(red: 0.2, green: 0.8, blue: 0.7), inputColor1: CIColor(red: 0.8, green: 0.2, blue: 0.1)) 25 | let outImg = LinearGradient(options) 26 | expect(outImg).toNot(beNil()) 27 | } 28 | } 29 | describe("The RadialGradient filter") { 30 | it("should be able to generate an image") { 31 | let options = RadialGradientOptions(inputCenter: XYPosition(x: 150.0, y: 300.0), inputRadius0: 300.0, inputRadius1: 800.0, inputColor0: CIColor(red: 0.2, green: 0.8, blue: 0.7), inputColor1: CIColor(red: 0.8, green: 0.2, blue: 0.1)) 32 | let outImg = RadialGradient(options) 33 | expect(outImg).toNot(beNil()) 34 | } 35 | } 36 | describe("The SmoothLinearGradient filter") { 37 | it("should be able to generate an image") { 38 | var options = SmoothLinearGradientOptions(inputPoint0: XYPosition(x: 150.0, y: 300.0),inputPoint1: XYPosition(x: 450.0, y: 900.0), inputColor0: CIColor(red: 0.2, green: 0.8, blue: 0.7), inputColor1: CIColor(red: 0.8, green: 0.2, blue: 0.1)) 39 | options.inputPoint0 = XYPosition(x: 20.0, y: 200.0) 40 | let outImg = SmoothLinearGradient(options) 41 | expect(outImg).toNot(beNil()) 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /CIFilterKitTests/HalftoneEffectFilterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HalftoneEffectFilterTests.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/28/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | class HalftoneEffectFilterTests: QuickSpec { 14 | override func spec() { 15 | var kevinBaconImg : UIImage! 16 | var kevinBaconCiImage: CIImage! 17 | beforeEach { 18 | let filePath = NSBundle(forClass: self.classForCoder).pathForResource("bacon", ofType: "jpg")! 19 | let imgData = NSData(contentsOfFile: filePath)! 20 | kevinBaconImg = UIImage(data: imgData)! 21 | expect(kevinBaconImg).toNot(beNil()) 22 | kevinBaconCiImage = CIImage(CGImage: kevinBaconImg.CGImage!) 23 | expect(kevinBaconCiImage).toNot(beNil()) 24 | } 25 | describe("The CircularScreen filter") { 26 | it("should be able to filter a picture of Kevin Bacon") { 27 | let options = CircularScreenOptions(inputCenter:XYPosition(x: 300.0, y: 600.0), inputWidth: 400.0, inputSharpness: 0.75) 28 | let aFilter = CircularScreen(options) 29 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 30 | } 31 | } 32 | describe("The DotScreen filter") { 33 | it("should be able to filter a picture of Kevin Bacon") { 34 | let options = DotScreenOptions(inputCenter:XYPosition(x: 300.0, y: 600.0), inputAngle:0.70, inputWidth: 400.0, inputSharpness: 0.75) 35 | let aFilter = DotScreen(options) 36 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 37 | } 38 | } 39 | describe("The HatchedScreen filter") { 40 | it("should be able to filter a picture of Kevin Bacon") { 41 | let options = HatchedScreenOptions(inputCenter:XYPosition(x: 300.0, y: 600.0), inputAngle:0.70, inputWidth: 400.0, inputSharpness: 0.75) 42 | let aFilter = HatchedScreen(options) 43 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 44 | } 45 | } 46 | describe("The LineScreen filter") { 47 | it("should be able to filter a picture of Kevin Bacon") { 48 | let options = LineScreenOptions(inputCenter:XYPosition(x: 300.0, y: 600.0), inputAngle:0.70, inputWidth: 400.0, inputSharpness: 0.75) 49 | let aFilter = LineScreen(options) 50 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /CIFilterKitTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /CIFilterKitTests/MiscFunctionTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MiscFunctionTests.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 5/25/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | class MiscFunctionTests: QuickSpec { 14 | override func spec() { 15 | describe("The isCubeRootable function") { 16 | it("Should give the right answer for a variety of integers") { 17 | expect(countIsCube(8)).to(beTruthy()) 18 | expect(countIsCube(1)).to(beTruthy()) 19 | expect(countIsCube(27)).to(beTruthy()) 20 | expect(countIsCube(-1)).to(beFalsy()) 21 | expect(countIsCube(0)).to(beFalsy()) 22 | expect(countIsCube(64)).to(beTruthy()) 23 | expect(countIsCube(262144)).to(beTruthy()) 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /CIFilterKitTests/ReductionFilterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ReductionFilterTests.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 6/2/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | class ReductionFilterTests: QuickSpec { 14 | override func spec() { 15 | var kevinBaconImg : UIImage! 16 | var kevinBaconCiImage: CIImage! 17 | beforeEach { 18 | let filePath = NSBundle(forClass: self.classForCoder).pathForResource("bacon", ofType: "jpg")! 19 | let imgData = NSData(contentsOfFile: filePath)! 20 | kevinBaconImg = UIImage(data: imgData)! 21 | expect(kevinBaconImg).toNot(beNil()) 22 | kevinBaconCiImage = CIImage(CGImage: kevinBaconImg.CGImage!) 23 | expect(kevinBaconCiImage).toNot(beNil()) 24 | } 25 | describe("The AreaHistogram filter") { 26 | it("should be able to filter a picture of Kevin Bacon") { 27 | let options = AreaHistogramOptions(inputExtent: kevinBaconCiImage.extent, inputCount: 256, inputScale: 0.7) 28 | let aFilter = AreaHistogram(options) 29 | 30 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 31 | } 32 | } 33 | describe("The HistogramDisplayFilter filter") { 34 | it("should be able to filter a histogram of a picture of Kevin Bacon") { 35 | let options = AreaHistogramOptions(inputExtent: kevinBaconCiImage.extent, inputCount: 256, inputScale: 1.0) 36 | let histogramData = AreaHistogram(options) 37 | var displayOptions = HistogramDisplayOptions() 38 | displayOptions.inputHeight = 500.0 39 | let histogramDisplay = HistogramDisplayFilter(displayOptions) 40 | let histogram = histogramData |>> histogramDisplay 41 | expect(histogram(kevinBaconCiImage)).toNot(beNil()) 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /CIFilterKitTests/SharpenFilterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SharpenFilterTests.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 6/2/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | import CIFilterKit 12 | 13 | class SharpenFilterTests: QuickSpec { 14 | override func spec() { 15 | var kevinBaconImg : UIImage! 16 | var kevinBaconCiImage: CIImage! 17 | beforeEach { 18 | let filePath = NSBundle(forClass: self.classForCoder).pathForResource("bacon", ofType: "jpg")! 19 | let imgData = NSData(contentsOfFile: filePath)! 20 | kevinBaconImg = UIImage(data: imgData)! 21 | expect(kevinBaconImg).toNot(beNil()) 22 | kevinBaconCiImage = CIImage(CGImage: kevinBaconImg.CGImage!) 23 | expect(kevinBaconCiImage).toNot(beNil()) 24 | } 25 | describe("The SharpenLuminance filter") { 26 | it("should be able to filter a picture of Kevin Bacon") { 27 | let aFilter = SharpenLuminance(15.0) 28 | expect(aFilter(kevinBaconCiImage)).toNot(beNil()) 29 | } 30 | } 31 | describe("The UnsharpMask filter") { 32 | it("should be able to filter a picture of Kevin Bacon") { 33 | let options = UnsharpMaskOptions(inputRadius: 50.0, inputIntensity: 75.0) 34 | let aFilter = UnsharpMask(options) 35 | let outImg = aFilter(kevinBaconCiImage) 36 | expect(outImg).toNot(beNil()) 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /CIFilterKitTests/bacon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/CIFilterKitTests/bacon.jpg -------------------------------------------------------------------------------- /CIFilterKitTests/banana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/CIFilterKitTests/banana.png -------------------------------------------------------------------------------- /CIFilterKitTests/rhinoceros.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/CIFilterKitTests/rhinoceros.jpg -------------------------------------------------------------------------------- /CIFilterKitTests/wutang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/CIFilterKitTests/wutang.png -------------------------------------------------------------------------------- /ExampleApp/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ExampleApp 4 | // 5 | // Created by Jeffrey Blagdon on 6/4/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ExampleApp/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ExampleApp/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ExampleApp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ExampleApp/Images.xcassets/kevin.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "bacon-1.jpg" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "bacon.jpg" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x", 16 | "filename" : "bacon-2.jpg" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ExampleApp/Images.xcassets/kevin.imageset/bacon-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/ExampleApp/Images.xcassets/kevin.imageset/bacon-1.jpg -------------------------------------------------------------------------------- /ExampleApp/Images.xcassets/kevin.imageset/bacon-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/ExampleApp/Images.xcassets/kevin.imageset/bacon-2.jpg -------------------------------------------------------------------------------- /ExampleApp/Images.xcassets/kevin.imageset/bacon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/ExampleApp/Images.xcassets/kevin.imageset/bacon.jpg -------------------------------------------------------------------------------- /ExampleApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ExampleApp/Oranization.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Organization.swift 3 | // CIFilterKit 4 | // 5 | // Created by Jeffrey Blagdon on 6/10/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CIFilterKit 11 | 12 | let BlurFilters: Array = [.GaussianBlur, .MotionBlur, .ZoomBlur] 13 | let ColorAdjustmentFilters: Array = [.ColorControls, .ColorMatrix, .ExposureAdjust, .GammaAdjust, .HueAdjust, .LinearToSRGBToneCurve, .SRGBToneCurveToLinear, .TemperatureAndTint, .ToneCurve, .Vibrance, .WhitePointAdjust] 14 | let ColorEffectFilters: Array = [.ColorClamp, .ColorCrossPolynomial, .ColorCube, .ColorCubeWithColorSpace, .ColorInvert, .ColorMap, .ColorMonochrome, .ColorPolynomial, .ColorPosterize, .FalseColor, .MaskToAlpha, .MaximumComponent, .MinimumComponent, .PhotoEffectChrome, .PhotoEffectFade, .PhotoEffectInstant, .PhotoEffectMono, .PhotoEffectNoir, .PhotoEffectProcess, .PhotoEffectTonal, .PhotoEffectTransfer, .SepiaTone, .Vignette, .VignetteEffect] 15 | let CompositeOperationFilters: Array = [.AdditionCompositing, .ColorBlendMode, .ColorBurnBlendMode, .ColorDodgeBlendMode, .DarkenBlendMode, .DifferenceBlendMode, .DivideBlendMode, .ExclusionBlendMode, .HardLightBlendMode, .HueBlendMode, .LightenBlendMode, .LinearBurnBlendMode, .LinearDodgeBlendMode, .LuminosityBlendMode, .MaximumCompositing, .MinimumCompositing, .MultiplyBlendMode, .MultiplyCompositing, .OverlayBlendMode, .PinLightBlendMode, .SaturationBlendMode, .ScreenBlendMode, .SoftLightBlendMode, .SourceAtopCompositing, .SourceInCompositing, .SourceOutCompositing, .SourceOverCompositing, .SubtractBlendMode] 16 | let DistortionEffectFilters: Array = [.BumpDistortion, .BumpDistortionLinear, .CircleSplashDistortion, .GlassDistortion, .HoleDistortion, .LightTunnel, .PinchDistortion, .TwirlDistortion, .VortexDistortion] 17 | let GeometryAdjustFilters: Array = [.AffineTransform, .Crop, .LanczosScaleTransform, .PerspectiveCorrection, .PerspectiveTile, .PerspectiveTransform, .PerspectiveTransformWithExtent, .StraightenFilter] 18 | let HalftoneEffectFilters: Array = [.CircularScreen, .DotScreen, .HatchedScreen, .LineScreen] 19 | let ReductionFilters: Array = [.AreaHistogram, .HistogramDisplayFilter] 20 | let SharpenFilters: Array = [.SharpenLuminance, .UnsharpMask] 21 | let StylizeFilters: Array = [.BlendWithAlphaMask, .BlendWithMask, .Bloom, .Convolution3X3, .Convolution5X5, .Convolution9Horizontal, .Convolution9Vertical, .Gloom, .HighlightShadowAdjust, .Pixellate] 22 | let TileEffectFilters: Array = [.AffineClamp, .AffineTile, .EightfoldReflectedTile, .FourfoldReflectedTile, .FourfoldRotatedTile, .FourfoldTranslatedTile, .GlideReflectedTile, .SixfoldReflectedTile, .SixfoldRotatedTile, .TriangleKaleidoscope, .TwelvefoldReflectedTile] 23 | 24 | 25 | let Gradients: Array = [.GaussianGradient, .LinearGradient, .RadialGradient, .SmoothLinearGradient] 26 | let Generators: Array = [.AztecCodeGenerator, .CheckerboardGenerator, .Code128BarcodeGenerator, .ConstantColorGenerator, .QRCodeGenerator, .RandomGenerator, .StarShineGenerator, .StripesGenerator] 27 | 28 | 29 | let TrueFilters = [BlurFilters, ColorAdjustmentFilters, ColorEffectFilters, CompositeOperationFilters, DistortionEffectFilters, GeometryAdjustFilters, HalftoneEffectFilters, ReductionFilters, SharpenFilters, StylizeFilters, TileEffectFilters] 30 | let GeneratorFilters = [Gradients, Generators] 31 | 32 | 33 | -------------------------------------------------------------------------------- /ExampleApp/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ExampleApp 4 | // 5 | // Created by Jeffrey Blagdon on 6/4/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CIFilterKit 11 | 12 | class ViewController: UIViewController { 13 | var filters: FilterStack? 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | let colorInvert = ColorInvert() 17 | let colorPosterize = ColorPosterize(nil) 18 | filters = [colorInvert, colorPosterize] 19 | } 20 | 21 | override func viewDidAppear(animated: Bool) { 22 | super.viewDidAppear(animated) 23 | var kevinBaconImg : UIImage! 24 | var kevinBaconCiImage: CIImage! 25 | kevinBaconImg = UIImage(named: "kevin") 26 | kevinBaconCiImage = CIImage(CGImage: kevinBaconImg.CGImage!) 27 | if let filters = filters, head = filters.first { 28 | let tail = Array(filters.dropFirst()) 29 | let cumulativeFilter = tail.reduce(head, combine: |>>) 30 | let outImg = cumulativeFilter(kevinBaconCiImage) 31 | guard let img = outImg else { 32 | return 33 | } 34 | 35 | let context = CIContext(options: nil) 36 | let cgImg = context.createCGImage(img, fromRect: img.extent) 37 | let imgView = (UIImageView(image: UIImage(CGImage: cgImg))) 38 | imgView.translatesAutoresizingMaskIntoConstraints = false 39 | imgView.contentMode = .ScaleAspectFill 40 | view.addSubview(imgView) 41 | view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("|[kevin]|", options: NSLayoutFormatOptions() , metrics: nil, views: ["kevin": imgView])) 42 | view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[kevin]|", options: NSLayoutFormatOptions() , metrics: nil, views: ["kevin": imgView])) 43 | 44 | } 45 | } 46 | 47 | override func didReceiveMemoryWarning() { 48 | super.didReceiveMemoryWarning() 49 | // Dispose of any resources that can be recreated. 50 | } 51 | 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /ExampleAppTests/ExampleAppTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleAppTests.swift 3 | // ExampleAppTests 4 | // 5 | // Created by Jeffrey Blagdon on 6/4/15. 6 | // Copyright (c) 2015 Jeffrey Blagdon. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class ExampleAppTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ExampleAppTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '6.0' 3 | 4 | use_frameworks! 5 | 6 | target 'CIFilterKit' do 7 | 8 | end 9 | 10 | target 'CIFilterKitTests' do 11 | pod 'Quick', '~> 0.9.1' 12 | pod 'Nimble', '~> 4.0.0' 13 | end 14 | 15 | target 'ExampleApp' do 16 | 17 | end 18 | 19 | target 'ExampleAppTests' do 20 | pod 'Quick', '~> 0.9.1' 21 | pod 'Nimble', '~> 4.0.0' 22 | end 23 | 24 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Nimble (4.0.0) 3 | - Quick (0.9.1) 4 | 5 | DEPENDENCIES: 6 | - Nimble (~> 4.0.0) 7 | - Quick (~> 0.9.1) 8 | 9 | SPEC CHECKSUMS: 10 | Nimble: 72bcc3e2f02242e6bfaaf8d9412ca7bfe3d8b417 11 | Quick: a5221fc21788b6aeda934805e68b061839bc3165 12 | 13 | PODFILE CHECKSUM: 346e8aeb08ddeabeafd93af3f9a93b93d2b29c22 14 | 15 | COCOAPODS: 1.0.0.beta.6 16 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Nimble (4.0.0) 3 | - Quick (0.9.1) 4 | 5 | DEPENDENCIES: 6 | - Nimble (~> 4.0.0) 7 | - Quick (~> 0.9.1) 8 | 9 | SPEC CHECKSUMS: 10 | Nimble: 72bcc3e2f02242e6bfaaf8d9412ca7bfe3d8b417 11 | Quick: a5221fc21788b6aeda934805e68b061839bc3165 12 | 13 | PODFILE CHECKSUM: 346e8aeb08ddeabeafd93af3f9a93b93d2b29c22 14 | 15 | COCOAPODS: 1.0.0.beta.6 16 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/AdapterProtocols.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Protocol for the assertion handler that Nimble uses for all expectations. 4 | public protocol AssertionHandler { 5 | func assert(assertion: Bool, message: FailureMessage, location: SourceLocation) 6 | } 7 | 8 | /// Global backing interface for assertions that Nimble creates. 9 | /// Defaults to a private test handler that passes through to XCTest. 10 | /// 11 | /// If XCTest is not available, you must assign your own assertion handler 12 | /// before using any matchers, otherwise Nimble will abort the program. 13 | /// 14 | /// @see AssertionHandler 15 | public var NimbleAssertionHandler: AssertionHandler = { () -> AssertionHandler in 16 | return isXCTestAvailable() ? NimbleXCTestHandler() : NimbleXCTestUnavailableHandler() 17 | }() 18 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift: -------------------------------------------------------------------------------- 1 | 2 | /// AssertionDispatcher allows multiple AssertionHandlers to receive 3 | /// assertion messages. 4 | /// 5 | /// @warning Does not fully dispatch if one of the handlers raises an exception. 6 | /// This is possible with XCTest-based assertion handlers. 7 | /// 8 | public class AssertionDispatcher: AssertionHandler { 9 | let handlers: [AssertionHandler] 10 | 11 | public init(handlers: [AssertionHandler]) { 12 | self.handlers = handlers 13 | } 14 | 15 | public func assert(assertion: Bool, message: FailureMessage, location: SourceLocation) { 16 | for handler in handlers { 17 | handler.assert(assertion, message: message, location: location) 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/AssertionRecorder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A data structure that stores information about an assertion when 4 | /// AssertionRecorder is set as the Nimble assertion handler. 5 | /// 6 | /// @see AssertionRecorder 7 | /// @see AssertionHandler 8 | public struct AssertionRecord: CustomStringConvertible { 9 | /// Whether the assertion succeeded or failed 10 | public let success: Bool 11 | /// The failure message the assertion would display on failure. 12 | public let message: FailureMessage 13 | /// The source location the expectation occurred on. 14 | public let location: SourceLocation 15 | 16 | public var description: String { 17 | return "AssertionRecord { success=\(success), message='\(message.stringValue)', location=\(location) }" 18 | } 19 | } 20 | 21 | /// An AssertionHandler that silently records assertions that Nimble makes. 22 | /// This is useful for testing failure messages for matchers. 23 | /// 24 | /// @see AssertionHandler 25 | public class AssertionRecorder : AssertionHandler { 26 | /// All the assertions that were captured by this recorder 27 | public var assertions = [AssertionRecord]() 28 | 29 | public init() {} 30 | 31 | public func assert(assertion: Bool, message: FailureMessage, location: SourceLocation) { 32 | assertions.append( 33 | AssertionRecord( 34 | success: assertion, 35 | message: message, 36 | location: location)) 37 | } 38 | } 39 | 40 | /// Allows you to temporarily replace the current Nimble assertion handler with 41 | /// the one provided for the scope of the closure. 42 | /// 43 | /// Once the closure finishes, then the original Nimble assertion handler is restored. 44 | /// 45 | /// @see AssertionHandler 46 | public func withAssertionHandler(tempAssertionHandler: AssertionHandler, closure: () throws -> Void) { 47 | let environment = NimbleEnvironment.activeInstance 48 | let oldRecorder = environment.assertionHandler 49 | let capturer = NMBExceptionCapture(handler: nil, finally: ({ 50 | environment.assertionHandler = oldRecorder 51 | })) 52 | environment.assertionHandler = tempAssertionHandler 53 | capturer.tryBlock { 54 | try! closure() 55 | } 56 | } 57 | 58 | /// Captures expectations that occur in the given closure. Note that all 59 | /// expectations will still go through to the default Nimble handler. 60 | /// 61 | /// This can be useful if you want to gather information about expectations 62 | /// that occur within a closure. 63 | /// 64 | /// @param silently expectations are no longer send to the default Nimble 65 | /// assertion handler when this is true. Defaults to false. 66 | /// 67 | /// @see gatherFailingExpectations 68 | public func gatherExpectations(silently silently: Bool = false, closure: () -> Void) -> [AssertionRecord] { 69 | let previousRecorder = NimbleEnvironment.activeInstance.assertionHandler 70 | let recorder = AssertionRecorder() 71 | let handlers: [AssertionHandler] 72 | 73 | if silently { 74 | handlers = [recorder] 75 | } else { 76 | handlers = [recorder, previousRecorder] 77 | } 78 | 79 | let dispatcher = AssertionDispatcher(handlers: handlers) 80 | withAssertionHandler(dispatcher, closure: closure) 81 | return recorder.assertions 82 | } 83 | 84 | /// Captures failed expectations that occur in the given closure. Note that all 85 | /// expectations will still go through to the default Nimble handler. 86 | /// 87 | /// This can be useful if you want to gather information about failed 88 | /// expectations that occur within a closure. 89 | /// 90 | /// @param silently expectations are no longer send to the default Nimble 91 | /// assertion handler when this is true. Defaults to false. 92 | /// 93 | /// @see gatherExpectations 94 | /// @see raiseException source for an example use case. 95 | public func gatherFailingExpectations(silently silently: Bool = false, closure: () -> Void) -> [AssertionRecord] { 96 | let assertions = gatherExpectations(silently: silently, closure: closure) 97 | return assertions.filter { assertion in 98 | !assertion.success 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this 4 | /// class' existance 5 | internal class NimbleEnvironment { 6 | static var activeInstance: NimbleEnvironment { 7 | get { 8 | let env = NSThread.currentThread().threadDictionary["NimbleEnvironment"] 9 | if let env = env as? NimbleEnvironment { 10 | return env 11 | } else { 12 | let newEnv = NimbleEnvironment() 13 | self.activeInstance = newEnv 14 | return newEnv 15 | } 16 | } 17 | set { 18 | NSThread.currentThread().threadDictionary["NimbleEnvironment"] = newValue 19 | } 20 | } 21 | 22 | // TODO: eventually migrate the global to this environment value 23 | var assertionHandler: AssertionHandler { 24 | get { return NimbleAssertionHandler } 25 | set { NimbleAssertionHandler = newValue } 26 | } 27 | 28 | #if _runtime(_ObjC) 29 | var awaiter: Awaiter 30 | 31 | init() { 32 | awaiter = Awaiter( 33 | waitLock: AssertionWaitLock(), 34 | asyncQueue: dispatch_get_main_queue(), 35 | timeoutQueue: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) 36 | } 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import XCTest 3 | 4 | /// Default handler for Nimble. This assertion handler passes failures along to 5 | /// XCTest. 6 | public class NimbleXCTestHandler : AssertionHandler { 7 | public func assert(assertion: Bool, message: FailureMessage, location: SourceLocation) { 8 | if !assertion { 9 | recordFailure("\(message.stringValue)\n", location: location) 10 | } 11 | } 12 | } 13 | 14 | /// Alternative handler for Nimble. This assertion handler passes failures along 15 | /// to XCTest by attempting to reduce the failure message size. 16 | public class NimbleShortXCTestHandler: AssertionHandler { 17 | public func assert(assertion: Bool, message: FailureMessage, location: SourceLocation) { 18 | if !assertion { 19 | let msg: String 20 | if let actual = message.actualValue { 21 | msg = "got: \(actual) \(message.postfixActual)" 22 | } else { 23 | msg = "expected \(message.to) \(message.postfixMessage)" 24 | } 25 | recordFailure("\(msg)\n", location: location) 26 | } 27 | } 28 | } 29 | 30 | /// Fallback handler in case XCTest is unavailable. This assertion handler will abort 31 | /// the program if it is invoked. 32 | class NimbleXCTestUnavailableHandler : AssertionHandler { 33 | func assert(assertion: Bool, message: FailureMessage, location: SourceLocation) { 34 | fatalError("XCTest is not available and no custom assertion handler was configured. Aborting.") 35 | } 36 | } 37 | 38 | #if _runtime(_ObjC) 39 | /// Helper class providing access to the currently executing XCTestCase instance, if any 40 | @objc final internal class CurrentTestCaseTracker: NSObject, XCTestObservation { 41 | @objc static let sharedInstance = CurrentTestCaseTracker() 42 | 43 | private(set) var currentTestCase: XCTestCase? 44 | 45 | @objc func testCaseWillStart(testCase: XCTestCase) { 46 | currentTestCase = testCase 47 | } 48 | 49 | @objc func testCaseDidFinish(testCase: XCTestCase) { 50 | currentTestCase = nil 51 | } 52 | } 53 | #endif 54 | 55 | 56 | func isXCTestAvailable() -> Bool { 57 | #if _runtime(_ObjC) 58 | // XCTest is weakly linked and so may not be present 59 | return NSClassFromString("XCTestCase") != nil 60 | #else 61 | return true 62 | #endif 63 | } 64 | 65 | private func recordFailure(message: String, location: SourceLocation) { 66 | #if _runtime(_ObjC) 67 | if let testCase = CurrentTestCaseTracker.sharedInstance.currentTestCase { 68 | testCase.recordFailureWithDescription(message, inFile: location.file, atLine: location.line, expected: true) 69 | } else { 70 | let msg = "Attempted to report a test failure to XCTest while no test case was running. " + 71 | "The failure was:\n\"\(message)\"\nIt occurred at: \(location.file):\(location.line)" 72 | NSException(name: NSInternalInconsistencyException, reason: msg, userInfo: nil).raise() 73 | } 74 | #else 75 | XCTFail("\(message)\n", file: location.file, line: location.line) 76 | #endif 77 | } 78 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/ObjectiveC/CurrentTestCaseTracker.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | SWIFT_CLASS("_TtC6Nimble22CurrentTestCaseTracker") 5 | @interface CurrentTestCaseTracker : NSObject 6 | + (CurrentTestCaseTracker *)sharedInstance; 7 | @end 8 | 9 | @interface CurrentTestCaseTracker (Register) @end 10 | 11 | @implementation CurrentTestCaseTracker (Register) 12 | 13 | + (void)load { 14 | CurrentTestCaseTracker *tracker = [CurrentTestCaseTracker sharedInstance]; 15 | // Xcode 7.3 introduced a bug where early registration of a test observer prevented 16 | // default XCTest test observer from being registered. That caused no logs being 17 | // printed to console, which in result broke several tools that relied on this. 18 | // In order to work around the issue we're deferring registration to allow default 19 | // test observer to register first. 20 | dispatch_async(dispatch_get_main_queue(), ^{ 21 | [[XCTestObservationCenter sharedTestObservationCenter] addTestObserver:tracker]; 22 | }); 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/ObjectiveC/NMBExceptionCapture.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface NMBExceptionCapture : NSObject 5 | 6 | - (id)initWithHandler:(void(^)(NSException *))handler finally:(void(^)())finally; 7 | - (void)tryBlock:(void(^)())unsafeBlock; 8 | 9 | @end 10 | 11 | typedef void(^NMBSourceCallbackBlock)(BOOL successful); 12 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/ObjectiveC/NMBExceptionCapture.m: -------------------------------------------------------------------------------- 1 | #import "NMBExceptionCapture.h" 2 | 3 | @interface NMBExceptionCapture () 4 | @property (nonatomic, copy) void(^handler)(NSException *exception); 5 | @property (nonatomic, copy) void(^finally)(); 6 | @end 7 | 8 | @implementation NMBExceptionCapture 9 | 10 | - (id)initWithHandler:(void(^)(NSException *))handler finally:(void(^)())finally { 11 | self = [super init]; 12 | if (self) { 13 | self.handler = handler; 14 | self.finally = finally; 15 | } 16 | return self; 17 | } 18 | 19 | - (void)tryBlock:(void(^)())unsafeBlock { 20 | @try { 21 | unsafeBlock(); 22 | } 23 | @catch (NSException *exception) { 24 | if (self.handler) { 25 | self.handler(exception); 26 | } 27 | } 28 | @finally { 29 | if (self.finally) { 30 | self.finally(); 31 | } 32 | } 33 | } 34 | 35 | @end -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/ObjectiveC/NMBObjCMatcher.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if _runtime(_ObjC) 4 | 5 | public typealias MatcherBlock = (actualExpression: Expression, failureMessage: FailureMessage) -> Bool 6 | public typealias FullMatcherBlock = (actualExpression: Expression, failureMessage: FailureMessage, shouldNotMatch: Bool) -> Bool 7 | 8 | public class NMBObjCMatcher : NSObject, NMBMatcher { 9 | let _match: MatcherBlock 10 | let _doesNotMatch: MatcherBlock 11 | let canMatchNil: Bool 12 | 13 | public init(canMatchNil: Bool, matcher: MatcherBlock, notMatcher: MatcherBlock) { 14 | self.canMatchNil = canMatchNil 15 | self._match = matcher 16 | self._doesNotMatch = notMatcher 17 | } 18 | 19 | public convenience init(matcher: MatcherBlock) { 20 | self.init(canMatchNil: true, matcher: matcher) 21 | } 22 | 23 | public convenience init(canMatchNil: Bool, matcher: MatcherBlock) { 24 | self.init(canMatchNil: canMatchNil, matcher: matcher, notMatcher: ({ actualExpression, failureMessage in 25 | return !matcher(actualExpression: actualExpression, failureMessage: failureMessage) 26 | })) 27 | } 28 | 29 | public convenience init(matcher: FullMatcherBlock) { 30 | self.init(canMatchNil: true, matcher: matcher) 31 | } 32 | 33 | public convenience init(canMatchNil: Bool, matcher: FullMatcherBlock) { 34 | self.init(canMatchNil: canMatchNil, matcher: ({ actualExpression, failureMessage in 35 | return matcher(actualExpression: actualExpression, failureMessage: failureMessage, shouldNotMatch: false) 36 | }), notMatcher: ({ actualExpression, failureMessage in 37 | return matcher(actualExpression: actualExpression, failureMessage: failureMessage, shouldNotMatch: true) 38 | })) 39 | } 40 | 41 | private func canMatch(actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 42 | do { 43 | if !canMatchNil { 44 | if try actualExpression.evaluate() == nil { 45 | failureMessage.postfixActual = " (use beNil() to match nils)" 46 | return false 47 | } 48 | } 49 | } catch let error { 50 | failureMessage.actualValue = "an unexpected error thrown: \(error)" 51 | return false 52 | } 53 | return true 54 | } 55 | 56 | public func matches(actualBlock: () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 57 | let expr = Expression(expression: actualBlock, location: location) 58 | let result = _match( 59 | actualExpression: expr, 60 | failureMessage: failureMessage) 61 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) { 62 | return result 63 | } else { 64 | return false 65 | } 66 | } 67 | 68 | public func doesNotMatch(actualBlock: () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 69 | let expr = Expression(expression: actualBlock, location: location) 70 | let result = _doesNotMatch( 71 | actualExpression: expr, 72 | failureMessage: failureMessage) 73 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) { 74 | return result 75 | } else { 76 | return false 77 | } 78 | } 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/ObjectiveC/NMBStringify.h: -------------------------------------------------------------------------------- 1 | @class NSString; 2 | 3 | /** 4 | * Returns a string appropriate for displaying in test output 5 | * from the provided value. 6 | * 7 | * @param value A value that will show up in a test's output. 8 | * 9 | * @return The string that is returned can be 10 | * customized per type by conforming a type to the `TestOutputStringConvertible` 11 | * protocol. When stringifying a non-`TestOutputStringConvertible` type, this 12 | * function will return the value's debug description and then its 13 | * normal description if available and in that order. Otherwise it 14 | * will return the result of constructing a string from the value. 15 | * 16 | * @see `TestOutputStringConvertible` 17 | */ 18 | extern NSString *_Nonnull NMBStringify(id _Nullable anyObject) __attribute__((warn_unused_result)); 19 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Adapters/ObjectiveC/NMBStringify.m: -------------------------------------------------------------------------------- 1 | #import "NMBStringify.h" 2 | #import 3 | 4 | NSString *_Nonnull NMBStringify(id _Nullable anyObject) { 5 | return [NMBStringer stringify:anyObject]; 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/DSL.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Make an expectation on a given actual value. The value given is lazily evaluated. 4 | @warn_unused_result(message="Follow 'expect(…)' with '.to(…)', '.toNot(…)', 'toEventually(…)', '==', etc.") 5 | public func expect(@autoclosure(escaping) expression: () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation { 6 | return Expectation( 7 | expression: Expression( 8 | expression: expression, 9 | location: SourceLocation(file: file, line: line), 10 | isClosure: true)) 11 | } 12 | 13 | /// Make an expectation on a given actual value. The closure is lazily invoked. 14 | @warn_unused_result(message="Follow 'expect(…)' with '.to(…)', '.toNot(…)', 'toEventually(…)', '==', etc.") 15 | public func expect(file: FileString = #file, line: UInt = #line, expression: () throws -> T?) -> Expectation { 16 | return Expectation( 17 | expression: Expression( 18 | expression: expression, 19 | location: SourceLocation(file: file, line: line), 20 | isClosure: true)) 21 | } 22 | 23 | /// Always fails the test with a message and a specified location. 24 | public func fail(message: String, location: SourceLocation) { 25 | let handler = NimbleEnvironment.activeInstance.assertionHandler 26 | handler.assert(false, message: FailureMessage(stringValue: message), location: location) 27 | } 28 | 29 | /// Always fails the test with a message. 30 | public func fail(message: String, file: FileString = #file, line: UInt = #line) { 31 | fail(message, location: SourceLocation(file: file, line: line)) 32 | } 33 | 34 | /// Always fails the test. 35 | public func fail(file: FileString = #file, line: UInt = #line) { 36 | fail("fail() always fails", file: file, line: line) 37 | } 38 | 39 | /// Like Swift's precondition(), but raises NSExceptions instead of sigaborts 40 | internal func nimblePrecondition( 41 | @autoclosure expr: () -> Bool, 42 | @autoclosure _ name: () -> String, 43 | @autoclosure _ message: () -> String, 44 | file: StaticString = #file, 45 | line: UInt = #line) -> Bool { 46 | let result = expr() 47 | if !result { 48 | #if _runtime(_ObjC) 49 | let e = NSException( 50 | name: name(), 51 | reason: message(), 52 | userInfo: nil) 53 | e.raise() 54 | #else 55 | preconditionFailure("\(name()) - \(message())", file: file, line: line) 56 | #endif 57 | } 58 | return result 59 | } 60 | 61 | @noreturn 62 | internal func internalError(msg: String, file: FileString = #file, line: UInt = #line) { 63 | fatalError( 64 | "Nimble Bug Found: \(msg) at \(file):\(line).\n" + 65 | "Please file a bug to Nimble: https://github.com/Quick/Nimble/issues with the " + 66 | "code snippet that caused this error." 67 | ) 68 | } -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Expectation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func expressionMatches(expression: Expression, matcher: U, to: String, description: String?) -> (Bool, FailureMessage) { 4 | let msg = FailureMessage() 5 | msg.userDescription = description 6 | msg.to = to 7 | do { 8 | let pass = try matcher.matches(expression, failureMessage: msg) 9 | if msg.actualValue == "" { 10 | msg.actualValue = "<\(stringify(try expression.evaluate()))>" 11 | } 12 | return (pass, msg) 13 | } catch let error { 14 | msg.actualValue = "an unexpected error thrown: <\(error)>" 15 | return (false, msg) 16 | } 17 | } 18 | 19 | internal func expressionDoesNotMatch(expression: Expression, matcher: U, toNot: String, description: String?) -> (Bool, FailureMessage) { 20 | let msg = FailureMessage() 21 | msg.userDescription = description 22 | msg.to = toNot 23 | do { 24 | let pass = try matcher.doesNotMatch(expression, failureMessage: msg) 25 | if msg.actualValue == "" { 26 | msg.actualValue = "<\(stringify(try expression.evaluate()))>" 27 | } 28 | return (pass, msg) 29 | } catch let error { 30 | msg.actualValue = "an unexpected error thrown: <\(error)>" 31 | return (false, msg) 32 | } 33 | } 34 | 35 | public struct Expectation { 36 | let expression: Expression 37 | 38 | public func verify(pass: Bool, _ message: FailureMessage) { 39 | let handler = NimbleEnvironment.activeInstance.assertionHandler 40 | handler.assert(pass, message: message, location: expression.location) 41 | } 42 | 43 | /// Tests the actual value using a matcher to match. 44 | public func to(matcher: U, description: String? = nil) { 45 | let (pass, msg) = expressionMatches(expression, matcher: matcher, to: "to", description: description) 46 | verify(pass, msg) 47 | } 48 | 49 | /// Tests the actual value using a matcher to not match. 50 | public func toNot(matcher: U, description: String? = nil) { 51 | let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description) 52 | verify(pass, msg) 53 | } 54 | 55 | /// Tests the actual value using a matcher to not match. 56 | /// 57 | /// Alias to toNot(). 58 | public func notTo(matcher: U, description: String? = nil) { 59 | toNot(matcher, description: description) 60 | } 61 | 62 | // see: 63 | // - AsyncMatcherWrapper for extension 64 | // - NMBExpectation for Objective-C interface 65 | } 66 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/FailureMessage.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Encapsulates the failure message that matchers can report to the end user. 4 | /// 5 | /// This is shared state between Nimble and matchers that mutate this value. 6 | public class FailureMessage: NSObject { 7 | public var expected: String = "expected" 8 | public var actualValue: String? = "" // empty string -> use default; nil -> exclude 9 | public var to: String = "to" 10 | public var postfixMessage: String = "match" 11 | public var postfixActual: String = "" 12 | public var userDescription: String? = nil 13 | 14 | public var stringValue: String { 15 | get { 16 | if let value = _stringValueOverride { 17 | return value 18 | } else { 19 | return computeStringValue() 20 | } 21 | } 22 | set { 23 | _stringValueOverride = newValue 24 | } 25 | } 26 | 27 | internal var _stringValueOverride: String? 28 | 29 | public override init() { 30 | } 31 | 32 | public init(stringValue: String) { 33 | _stringValueOverride = stringValue 34 | } 35 | 36 | internal func stripNewlines(str: String) -> String { 37 | var lines: [String] = NSString(string: str).componentsSeparatedByString("\n") as [String] 38 | let whitespace = NSCharacterSet.whitespaceAndNewlineCharacterSet() 39 | lines = lines.map { line in NSString(string: line).stringByTrimmingCharactersInSet(whitespace) } 40 | return lines.joinWithSeparator("") 41 | } 42 | 43 | internal func computeStringValue() -> String { 44 | var value = "\(expected) \(to) \(postfixMessage)" 45 | if let actualValue = actualValue { 46 | value = "\(expected) \(to) \(postfixMessage), got \(actualValue)\(postfixActual)" 47 | } 48 | value = stripNewlines(value) 49 | 50 | if let userDescription = userDescription { 51 | return "\(userDescription)\n\(value)" 52 | } 53 | 54 | return value 55 | } 56 | } -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/AllPass.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public func allPass 4 | (passFunc: (T?) -> Bool) -> NonNilMatcherFunc { 5 | return allPass("pass a condition", passFunc) 6 | } 7 | 8 | public func allPass 9 | (passName: String, _ passFunc: (T?) -> Bool) -> NonNilMatcherFunc { 10 | return createAllPassMatcher() { 11 | expression, failureMessage in 12 | failureMessage.postfixMessage = passName 13 | return passFunc(try expression.evaluate()) 14 | } 15 | } 16 | 17 | public func allPass 18 | (matcher: V) -> NonNilMatcherFunc { 19 | return createAllPassMatcher() { 20 | try matcher.matches($0, failureMessage: $1) 21 | } 22 | } 23 | 24 | private func createAllPassMatcher 25 | (elementEvaluator:(Expression, FailureMessage) throws -> Bool) -> NonNilMatcherFunc { 26 | return NonNilMatcherFunc { actualExpression, failureMessage in 27 | failureMessage.actualValue = nil 28 | if let actualValue = try actualExpression.evaluate() { 29 | for currentElement in actualValue { 30 | let exp = Expression( 31 | expression: {currentElement}, location: actualExpression.location) 32 | if try !elementEvaluator(exp, failureMessage) { 33 | failureMessage.postfixMessage = 34 | "all \(failureMessage.postfixMessage)," 35 | + " but failed first at element <\(stringify(currentElement))>" 36 | + " in <\(stringify(actualValue))>" 37 | return false 38 | } 39 | } 40 | failureMessage.postfixMessage = "all \(failureMessage.postfixMessage)" 41 | } else { 42 | failureMessage.postfixMessage = "all pass (use beNil() to match nils)" 43 | return false 44 | } 45 | 46 | return true 47 | } 48 | } 49 | 50 | #if _runtime(_ObjC) 51 | extension NMBObjCMatcher { 52 | public class func allPassMatcher(matcher: NMBObjCMatcher) -> NMBObjCMatcher { 53 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 54 | let location = actualExpression.location 55 | let actualValue = try! actualExpression.evaluate() 56 | var nsObjects = [NSObject]() 57 | 58 | var collectionIsUsable = true 59 | if let value = actualValue as? NSFastEnumeration { 60 | let generator = NSFastGenerator(value) 61 | while let obj:AnyObject = generator.next() { 62 | if let nsObject = obj as? NSObject { 63 | nsObjects.append(nsObject) 64 | } else { 65 | collectionIsUsable = false 66 | break 67 | } 68 | } 69 | } else { 70 | collectionIsUsable = false 71 | } 72 | 73 | if !collectionIsUsable { 74 | failureMessage.postfixMessage = 75 | "allPass only works with NSFastEnumeration (NSArray, NSSet, ...) of NSObjects" 76 | failureMessage.expected = "" 77 | failureMessage.to = "" 78 | return false 79 | } 80 | 81 | let expr = Expression(expression: ({ nsObjects }), location: location) 82 | let elementEvaluator: (Expression, FailureMessage) -> Bool = { 83 | expression, failureMessage in 84 | return matcher.matches( 85 | {try! expression.evaluate()}, failureMessage: failureMessage, location: expr.location) 86 | } 87 | return try! createAllPassMatcher(elementEvaluator).matches( 88 | expr, failureMessage: failureMessage) 89 | } 90 | } 91 | } 92 | #endif 93 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if _runtime(_ObjC) 4 | 5 | // A Nimble matcher that catches attempts to use beAKindOf with non Objective-C types 6 | public func beAKindOf(expectedClass: Any) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc {actualExpression, failureMessage in 8 | failureMessage.stringValue = "beAKindOf only works on Objective-C types since" 9 | + " the Swift compiler will automatically type check Swift-only types." 10 | + " This expectation is redundant." 11 | return false 12 | } 13 | } 14 | 15 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 16 | /// @see beAnInstanceOf if you want to match against the exact class 17 | public func beAKindOf(expectedClass: AnyClass) -> NonNilMatcherFunc { 18 | return NonNilMatcherFunc { actualExpression, failureMessage in 19 | let instance = try actualExpression.evaluate() 20 | if let validInstance = instance { 21 | failureMessage.actualValue = "<\(classAsString(validInstance.dynamicType)) instance>" 22 | } else { 23 | failureMessage.actualValue = "" 24 | } 25 | failureMessage.postfixMessage = "be a kind of \(classAsString(expectedClass))" 26 | return instance != nil && instance!.isKindOfClass(expectedClass) 27 | } 28 | } 29 | 30 | extension NMBObjCMatcher { 31 | public class func beAKindOfMatcher(expected: AnyClass) -> NMBMatcher { 32 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 33 | return try! beAKindOf(expected).matches(actualExpression, failureMessage: failureMessage) 34 | } 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // A Nimble matcher that catches attempts to use beAnInstanceOf with non Objective-C types 4 | public func beAnInstanceOf(expectedClass: Any) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc {actualExpression, failureMessage in 6 | failureMessage.stringValue = "beAnInstanceOf only works on Objective-C types since" 7 | + " the Swift compiler will automatically type check Swift-only types." 8 | + " This expectation is redundant." 9 | return false 10 | } 11 | } 12 | 13 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 14 | /// @see beAKindOf if you want to match against subclasses 15 | public func beAnInstanceOf(expectedClass: AnyClass) -> NonNilMatcherFunc { 16 | return NonNilMatcherFunc { actualExpression, failureMessage in 17 | let instance = try actualExpression.evaluate() 18 | if let validInstance = instance { 19 | failureMessage.actualValue = "<\(classAsString(validInstance.dynamicType)) instance>" 20 | } else { 21 | failureMessage.actualValue = "" 22 | } 23 | failureMessage.postfixMessage = "be an instance of \(classAsString(expectedClass))" 24 | #if _runtime(_ObjC) 25 | return instance != nil && instance!.isMemberOfClass(expectedClass) 26 | #else 27 | return instance != nil && instance!.dynamicType == expectedClass 28 | #endif 29 | } 30 | } 31 | 32 | #if _runtime(_ObjC) 33 | extension NMBObjCMatcher { 34 | public class func beAnInstanceOfMatcher(expected: AnyClass) -> NMBMatcher { 35 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 36 | return try! beAnInstanceOf(expected).matches(actualExpression, failureMessage: failureMessage) 37 | } 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 5 | public func beGreaterThan(expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 8 | return try actualExpression.evaluate() > expectedValue 9 | } 10 | } 11 | 12 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 13 | public func beGreaterThan(expectedValue: NMBComparable?) -> NonNilMatcherFunc { 14 | return NonNilMatcherFunc { actualExpression, failureMessage in 15 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 16 | let actualValue = try actualExpression.evaluate() 17 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == NSComparisonResult.OrderedDescending 18 | return matches 19 | } 20 | } 21 | 22 | public func >(lhs: Expectation, rhs: T) { 23 | lhs.to(beGreaterThan(rhs)) 24 | } 25 | 26 | public func >(lhs: Expectation, rhs: NMBComparable?) { 27 | lhs.to(beGreaterThan(rhs)) 28 | } 29 | 30 | #if _runtime(_ObjC) 31 | extension NMBObjCMatcher { 32 | public class func beGreaterThanMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 33 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 34 | let expr = actualExpression.cast { $0 as? NMBComparable } 35 | return try! beGreaterThan(expected).matches(expr, failureMessage: failureMessage) 36 | } 37 | } 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is greater than 4 | /// or equal to the expected value. 5 | public func beGreaterThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 8 | let actualValue = try actualExpression.evaluate() 9 | return actualValue >= expectedValue 10 | } 11 | } 12 | 13 | /// A Nimble matcher that succeeds when the actual value is greater than 14 | /// or equal to the expected value. 15 | public func beGreaterThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 16 | return NonNilMatcherFunc { actualExpression, failureMessage in 17 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 18 | let actualValue = try actualExpression.evaluate() 19 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) != NSComparisonResult.OrderedAscending 20 | return matches 21 | } 22 | } 23 | 24 | public func >=(lhs: Expectation, rhs: T) { 25 | lhs.to(beGreaterThanOrEqualTo(rhs)) 26 | } 27 | 28 | public func >=(lhs: Expectation, rhs: T) { 29 | lhs.to(beGreaterThanOrEqualTo(rhs)) 30 | } 31 | 32 | #if _runtime(_ObjC) 33 | extension NMBObjCMatcher { 34 | public class func beGreaterThanOrEqualToMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 35 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 36 | let expr = actualExpression.cast { $0 as? NMBComparable } 37 | return try! beGreaterThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 38 | } 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual value is the same instance 5 | /// as the expected instance. 6 | public func beIdenticalTo(expected: AnyObject?) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | let actual = try actualExpression.evaluate() 9 | failureMessage.actualValue = "\(identityAsString(actual))" 10 | failureMessage.postfixMessage = "be identical to \(identityAsString(expected))" 11 | return actual === expected && actual !== nil 12 | } 13 | } 14 | 15 | public func ===(lhs: Expectation, rhs: AnyObject?) { 16 | lhs.to(beIdenticalTo(rhs)) 17 | } 18 | public func !==(lhs: Expectation, rhs: AnyObject?) { 19 | lhs.toNot(beIdenticalTo(rhs)) 20 | } 21 | 22 | /// A Nimble matcher that succeeds when the actual value is the same instance 23 | /// as the expected instance. 24 | /// 25 | /// Alias for "beIdenticalTo". 26 | public func be(expected: AnyObject?) -> NonNilMatcherFunc { 27 | return beIdenticalTo(expected) 28 | } 29 | 30 | #if _runtime(_ObjC) 31 | extension NMBObjCMatcher { 32 | public class func beIdenticalToMatcher(expected: NSObject?) -> NMBObjCMatcher { 33 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 34 | let aExpr = actualExpression.cast { $0 as AnyObject? } 35 | return try! beIdenticalTo(expected).matches(aExpr, failureMessage: failureMessage) 36 | } 37 | } 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeLessThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 4 | public func beLessThan(expectedValue: T?) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 7 | return try actualExpression.evaluate() < expectedValue 8 | } 9 | } 10 | 11 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 12 | public func beLessThan(expectedValue: NMBComparable?) -> NonNilMatcherFunc { 13 | return NonNilMatcherFunc { actualExpression, failureMessage in 14 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 15 | let actualValue = try actualExpression.evaluate() 16 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == NSComparisonResult.OrderedAscending 17 | return matches 18 | } 19 | } 20 | 21 | public func <(lhs: Expectation, rhs: T) { 22 | lhs.to(beLessThan(rhs)) 23 | } 24 | 25 | public func <(lhs: Expectation, rhs: NMBComparable?) { 26 | lhs.to(beLessThan(rhs)) 27 | } 28 | 29 | #if _runtime(_ObjC) 30 | extension NMBObjCMatcher { 31 | public class func beLessThanMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 32 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 33 | let expr = actualExpression.cast { $0 as! NMBComparable? } 34 | return try! beLessThan(expected).matches(expr, failureMessage: failureMessage) 35 | } 36 | } 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeLessThanOrEqual.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than 4 | /// or equal to the expected value. 5 | public func beLessThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 8 | return try actualExpression.evaluate() <= expectedValue 9 | } 10 | } 11 | 12 | /// A Nimble matcher that succeeds when the actual value is less than 13 | /// or equal to the expected value. 14 | public func beLessThanOrEqualTo(expectedValue: T?) -> NonNilMatcherFunc { 15 | return NonNilMatcherFunc { actualExpression, failureMessage in 16 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 17 | let actualValue = try actualExpression.evaluate() 18 | return actualValue != nil && actualValue!.NMB_compare(expectedValue) != NSComparisonResult.OrderedDescending 19 | } 20 | } 21 | 22 | public func <=(lhs: Expectation, rhs: T) { 23 | lhs.to(beLessThanOrEqualTo(rhs)) 24 | } 25 | 26 | public func <=(lhs: Expectation, rhs: T) { 27 | lhs.to(beLessThanOrEqualTo(rhs)) 28 | } 29 | 30 | #if _runtime(_ObjC) 31 | extension NMBObjCMatcher { 32 | public class func beLessThanOrEqualToMatcher(expected: NMBComparable?) -> NMBObjCMatcher { 33 | return NMBObjCMatcher(canMatchNil:false) { actualExpression, failureMessage in 34 | let expr = actualExpression.cast { $0 as? NMBComparable } 35 | return try! beLessThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 36 | } 37 | } 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeLogical.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func matcherWithFailureMessage(matcher: NonNilMatcherFunc, postprocessor: (FailureMessage) -> Void) -> NonNilMatcherFunc { 4 | return NonNilMatcherFunc { actualExpression, failureMessage in 5 | defer { postprocessor(failureMessage) } 6 | return try matcher.matcher(actualExpression, failureMessage) 7 | } 8 | } 9 | 10 | // MARK: beTrue() / beFalse() 11 | 12 | /// A Nimble matcher that succeeds when the actual value is exactly true. 13 | /// This matcher will not match against nils. 14 | public func beTrue() -> NonNilMatcherFunc { 15 | return matcherWithFailureMessage(equal(true)) { failureMessage in 16 | failureMessage.postfixMessage = "be true" 17 | } 18 | } 19 | 20 | /// A Nimble matcher that succeeds when the actual value is exactly false. 21 | /// This matcher will not match against nils. 22 | public func beFalse() -> NonNilMatcherFunc { 23 | return matcherWithFailureMessage(equal(false)) { failureMessage in 24 | failureMessage.postfixMessage = "be false" 25 | } 26 | } 27 | 28 | // MARK: beTruthy() / beFalsy() 29 | 30 | /// A Nimble matcher that succeeds when the actual value is not logically false. 31 | public func beTruthy() -> MatcherFunc { 32 | return MatcherFunc { actualExpression, failureMessage in 33 | failureMessage.postfixMessage = "be truthy" 34 | let actualValue = try actualExpression.evaluate() 35 | if let actualValue = actualValue { 36 | if let actualValue = actualValue as? BooleanType { 37 | return actualValue.boolValue == true 38 | } 39 | } 40 | return actualValue != nil 41 | } 42 | } 43 | 44 | /// A Nimble matcher that succeeds when the actual value is logically false. 45 | /// This matcher will match against nils. 46 | public func beFalsy() -> MatcherFunc { 47 | return MatcherFunc { actualExpression, failureMessage in 48 | failureMessage.postfixMessage = "be falsy" 49 | let actualValue = try actualExpression.evaluate() 50 | if let actualValue = actualValue { 51 | if let actualValue = actualValue as? BooleanType { 52 | return actualValue.boolValue != true 53 | } 54 | } 55 | return actualValue == nil 56 | } 57 | } 58 | 59 | #if _runtime(_ObjC) 60 | extension NMBObjCMatcher { 61 | public class func beTruthyMatcher() -> NMBObjCMatcher { 62 | return NMBObjCMatcher { actualExpression, failureMessage in 63 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as BooleanType? } 64 | return try! beTruthy().matches(expr, failureMessage: failureMessage) 65 | } 66 | } 67 | 68 | public class func beFalsyMatcher() -> NMBObjCMatcher { 69 | return NMBObjCMatcher { actualExpression, failureMessage in 70 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as BooleanType? } 71 | return try! beFalsy().matches(expr, failureMessage: failureMessage) 72 | } 73 | } 74 | 75 | public class func beTrueMatcher() -> NMBObjCMatcher { 76 | return NMBObjCMatcher { actualExpression, failureMessage in 77 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } 78 | return try! beTrue().matches(expr, failureMessage: failureMessage) 79 | } 80 | } 81 | 82 | public class func beFalseMatcher() -> NMBObjCMatcher { 83 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 84 | let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } 85 | return try! beFalse().matches(expr, failureMessage: failureMessage) 86 | } 87 | } 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeNil.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is nil. 4 | public func beNil() -> MatcherFunc { 5 | return MatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be nil" 7 | let actualValue = try actualExpression.evaluate() 8 | return actualValue == nil 9 | } 10 | } 11 | 12 | #if _runtime(_ObjC) 13 | extension NMBObjCMatcher { 14 | public class func beNilMatcher() -> NMBObjCMatcher { 15 | return NMBObjCMatcher { actualExpression, failureMessage in 16 | return try! beNil().matches(actualExpression, failureMessage: failureMessage) 17 | } 18 | } 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeVoid.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is Void. 4 | public func beVoid() -> MatcherFunc<()> { 5 | return MatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be void" 7 | let actualValue: ()? = try actualExpression.evaluate() 8 | return actualValue != nil 9 | } 10 | } 11 | 12 | public func ==(lhs: Expectation<()>, rhs: ()) { 13 | lhs.to(beVoid()) 14 | } 15 | 16 | public func !=(lhs: Expectation<()>, rhs: ()) { 17 | lhs.toNot(beVoid()) 18 | } -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/BeginWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual sequence's first element 5 | /// is equal to the expected value. 6 | public func beginWith(startingElement: T) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 9 | if let actualValue = try actualExpression.evaluate() { 10 | var actualGenerator = actualValue.generate() 11 | return actualGenerator.next() == startingElement 12 | } 13 | return false 14 | } 15 | } 16 | 17 | /// A Nimble matcher that succeeds when the actual collection's first element 18 | /// is equal to the expected object. 19 | public func beginWith(startingElement: AnyObject) -> NonNilMatcherFunc { 20 | return NonNilMatcherFunc { actualExpression, failureMessage in 21 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 22 | let collection = try actualExpression.evaluate() 23 | return collection != nil && collection!.indexOfObject(startingElement) == 0 24 | } 25 | } 26 | 27 | /// A Nimble matcher that succeeds when the actual string contains expected substring 28 | /// where the expected substring's location is zero. 29 | public func beginWith(startingSubstring: String) -> NonNilMatcherFunc { 30 | return NonNilMatcherFunc { actualExpression, failureMessage in 31 | failureMessage.postfixMessage = "begin with <\(startingSubstring)>" 32 | if let actual = try actualExpression.evaluate() { 33 | let range = actual.rangeOfString(startingSubstring) 34 | return range != nil && range!.startIndex == actual.startIndex 35 | } 36 | return false 37 | } 38 | } 39 | 40 | #if _runtime(_ObjC) 41 | extension NMBObjCMatcher { 42 | public class func beginWithMatcher(expected: AnyObject) -> NMBObjCMatcher { 43 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 44 | let actual = try! actualExpression.evaluate() 45 | if let _ = actual as? String { 46 | let expr = actualExpression.cast { $0 as? String } 47 | return try! beginWith(expected as! String).matches(expr, failureMessage: failureMessage) 48 | } else { 49 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection } 50 | return try! beginWith(expected).matches(expr, failureMessage: failureMessage) 51 | } 52 | } 53 | } 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/EndWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual sequence's last element 5 | /// is equal to the expected value. 6 | public func endWith(endingElement: T) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "end with <\(endingElement)>" 9 | 10 | if let actualValue = try actualExpression.evaluate() { 11 | var actualGenerator = actualValue.generate() 12 | var lastItem: T? 13 | var item: T? 14 | repeat { 15 | lastItem = item 16 | item = actualGenerator.next() 17 | } while(item != nil) 18 | 19 | return lastItem == endingElement 20 | } 21 | return false 22 | } 23 | } 24 | 25 | /// A Nimble matcher that succeeds when the actual collection's last element 26 | /// is equal to the expected object. 27 | public func endWith(endingElement: AnyObject) -> NonNilMatcherFunc { 28 | return NonNilMatcherFunc { actualExpression, failureMessage in 29 | failureMessage.postfixMessage = "end with <\(endingElement)>" 30 | let collection = try actualExpression.evaluate() 31 | return collection != nil && collection!.indexOfObject(endingElement) == collection!.count - 1 32 | } 33 | } 34 | 35 | 36 | /// A Nimble matcher that succeeds when the actual string contains the expected substring 37 | /// where the expected substring's location is the actual string's length minus the 38 | /// expected substring's length. 39 | public func endWith(endingSubstring: String) -> NonNilMatcherFunc { 40 | return NonNilMatcherFunc { actualExpression, failureMessage in 41 | failureMessage.postfixMessage = "end with <\(endingSubstring)>" 42 | if let collection = try actualExpression.evaluate() { 43 | let range = collection.rangeOfString(endingSubstring) 44 | return range != nil && range!.endIndex == collection.endIndex 45 | } 46 | return false 47 | } 48 | } 49 | 50 | #if _runtime(_ObjC) 51 | extension NMBObjCMatcher { 52 | public class func endWithMatcher(expected: AnyObject) -> NMBObjCMatcher { 53 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 54 | let actual = try! actualExpression.evaluate() 55 | if let _ = actual as? String { 56 | let expr = actualExpression.cast { $0 as? String } 57 | return try! endWith(expected as! String).matches(expr, failureMessage: failureMessage) 58 | } else { 59 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection } 60 | return try! endWith(expected).matches(expr, failureMessage: failureMessage) 61 | } 62 | } 63 | } 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/HaveCount.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual CollectionType's count equals 4 | /// the expected value 5 | public func haveCount(expectedValue: T.Index.Distance) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | if let actualValue = try actualExpression.evaluate() { 8 | failureMessage.postfixMessage = "have \(stringify(actualValue)) with count \(stringify(expectedValue))" 9 | let result = expectedValue == actualValue.count 10 | failureMessage.actualValue = "\(actualValue.count)" 11 | return result 12 | } else { 13 | return false 14 | } 15 | } 16 | } 17 | 18 | /// A Nimble matcher that succeeds when the actual collection's count equals 19 | /// the expected value 20 | public func haveCount(expectedValue: Int) -> MatcherFunc { 21 | return MatcherFunc { actualExpression, failureMessage in 22 | if let actualValue = try actualExpression.evaluate() { 23 | failureMessage.postfixMessage = "have \(stringify(actualValue)) with count \(stringify(expectedValue))" 24 | let result = expectedValue == actualValue.count 25 | failureMessage.actualValue = "\(actualValue.count)" 26 | return result 27 | } else { 28 | return false 29 | } 30 | } 31 | } 32 | 33 | #if _runtime(_ObjC) 34 | extension NMBObjCMatcher { 35 | public class func haveCountMatcher(expected: NSNumber) -> NMBObjCMatcher { 36 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 37 | let location = actualExpression.location 38 | let actualValue = try! actualExpression.evaluate() 39 | if let value = actualValue as? NMBCollection { 40 | let expr = Expression(expression: ({ value as NMBCollection}), location: location) 41 | return try! haveCount(expected.integerValue).matches(expr, failureMessage: failureMessage) 42 | } else if let actualValue = actualValue { 43 | failureMessage.postfixMessage = "get type of NSArray, NSSet, NSDictionary, or NSHashTable" 44 | failureMessage.actualValue = "\(classAsString(actualValue.dynamicType))" 45 | } 46 | return false 47 | } 48 | } 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/Match.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if _runtime(_ObjC) 4 | 5 | /// A Nimble matcher that succeeds when the actual string satisfies the regular expression 6 | /// described by the expected string. 7 | public func match(expectedValue: String?) -> NonNilMatcherFunc { 8 | return NonNilMatcherFunc { actualExpression, failureMessage in 9 | failureMessage.postfixMessage = "match <\(stringify(expectedValue))>" 10 | 11 | if let actual = try actualExpression.evaluate() { 12 | if let regexp = expectedValue { 13 | return actual.rangeOfString(regexp, options: .RegularExpressionSearch) != nil 14 | } 15 | } 16 | 17 | return false 18 | } 19 | } 20 | 21 | extension NMBObjCMatcher { 22 | public class func matchMatcher(expected: NSString) -> NMBMatcher { 23 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 24 | let actual = actualExpression.cast { $0 as? String } 25 | return try! match(expected.description).matches(actual, failureMessage: failureMessage) 26 | } 27 | } 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/MatchError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual expression evaluates to an 4 | /// error from the specified case. 5 | /// 6 | /// Errors are tried to be compared by their implementation of Equatable, 7 | /// otherwise they fallback to comparision by _domain and _code. 8 | public func matchError(error: T) -> NonNilMatcherFunc { 9 | return NonNilMatcherFunc { actualExpression, failureMessage in 10 | let actualError: ErrorType? = try actualExpression.evaluate() 11 | 12 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, error: error) 13 | return errorMatchesNonNilFieldsOrClosure(actualError, error: error) 14 | } 15 | } 16 | 17 | /// A Nimble matcher that succeeds when the actual expression evaluates to an 18 | /// error of the specified type 19 | public func matchError(errorType: T.Type) -> NonNilMatcherFunc { 20 | return NonNilMatcherFunc { actualExpression, failureMessage in 21 | let actualError: ErrorType? = try actualExpression.evaluate() 22 | 23 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, errorType: errorType) 24 | return errorMatchesNonNilFieldsOrClosure(actualError, errorType: errorType) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/MatcherFunc.swift: -------------------------------------------------------------------------------- 1 | /// A convenience API to build matchers that don't need special negation 2 | /// behavior. The toNot() behavior is the negation of to(). 3 | /// 4 | /// @see NonNilMatcherFunc if you prefer to have this matcher fail when nil 5 | /// values are recieved in an expectation. 6 | /// 7 | /// You may use this when implementing your own custom matchers. 8 | /// 9 | /// Use the Matcher protocol instead of this type to accept custom matchers as 10 | /// input parameters. 11 | /// @see allPass for an example that uses accepts other matchers as input. 12 | public struct MatcherFunc: Matcher { 13 | public let matcher: (Expression, FailureMessage) throws -> Bool 14 | 15 | public init(_ matcher: (Expression, FailureMessage) throws -> Bool) { 16 | self.matcher = matcher 17 | } 18 | 19 | public func matches(actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 20 | return try matcher(actualExpression, failureMessage) 21 | } 22 | 23 | public func doesNotMatch(actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 24 | return try !matcher(actualExpression, failureMessage) 25 | } 26 | } 27 | 28 | /// A convenience API to build matchers that don't need special negation 29 | /// behavior. The toNot() behavior is the negation of to(). 30 | /// 31 | /// Unlike MatcherFunc, this will always fail if an expectation contains nil. 32 | /// This applies regardless of using to() or toNot(). 33 | /// 34 | /// You may use this when implementing your own custom matchers. 35 | /// 36 | /// Use the Matcher protocol instead of this type to accept custom matchers as 37 | /// input parameters. 38 | /// @see allPass for an example that uses accepts other matchers as input. 39 | public struct NonNilMatcherFunc: Matcher { 40 | public let matcher: (Expression, FailureMessage) throws -> Bool 41 | 42 | public init(_ matcher: (Expression, FailureMessage) throws -> Bool) { 43 | self.matcher = matcher 44 | } 45 | 46 | public func matches(actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 47 | let pass = try matcher(actualExpression, failureMessage) 48 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { 49 | return false 50 | } 51 | return pass 52 | } 53 | 54 | public func doesNotMatch(actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 55 | let pass = try !matcher(actualExpression, failureMessage) 56 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { 57 | return false 58 | } 59 | return pass 60 | } 61 | 62 | internal func attachNilErrorIfNeeded(actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 63 | if try actualExpression.evaluate() == nil { 64 | failureMessage.postfixActual = " (use beNil() to match nils)" 65 | return true 66 | } 67 | return false 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/PostNotification.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal class NotificationCollector { 4 | private(set) var observedNotifications: [NSNotification] 5 | private let notificationCenter: NSNotificationCenter 6 | #if _runtime(_ObjC) 7 | private var token: AnyObject? 8 | #else 9 | private var token: NSObjectProtocol? 10 | #endif 11 | 12 | required init(notificationCenter: NSNotificationCenter) { 13 | self.notificationCenter = notificationCenter 14 | self.observedNotifications = [] 15 | } 16 | 17 | func startObserving() { 18 | self.token = self.notificationCenter.addObserverForName(nil, object: nil, queue: nil) { 19 | // linux-swift gets confused by .append(n) 20 | [weak self] n in self?.observedNotifications += [n] 21 | } 22 | } 23 | 24 | deinit { 25 | #if _runtime(_ObjC) 26 | if let token = self.token { 27 | self.notificationCenter.removeObserver(token) 28 | } 29 | #else 30 | if let token = self.token as? AnyObject { 31 | self.notificationCenter.removeObserver(token) 32 | } 33 | #endif 34 | } 35 | } 36 | 37 | private let mainThread = pthread_self() 38 | 39 | public func postNotifications( 40 | notificationsMatcher: T, 41 | fromNotificationCenter center: NSNotificationCenter = NSNotificationCenter.defaultCenter()) 42 | -> MatcherFunc { 43 | let _ = mainThread // Force lazy-loading of this value 44 | let collector = NotificationCollector(notificationCenter: center) 45 | collector.startObserving() 46 | var once: Bool = false 47 | return MatcherFunc { actualExpression, failureMessage in 48 | let collectorNotificationsExpression = Expression(memoizedExpression: { _ in 49 | return collector.observedNotifications 50 | }, location: actualExpression.location, withoutCaching: true) 51 | 52 | assert(pthread_equal(mainThread, pthread_self()) != 0, "Only expecting closure to be evaluated on main thread.") 53 | if !once { 54 | once = true 55 | try actualExpression.evaluate() 56 | } 57 | 58 | let match = try notificationsMatcher.matches(collectorNotificationsExpression, failureMessage: failureMessage) 59 | if collector.observedNotifications.isEmpty { 60 | failureMessage.actualValue = "no notifications" 61 | } else { 62 | failureMessage.actualValue = "<\(stringify(collector.observedNotifications))>" 63 | } 64 | return match 65 | } 66 | } -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value matches with any of the matchers 4 | /// provided in the variable list of matchers. 5 | public func satisfyAnyOf(matchers: U...) -> NonNilMatcherFunc { 6 | return satisfyAnyOf(matchers) 7 | } 8 | 9 | internal func satisfyAnyOf(matchers: [U]) -> NonNilMatcherFunc { 10 | return NonNilMatcherFunc { actualExpression, failureMessage in 11 | let postfixMessages = NSMutableArray() 12 | var matches = false 13 | for matcher in matchers { 14 | if try matcher.matches(actualExpression, failureMessage: failureMessage) { 15 | matches = true 16 | } 17 | postfixMessages.addObject(NSString(string: "{\(failureMessage.postfixMessage)}")) 18 | } 19 | 20 | failureMessage.postfixMessage = "match one of: " + postfixMessages.componentsJoinedByString(", or ") 21 | if let actualValue = try actualExpression.evaluate() { 22 | failureMessage.actualValue = "\(actualValue)" 23 | } 24 | 25 | return matches 26 | } 27 | } 28 | 29 | public func ||(left: NonNilMatcherFunc, right: NonNilMatcherFunc) -> NonNilMatcherFunc { 30 | return satisfyAnyOf(left, right) 31 | } 32 | 33 | public func ||(left: MatcherFunc, right: MatcherFunc) -> NonNilMatcherFunc { 34 | return satisfyAnyOf(left, right) 35 | } 36 | 37 | #if _runtime(_ObjC) 38 | extension NMBObjCMatcher { 39 | public class func satisfyAnyOfMatcher(matchers: [NMBObjCMatcher]) -> NMBObjCMatcher { 40 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 41 | if matchers.isEmpty { 42 | failureMessage.stringValue = "satisfyAnyOf must be called with at least one matcher" 43 | return false 44 | } 45 | 46 | var elementEvaluators = [NonNilMatcherFunc]() 47 | for matcher in matchers { 48 | let elementEvaluator: (Expression, FailureMessage) -> Bool = { 49 | expression, failureMessage in 50 | return matcher.matches( 51 | {try! expression.evaluate()}, failureMessage: failureMessage, location: actualExpression.location) 52 | } 53 | 54 | elementEvaluators.append(NonNilMatcherFunc(elementEvaluator)) 55 | } 56 | 57 | return try! satisfyAnyOf(elementEvaluators).matches(actualExpression, failureMessage: failureMessage) 58 | } 59 | } 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Matchers/ThrowError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual expression throws an 4 | /// error of the specified type or from the specified case. 5 | /// 6 | /// Errors are tried to be compared by their implementation of Equatable, 7 | /// otherwise they fallback to comparision by _domain and _code. 8 | /// 9 | /// Alternatively, you can pass a closure to do any arbitrary custom matching 10 | /// to the thrown error. The closure only gets called when an error was thrown. 11 | /// 12 | /// nil arguments indicates that the matcher should not attempt to match against 13 | /// that parameter. 14 | public func throwError( 15 | error: T? = nil, 16 | errorType: T.Type? = nil, 17 | closure: ((T) -> Void)? = nil) -> MatcherFunc { 18 | return MatcherFunc { actualExpression, failureMessage in 19 | 20 | var actualError: ErrorType? 21 | do { 22 | try actualExpression.evaluate() 23 | } catch let catchedError { 24 | actualError = catchedError 25 | } 26 | 27 | setFailureMessageForError(failureMessage, actualError: actualError, error: error, errorType: errorType, closure: closure) 28 | return errorMatchesNonNilFieldsOrClosure(actualError, error: error, errorType: errorType, closure: closure) 29 | } 30 | } 31 | 32 | /// A Nimble matcher that succeeds when the actual expression throws any 33 | /// error or when the passed closures' arbitrary custom matching succeeds. 34 | /// 35 | /// This duplication to it's generic adequate is required to allow to receive 36 | /// values of the existential type ErrorType in the closure. 37 | /// 38 | /// The closure only gets called when an error was thrown. 39 | public func throwError( 40 | closure closure: ((ErrorType) -> Void)? = nil) -> MatcherFunc { 41 | return MatcherFunc { actualExpression, failureMessage in 42 | 43 | var actualError: ErrorType? 44 | do { 45 | try actualExpression.evaluate() 46 | } catch let catchedError { 47 | actualError = catchedError 48 | } 49 | 50 | setFailureMessageForError(failureMessage, actualError: actualError, closure: closure) 51 | return errorMatchesNonNilFieldsOrClosure(actualError, closure: closure) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Nimble.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NMBExceptionCapture.h" 3 | #import "NMBStringify.h" 4 | #import "DSL.h" 5 | 6 | FOUNDATION_EXPORT double NimbleVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Utils/Functional.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension SequenceType { 4 | internal func all(fn: Generator.Element -> Bool) -> Bool { 5 | for item in self { 6 | if !fn(item) { 7 | return false 8 | } 9 | } 10 | return true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Pods/Nimble/Sources/Nimble/Utils/SourceLocation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // Ideally we would always use `StaticString` as the type for tracking the file name 4 | // that expectations originate from, for consistency with `assert` etc. from the 5 | // stdlib, and because recent versions of the XCTest overlay require `StaticString` 6 | // when calling `XCTFail`. Under the Objective-C runtime (i.e. building on Mac), we 7 | // have to use `String` instead because StaticString can't be generated from Objective-C 8 | #if _runtime(_ObjC) 9 | public typealias FileString = String 10 | #else 11 | public typealias FileString = StaticString 12 | #endif 13 | 14 | public final class SourceLocation : NSObject { 15 | public let file: FileString 16 | public let line: UInt 17 | 18 | override init() { 19 | file = "Unknown File" 20 | line = 0 21 | } 22 | 23 | init(file: FileString, line: UInt) { 24 | self.file = file 25 | self.line = line 26 | } 27 | 28 | override public var description: String { 29 | return "\(file):\(line)" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/jeff.xcuserdatad/xcschemes/Pods-CIFilterKitTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/jeff.xcuserdatad/xcschemes/Pods-ExampleAppTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/jeff.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Nimble.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-CIFilterKit.xcscheme 13 | 14 | isShown 15 | 16 | 17 | Pods-CIFilterKitTests.xcscheme 18 | 19 | isShown 20 | 21 | 22 | Pods-ExampleApp.xcscheme 23 | 24 | isShown 25 | 26 | 27 | Pods-ExampleAppTests.xcscheme 28 | 29 | isShown 30 | 31 | 32 | Quick.xcscheme 33 | 34 | isShown 35 | 36 | 37 | 38 | SuppressBuildableAutocreation 39 | 40 | 4FA852B36637F5FBFB642C28D8B6C6BC 41 | 42 | primary 43 | 44 | 45 | A8D2D46350F9F0D99C8BDCDA54210441 46 | 47 | primary 48 | 49 | 50 | D5557DF4776DE05F5FF465C5269830E9 51 | 52 | primary 53 | 54 | 55 | E932F9217B2B431BC4F4E2B687EF00D7 56 | 57 | primary 58 | 59 | 60 | FCC80D135E7E0269D7700256C2733574 61 | 62 | primary 63 | 64 | 65 | FEC868B969EC456774D9FC014D4A49F2 66 | 67 | primary 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Pods/Quick/README.md: -------------------------------------------------------------------------------- 1 | ![](http://f.cl.ly/items/0r1E192C1R0b2g2Q3h2w/QuickLogo_Color.png) 2 | 3 | Quick is a behavior-driven development framework for Swift and Objective-C. 4 | Inspired by [RSpec](https://github.com/rspec/rspec), [Specta](https://github.com/specta/specta), and [Ginkgo](https://github.com/onsi/ginkgo). 5 | 6 | ![](https://raw.githubusercontent.com/Quick/Assets/master/Screenshots/QuickSpec%20screenshot.png) 7 | 8 | ```swift 9 | // Swift 10 | 11 | import Quick 12 | import Nimble 13 | 14 | class TableOfContentsSpec: QuickSpec { 15 | override func spec() { 16 | describe("the 'Documentation' directory") { 17 | it("has everything you need to get started") { 18 | let sections = Directory("Documentation").sections 19 | expect(sections).to(contain("Organized Tests with Quick Examples and Example Groups")) 20 | expect(sections).to(contain("Installing Quick")) 21 | } 22 | 23 | context("if it doesn't have what you're looking for") { 24 | it("needs to be updated") { 25 | let you = You(awesome: true) 26 | expect{you.submittedAnIssue}.toEventually(beTruthy()) 27 | } 28 | } 29 | } 30 | } 31 | } 32 | ``` 33 | #### Nimble 34 | Quick comes together with [Nimble](https://github.com/Quick/Nimble) — a matcher framework for your tests. You can learn why `XCTAssert()` statements make your expectations unclear and how to fix that using Nimble assertions [here](./Documentation/NimbleAssertions.md). 35 | 36 | ## Documentation 37 | 38 | All documentation can be found in the [Documentation folder](./Documentation), including [detailed installation instructions](./Documentation/InstallingQuick.md) for CocoaPods, Carthage, Git submodules, and more. For example, you can install Quick and [Nimble](https://github.com/Quick/Nimble) using CocoaPods by adding the following to your Podfile: 39 | 40 | ```rb 41 | # Podfile 42 | 43 | use_frameworks! 44 | 45 | def testing_pods 46 | pod 'Quick', '~> 0.9.0' 47 | pod 'Nimble', '3.0.0' 48 | end 49 | 50 | target 'MyTests' do 51 | testing_pods 52 | end 53 | 54 | target 'MyUITests' do 55 | testing_pods 56 | end 57 | ``` 58 | 59 | ## License 60 | 61 | Apache 2.0 license. See the `LICENSE` file for details. 62 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Callsite.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | An object encapsulating the file and line number at which 5 | a particular example is defined. 6 | */ 7 | final public class Callsite: NSObject { 8 | /** 9 | The absolute path of the file in which an example is defined. 10 | */ 11 | public let file: String 12 | 13 | /** 14 | The line number on which an example is defined. 15 | */ 16 | public let line: UInt 17 | 18 | internal init(file: String, line: UInt) { 19 | self.file = file 20 | self.line = line 21 | } 22 | } 23 | 24 | /** 25 | Returns a boolean indicating whether two Callsite objects are equal. 26 | If two callsites are in the same file and on the same line, they must be equal. 27 | */ 28 | public func ==(lhs: Callsite, rhs: Callsite) -> Bool { 29 | return lhs.file == rhs.file && lhs.line == rhs.line 30 | } 31 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Configuration/QuickConfiguration.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Configuration; 4 | 5 | /** 6 | Subclass QuickConfiguration and override the +[QuickConfiguration configure:] 7 | method in order to configure how Quick behaves when running specs, or to define 8 | shared examples that are used across spec files. 9 | */ 10 | @interface QuickConfiguration : NSObject 11 | 12 | /** 13 | This method is executed on each subclass of this class before Quick runs 14 | any examples. You may override this method on as many subclasses as you like, but 15 | there is no guarantee as to the order in which these methods are executed. 16 | 17 | You can override this method in order to: 18 | 19 | 1. Configure how Quick behaves, by modifying properties on the Configuration object. 20 | Setting the same properties in several methods has undefined behavior. 21 | 22 | 2. Define shared examples using `sharedExamples`. 23 | 24 | @param configuration A mutable object that is used to configure how Quick behaves on 25 | a framework level. For details on all the options, see the 26 | documentation in Configuration.swift. 27 | */ 28 | + (void)configure:(Configuration *)configuration; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Configuration/QuickConfiguration.m: -------------------------------------------------------------------------------- 1 | #import "QuickConfiguration.h" 2 | #import "World.h" 3 | #import 4 | 5 | typedef void (^QCKClassEnumerationBlock)(Class klass); 6 | 7 | /** 8 | Finds all direct subclasses of the given class and passes them to the block provided. 9 | The classes are iterated over in the order that objc_getClassList returns them. 10 | 11 | @param klass The base class to find subclasses of. 12 | @param block A block that takes a Class. This block will be executed once for each subclass of klass. 13 | */ 14 | void qck_enumerateSubclasses(Class klass, QCKClassEnumerationBlock block) { 15 | Class *classes = NULL; 16 | int classesCount = objc_getClassList(NULL, 0); 17 | 18 | if (classesCount > 0) { 19 | classes = (Class *)calloc(sizeof(Class), classesCount); 20 | classesCount = objc_getClassList(classes, classesCount); 21 | 22 | Class subclass, superclass; 23 | for(int i = 0; i < classesCount; i++) { 24 | subclass = classes[i]; 25 | superclass = class_getSuperclass(subclass); 26 | if (superclass == klass && block) { 27 | block(subclass); 28 | } 29 | } 30 | 31 | free(classes); 32 | } 33 | } 34 | 35 | @implementation QuickConfiguration 36 | 37 | #pragma mark - Object Lifecycle 38 | 39 | /** 40 | QuickConfiguration is not meant to be instantiated; it merely provides a hook 41 | for users to configure how Quick behaves. Raise an exception if an instance of 42 | QuickConfiguration is created. 43 | */ 44 | - (instancetype)init { 45 | NSString *className = NSStringFromClass([self class]); 46 | NSString *selectorName = NSStringFromSelector(@selector(configure:)); 47 | [NSException raise:NSInternalInconsistencyException 48 | format:@"%@ is not meant to be instantiated; " 49 | @"subclass %@ and override %@ to configure Quick.", 50 | className, className, selectorName]; 51 | return nil; 52 | } 53 | 54 | #pragma mark - NSObject Overrides 55 | 56 | /** 57 | Hook into when QuickConfiguration is initialized in the runtime in order to 58 | call +[QuickConfiguration configure:] on each of its subclasses. 59 | */ 60 | + (void)initialize { 61 | // Only enumerate over the subclasses of QuickConfiguration, not any of its subclasses. 62 | if ([self class] == [QuickConfiguration class]) { 63 | 64 | // Only enumerate over subclasses once, even if +[QuickConfiguration initialize] 65 | // were to be called several times. This is necessary because +[QuickSpec initialize] 66 | // manually calls +[QuickConfiguration initialize]. 67 | static dispatch_once_t onceToken; 68 | dispatch_once(&onceToken, ^{ 69 | qck_enumerateSubclasses([QuickConfiguration class], ^(__unsafe_unretained Class klass) { 70 | [[World sharedWorld] configure:^(Configuration *configuration) { 71 | [klass configure:configuration]; 72 | }]; 73 | }); 74 | [[World sharedWorld] finalizeConfiguration]; 75 | }); 76 | } 77 | } 78 | 79 | #pragma mark - Public Interface 80 | 81 | + (void)configure:(Configuration *)configuration { } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/DSL/QCKDSL.m: -------------------------------------------------------------------------------- 1 | #import "QCKDSL.h" 2 | #import "World.h" 3 | #import "World+DSL.h" 4 | 5 | void qck_beforeSuite(QCKDSLEmptyBlock closure) { 6 | [[World sharedWorld] beforeSuite:closure]; 7 | } 8 | 9 | void qck_afterSuite(QCKDSLEmptyBlock closure) { 10 | [[World sharedWorld] afterSuite:closure]; 11 | } 12 | 13 | void qck_sharedExamples(NSString *name, QCKDSLSharedExampleBlock closure) { 14 | [[World sharedWorld] sharedExamples:name closure:closure]; 15 | } 16 | 17 | void qck_describe(NSString *description, QCKDSLEmptyBlock closure) { 18 | [[World sharedWorld] describe:description flags:@{} closure:closure]; 19 | } 20 | 21 | void qck_context(NSString *description, QCKDSLEmptyBlock closure) { 22 | qck_describe(description, closure); 23 | } 24 | 25 | void qck_beforeEach(QCKDSLEmptyBlock closure) { 26 | [[World sharedWorld] beforeEach:closure]; 27 | } 28 | 29 | void qck_beforeEachWithMetadata(QCKDSLExampleMetadataBlock closure) { 30 | [[World sharedWorld] beforeEachWithMetadata:closure]; 31 | } 32 | 33 | void qck_afterEach(QCKDSLEmptyBlock closure) { 34 | [[World sharedWorld] afterEach:closure]; 35 | } 36 | 37 | void qck_afterEachWithMetadata(QCKDSLExampleMetadataBlock closure) { 38 | [[World sharedWorld] afterEachWithMetadata:closure]; 39 | } 40 | 41 | QCKItBlock qck_it_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 42 | return ^(NSString *description, QCKDSLEmptyBlock closure) { 43 | [[World sharedWorld] itWithDescription:description 44 | flags:flags 45 | file:file 46 | line:line 47 | closure:closure]; 48 | }; 49 | } 50 | 51 | QCKItBehavesLikeBlock qck_itBehavesLike_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 52 | return ^(NSString *name, QCKDSLSharedExampleContext context) { 53 | [[World sharedWorld] itBehavesLikeSharedExampleNamed:name 54 | sharedExampleContext:context 55 | flags:flags 56 | file:file 57 | line:line]; 58 | }; 59 | } 60 | 61 | void qck_pending(NSString *description, QCKDSLEmptyBlock closure) { 62 | [[World sharedWorld] pending:description closure:closure]; 63 | } 64 | 65 | void qck_xdescribe(NSString *description, QCKDSLEmptyBlock closure) { 66 | [[World sharedWorld] xdescribe:description flags:@{} closure:closure]; 67 | } 68 | 69 | void qck_xcontext(NSString *description, QCKDSLEmptyBlock closure) { 70 | qck_xdescribe(description, closure); 71 | } 72 | 73 | void qck_fdescribe(NSString *description, QCKDSLEmptyBlock closure) { 74 | [[World sharedWorld] fdescribe:description flags:@{} closure:closure]; 75 | } 76 | 77 | void qck_fcontext(NSString *description, QCKDSLEmptyBlock closure) { 78 | qck_fdescribe(description, closure); 79 | } 80 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/DSL/World+DSL.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface World (SWIFT_EXTENSION(Quick)) 4 | - (void)beforeSuite:(void (^ __nonnull)(void))closure; 5 | - (void)afterSuite:(void (^ __nonnull)(void))closure; 6 | - (void)sharedExamples:(NSString * __nonnull)name closure:(void (^ __nonnull)(NSDictionary * __nonnull (^ __nonnull)(void)))closure; 7 | - (void)describe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 8 | - (void)context:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 9 | - (void)fdescribe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 10 | - (void)xdescribe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 11 | - (void)beforeEach:(void (^ __nonnull)(void))closure; 12 | - (void)beforeEachWithMetadata:(void (^ __nonnull)(ExampleMetadata * __nonnull))closure; 13 | - (void)afterEach:(void (^ __nonnull)(void))closure; 14 | - (void)afterEachWithMetadata:(void (^ __nonnull)(ExampleMetadata * __nonnull))closure; 15 | - (void)itWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 16 | - (void)fitWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 17 | - (void)xitWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 18 | - (void)itBehavesLikeSharedExampleNamed:(NSString * __nonnull)name sharedExampleContext:(NSDictionary * __nonnull (^ __nonnull)(void))sharedExampleContext flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line; 19 | - (void)pending:(NSString * __nonnull)description closure:(void (^ __nonnull)(void))closure; 20 | @end 21 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/ErrorUtility.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @noreturn internal func raiseError(message: String) { 4 | #if _runtime(_ObjC) 5 | NSException(name: NSInternalInconsistencyException, reason: message, userInfo: nil).raise() 6 | #endif 7 | 8 | // This won't be reached when ObjC is available and the exception above is raisd 9 | fatalError(message) 10 | } 11 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Example.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | private var numberOfExamplesRun = 0 4 | 5 | /** 6 | Examples, defined with the `it` function, use assertions to 7 | demonstrate how code should behave. These are like "tests" in XCTest. 8 | */ 9 | final public class Example: NSObject { 10 | /** 11 | A boolean indicating whether the example is a shared example; 12 | i.e.: whether it is an example defined with `itBehavesLike`. 13 | */ 14 | public var isSharedExample = false 15 | 16 | /** 17 | The site at which the example is defined. 18 | This must be set correctly in order for Xcode to highlight 19 | the correct line in red when reporting a failure. 20 | */ 21 | public var callsite: Callsite 22 | 23 | weak internal var group: ExampleGroup? 24 | 25 | private let internalDescription: String 26 | private let closure: () -> () 27 | private let flags: FilterFlags 28 | 29 | internal init(description: String, callsite: Callsite, flags: FilterFlags, closure: () -> ()) { 30 | self.internalDescription = description 31 | self.closure = closure 32 | self.callsite = callsite 33 | self.flags = flags 34 | } 35 | 36 | public override var description: String { 37 | return internalDescription 38 | } 39 | 40 | /** 41 | The example name. A name is a concatenation of the name of 42 | the example group the example belongs to, followed by the 43 | description of the example itself. 44 | 45 | The example name is used to generate a test method selector 46 | to be displayed in Xcode's test navigator. 47 | */ 48 | public var name: String { 49 | switch group!.name { 50 | case .Some(let groupName): return "\(groupName), \(description)" 51 | case .None: return description 52 | } 53 | } 54 | 55 | /** 56 | Executes the example closure, as well as all before and after 57 | closures defined in the its surrounding example groups. 58 | */ 59 | public func run() { 60 | let world = World.sharedWorld 61 | 62 | if numberOfExamplesRun == 0 { 63 | world.suiteHooks.executeBefores() 64 | } 65 | 66 | let exampleMetadata = ExampleMetadata(example: self, exampleIndex: numberOfExamplesRun) 67 | world.currentExampleMetadata = exampleMetadata 68 | 69 | world.exampleHooks.executeBefores(exampleMetadata) 70 | group!.phase = .BeforesExecuting 71 | for before in group!.befores { 72 | before(exampleMetadata: exampleMetadata) 73 | } 74 | group!.phase = .BeforesFinished 75 | 76 | closure() 77 | 78 | group!.phase = .AftersExecuting 79 | for after in group!.afters { 80 | after(exampleMetadata: exampleMetadata) 81 | } 82 | group!.phase = .AftersFinished 83 | world.exampleHooks.executeAfters(exampleMetadata) 84 | 85 | numberOfExamplesRun += 1 86 | 87 | if !world.isRunningAdditionalSuites && numberOfExamplesRun >= world.exampleCount { 88 | world.suiteHooks.executeAfters() 89 | } 90 | } 91 | 92 | /** 93 | Evaluates the filter flags set on this example and on the example groups 94 | this example belongs to. Flags set on the example are trumped by flags on 95 | the example group it belongs to. Flags on inner example groups are trumped 96 | by flags on outer example groups. 97 | */ 98 | internal var filterFlags: FilterFlags { 99 | var aggregateFlags = flags 100 | for (key, value) in group!.filterFlags { 101 | aggregateFlags[key] = value 102 | } 103 | return aggregateFlags 104 | } 105 | } 106 | 107 | /** 108 | Returns a boolean indicating whether two Example objects are equal. 109 | If two examples are defined at the exact same callsite, they must be equal. 110 | */ 111 | public func ==(lhs: Example, rhs: Example) -> Bool { 112 | return lhs.callsite == rhs.callsite 113 | } 114 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/ExampleGroup.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | Example groups are logical groupings of examples, defined with 5 | the `describe` and `context` functions. Example groups can share 6 | setup and teardown code. 7 | */ 8 | final public class ExampleGroup: NSObject { 9 | weak internal var parent: ExampleGroup? 10 | internal let hooks = ExampleHooks() 11 | 12 | internal var phase: HooksPhase = .NothingExecuted 13 | 14 | private let internalDescription: String 15 | private let flags: FilterFlags 16 | private let isInternalRootExampleGroup: Bool 17 | private var childGroups = [ExampleGroup]() 18 | private var childExamples = [Example]() 19 | 20 | internal init(description: String, flags: FilterFlags, isInternalRootExampleGroup: Bool = false) { 21 | self.internalDescription = description 22 | self.flags = flags 23 | self.isInternalRootExampleGroup = isInternalRootExampleGroup 24 | } 25 | 26 | public override var description: String { 27 | return internalDescription 28 | } 29 | 30 | /** 31 | Returns a list of examples that belong to this example group, 32 | or to any of its descendant example groups. 33 | */ 34 | public var examples: [Example] { 35 | var examples = childExamples 36 | for group in childGroups { 37 | examples.appendContentsOf(group.examples) 38 | } 39 | return examples 40 | } 41 | 42 | internal var name: String? { 43 | if let parent = parent { 44 | switch(parent.name) { 45 | case .Some(let name): return "\(name), \(description)" 46 | case .None: return description 47 | } 48 | } else { 49 | return isInternalRootExampleGroup ? nil : description 50 | } 51 | } 52 | 53 | internal var filterFlags: FilterFlags { 54 | var aggregateFlags = flags 55 | walkUp() { (group: ExampleGroup) -> () in 56 | for (key, value) in group.flags { 57 | aggregateFlags[key] = value 58 | } 59 | } 60 | return aggregateFlags 61 | } 62 | 63 | internal var befores: [BeforeExampleWithMetadataClosure] { 64 | var closures = Array(hooks.befores.reverse()) 65 | walkUp() { (group: ExampleGroup) -> () in 66 | closures.appendContentsOf(Array(group.hooks.befores.reverse())) 67 | } 68 | return Array(closures.reverse()) 69 | } 70 | 71 | internal var afters: [AfterExampleWithMetadataClosure] { 72 | var closures = hooks.afters 73 | walkUp() { (group: ExampleGroup) -> () in 74 | closures.appendContentsOf(group.hooks.afters) 75 | } 76 | return closures 77 | } 78 | 79 | internal func walkDownExamples(callback: (example: Example) -> ()) { 80 | for example in childExamples { 81 | callback(example: example) 82 | } 83 | for group in childGroups { 84 | group.walkDownExamples(callback) 85 | } 86 | } 87 | 88 | internal func appendExampleGroup(group: ExampleGroup) { 89 | group.parent = self 90 | childGroups.append(group) 91 | } 92 | 93 | internal func appendExample(example: Example) { 94 | example.group = self 95 | childExamples.append(example) 96 | } 97 | 98 | private func walkUp(callback: (group: ExampleGroup) -> ()) { 99 | var group = self 100 | while let parent = group.parent { 101 | callback(group: parent) 102 | group = parent 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/ExampleMetadata.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | A class that encapsulates information about an example, 5 | including the index at which the example was executed, as 6 | well as the example itself. 7 | */ 8 | final public class ExampleMetadata: NSObject { 9 | /** 10 | The example for which this metadata was collected. 11 | */ 12 | public let example: Example 13 | 14 | /** 15 | The index at which this example was executed in the 16 | test suite. 17 | */ 18 | public let exampleIndex: Int 19 | 20 | internal init(example: Example, exampleIndex: Int) { 21 | self.example = example 22 | self.exampleIndex = exampleIndex 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Filter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | A mapping of string keys to booleans that can be used to 5 | filter examples or example groups. For example, a "focused" 6 | example would have the flags [Focused: true]. 7 | */ 8 | public typealias FilterFlags = [String: Bool] 9 | 10 | /** 11 | A namespace for filter flag keys, defined primarily to make the 12 | keys available in Objective-C. 13 | */ 14 | final public class Filter: NSObject { 15 | /** 16 | Example and example groups with [Focused: true] are included in test runs, 17 | excluding all other examples without this flag. Use this to only run one or 18 | two tests that you're currently focusing on. 19 | */ 20 | public class var focused: String { 21 | return "focused" 22 | } 23 | 24 | /** 25 | Example and example groups with [Pending: true] are excluded from test runs. 26 | Use this to temporarily suspend examples that you know do not pass yet. 27 | */ 28 | public class var pending: String { 29 | return "pending" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Hooks/Closures.swift: -------------------------------------------------------------------------------- 1 | // MARK: Example Hooks 2 | 3 | /** 4 | A closure executed before an example is run. 5 | */ 6 | public typealias BeforeExampleClosure = () -> () 7 | 8 | /** 9 | A closure executed before an example is run. The closure is given example metadata, 10 | which contains information about the example that is about to be run. 11 | */ 12 | public typealias BeforeExampleWithMetadataClosure = (exampleMetadata: ExampleMetadata) -> () 13 | 14 | /** 15 | A closure executed after an example is run. 16 | */ 17 | public typealias AfterExampleClosure = BeforeExampleClosure 18 | 19 | /** 20 | A closure executed after an example is run. The closure is given example metadata, 21 | which contains information about the example that has just finished running. 22 | */ 23 | public typealias AfterExampleWithMetadataClosure = BeforeExampleWithMetadataClosure 24 | 25 | // MARK: Suite Hooks 26 | 27 | /** 28 | A closure executed before any examples are run. 29 | */ 30 | public typealias BeforeSuiteClosure = () -> () 31 | 32 | /** 33 | A closure executed after all examples have finished running. 34 | */ 35 | public typealias AfterSuiteClosure = BeforeSuiteClosure 36 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Hooks/ExampleHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after each example. 3 | */ 4 | final internal class ExampleHooks { 5 | internal var befores: [BeforeExampleWithMetadataClosure] = [] 6 | internal var afters: [AfterExampleWithMetadataClosure] = [] 7 | internal var phase: HooksPhase = .NothingExecuted 8 | 9 | internal func appendBefore(closure: BeforeExampleWithMetadataClosure) { 10 | befores.append(closure) 11 | } 12 | 13 | internal func appendBefore(closure: BeforeExampleClosure) { 14 | befores.append { (exampleMetadata: ExampleMetadata) in closure() } 15 | } 16 | 17 | internal func appendAfter(closure: AfterExampleWithMetadataClosure) { 18 | afters.append(closure) 19 | } 20 | 21 | internal func appendAfter(closure: AfterExampleClosure) { 22 | afters.append { (exampleMetadata: ExampleMetadata) in closure() } 23 | } 24 | 25 | internal func executeBefores(exampleMetadata: ExampleMetadata) { 26 | phase = .BeforesExecuting 27 | for before in befores { 28 | before(exampleMetadata: exampleMetadata) 29 | } 30 | 31 | phase = .BeforesFinished 32 | } 33 | 34 | internal func executeAfters(exampleMetadata: ExampleMetadata) { 35 | phase = .AftersExecuting 36 | for after in afters { 37 | after(exampleMetadata: exampleMetadata) 38 | } 39 | 40 | phase = .AftersFinished 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Hooks/HooksPhase.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A description of the execution cycle of the current example with 3 | respect to the hooks of that example. 4 | */ 5 | internal enum HooksPhase: Int { 6 | case NothingExecuted = 0 7 | case BeforesExecuting 8 | case BeforesFinished 9 | case AftersExecuting 10 | case AftersFinished 11 | } 12 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Hooks/SuiteHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after all examples. 3 | */ 4 | final internal class SuiteHooks { 5 | internal var befores: [BeforeSuiteClosure] = [] 6 | internal var afters: [AfterSuiteClosure] = [] 7 | internal var phase: HooksPhase = .NothingExecuted 8 | 9 | internal func appendBefore(closure: BeforeSuiteClosure) { 10 | befores.append(closure) 11 | } 12 | 13 | internal func appendAfter(closure: AfterSuiteClosure) { 14 | afters.append(closure) 15 | } 16 | 17 | internal func executeBefores() { 18 | phase = .BeforesExecuting 19 | for before in befores { 20 | before() 21 | } 22 | phase = .BeforesFinished 23 | } 24 | 25 | internal func executeAfters() { 26 | phase = .AftersExecuting 27 | for after in afters { 28 | after() 29 | } 30 | phase = .AftersFinished 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/NSBundle+CurrentTestBundle.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | 3 | import Foundation 4 | 5 | extension NSBundle { 6 | 7 | /** 8 | Locates the first bundle with a '.xctest' file extension. 9 | */ 10 | internal static var currentTestBundle: NSBundle? { 11 | return allBundles().lazy 12 | .filter { 13 | $0.bundlePath.hasSuffix(".xctest") 14 | } 15 | .first 16 | } 17 | 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/NSString+QCKSelectorName.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | QuickSpec converts example names into test methods. 5 | Those test methods need valid selector names, which means no whitespace, 6 | control characters, etc. This category gives NSString objects an easy way 7 | to replace those illegal characters with underscores. 8 | */ 9 | @interface NSString (QCKSelectorName) 10 | 11 | /** 12 | Returns a string with underscores in place of all characters that cannot 13 | be included in a selector (SEL) name. 14 | */ 15 | @property (nonatomic, readonly) NSString *qck_selectorName; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/NSString+QCKSelectorName.m: -------------------------------------------------------------------------------- 1 | #import "NSString+QCKSelectorName.h" 2 | 3 | @implementation NSString (QCKSelectorName) 4 | 5 | - (NSString *)qck_selectorName { 6 | static NSMutableCharacterSet *invalidCharacters = nil; 7 | static dispatch_once_t onceToken; 8 | dispatch_once(&onceToken, ^{ 9 | invalidCharacters = [NSMutableCharacterSet new]; 10 | 11 | NSCharacterSet *whitespaceCharacterSet = [NSCharacterSet whitespaceCharacterSet]; 12 | NSCharacterSet *newlineCharacterSet = [NSCharacterSet newlineCharacterSet]; 13 | NSCharacterSet *illegalCharacterSet = [NSCharacterSet illegalCharacterSet]; 14 | NSCharacterSet *controlCharacterSet = [NSCharacterSet controlCharacterSet]; 15 | NSCharacterSet *punctuationCharacterSet = [NSCharacterSet punctuationCharacterSet]; 16 | NSCharacterSet *nonBaseCharacterSet = [NSCharacterSet nonBaseCharacterSet]; 17 | NSCharacterSet *symbolCharacterSet = [NSCharacterSet symbolCharacterSet]; 18 | 19 | [invalidCharacters formUnionWithCharacterSet:whitespaceCharacterSet]; 20 | [invalidCharacters formUnionWithCharacterSet:newlineCharacterSet]; 21 | [invalidCharacters formUnionWithCharacterSet:illegalCharacterSet]; 22 | [invalidCharacters formUnionWithCharacterSet:controlCharacterSet]; 23 | [invalidCharacters formUnionWithCharacterSet:punctuationCharacterSet]; 24 | [invalidCharacters formUnionWithCharacterSet:nonBaseCharacterSet]; 25 | [invalidCharacters formUnionWithCharacterSet:symbolCharacterSet]; 26 | }); 27 | 28 | NSArray *validComponents = [self componentsSeparatedByCharactersInSet:invalidCharacters]; 29 | 30 | NSString *result = [validComponents componentsJoinedByString:@"_"]; 31 | 32 | return ([result length] == 0 33 | ? @"_" 34 | : result); 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/Quick.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for Quick. 4 | FOUNDATION_EXPORT double QuickVersionNumber; 5 | 6 | //! Project version string for Quick. 7 | FOUNDATION_EXPORT const unsigned char QuickVersionString[]; 8 | 9 | #import "QuickSpec.h" 10 | #import "QCKDSL.h" 11 | #import "QuickConfiguration.h" 12 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | 3 | /** 4 | Responsible for building a "Selected tests" suite. This corresponds to a single 5 | spec, and all its examples. 6 | */ 7 | internal class QuickSelectedTestSuiteBuilder: QuickTestSuiteBuilder { 8 | 9 | /** 10 | The test spec class to run. 11 | */ 12 | let testCaseClass: AnyClass! 13 | 14 | /** 15 | For Objective-C classes, returns the class name. For Swift classes without, 16 | an explicit Objective-C name, returns a module-namespaced class name 17 | (e.g., "FooTests.FooSpec"). 18 | */ 19 | var testSuiteClassName: String { 20 | return NSStringFromClass(testCaseClass) 21 | } 22 | 23 | /** 24 | Given a test case name: 25 | 26 | FooSpec/testFoo 27 | 28 | Optionally constructs a test suite builder for the named test case class 29 | in the running test bundle. 30 | 31 | If no test bundle can be found, or the test case class can't be found, 32 | initialization fails and returns `nil`. 33 | */ 34 | init?(forTestCaseWithName name: String) { 35 | guard let testCaseClass = testCaseClassForTestCaseWithName(name) else { 36 | self.testCaseClass = nil 37 | return nil 38 | } 39 | 40 | self.testCaseClass = testCaseClass 41 | } 42 | 43 | /** 44 | Returns a `QuickTestSuite` that runs the associated test case class. 45 | */ 46 | func buildTestSuite() -> QuickTestSuite { 47 | return QuickTestSuite(forTestCaseClass: testCaseClass) 48 | } 49 | 50 | } 51 | 52 | /** 53 | Searches `NSBundle.allBundles()` for an xctest bundle, then looks up the named 54 | test case class in that bundle. 55 | 56 | Returns `nil` if a bundle or test case class cannot be found. 57 | */ 58 | private func testCaseClassForTestCaseWithName(name: String) -> AnyClass? { 59 | func extractClassName(name: String) -> String? { 60 | return name.characters.split("/").first.map(String.init) 61 | } 62 | 63 | guard let className = extractClassName(name) else { return nil } 64 | guard let bundle = NSBundle.currentTestBundle else { return nil } 65 | 66 | if let testCaseClass = bundle.classNamed(className) { return testCaseClass } 67 | 68 | guard let moduleName = bundle.bundlePath.fileName else { return nil } 69 | 70 | return NSClassFromString("\(moduleName).\(className)") 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/QuickSpec.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | QuickSpec is a base class all specs written in Quick inherit from. 5 | They need to inherit from QuickSpec, a subclass of XCTestCase, in 6 | order to be discovered by the XCTest framework. 7 | 8 | XCTest automatically compiles a list of XCTestCase subclasses included 9 | in the test target. It iterates over each class in that list, and creates 10 | a new instance of that class for each test method. It then creates an 11 | "invocation" to execute that test method. The invocation is an instance of 12 | NSInvocation, which represents a single message send in Objective-C. 13 | The invocation is set on the XCTestCase instance, and the test is run. 14 | 15 | Most of the code in QuickSpec is dedicated to hooking into XCTest events. 16 | First, when the spec is first loaded and before it is sent any messages, 17 | the +[NSObject initialize] method is called. QuickSpec overrides this method 18 | to call +[QuickSpec spec]. This builds the example group stacks and 19 | registers them with Quick.World, a global register of examples. 20 | 21 | Then, XCTest queries QuickSpec for a list of test methods. Normally, XCTest 22 | automatically finds all methods whose selectors begin with the string "test". 23 | However, QuickSpec overrides this default behavior by implementing the 24 | +[XCTestCase testInvocations] method. This method iterates over each example 25 | registered in Quick.World, defines a new method for that example, and 26 | returns an invocation to call that method to XCTest. Those invocations are 27 | the tests that are run by XCTest. Their selector names are displayed in 28 | the Xcode test navigation bar. 29 | */ 30 | @interface QuickSpec : XCTestCase 31 | 32 | /** 33 | Override this method in your spec to define a set of example groups 34 | and examples. 35 | 36 | override class func spec() { 37 | describe("winter") { 38 | it("is coming") { 39 | // ... 40 | } 41 | } 42 | } 43 | 44 | See DSL.swift for more information on what syntax is available. 45 | */ 46 | - (void)spec; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/QuickTestSuite.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | 3 | import XCTest 4 | 5 | /** 6 | This protocol defines the role of an object that builds test suites. 7 | */ 8 | internal protocol QuickTestSuiteBuilder { 9 | 10 | /** 11 | Construct a `QuickTestSuite` instance with the appropriate test cases added as tests. 12 | 13 | Subsequent calls to this method should return equivalent test suites. 14 | */ 15 | func buildTestSuite() -> QuickTestSuite 16 | 17 | } 18 | 19 | /** 20 | A base class for a class cluster of Quick test suites, that should correctly 21 | build dynamic test suites for XCTest to execute. 22 | */ 23 | public class QuickTestSuite: XCTestSuite { 24 | 25 | private static var builtTestSuites: Set = Set() 26 | 27 | /** 28 | Construct a test suite for a specific, selected subset of test cases (rather 29 | than the default, which as all test cases). 30 | 31 | If this method is called multiple times for the same test case class, e.g.. 32 | 33 | FooSpec/testFoo 34 | FooSpec/testBar 35 | 36 | It is expected that the first call should return a valid test suite, and 37 | all subsequent calls should return `nil`. 38 | */ 39 | public static func selectedTestSuite(forTestCaseWithName name: String) -> QuickTestSuite? { 40 | guard let builder = QuickSelectedTestSuiteBuilder(forTestCaseWithName: name) else { return nil } 41 | 42 | if builtTestSuites.contains(builder.testSuiteClassName) { 43 | return nil 44 | } else { 45 | builtTestSuites.insert(builder.testSuiteClassName) 46 | return builder.buildTestSuite() 47 | } 48 | } 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/String+FileName.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension String { 4 | 5 | /** 6 | If the receiver represents a path, returns its file name with a file extension. 7 | */ 8 | var fileName: String? { 9 | return NSURL(string: self)?.URLByDeletingPathExtension?.lastPathComponent 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/World.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class ExampleGroup; 4 | @class ExampleMetadata; 5 | 6 | SWIFT_CLASS("_TtC5Quick5World") 7 | @interface World 8 | 9 | @property (nonatomic) ExampleGroup * __nullable currentExampleGroup; 10 | @property (nonatomic) ExampleMetadata * __nullable currentExampleMetadata; 11 | @property (nonatomic) BOOL isRunningAdditionalSuites; 12 | + (World * __nonnull)sharedWorld; 13 | - (void)configure:(void (^ __nonnull)(Configuration * __nonnull))closure; 14 | - (void)finalizeConfiguration; 15 | - (ExampleGroup * __nonnull)rootExampleGroupForSpecClass:(Class __nonnull)cls; 16 | - (NSArray * __nonnull)examplesForSpecClass:(Class __nonnull)specClass; 17 | @end 18 | -------------------------------------------------------------------------------- /Pods/Quick/Sources/Quick/XCTestSuite+QuickTestSuiteBuilder.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface XCTestSuite (QuickTestSuiteBuilder) 6 | @end 7 | 8 | @implementation XCTestSuite (QuickTestSuiteBuilder) 9 | 10 | /** 11 | In order to ensure we can correctly build dynamic test suites, we need to 12 | replace some of the default test suite constructors. 13 | */ 14 | + (void)load { 15 | Method testCaseWithName = class_getClassMethod(self, @selector(testSuiteForTestCaseWithName:)); 16 | Method hooked_testCaseWithName = class_getClassMethod(self, @selector(qck_hooked_testSuiteForTestCaseWithName:)); 17 | method_exchangeImplementations(testCaseWithName, hooked_testCaseWithName); 18 | } 19 | 20 | /** 21 | The `+testSuiteForTestCaseWithName:` method is called when a specific test case 22 | class is run from the Xcode test navigator. If the built test suite is `nil`, 23 | Xcode will not run any tests for that test case. 24 | 25 | Given if the following test case class is run from the Xcode test navigator: 26 | 27 | FooSpec 28 | testFoo 29 | testBar 30 | 31 | XCTest will invoke this once per test case, with test case names following this format: 32 | 33 | FooSpec/testFoo 34 | FooSpec/testBar 35 | */ 36 | + (nullable instancetype)qck_hooked_testSuiteForTestCaseWithName:(nonnull NSString *)name { 37 | return [QuickTestSuite selectedTestSuiteForTestCaseWithName:name]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Nimble/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Nimble/Nimble-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Nimble : NSObject 3 | @end 4 | @implementation PodsDummy_Nimble 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Nimble/Nimble-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Nimble/Nimble-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "DSL.h" 4 | #import "NMBExceptionCapture.h" 5 | #import "NMBStringify.h" 6 | #import "Nimble.h" 7 | 8 | FOUNDATION_EXPORT double NimbleVersionNumber; 9 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; 10 | 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Nimble/Nimble.modulemap: -------------------------------------------------------------------------------- 1 | framework module Nimble { 2 | umbrella header "Nimble-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Nimble/Nimble.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_SHARED_BUILD_DIR/Nimble 2 | ENABLE_BITCODE = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 6 | OTHER_LDFLAGS = -weak-lswiftXCTest -weak_framework "XCTest" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_SHARED_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_CIFilterKit : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_CIFilterKit 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_CIFilterKitVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_CIFilterKitVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_ROOT = ${SRCROOT}/Pods 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_CIFilterKit { 2 | umbrella header "Pods-CIFilterKit-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKit/Pods-CIFilterKit.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_ROOT = ${SRCROOT}/Pods 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKitTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKitTests/Pods-CIFilterKitTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_CIFilterKitTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_CIFilterKitTests 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKitTests/Pods-CIFilterKitTests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/Nimble/Nimble.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/Quick/Quick.framework" 89 | fi 90 | if [[ "$CONFIGURATION" == "Release" ]]; then 91 | install_framework "$BUILT_PRODUCTS_DIR/Nimble/Nimble.framework" 92 | install_framework "$BUILT_PRODUCTS_DIR/Quick/Quick.framework" 93 | fi 94 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKitTests/Pods-CIFilterKitTests-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_CIFilterKitTestsVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_CIFilterKitTestsVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKitTests/Pods-CIFilterKitTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$CONFIGURATION_BUILD_DIR/Nimble" "$CONFIGURATION_BUILD_DIR/Quick" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Nimble" -framework "Quick" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKitTests/Pods-CIFilterKitTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_CIFilterKitTests { 2 | umbrella header "Pods-CIFilterKitTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-CIFilterKitTests/Pods-CIFilterKitTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$CONFIGURATION_BUILD_DIR/Nimble" "$CONFIGURATION_BUILD_DIR/Quick" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Nimble" -framework "Quick" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ExampleApp : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ExampleApp 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_ExampleAppVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_ExampleAppVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_ROOT = ${SRCROOT}/Pods 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ExampleApp { 2 | umbrella header "Pods-ExampleApp-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleApp/Pods-ExampleApp.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | PODS_ROOT = ${SRCROOT}/Pods 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleAppTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleAppTests/Pods-ExampleAppTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ExampleAppTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ExampleAppTests 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleAppTests/Pods-ExampleAppTests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/Nimble/Nimble.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/Quick/Quick.framework" 89 | fi 90 | if [[ "$CONFIGURATION" == "Release" ]]; then 91 | install_framework "$BUILT_PRODUCTS_DIR/Nimble/Nimble.framework" 92 | install_framework "$BUILT_PRODUCTS_DIR/Quick/Quick.framework" 93 | fi 94 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleAppTests/Pods-ExampleAppTests-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_ExampleAppTestsVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_ExampleAppTestsVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleAppTests/Pods-ExampleAppTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$CONFIGURATION_BUILD_DIR/Nimble" "$CONFIGURATION_BUILD_DIR/Quick" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Nimble" -framework "Quick" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleAppTests/Pods-ExampleAppTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ExampleAppTests { 2 | umbrella header "Pods-ExampleAppTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ExampleAppTests/Pods-ExampleAppTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$CONFIGURATION_BUILD_DIR/Nimble" "$CONFIGURATION_BUILD_DIR/Quick" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Nimble" -framework "Quick" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Quick/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.9.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Quick/Quick-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Quick : NSObject 3 | @end 4 | @implementation PodsDummy_Quick 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Quick/Quick-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Quick/Quick-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "QuickConfiguration.h" 4 | #import "QCKDSL.h" 5 | #import "Quick.h" 6 | #import "QuickSpec.h" 7 | 8 | FOUNDATION_EXPORT double QuickVersionNumber; 9 | FOUNDATION_EXPORT const unsigned char QuickVersionString[]; 10 | 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Quick/Quick.modulemap: -------------------------------------------------------------------------------- 1 | framework module Quick { 2 | umbrella header "Quick-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Quick/Quick.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_SHARED_BUILD_DIR/Quick 2 | ENABLE_BITCODE = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 6 | OTHER_LDFLAGS = -framework "XCTest" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_SHARED_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![icon](https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/master/filter.png) 2 | 3 | #CIFilterKit 4 | 5 | [![Build Status](https://travis-ci.org/jefflovejapan/CIFilterKit.svg?branch=master)](https://travis-ci.org/jefflovejapan/CIFilterKit) 6 | 7 | In order to use Core Image you have to create an instance of `CIFilter`, set the appropriate keys and values, then extract the filter's output image. 8 | 9 | ```swift 10 | let inImg = CIImage(CGImage:someUIImage.CGImage!) 11 | let filter = CIFilter(name:"CIGaussianBlur", withInputParameters:[kCIInputRadiusKey: 100.0, kCIInputImageKey: inImg]) 12 | let outImg = filter.outputImage 13 | ``` 14 | 15 | That's a lot of work to essentially call a single function, and it gets more cumbersome the more filters you chain together. CIFilterKit provides a functional, composable wrapper that can make Core Image easier to work with. 16 | 17 | ###Installation 18 | 19 | The easiest way to install CIFilterKit is with [CocoaPods](cocoapods.org). Just add the following to your Podfile: 20 | 21 | ```swift 22 | pod 'CIFilterKit' 23 | ``` 24 | 25 | Note that you'll also need to [add `use_frameworks!` to your Podfile](http://blog.cocoapods.org/CocoaPods-0.36/) if you haven't already. 26 | 27 | ###Usage 28 | 29 | A `Filter` is a function of type `CIImage -> CIImage`. You can create an instance of any of the available Core Image filters by calling the respective function, the name of the equivalent `CIFilter` minus the "CI". For example, the code from the introduction becomes: 30 | 31 | ```swift 32 | let outImg = GaussianBlur(100.0)(inImg) 33 | ``` 34 | 35 | Many filters take an associated `options` struct as an argument. These each implement two initializers -- one that takes an argument for each variable in the struct, and one that takes no arguments, setting them all to their default values. The latter provides an easy way to to set a single value for the one parameter you care about and leave everything else at its default value, without having to deal with optionals. 36 | 37 | ```swift 38 | let options1 = DotScreenOptions(inputCenter:XYPosition(x:150.0, y:150.0), inputAngle:1.6, inputWidth:6.0, inputSharpness:0.7) 39 | var options2 = DotScreenOptions() 40 | options2.inputAngle = 1.6 41 | ``` 42 | 43 | ###Chaining 44 | 45 | Filters can be chained together using the `|>>` operator. 46 | 47 | ```swift 48 | let inImg = CIImage(CGImage:someUIImage.CGImage!) 49 | let filter1 = GaussianBlur(100.0) 50 | let filter2 = PhotoEffectChrome() 51 | let filter3 = ColorPosterize(50.0) 52 | let stacked: Filter = filter1 |>> filter2 |>> filter3 53 | let outImg = stacked(inImg) 54 | ``` 55 | 56 | ###Attributes 57 | 58 | And we can get the filter's associated `attributes` dictionary by calling `attributesForFilter` 59 | 60 | ```swift 61 | let dotScreenAttributes: FilterAttributes = attributesForFilter(FilterName.DotScreen) 62 | ``` 63 | 64 | ###Generators 65 | 66 | Lastly, CIFilters that are members of `CICategoryGenerator` or `CICategoryGradient` don't take input images as arguments, and so their respective functions simply return the output `CIImage` rather than a `Filter` closure. 67 | 68 | ```swift 69 | let aGradient: CIImage = GaussianGradient(GaussianGradientOptions()) 70 | ``` 71 | 72 | ###Thanks 73 | 74 | Inspired by the "Wrapping Core Image" chapter of [*Functional Programming in Swift*](http://www.objc.io/books/) by Chris Eidhof, Florian Kugler, and Wouter Swierstra. -------------------------------------------------------------------------------- /filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jefflovejapan/CIFilterKit/84cef926adee9da34c7aacde8b443bf0784f5c06/filter.png --------------------------------------------------------------------------------