├── .gitignore
├── .swift-version
├── .travis.yml
├── Example
├── Empty
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ └── ViewController.swift
├── Podfile
├── Podfile.lock
├── Pods
│ ├── Local Podspecs
│ │ └── RxEventHub.podspec.json
│ ├── Manifest.lock
│ ├── Nimble
│ │ ├── LICENSE
│ │ ├── README.md
│ │ └── Sources
│ │ │ ├── Nimble
│ │ │ ├── Adapters
│ │ │ │ ├── AdapterProtocols.swift
│ │ │ │ ├── AssertionDispatcher.swift
│ │ │ │ ├── AssertionRecorder.swift
│ │ │ │ ├── NMBExpectation.swift
│ │ │ │ ├── NMBObjCMatcher.swift
│ │ │ │ ├── NimbleEnvironment.swift
│ │ │ │ └── NimbleXCTestHandler.swift
│ │ │ ├── DSL+Wait.swift
│ │ │ ├── DSL.swift
│ │ │ ├── Expectation.swift
│ │ │ ├── ExpectationMessage.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
│ │ │ │ ├── ContainElementSatisfying.swift
│ │ │ │ ├── EndWith.swift
│ │ │ │ ├── Equal.swift
│ │ │ │ ├── HaveCount.swift
│ │ │ │ ├── Match.swift
│ │ │ │ ├── MatchError.swift
│ │ │ │ ├── MatcherFunc.swift
│ │ │ │ ├── MatcherProtocols.swift
│ │ │ │ ├── PostNotification.swift
│ │ │ │ ├── Predicate.swift
│ │ │ │ ├── RaisesException.swift
│ │ │ │ ├── SatisfyAnyOf.swift
│ │ │ │ ├── ThrowAssertion.swift
│ │ │ │ ├── ThrowError.swift
│ │ │ │ └── ToSucceed.swift
│ │ │ ├── Nimble.h
│ │ │ └── Utils
│ │ │ │ ├── Async.swift
│ │ │ │ ├── Errors.swift
│ │ │ │ ├── Functional.swift
│ │ │ │ ├── SourceLocation.swift
│ │ │ │ └── Stringers.swift
│ │ │ └── NimbleObjectiveC
│ │ │ ├── CurrentTestCaseTracker.h
│ │ │ ├── DSL.h
│ │ │ ├── DSL.m
│ │ │ ├── NMBExceptionCapture.h
│ │ │ ├── NMBExceptionCapture.m
│ │ │ ├── NMBStringify.h
│ │ │ ├── NMBStringify.m
│ │ │ └── XCTestObservationCenter+Register.m
│ ├── Pods.xcodeproj
│ │ └── project.pbxproj
│ ├── Quick
│ │ ├── LICENSE
│ │ ├── README.md
│ │ └── Sources
│ │ │ ├── Quick
│ │ │ ├── Behavior.swift
│ │ │ ├── Callsite.swift
│ │ │ ├── Configuration
│ │ │ │ └── Configuration.swift
│ │ │ ├── DSL
│ │ │ │ ├── DSL.swift
│ │ │ │ └── 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+C99ExtendedIdentifier.swift
│ │ │ ├── QuickSelectedTestSuiteBuilder.swift
│ │ │ ├── QuickTestSuite.swift
│ │ │ ├── URL+FileName.swift
│ │ │ └── World.swift
│ │ │ ├── QuickObjectiveC
│ │ │ ├── Configuration
│ │ │ │ ├── QuickConfiguration.h
│ │ │ │ └── QuickConfiguration.m
│ │ │ ├── DSL
│ │ │ │ ├── QCKDSL.h
│ │ │ │ ├── QCKDSL.m
│ │ │ │ └── World+DSL.h
│ │ │ ├── Quick.h
│ │ │ ├── QuickSpec.h
│ │ │ ├── QuickSpec.m
│ │ │ ├── World.h
│ │ │ └── XCTestSuite+QuickTestSuiteBuilder.m
│ │ │ └── QuickSpecBase
│ │ │ ├── QuickSpecBase.m
│ │ │ └── include
│ │ │ └── QuickSpecBase.h
│ ├── RxSwift
│ │ ├── LICENSE.md
│ │ ├── Platform
│ │ │ ├── DataStructures
│ │ │ │ ├── Bag.swift
│ │ │ │ ├── InfiniteSequence.swift
│ │ │ │ ├── PriorityQueue.swift
│ │ │ │ └── Queue.swift
│ │ │ ├── DispatchQueue+Extensions.swift
│ │ │ ├── Platform.Darwin.swift
│ │ │ ├── Platform.Linux.swift
│ │ │ └── RecursiveLock.swift
│ │ ├── README.md
│ │ └── RxSwift
│ │ │ ├── AnyObserver.swift
│ │ │ ├── Cancelable.swift
│ │ │ ├── Concurrency
│ │ │ ├── AsyncLock.swift
│ │ │ ├── Lock.swift
│ │ │ ├── LockOwnerType.swift
│ │ │ ├── SynchronizedDisposeType.swift
│ │ │ ├── SynchronizedOnType.swift
│ │ │ ├── SynchronizedSubscribeType.swift
│ │ │ └── SynchronizedUnsubscribeType.swift
│ │ │ ├── ConnectableObservableType.swift
│ │ │ ├── Deprecated.swift
│ │ │ ├── Disposable.swift
│ │ │ ├── Disposables
│ │ │ ├── AnonymousDisposable.swift
│ │ │ ├── BinaryDisposable.swift
│ │ │ ├── BooleanDisposable.swift
│ │ │ ├── CompositeDisposable.swift
│ │ │ ├── Disposables.swift
│ │ │ ├── DisposeBag.swift
│ │ │ ├── DisposeBase.swift
│ │ │ ├── NopDisposable.swift
│ │ │ ├── RefCountDisposable.swift
│ │ │ ├── ScheduledDisposable.swift
│ │ │ ├── SerialDisposable.swift
│ │ │ ├── SingleAssignmentDisposable.swift
│ │ │ └── SubscriptionDisposable.swift
│ │ │ ├── Errors.swift
│ │ │ ├── Event.swift
│ │ │ ├── Extensions
│ │ │ ├── Bag+Rx.swift
│ │ │ └── String+Rx.swift
│ │ │ ├── GroupedObservable.swift
│ │ │ ├── ImmediateSchedulerType.swift
│ │ │ ├── Observable.swift
│ │ │ ├── ObservableConvertibleType.swift
│ │ │ ├── ObservableType+Extensions.swift
│ │ │ ├── ObservableType.swift
│ │ │ ├── Observables
│ │ │ ├── AddRef.swift
│ │ │ ├── Amb.swift
│ │ │ ├── AsMaybe.swift
│ │ │ ├── AsSingle.swift
│ │ │ ├── Buffer.swift
│ │ │ ├── Catch.swift
│ │ │ ├── CombineLatest+Collection.swift
│ │ │ ├── CombineLatest+arity.swift
│ │ │ ├── CombineLatest.swift
│ │ │ ├── Concat.swift
│ │ │ ├── Create.swift
│ │ │ ├── Debounce.swift
│ │ │ ├── Debug.swift
│ │ │ ├── DefaultIfEmpty.swift
│ │ │ ├── Deferred.swift
│ │ │ ├── Delay.swift
│ │ │ ├── DelaySubscription.swift
│ │ │ ├── Dematerialize.swift
│ │ │ ├── DistinctUntilChanged.swift
│ │ │ ├── Do.swift
│ │ │ ├── ElementAt.swift
│ │ │ ├── Empty.swift
│ │ │ ├── Error.swift
│ │ │ ├── Filter.swift
│ │ │ ├── Generate.swift
│ │ │ ├── GroupBy.swift
│ │ │ ├── Just.swift
│ │ │ ├── Map.swift
│ │ │ ├── Materialize.swift
│ │ │ ├── Merge.swift
│ │ │ ├── Multicast.swift
│ │ │ ├── Never.swift
│ │ │ ├── ObserveOn.swift
│ │ │ ├── Optional.swift
│ │ │ ├── Producer.swift
│ │ │ ├── Range.swift
│ │ │ ├── Reduce.swift
│ │ │ ├── Repeat.swift
│ │ │ ├── RetryWhen.swift
│ │ │ ├── Sample.swift
│ │ │ ├── Scan.swift
│ │ │ ├── Sequence.swift
│ │ │ ├── ShareReplayScope.swift
│ │ │ ├── SingleAsync.swift
│ │ │ ├── Sink.swift
│ │ │ ├── Skip.swift
│ │ │ ├── SkipUntil.swift
│ │ │ ├── SkipWhile.swift
│ │ │ ├── StartWith.swift
│ │ │ ├── SubscribeOn.swift
│ │ │ ├── Switch.swift
│ │ │ ├── SwitchIfEmpty.swift
│ │ │ ├── Take.swift
│ │ │ ├── TakeLast.swift
│ │ │ ├── TakeUntil.swift
│ │ │ ├── TakeWhile.swift
│ │ │ ├── Throttle.swift
│ │ │ ├── Timeout.swift
│ │ │ ├── Timer.swift
│ │ │ ├── ToArray.swift
│ │ │ ├── Using.swift
│ │ │ ├── Window.swift
│ │ │ ├── WithLatestFrom.swift
│ │ │ ├── Zip+Collection.swift
│ │ │ ├── Zip+arity.swift
│ │ │ └── Zip.swift
│ │ │ ├── ObserverType.swift
│ │ │ ├── Observers
│ │ │ ├── AnonymousObserver.swift
│ │ │ ├── ObserverBase.swift
│ │ │ └── TailRecursiveSink.swift
│ │ │ ├── Reactive.swift
│ │ │ ├── Rx.swift
│ │ │ ├── RxMutableBox.swift
│ │ │ ├── SchedulerType.swift
│ │ │ ├── Schedulers
│ │ │ ├── ConcurrentDispatchQueueScheduler.swift
│ │ │ ├── ConcurrentMainScheduler.swift
│ │ │ ├── CurrentThreadScheduler.swift
│ │ │ ├── HistoricalScheduler.swift
│ │ │ ├── HistoricalSchedulerTimeConverter.swift
│ │ │ ├── ImmediateScheduler.swift
│ │ │ ├── Internal
│ │ │ │ ├── AnonymousInvocable.swift
│ │ │ │ ├── DispatchQueueConfiguration.swift
│ │ │ │ ├── InvocableScheduledItem.swift
│ │ │ │ ├── InvocableType.swift
│ │ │ │ ├── ScheduledItem.swift
│ │ │ │ └── ScheduledItemType.swift
│ │ │ ├── MainScheduler.swift
│ │ │ ├── OperationQueueScheduler.swift
│ │ │ ├── RecursiveScheduler.swift
│ │ │ ├── SchedulerServices+Emulation.swift
│ │ │ ├── SerialDispatchQueueScheduler.swift
│ │ │ ├── VirtualTimeConverterType.swift
│ │ │ └── VirtualTimeScheduler.swift
│ │ │ ├── Subjects
│ │ │ ├── AsyncSubject.swift
│ │ │ ├── BehaviorSubject.swift
│ │ │ ├── PublishSubject.swift
│ │ │ ├── ReplaySubject.swift
│ │ │ ├── SubjectType.swift
│ │ │ └── Variable.swift
│ │ │ └── Traits
│ │ │ ├── Completable+AndThen.swift
│ │ │ ├── PrimitiveSequence+Zip+arity.swift
│ │ │ └── PrimitiveSequence.swift
│ └── Target Support Files
│ │ ├── Nimble
│ │ ├── Info.plist
│ │ ├── Nimble-dummy.m
│ │ ├── Nimble-prefix.pch
│ │ ├── Nimble-umbrella.h
│ │ ├── Nimble.modulemap
│ │ └── Nimble.xcconfig
│ │ ├── Pods-RxEventHub_Tests
│ │ ├── Info.plist
│ │ ├── Pods-RxEventHub_Tests-acknowledgements.markdown
│ │ ├── Pods-RxEventHub_Tests-acknowledgements.plist
│ │ ├── Pods-RxEventHub_Tests-dummy.m
│ │ ├── Pods-RxEventHub_Tests-frameworks.sh
│ │ ├── Pods-RxEventHub_Tests-resources.sh
│ │ ├── Pods-RxEventHub_Tests-umbrella.h
│ │ ├── Pods-RxEventHub_Tests.debug.xcconfig
│ │ ├── Pods-RxEventHub_Tests.modulemap
│ │ └── Pods-RxEventHub_Tests.release.xcconfig
│ │ ├── Quick
│ │ ├── Info.plist
│ │ ├── Quick-dummy.m
│ │ ├── Quick-prefix.pch
│ │ ├── Quick-umbrella.h
│ │ ├── Quick.modulemap
│ │ └── Quick.xcconfig
│ │ ├── RxEventHub
│ │ ├── Info.plist
│ │ ├── RxEventHub-dummy.m
│ │ ├── RxEventHub-prefix.pch
│ │ ├── RxEventHub-umbrella.h
│ │ ├── RxEventHub.modulemap
│ │ └── RxEventHub.xcconfig
│ │ └── RxSwift
│ │ ├── Info.plist
│ │ ├── RxSwift-dummy.m
│ │ ├── RxSwift-prefix.pch
│ │ ├── RxSwift-umbrella.h
│ │ ├── RxSwift.modulemap
│ │ └── RxSwift.xcconfig
├── RxEventHub.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── RxEventHub-Example.xcscheme
├── RxEventHub.xcworkspace
│ └── contents.xcworkspacedata
└── Tests
│ ├── Info.plist
│ └── Tests.swift
├── LICENSE
├── README.md
├── RxEventHub.podspec
├── RxEventHub
├── Assets
│ └── .gitkeep
└── Classes
│ ├── .gitkeep
│ └── RxEventHub.swift
└── _Pods.xcodeproj
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 |
4 | # Xcode
5 | build/
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata/
15 | *.xccheckout
16 | profile
17 | *.moved-aside
18 | DerivedData
19 | *.hmap
20 | *.ipa
21 |
22 | # Bundler
23 | .bundle
24 |
25 | Carthage
26 | # We recommend against adding the Pods directory to your .gitignore. However
27 | # you should judge for yourself, the pros and cons are mentioned at:
28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
29 | #
30 | # Note: if you ignore the Pods directory, make sure to uncomment
31 | # `pod install` in .travis.yml
32 | #
33 | # Pods/
34 |
--------------------------------------------------------------------------------
/.swift-version:
--------------------------------------------------------------------------------
1 | 3.2
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # references:
2 | # * http://www.objc.io/issue-6/travis-ci.html
3 | # * https://github.com/supermarin/xcpretty#usage
4 |
5 | osx_image: xcode9.1
6 | language: swift
7 | # cache: cocoapods
8 | # podfile: Example/Podfile
9 | # before_install:
10 | # - gem install cocoapods # Since Travis is not always on latest version
11 | # - pod install --project-directory=Example
12 | script:
13 | - set -o pipefail && xcodebuild test -workspace Example/RxEventHub.xcworkspace -scheme RxEventHub-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
14 | - pod lib lint
15 |
--------------------------------------------------------------------------------
/Example/Empty/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Empty
4 | //
5 | // Created by 陈圣晗 on 07/12/2017.
6 | // Copyright © 2017 CocoaPods. 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: [UIApplicationLaunchOptionsKey: Any]?) -> 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 invalidate graphics rendering callbacks. 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 active 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 |
--------------------------------------------------------------------------------
/Example/Empty/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | }
88 | ],
89 | "info" : {
90 | "version" : 1,
91 | "author" : "xcode"
92 | }
93 | }
--------------------------------------------------------------------------------
/Example/Empty/Base.lproj/LaunchScreen.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 |
--------------------------------------------------------------------------------
/Example/Empty/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 |
--------------------------------------------------------------------------------
/Example/Empty/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Example/Empty/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // Empty
4 | //
5 | // Created by 陈圣晗 on 07/12/2017.
6 | // Copyright © 2017 CocoaPods. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 | // Do any additional setup after loading the view, typically from a nib.
16 | }
17 |
18 | override func didReceiveMemoryWarning() {
19 | super.didReceiveMemoryWarning()
20 | // Dispose of any resources that can be recreated.
21 | }
22 |
23 |
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/Example/Podfile:
--------------------------------------------------------------------------------
1 | use_frameworks!
2 |
3 | target 'RxEventHub_Tests' do
4 | pod 'RxEventHub', :path => '../'
5 |
6 | pod 'Quick', '1.2.0'
7 | pod 'Nimble', '7.0.3'
8 | pod 'RxSwift', '3.6.1'
9 | end
10 |
11 |
12 | post_install do |installer|
13 | installer.pods_project.targets.each do |target|
14 | target.build_configurations.each do |config|
15 | config.build_settings['SWIFT_VERSION'] = '3.2'
16 | config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/Example/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Nimble (7.0.3)
3 | - Quick (1.2.0)
4 | - RxEventHub (3.0):
5 | - RxSwift (~> 3.0)
6 | - RxSwift (3.6.1)
7 |
8 | DEPENDENCIES:
9 | - Nimble (= 7.0.3)
10 | - Quick (= 1.2.0)
11 | - RxEventHub (from `../`)
12 | - RxSwift (= 3.6.1)
13 |
14 | EXTERNAL SOURCES:
15 | RxEventHub:
16 | :path: ../
17 |
18 | SPEC CHECKSUMS:
19 | Nimble: 7f5a9c447a33002645a071bddafbfb24ea70e0ac
20 | Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08
21 | RxEventHub: f34a208a3a43ed0bfb13d223a87828f3e1528ad9
22 | RxSwift: f9de85ea20cd2f7716ee5409fc13523dc638e4e4
23 |
24 | PODFILE CHECKSUM: b2538567d819748cca212013bcb1cf0999da3302
25 |
26 | COCOAPODS: 1.4.0.beta.1
27 |
--------------------------------------------------------------------------------
/Example/Pods/Local Podspecs/RxEventHub.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "RxEventHub",
3 | "version": "3.0",
4 | "summary": "`RxEventHub` makes multicasting event easy, type-safe and error-free, use it instead of `NSNotificationCenter` now!",
5 | "description": "`RxEventHub` is an event hub in `RxSwift` world, it makes multicasting event easy, type-safe and error-free, use it instead of `NSNotificationCenter` now!",
6 | "homepage": "https://github.com/RxSwiftCommunity/RxEventHub",
7 | "license": {
8 | "type": "MIT",
9 | "file": "LICENSE"
10 | },
11 | "authors": {
12 | "zzdjk6": "zzdjk6@126.com"
13 | },
14 | "source": {
15 | "git": "https://github.com/RxSwiftCommunity/RxEventHub.git",
16 | "tag": "3.0"
17 | },
18 | "platforms": {
19 | "ios": "8.0"
20 | },
21 | "source_files": "RxEventHub/Classes/**/*",
22 | "dependencies": {
23 | "RxSwift": [
24 | "~> 3.0"
25 | ]
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Example/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Nimble (7.0.3)
3 | - Quick (1.2.0)
4 | - RxEventHub (3.0):
5 | - RxSwift (~> 3.0)
6 | - RxSwift (3.6.1)
7 |
8 | DEPENDENCIES:
9 | - Nimble (= 7.0.3)
10 | - Quick (= 1.2.0)
11 | - RxEventHub (from `../`)
12 | - RxSwift (= 3.6.1)
13 |
14 | EXTERNAL SOURCES:
15 | RxEventHub:
16 | :path: ../
17 |
18 | SPEC CHECKSUMS:
19 | Nimble: 7f5a9c447a33002645a071bddafbfb24ea70e0ac
20 | Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08
21 | RxEventHub: f34a208a3a43ed0bfb13d223a87828f3e1528ad9
22 | RxSwift: f9de85ea20cd2f7716ee5409fc13523dc638e4e4
23 |
24 | PODFILE CHECKSUM: b2538567d819748cca212013bcb1cf0999da3302
25 |
26 | COCOAPODS: 1.4.0.beta.1
27 |
--------------------------------------------------------------------------------
/Example/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 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift:
--------------------------------------------------------------------------------
1 | /// AssertionDispatcher allows multiple AssertionHandlers to receive
2 | /// assertion messages.
3 | ///
4 | /// @warning Does not fully dispatch if one of the handlers raises an exception.
5 | /// This is possible with XCTest-based assertion handlers.
6 | ///
7 | public class AssertionDispatcher: AssertionHandler {
8 | let handlers: [AssertionHandler]
9 |
10 | public init(handlers: [AssertionHandler]) {
11 | self.handlers = handlers
12 | }
13 |
14 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) {
15 | for handler in handlers {
16 | handler.assert(assertion, message: message, location: location)
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift:
--------------------------------------------------------------------------------
1 | import Dispatch
2 | import Foundation
3 |
4 | /// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this
5 | /// class' existence
6 | internal class NimbleEnvironment {
7 | static var activeInstance: NimbleEnvironment {
8 | get {
9 | let env = Thread.current.threadDictionary["NimbleEnvironment"]
10 | if let env = env as? NimbleEnvironment {
11 | return env
12 | } else {
13 | let newEnv = NimbleEnvironment()
14 | self.activeInstance = newEnv
15 | return newEnv
16 | }
17 | }
18 | set {
19 | Thread.current.threadDictionary["NimbleEnvironment"] = newValue
20 | }
21 | }
22 |
23 | // TODO: eventually migrate the global to this environment value
24 | var assertionHandler: AssertionHandler {
25 | get { return NimbleAssertionHandler }
26 | set { NimbleAssertionHandler = newValue }
27 | }
28 |
29 | var suppressTVOSAssertionWarning: Bool = false
30 | var awaiter: Awaiter
31 |
32 | init() {
33 | let timeoutQueue: DispatchQueue
34 | if #available(OSX 10.10, *) {
35 | timeoutQueue = DispatchQueue.global(qos: .userInitiated)
36 | } else {
37 | timeoutQueue = DispatchQueue.global(priority: .high)
38 | }
39 |
40 | awaiter = Awaiter(
41 | waitLock: AssertionWaitLock(),
42 | asyncQueue: .main,
43 | timeoutQueue: timeoutQueue)
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Example/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 | public func expect(_ expression: @autoclosure @escaping () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation {
5 | return Expectation(
6 | expression: Expression(
7 | expression: expression,
8 | location: SourceLocation(file: file, line: line),
9 | isClosure: true))
10 | }
11 |
12 | /// Make an expectation on a given actual value. The closure is lazily invoked.
13 | public func expect(_ file: FileString = #file, line: UInt = #line, expression: @escaping () throws -> T?) -> Expectation {
14 | return Expectation(
15 | expression: Expression(
16 | expression: expression,
17 | location: SourceLocation(file: file, line: line),
18 | isClosure: true))
19 | }
20 |
21 | /// Always fails the test with a message and a specified location.
22 | public func fail(_ message: String, location: SourceLocation) {
23 | let handler = NimbleEnvironment.activeInstance.assertionHandler
24 | handler.assert(false, message: FailureMessage(stringValue: message), location: location)
25 | }
26 |
27 | /// Always fails the test with a message.
28 | public func fail(_ message: String, file: FileString = #file, line: UInt = #line) {
29 | fail(message, location: SourceLocation(file: file, line: line))
30 | }
31 |
32 | /// Always fails the test.
33 | public func fail(_ file: FileString = #file, line: UInt = #line) {
34 | fail("fail() always fails", file: file, line: line)
35 | }
36 |
37 | /// Like Swift's precondition(), but raises NSExceptions instead of sigaborts
38 | internal func nimblePrecondition(
39 | _ expr: @autoclosure() -> Bool,
40 | _ name: @autoclosure() -> String,
41 | _ message: @autoclosure() -> String,
42 | file: StaticString = #file,
43 | line: UInt = #line) {
44 | let result = expr()
45 | if !result {
46 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
47 | let e = NSException(
48 | name: NSExceptionName(name()),
49 | reason: message(),
50 | userInfo: nil)
51 | e.raise()
52 | #else
53 | preconditionFailure("\(name()) - \(message())", file: file, line: line)
54 | #endif
55 | }
56 | }
57 |
58 | internal func internalError(_ msg: String, file: FileString = #file, line: UInt = #line) -> Never {
59 | fatalError(
60 | "Nimble Bug Found: \(msg) at \(file):\(line).\n" +
61 | "Please file a bug to Nimble: https://github.com/Quick/Nimble/issues with the " +
62 | "code snippet that caused this error."
63 | )
64 | }
65 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | private func matcherMessage(forType expectedType: T.Type) -> String {
4 | return "be a kind of \(String(describing: expectedType))"
5 | }
6 | private func matcherMessage(forClass expectedClass: AnyClass) -> String {
7 | return "be a kind of \(String(describing: expectedClass))"
8 | }
9 |
10 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class.
11 | public func beAKindOf(_ expectedType: T.Type) -> Predicate {
12 | return Predicate.define { actualExpression in
13 | let message: ExpectationMessage
14 |
15 | let instance = try actualExpression.evaluate()
16 | guard let validInstance = instance else {
17 | message = .expectedCustomValueTo(matcherMessage(forType: expectedType), "")
18 | return PredicateResult(status: .fail, message: message)
19 | }
20 | message = .expectedCustomValueTo(
21 | "be a kind of \(String(describing: expectedType))",
22 | "<\(String(describing: type(of: validInstance))) instance>"
23 | )
24 |
25 | return PredicateResult(
26 | bool: validInstance is T,
27 | message: message
28 | )
29 | }
30 | }
31 |
32 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
33 |
34 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class.
35 | /// @see beAnInstanceOf if you want to match against the exact class
36 | public func beAKindOf(_ expectedClass: AnyClass) -> Predicate {
37 | return Predicate.define { actualExpression in
38 | let message: ExpectationMessage
39 | let status: PredicateStatus
40 |
41 | let instance = try actualExpression.evaluate()
42 | if let validInstance = instance {
43 | status = PredicateStatus(bool: instance != nil && instance!.isKind(of: expectedClass))
44 | message = .expectedCustomValueTo(
45 | matcherMessage(forClass: expectedClass),
46 | "<\(String(describing: type(of: validInstance))) instance>"
47 | )
48 | } else {
49 | status = .fail
50 | message = .expectedCustomValueTo(
51 | matcherMessage(forClass: expectedClass),
52 | ""
53 | )
54 | }
55 |
56 | return PredicateResult(status: status, message: message)
57 | }
58 | }
59 |
60 | extension NMBObjCMatcher {
61 | @objc public class func beAKindOfMatcher(_ expected: AnyClass) -> NMBMatcher {
62 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
63 | return try! beAKindOf(expected).matches(actualExpression, failureMessage: failureMessage)
64 | }
65 | }
66 | }
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is an _exact_ instance of the given class.
4 | public func beAnInstanceOf(_ expectedType: T.Type) -> Predicate {
5 | let errorMessage = "be an instance of \(String(describing: expectedType))"
6 | return Predicate.define { actualExpression in
7 | let instance = try actualExpression.evaluate()
8 | guard let validInstance = instance else {
9 | return PredicateResult(
10 | status: .doesNotMatch,
11 | message: .expectedActualValueTo(errorMessage)
12 | )
13 | }
14 |
15 | let actualString = "<\(String(describing: type(of: validInstance))) instance>"
16 |
17 | return PredicateResult(
18 | status: PredicateStatus(bool: type(of: validInstance) == expectedType),
19 | message: .expectedCustomValueTo(errorMessage, actualString)
20 | )
21 | }
22 | }
23 |
24 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class.
25 | /// @see beAKindOf if you want to match against subclasses
26 | public func beAnInstanceOf(_ expectedClass: AnyClass) -> Predicate {
27 | let errorMessage = "be an instance of \(String(describing: expectedClass))"
28 | return Predicate.define { actualExpression in
29 | let instance = try actualExpression.evaluate()
30 | let actualString: String
31 | if let validInstance = instance {
32 | actualString = "<\(String(describing: type(of: validInstance))) instance>"
33 | } else {
34 | actualString = ""
35 | }
36 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
37 | let matches = instance != nil && instance!.isMember(of: expectedClass)
38 | #else
39 | let matches = instance != nil && type(of: instance!) == expectedClass
40 | #endif
41 | return PredicateResult(
42 | status: PredicateStatus(bool: matches),
43 | message: .expectedCustomValueTo(errorMessage, actualString)
44 | )
45 | }
46 | }
47 |
48 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
49 | extension NMBObjCMatcher {
50 | @objc public class func beAnInstanceOfMatcher(_ expected: AnyClass) -> NMBMatcher {
51 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
52 | return try! beAnInstanceOf(expected).matches(actualExpression, failureMessage: failureMessage)
53 | }
54 | }
55 | }
56 | #endif
57 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value.
4 | public func beGreaterThan(_ expectedValue: T?) -> Predicate {
5 | let errorMessage = "be greater than <\(stringify(expectedValue))>"
6 | return Predicate.simple(errorMessage) { actualExpression in
7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue {
8 | return PredicateStatus(bool: actual > expected)
9 | }
10 | return .fail
11 | }
12 | }
13 |
14 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value.
15 | public func beGreaterThan(_ expectedValue: NMBComparable?) -> Predicate {
16 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
17 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>"
18 | let actualValue = try actualExpression.evaluate()
19 | let matches = actualValue != nil
20 | && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedDescending
21 | return matches
22 | }.requireNonNil
23 | }
24 |
25 | public func >(lhs: Expectation, rhs: T) {
26 | lhs.to(beGreaterThan(rhs))
27 | }
28 |
29 | public func > (lhs: Expectation, rhs: NMBComparable?) {
30 | lhs.to(beGreaterThan(rhs))
31 | }
32 |
33 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
34 | extension NMBObjCMatcher {
35 | @objc public class func beGreaterThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher {
36 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
37 | let expr = actualExpression.cast { $0 as? NMBComparable }
38 | return try! beGreaterThan(expected).matches(expr, failureMessage: failureMessage)
39 | }
40 | }
41 | }
42 | #endif
43 |
--------------------------------------------------------------------------------
/Example/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?) -> Predicate {
6 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
7 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>"
8 | let actualValue = try actualExpression.evaluate()
9 | if let actual = actualValue, let expected = expectedValue {
10 | return actual >= expected
11 | }
12 | return false
13 | }.requireNonNil
14 | }
15 |
16 | /// A Nimble matcher that succeeds when the actual value is greater than
17 | /// or equal to the expected value.
18 | public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> Predicate {
19 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
20 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>"
21 | let actualValue = try actualExpression.evaluate()
22 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) != ComparisonResult.orderedAscending
23 | return matches
24 | }.requireNonNil
25 | }
26 |
27 | public func >=(lhs: Expectation, rhs: T) {
28 | lhs.to(beGreaterThanOrEqualTo(rhs))
29 | }
30 |
31 | public func >=(lhs: Expectation, rhs: T) {
32 | lhs.to(beGreaterThanOrEqualTo(rhs))
33 | }
34 |
35 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
36 | extension NMBObjCMatcher {
37 | @objc public class func beGreaterThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher {
38 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
39 | let expr = actualExpression.cast { $0 as? NMBComparable }
40 | return try! beGreaterThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage)
41 | }
42 | }
43 | }
44 | #endif
45 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual value is the same instance
4 | /// as the expected instance.
5 | public func beIdenticalTo(_ expected: Any?) -> Predicate {
6 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
7 | #if os(Linux)
8 | let actual = try actualExpression.evaluate() as? AnyObject
9 | #else
10 | let actual = try actualExpression.evaluate() as AnyObject?
11 | #endif
12 | failureMessage.actualValue = "\(identityAsString(actual))"
13 | failureMessage.postfixMessage = "be identical to \(identityAsString(expected))"
14 | #if os(Linux)
15 | return actual === (expected as? AnyObject) && actual !== nil
16 | #else
17 | return actual === (expected as AnyObject?) && actual !== nil
18 | #endif
19 | }.requireNonNil
20 | }
21 |
22 | public func === (lhs: Expectation, rhs: Any?) {
23 | lhs.to(beIdenticalTo(rhs))
24 | }
25 | public func !== (lhs: Expectation, rhs: Any?) {
26 | lhs.toNot(beIdenticalTo(rhs))
27 | }
28 |
29 | /// A Nimble matcher that succeeds when the actual value is the same instance
30 | /// as the expected instance.
31 | ///
32 | /// Alias for "beIdenticalTo".
33 | public func be(_ expected: Any?) -> Predicate {
34 | return beIdenticalTo(expected)
35 | }
36 |
37 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
38 | extension NMBObjCMatcher {
39 | @objc public class func beIdenticalToMatcher(_ expected: NSObject?) -> NMBObjCMatcher {
40 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
41 | let aExpr = actualExpression.cast { $0 as Any? }
42 | return try! beIdenticalTo(expected).matches(aExpr, failureMessage: failureMessage)
43 | }
44 | }
45 | }
46 | #endif
47 |
--------------------------------------------------------------------------------
/Example/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?) -> Predicate {
5 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
6 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>"
7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue {
8 | return actual < expected
9 | }
10 | return false
11 | }.requireNonNil
12 | }
13 |
14 | /// A Nimble matcher that succeeds when the actual value is less than the expected value.
15 | public func beLessThan(_ expectedValue: NMBComparable?) -> Predicate {
16 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
17 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>"
18 | let actualValue = try actualExpression.evaluate()
19 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedAscending
20 | return matches
21 | }.requireNonNil
22 | }
23 |
24 | public func <(lhs: Expectation, rhs: T) {
25 | lhs.to(beLessThan(rhs))
26 | }
27 |
28 | public func < (lhs: Expectation, rhs: NMBComparable?) {
29 | lhs.to(beLessThan(rhs))
30 | }
31 |
32 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
33 | extension NMBObjCMatcher {
34 | @objc public class func beLessThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher {
35 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
36 | let expr = actualExpression.cast { $0 as? NMBComparable }
37 | return try! beLessThan(expected).matches(expr, failureMessage: failureMessage)
38 | }
39 | }
40 | }
41 | #endif
42 |
--------------------------------------------------------------------------------
/Example/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?) -> Predicate {
6 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
7 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>"
8 | if let actual = try actualExpression.evaluate(), let expected = expectedValue {
9 | return actual <= expected
10 | }
11 | return false
12 | }.requireNonNil
13 | }
14 |
15 | /// A Nimble matcher that succeeds when the actual value is less than
16 | /// or equal to the expected value.
17 | public func beLessThanOrEqualTo(_ expectedValue: T?) -> Predicate {
18 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
19 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>"
20 | let actualValue = try actualExpression.evaluate()
21 | return actualValue != nil && actualValue!.NMB_compare(expectedValue) != ComparisonResult.orderedDescending
22 | }.requireNonNil
23 | }
24 |
25 | public func <=(lhs: Expectation, rhs: T) {
26 | lhs.to(beLessThanOrEqualTo(rhs))
27 | }
28 |
29 | public func <=(lhs: Expectation, rhs: T) {
30 | lhs.to(beLessThanOrEqualTo(rhs))
31 | }
32 |
33 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
34 | extension NMBObjCMatcher {
35 | @objc public class func beLessThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher {
36 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
37 | let expr = actualExpression.cast { $0 as? NMBComparable }
38 | return try! beLessThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage)
39 | }
40 | }
41 | }
42 | #endif
43 |
--------------------------------------------------------------------------------
/Example/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() -> Predicate {
5 | return Predicate.simpleNilable("be nil") { actualExpression in
6 | let actualValue = try actualExpression.evaluate()
7 | return PredicateStatus(bool: actualValue == nil)
8 | }
9 | }
10 |
11 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
12 | extension NMBObjCMatcher {
13 | @objc public class func beNilMatcher() -> NMBObjCMatcher {
14 | return NMBObjCMatcher { actualExpression, failureMessage in
15 | return try! beNil().matches(actualExpression, failureMessage: failureMessage)
16 | }
17 | }
18 | }
19 | #endif
20 |
--------------------------------------------------------------------------------
/Example/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() -> Predicate<()> {
5 | return Predicate.fromDeprecatedClosure { 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 | }
19 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/ContainElementSatisfying.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | public func containElementSatisfying(_ predicate: @escaping ((T) -> Bool), _ predicateDescription: String = "") -> Predicate where S.Iterator.Element == T {
4 |
5 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
6 | failureMessage.actualValue = nil
7 |
8 | if predicateDescription == "" {
9 | failureMessage.postfixMessage = "find object in collection that satisfies predicate"
10 | } else {
11 | failureMessage.postfixMessage = "find object in collection \(predicateDescription)"
12 | }
13 |
14 | if let sequence = try actualExpression.evaluate() {
15 | for object in sequence {
16 | if predicate(object) {
17 | return true
18 | }
19 | }
20 |
21 | return false
22 | }
23 |
24 | return false
25 | }.requireNonNil
26 | }
27 |
28 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
29 | extension NMBObjCMatcher {
30 | @objc public class func containElementSatisfyingMatcher(_ predicate: @escaping ((NSObject) -> Bool)) -> NMBObjCMatcher {
31 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
32 | let value = try! actualExpression.evaluate()
33 | guard let enumeration = value as? NSFastEnumeration else {
34 | // swiftlint:disable:next line_length
35 | failureMessage.postfixMessage = "containElementSatisfying must be provided an NSFastEnumeration object"
36 | failureMessage.actualValue = nil
37 | failureMessage.expected = ""
38 | failureMessage.to = ""
39 | return false
40 | }
41 |
42 | var iterator = NSFastEnumerationIterator(enumeration)
43 | while let item = iterator.next() {
44 | guard let object = item as? NSObject else {
45 | continue
46 | }
47 |
48 | if predicate(object) {
49 | return true
50 | }
51 | }
52 |
53 | failureMessage.actualValue = nil
54 | failureMessage.postfixMessage = ""
55 | failureMessage.to = "to find object in collection that satisfies predicate"
56 | return false
57 | }
58 | }
59 | }
60 | #endif
61 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/Match.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | /// A Nimble matcher that succeeds when the actual string satisfies the regular expression
4 | /// described by the expected string.
5 | public func match(_ expectedValue: String?) -> Predicate {
6 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
7 | failureMessage.postfixMessage = "match <\(stringify(expectedValue))>"
8 |
9 | if let actual = try actualExpression.evaluate() {
10 | if let regexp = expectedValue {
11 | return actual.range(of: regexp, options: .regularExpression) != nil
12 | }
13 | }
14 |
15 | return false
16 | }.requireNonNil
17 | }
18 |
19 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
20 |
21 | extension NMBObjCMatcher {
22 | @objc 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 |
--------------------------------------------------------------------------------
/Example/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 comparison by _domain and _code.
8 | public func matchError(_ error: T) -> Predicate {
9 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
10 | let actualError: Error? = try actualExpression.evaluate()
11 |
12 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, error: error)
13 | var matches = false
14 | if let actualError = actualError, errorMatchesExpectedError(actualError, expectedError: error) {
15 | matches = true
16 | }
17 | return matches
18 | }.requireNonNil
19 | }
20 |
21 | /// A Nimble matcher that succeeds when the actual expression evaluates to an
22 | /// error from the specified case.
23 | ///
24 | /// Errors are tried to be compared by their implementation of Equatable,
25 | /// otherwise they fallback to comparision by _domain and _code.
26 | public func matchError(_ error: T) -> Predicate {
27 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
28 | let actualError: Error? = try actualExpression.evaluate()
29 |
30 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, error: error)
31 |
32 | var matches = false
33 | if let actualError = actualError as? T, error == actualError {
34 | matches = true
35 | }
36 | return matches
37 | }.requireNonNil
38 | }
39 |
40 | /// A Nimble matcher that succeeds when the actual expression evaluates to an
41 | /// error of the specified type
42 | public func matchError(_ errorType: T.Type) -> Predicate {
43 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
44 | let actualError: Error? = try actualExpression.evaluate()
45 |
46 | setFailureMessageForError(
47 | failureMessage,
48 | postfixMessageVerb: "match",
49 | actualError: actualError,
50 | errorType: errorType
51 | )
52 | var matches = false
53 | if actualError as? T != nil {
54 | matches = true
55 | }
56 | return matches
57 | }.requireNonNil
58 | }
59 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | public func throwAssertion() -> Predicate {
4 | return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
5 | #if arch(x86_64) && (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_PACKAGE
6 | failureMessage.postfixMessage = "throw an assertion"
7 | failureMessage.actualValue = nil
8 |
9 | var succeeded = true
10 |
11 | let caughtException: BadInstructionException? = catchBadInstruction {
12 | #if os(tvOS)
13 | if !NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning {
14 | print()
15 | print("[Nimble Warning]: If you're getting stuck on a debugger breakpoint for a " +
16 | "fatal error while using throwAssertion(), please disable 'Debug Executable' " +
17 | "in your scheme. Go to 'Edit Scheme > Test > Info' and uncheck " +
18 | "'Debug Executable'. If you've already done that, suppress this warning " +
19 | "by setting `NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true`. " +
20 | "This is required because the standard methods of catching assertions " +
21 | "(mach APIs) are unavailable for tvOS. Instead, the same mechanism the " +
22 | "debugger uses is the fallback method for tvOS."
23 | )
24 | print()
25 | NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true
26 | }
27 | #endif
28 | do {
29 | try actualExpression.evaluate()
30 | } catch let error {
31 | succeeded = false
32 | failureMessage.postfixMessage += "; threw error instead <\(error)>"
33 | }
34 | }
35 |
36 | if !succeeded {
37 | return false
38 | }
39 |
40 | if caughtException == nil {
41 | return false
42 | }
43 |
44 | return true
45 | #elseif SWIFT_PACKAGE
46 | fatalError("The throwAssertion Nimble matcher does not currently support Swift CLI." +
47 | " You can silence this error by placing the test case inside an #if !SWIFT_PACKAGE" +
48 | " conditional statement")
49 | #else
50 | fatalError("The throwAssertion Nimble matcher can only run on x86_64 platforms with " +
51 | "Objective-C (e.g. Mac, iPhone 5s or later simulators). You can silence this error " +
52 | "by placing the test case inside an #if arch(x86_64) or (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) conditional statement")
53 | // swiftlint:disable:previous line_length
54 | #endif
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Matchers/ToSucceed.swift:
--------------------------------------------------------------------------------
1 | /**
2 | Used by the `toSucceed` matcher.
3 |
4 | This is the return type for the closure.
5 | */
6 | public enum ToSucceedResult {
7 | case succeeded
8 | case failed(reason: String)
9 | }
10 |
11 | /**
12 | A Nimble matcher that takes in a closure for validation.
13 |
14 | Return `.succeeded` when the validation succeeds.
15 | Return `.failed` with a failure reason when the validation fails.
16 | */
17 | public func succeed() -> Predicate<() -> ToSucceedResult> {
18 | return Predicate.define { actualExpression in
19 | let optActual = try actualExpression.evaluate()
20 | guard let actual = optActual else {
21 | return PredicateResult(status: .fail, message: .fail("expected a closure, got "))
22 | }
23 |
24 | switch actual() {
25 | case .succeeded:
26 | return PredicateResult(
27 | bool: true,
28 | message: .expectedCustomValueTo("succeed", "")
29 | )
30 | case .failed(let reason):
31 | return PredicateResult(
32 | bool: false,
33 | message: .expectedCustomValueTo("succeed", " because <\(reason)>")
34 | )
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Nimble.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "NMBExceptionCapture.h"
3 | #import "NMBStringify.h"
4 | #import "DSL.h"
5 |
6 | #if TARGET_OS_TV
7 | #import "CwlPreconditionTesting_POSIX.h"
8 | #else
9 | #import "CwlPreconditionTesting.h"
10 | #endif
11 |
12 | FOUNDATION_EXPORT double NimbleVersionNumber;
13 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
14 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Utils/Errors.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | // Generic
4 |
5 | internal func setFailureMessageForError(
6 | _ failureMessage: FailureMessage,
7 | postfixMessageVerb: String = "throw",
8 | actualError: Error?,
9 | error: T? = nil,
10 | errorType: T.Type? = nil,
11 | closure: ((T) -> Void)? = nil) {
12 | failureMessage.postfixMessage = "\(postfixMessageVerb) error"
13 |
14 | if let error = error {
15 | failureMessage.postfixMessage += " <\(error)>"
16 | } else if errorType != nil || closure != nil {
17 | failureMessage.postfixMessage += " from type <\(T.self)>"
18 | }
19 | if closure != nil {
20 | failureMessage.postfixMessage += " that satisfies block"
21 | }
22 | if error == nil && errorType == nil && closure == nil {
23 | failureMessage.postfixMessage = "\(postfixMessageVerb) any error"
24 | }
25 |
26 | if let actualError = actualError {
27 | failureMessage.actualValue = "<\(actualError)>"
28 | } else {
29 | failureMessage.actualValue = "no error"
30 | }
31 | }
32 |
33 | internal func errorMatchesExpectedError(
34 | _ actualError: Error,
35 | expectedError: T) -> Bool {
36 | return actualError._domain == expectedError._domain
37 | && actualError._code == expectedError._code
38 | }
39 |
40 | // Non-generic
41 |
42 | internal func setFailureMessageForError(
43 | _ failureMessage: FailureMessage,
44 | actualError: Error?,
45 | closure: ((Error) -> Void)?) {
46 | failureMessage.postfixMessage = "throw error"
47 |
48 | if closure != nil {
49 | failureMessage.postfixMessage += " that satisfies block"
50 | } else {
51 | failureMessage.postfixMessage = "throw any error"
52 | }
53 |
54 | if let actualError = actualError {
55 | failureMessage.actualValue = "<\(actualError)>"
56 | } else {
57 | failureMessage.actualValue = "no error"
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/Nimble/Utils/Functional.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | extension Sequence {
4 | internal func all(_ fn: (Iterator.Element) -> Bool) -> Bool {
5 | for item in self {
6 | if !fn(item) {
7 | return false
8 | }
9 | }
10 | return true
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Example/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 SWIFT_PACKAGE
9 | public typealias FileString = StaticString
10 | #else
11 | public typealias FileString = String
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 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/CurrentTestCaseTracker.h:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface NMBExceptionCapture : NSObject
5 |
6 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(void))finally;
7 | - (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)(void))unsafeBlock NS_SWIFT_NAME(tryBlock(_:));
8 |
9 | @end
10 |
11 | typedef void(^NMBSourceCallbackBlock)(BOOL successful);
12 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m:
--------------------------------------------------------------------------------
1 | #import "NMBExceptionCapture.h"
2 |
3 | @interface NMBExceptionCapture ()
4 | @property (nonatomic, copy) void(^ _Nullable handler)(NSException * _Nullable);
5 | @property (nonatomic, copy) void(^ _Nullable finally)(void);
6 | @end
7 |
8 | @implementation NMBExceptionCapture
9 |
10 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(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(^ _Nonnull)(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
36 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/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 anyObject 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 |
--------------------------------------------------------------------------------
/Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBStringify.m:
--------------------------------------------------------------------------------
1 | #import "NMBStringify.h"
2 | #import
3 |
4 | NSString *_Nonnull NMBStringify(id _Nullable anyObject) {
5 | return [NMBStringer stringify:anyObject];
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/Behavior.swift:
--------------------------------------------------------------------------------
1 | /**
2 | A `Behavior` encapsulates a set of examples that can be re-used in several locations using the `itBehavesLike` function with a context instance of the generic type.
3 | */
4 |
5 | open class Behavior {
6 |
7 | open static var name: String { return String(describing: self) }
8 | /**
9 | override this method in your behavior to define a set of reusable examples.
10 |
11 | This behaves just like an example group defines using `describe` or `context`--it may contain any number of `beforeEach`
12 | and `afterEach` closures, as well as any number of examples (defined using `it`).
13 |
14 | - parameter aContext: A closure that, when evaluated, returns a `Context` instance that provide the information on the subject.
15 | */
16 | open class func spec(_ aContext: @escaping () -> Context) {}
17 | }
18 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/Callsite.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | // `#if swift(>=3.2) && (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_PACKAGE`
4 | // does not work as expected.
5 | #if swift(>=3.2)
6 | #if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_PACKAGE
7 | @objcMembers
8 | public class _CallsiteBase: NSObject {}
9 | #else
10 | public class _CallsiteBase: NSObject {}
11 | #endif
12 | #else
13 | public class _CallsiteBase: NSObject {}
14 | #endif
15 |
16 | /**
17 | An object encapsulating the file and line number at which
18 | a particular example is defined.
19 | */
20 | final public class Callsite: _CallsiteBase {
21 | /**
22 | The absolute path of the file in which an example is defined.
23 | */
24 | public let file: String
25 |
26 | /**
27 | The line number on which an example is defined.
28 | */
29 | public let line: UInt
30 |
31 | internal init(file: String, line: UInt) {
32 | self.file = file
33 | self.line = line
34 | }
35 | }
36 |
37 | extension Callsite {
38 | /**
39 | Returns a boolean indicating whether two Callsite objects are equal.
40 | If two callsites are in the same file and on the same line, they must be equal.
41 | */
42 | @nonobjc public static func == (lhs: Callsite, rhs: Callsite) -> Bool {
43 | return lhs.file == rhs.file && lhs.line == rhs.line
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/ErrorUtility.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | internal func raiseError(_ message: String) -> Never {
4 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
5 | NSException(name: .internalInconsistencyException, 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 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/ExampleMetadata.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | // `#if swift(>=3.2) && (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_PACKAGE`
4 | // does not work as expected.
5 | #if swift(>=3.2)
6 | #if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_PACKAGE
7 | @objcMembers
8 | public class _ExampleMetadataBase: NSObject {}
9 | #else
10 | public class _ExampleMetadataBase: NSObject {}
11 | #endif
12 | #else
13 | public class _ExampleMetadataBase: NSObject {}
14 | #endif
15 |
16 | /**
17 | A class that encapsulates information about an example,
18 | including the index at which the example was executed, as
19 | well as the example itself.
20 | */
21 | final public class ExampleMetadata: _ExampleMetadataBase {
22 | /**
23 | The example for which this metadata was collected.
24 | */
25 | public let example: Example
26 |
27 | /**
28 | The index at which this example was executed in the
29 | test suite.
30 | */
31 | public let exampleIndex: Int
32 |
33 | internal init(example: Example, exampleIndex: Int) {
34 | self.example = example
35 | self.exampleIndex = exampleIndex
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/Filter.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | // `#if swift(>=3.2) && (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_PACKAGE`
4 | // does not work as expected.
5 | #if swift(>=3.2)
6 | #if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_PACKAGE
7 | @objcMembers
8 | public class _FilterBase: NSObject {}
9 | #else
10 | public class _FilterBase: NSObject {}
11 | #endif
12 | #else
13 | public class _FilterBase: NSObject {}
14 | #endif
15 |
16 | /**
17 | A mapping of string keys to booleans that can be used to
18 | filter examples or example groups. For example, a "focused"
19 | example would have the flags [Focused: true].
20 | */
21 | public typealias FilterFlags = [String: Bool]
22 |
23 | /**
24 | A namespace for filter flag keys, defined primarily to make the
25 | keys available in Objective-C.
26 | */
27 | final public class Filter: _FilterBase {
28 | /**
29 | Example and example groups with [Focused: true] are included in test runs,
30 | excluding all other examples without this flag. Use this to only run one or
31 | two tests that you're currently focusing on.
32 | */
33 | public class var focused: String {
34 | return "focused"
35 | }
36 |
37 | /**
38 | Example and example groups with [Pending: true] are excluded from test runs.
39 | Use this to temporarily suspend examples that you know do not pass yet.
40 | */
41 | public class var pending: String {
42 | return "pending"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Example/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 = () -> Void
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) -> Void
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 = () -> Void
31 |
32 | /**
33 | A closure executed after all examples have finished running.
34 | */
35 | public typealias AfterSuiteClosure = BeforeSuiteClosure
36 |
--------------------------------------------------------------------------------
/Example/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: @escaping BeforeExampleWithMetadataClosure) {
10 | befores.append(closure)
11 | }
12 |
13 | internal func appendBefore(_ closure: @escaping BeforeExampleClosure) {
14 | befores.append { (_: ExampleMetadata) in closure() }
15 | }
16 |
17 | internal func appendAfter(_ closure: @escaping AfterExampleWithMetadataClosure) {
18 | afters.append(closure)
19 | }
20 |
21 | internal func appendAfter(_ closure: @escaping AfterExampleClosure) {
22 | afters.append { (_: ExampleMetadata) in closure() }
23 | }
24 |
25 | internal func executeBefores(_ exampleMetadata: ExampleMetadata) {
26 | phase = .beforesExecuting
27 | for before in befores {
28 | before(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)
38 | }
39 |
40 | phase = .aftersFinished
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Example/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 {
6 | case nothingExecuted
7 | case beforesExecuting
8 | case beforesFinished
9 | case aftersExecuting
10 | case aftersFinished
11 | }
12 |
--------------------------------------------------------------------------------
/Example/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: @escaping BeforeSuiteClosure) {
10 | befores.append(closure)
11 | }
12 |
13 | internal func appendAfter(_ closure: @escaping 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 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/NSBundle+CurrentTestBundle.swift:
--------------------------------------------------------------------------------
1 | #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
2 |
3 | import Foundation
4 |
5 | extension Bundle {
6 |
7 | /**
8 | Locates the first bundle with a '.xctest' file extension.
9 | */
10 | internal static var currentTestBundle: Bundle? {
11 | return allBundles.first { $0.bundlePath.hasSuffix(".xctest") }
12 | }
13 |
14 | /**
15 | Return the module name of the bundle.
16 | Uses the bundle filename and transform it to match Xcode's transformation.
17 | Module name has to be a valid "C99 extended identifier".
18 | */
19 | internal var moduleName: String {
20 | let fileName = bundleURL.fileName as NSString
21 | return fileName.c99ExtendedIdentifier
22 | }
23 | }
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/NSString+C99ExtendedIdentifier.swift:
--------------------------------------------------------------------------------
1 | #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
2 | import Foundation
3 |
4 | public extension NSString {
5 |
6 | private static var invalidCharacters: CharacterSet = {
7 | var invalidCharacters = CharacterSet()
8 |
9 | let invalidCharacterSets: [CharacterSet] = [
10 | .whitespacesAndNewlines,
11 | .illegalCharacters,
12 | .controlCharacters,
13 | .punctuationCharacters,
14 | .nonBaseCharacters,
15 | .symbols
16 | ]
17 |
18 | for invalidSet in invalidCharacterSets {
19 | invalidCharacters.formUnion(invalidSet)
20 | }
21 |
22 | return invalidCharacters
23 | }()
24 |
25 | @objc(qck_c99ExtendedIdentifier)
26 | var c99ExtendedIdentifier: String {
27 | let validComponents = components(separatedBy: NSString.invalidCharacters)
28 | let result = validComponents.joined(separator: "_")
29 |
30 | return result.isEmpty ? "_" : result
31 | }
32 | }
33 | #endif
34 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift:
--------------------------------------------------------------------------------
1 | #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
2 | import Foundation
3 |
4 | /**
5 | Responsible for building a "Selected tests" suite. This corresponds to a single
6 | spec, and all its examples.
7 | */
8 | internal class QuickSelectedTestSuiteBuilder: QuickTestSuiteBuilder {
9 |
10 | /**
11 | The test spec class to run.
12 | */
13 | let testCaseClass: AnyClass!
14 |
15 | /**
16 | For Objective-C classes, returns the class name. For Swift classes without,
17 | an explicit Objective-C name, returns a module-namespaced class name
18 | (e.g., "FooTests.FooSpec").
19 | */
20 | var testSuiteClassName: String {
21 | return NSStringFromClass(testCaseClass)
22 | }
23 |
24 | /**
25 | Given a test case name:
26 |
27 | FooSpec/testFoo
28 |
29 | Optionally constructs a test suite builder for the named test case class
30 | in the running test bundle.
31 |
32 | If no test bundle can be found, or the test case class can't be found,
33 | initialization fails and returns `nil`.
34 | */
35 | init?(forTestCaseWithName name: String) {
36 | guard let testCaseClass = testCaseClassForTestCaseWithName(name) else {
37 | self.testCaseClass = nil
38 | return nil
39 | }
40 |
41 | self.testCaseClass = testCaseClass
42 | }
43 |
44 | /**
45 | Returns a `QuickTestSuite` that runs the associated test case class.
46 | */
47 | func buildTestSuite() -> QuickTestSuite {
48 | return QuickTestSuite(forTestCaseClass: testCaseClass)
49 | }
50 |
51 | }
52 |
53 | /**
54 | Searches `Bundle.allBundles()` for an xctest bundle, then looks up the named
55 | test case class in that bundle.
56 |
57 | Returns `nil` if a bundle or test case class cannot be found.
58 | */
59 | private func testCaseClassForTestCaseWithName(_ name: String) -> AnyClass? {
60 | func extractClassName(_ name: String) -> String? {
61 | return name.components(separatedBy: "/").first
62 | }
63 |
64 | guard let className = extractClassName(name) else { return nil }
65 | guard let bundle = Bundle.currentTestBundle else { return nil }
66 |
67 | if let testCaseClass = bundle.classNamed(className) { return testCaseClass }
68 |
69 | let moduleName = bundle.moduleName
70 |
71 | return NSClassFromString("\(moduleName).\(className)")
72 | }
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/QuickTestSuite.swift:
--------------------------------------------------------------------------------
1 | #if os(macOS) || 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 | @objc
40 | public static func selectedTestSuite(forTestCaseWithName name: String) -> QuickTestSuite? {
41 | guard let builder = QuickSelectedTestSuiteBuilder(forTestCaseWithName: name) else { return nil }
42 |
43 | let (inserted, _) = builtTestSuites.insert(builder.testSuiteClassName)
44 | if inserted {
45 | return builder.buildTestSuite()
46 | } else {
47 | return nil
48 | }
49 | }
50 | }
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/Quick/URL+FileName.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | extension URL {
4 |
5 | /**
6 | Returns the path file name without file extension.
7 | */
8 | var fileName: String {
9 | return self.deletingPathExtension().lastPathComponent
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickObjectiveC/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 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickObjectiveC/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 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickObjectiveC/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 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickObjectiveC/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 | @code
37 | override func spec() {
38 | describe("winter") {
39 | it("is coming") {
40 | // ...
41 | }
42 | }
43 | }
44 | @endcode
45 |
46 | See DSL.swift for more information on what syntax is available.
47 | */
48 | - (void)spec;
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickObjectiveC/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 | - (void)performWithCurrentExampleGroup:(ExampleGroup * __nonnull)group closure:(void (^ __nonnull)(void))closure;
18 | @end
19 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickObjectiveC/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 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickSpecBase/QuickSpecBase.m:
--------------------------------------------------------------------------------
1 | #import "QuickSpecBase.h"
2 |
3 | #pragma mark - _QuickSelectorWrapper
4 |
5 | @interface _QuickSelectorWrapper ()
6 | @property(nonatomic, assign) SEL selector;
7 | @end
8 |
9 | @implementation _QuickSelectorWrapper
10 |
11 | - (instancetype)initWithSelector:(SEL)selector {
12 | self = [super init];
13 | _selector = selector;
14 | return self;
15 | }
16 |
17 | @end
18 |
19 |
20 | #pragma mark - _QuickSpecBase
21 |
22 | @implementation _QuickSpecBase
23 |
24 | - (instancetype)init {
25 | self = [super initWithInvocation: nil];
26 | return self;
27 | }
28 |
29 | /**
30 | Invocations for each test method in the test case. QuickSpec overrides this method to define a
31 | new method for each example defined in +[QuickSpec spec].
32 |
33 | @return An array of invocations that execute the newly defined example methods.
34 | */
35 | + (NSArray *)testInvocations {
36 | NSArray<_QuickSelectorWrapper *> *wrappers = [self _qck_testMethodSelectors];
37 | NSMutableArray *invocations = [NSMutableArray arrayWithCapacity:wrappers.count];
38 |
39 | for (_QuickSelectorWrapper *wrapper in wrappers) {
40 | SEL selector = wrapper.selector;
41 | NSMethodSignature *signature = [self instanceMethodSignatureForSelector:selector];
42 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
43 | invocation.selector = selector;
44 |
45 | [invocations addObject:invocation];
46 | }
47 |
48 | return invocations;
49 | }
50 |
51 | + (NSArray<_QuickSelectorWrapper *> *)_qck_testMethodSelectors {
52 | return @[];
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/Example/Pods/Quick/Sources/QuickSpecBase/include/QuickSpecBase.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface _QuickSelectorWrapper : NSObject
5 | - (instancetype)initWithSelector:(SEL)selector;
6 | @end
7 |
8 | @interface _QuickSpecBase : XCTestCase
9 | + (NSArray<_QuickSelectorWrapper *> *)_qck_testMethodSelectors;
10 | - (instancetype)init NS_DESIGNATED_INITIALIZER;
11 | @end
12 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/LICENSE.md:
--------------------------------------------------------------------------------
1 | **The MIT License**
2 | **Copyright © 2015 Krunoslav Zaher**
3 | **All rights reserved.**
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift:
--------------------------------------------------------------------------------
1 | //
2 | // InfiniteSequence.swift
3 | // Platform
4 | //
5 | // Created by Krunoslav Zaher on 6/13/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Sequence that repeats `repeatedValue` infinite number of times.
10 | struct InfiniteSequence : Sequence {
11 | typealias Element = E
12 | typealias Iterator = AnyIterator
13 |
14 | private let _repeatedValue: E
15 |
16 | init(repeatedValue: E) {
17 | _repeatedValue = repeatedValue
18 | }
19 |
20 | func makeIterator() -> Iterator {
21 | let repeatedValue = _repeatedValue
22 | return AnyIterator {
23 | return repeatedValue
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DispatchQueue+Extensions.swift
3 | // Platform
4 | //
5 | // Created by Krunoslav Zaher on 10/22/16.
6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | import Dispatch
10 |
11 | extension DispatchQueue {
12 | private static var token: DispatchSpecificKey<()> = {
13 | let key = DispatchSpecificKey<()>()
14 | DispatchQueue.main.setSpecific(key: key, value: ())
15 | return key
16 | }()
17 |
18 | static var isMain: Bool {
19 | return DispatchQueue.getSpecific(key: token) != nil
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/Platform/Platform.Darwin.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Platform.Darwin.swift
3 | // Platform
4 | //
5 | // Created by Krunoslav Zaher on 12/29/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
10 |
11 | import Darwin
12 | import class Foundation.Thread
13 | import func Foundation.OSAtomicCompareAndSwap32Barrier
14 | import func Foundation.OSAtomicIncrement32Barrier
15 | import func Foundation.OSAtomicDecrement32Barrier
16 | import protocol Foundation.NSCopying
17 |
18 | typealias AtomicInt = Int32
19 |
20 | fileprivate func castToUInt32Pointer(_ pointer: UnsafeMutablePointer) -> UnsafeMutablePointer {
21 | let raw = UnsafeMutableRawPointer(pointer)
22 | return raw.assumingMemoryBound(to: UInt32.self)
23 | }
24 |
25 | let AtomicCompareAndSwap = OSAtomicCompareAndSwap32Barrier
26 | let AtomicIncrement = OSAtomicIncrement32Barrier
27 | let AtomicDecrement = OSAtomicDecrement32Barrier
28 | func AtomicOr(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Int32 {
29 | return OSAtomicOr32OrigBarrier(mask, castToUInt32Pointer(theValue))
30 | }
31 | func AtomicFlagSet(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Bool {
32 | // just used to create a barrier
33 | OSAtomicXor32OrigBarrier(0, castToUInt32Pointer(theValue))
34 | return (theValue.pointee & Int32(mask)) != 0
35 | }
36 |
37 | extension Thread {
38 |
39 | static func setThreadLocalStorageValue(_ value: T?, forKey key: NSCopying
40 | ) {
41 | let currentThread = Thread.current
42 | let threadDictionary = currentThread.threadDictionary
43 |
44 | if let newValue = value {
45 | threadDictionary[key] = newValue
46 | }
47 | else {
48 | threadDictionary[key] = nil
49 | }
50 |
51 | }
52 | static func getThreadLocalStorageValueForKey(_ key: NSCopying) -> T? {
53 | let currentThread = Thread.current
54 | let threadDictionary = currentThread.threadDictionary
55 |
56 | return threadDictionary[key] as? T
57 | }
58 | }
59 |
60 | extension AtomicInt {
61 | func valueSnapshot() -> Int32 {
62 | return self
63 | }
64 | }
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/Platform/RecursiveLock.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RecursiveLock.swift
3 | // Platform
4 | //
5 | // Created by Krunoslav Zaher on 12/18/16.
6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | import class Foundation.NSRecursiveLock
10 |
11 | #if TRACE_RESOURCES
12 | class RecursiveLock: NSRecursiveLock {
13 | override init() {
14 | _ = Resources.incrementTotal()
15 | super.init()
16 | }
17 |
18 | override func lock() {
19 | super.lock()
20 | _ = Resources.incrementTotal()
21 | }
22 |
23 | override func unlock() {
24 | super.unlock()
25 | _ = Resources.decrementTotal()
26 | }
27 |
28 | deinit {
29 | _ = Resources.decrementTotal()
30 | }
31 | }
32 | #else
33 | typealias RecursiveLock = NSRecursiveLock
34 | #endif
35 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/AnyObserver.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AnyObserver.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/28/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// A type-erased `ObserverType`.
10 | ///
11 | /// Forwards operations to an arbitrary underlying observer with the same `Element` type, hiding the specifics of the underlying observer type.
12 | public struct AnyObserver : ObserverType {
13 | /// The type of elements in sequence that observer can observe.
14 | public typealias E = Element
15 |
16 | /// Anonymous event handler type.
17 | public typealias EventHandler = (Event) -> Void
18 |
19 | private let observer: EventHandler
20 |
21 | /// Construct an instance whose `on(event)` calls `eventHandler(event)`
22 | ///
23 | /// - parameter eventHandler: Event handler that observes sequences events.
24 | public init(eventHandler: @escaping EventHandler) {
25 | self.observer = eventHandler
26 | }
27 |
28 | /// Construct an instance whose `on(event)` calls `observer.on(event)`
29 | ///
30 | /// - parameter observer: Observer that receives sequence events.
31 | public init(_ observer: O) where O.E == Element {
32 | self.observer = observer.on
33 | }
34 |
35 | /// Send `event` to this observer.
36 | ///
37 | /// - parameter event: Event instance.
38 | public func on(_ event: Event) {
39 | return self.observer(event)
40 | }
41 |
42 | /// Erases type of observer and returns canonical observer.
43 | ///
44 | /// - returns: type erased observer.
45 | public func asObserver() -> AnyObserver {
46 | return self
47 | }
48 | }
49 |
50 | extension AnyObserver {
51 | /// Collection of `AnyObserver`s
52 | typealias s = Bag<(Event) -> ()>
53 | }
54 |
55 | extension ObserverType {
56 | /// Erases type of observer and returns canonical observer.
57 | ///
58 | /// - returns: type erased observer.
59 | public func asObserver() -> AnyObserver {
60 | return AnyObserver(self)
61 | }
62 |
63 | /// Transforms observer of type R to type E using custom transform method.
64 | /// Each event sent to result observer is transformed and sent to `self`.
65 | ///
66 | /// - returns: observer that transforms events.
67 | public func mapObserver(_ transform: @escaping (R) throws -> E) -> AnyObserver {
68 | return AnyObserver { e in
69 | self.on(e.map(transform))
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Cancelable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Cancelable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/12/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents disposable resource with state tracking.
10 | public protocol Cancelable : Disposable {
11 | /// Was resource disposed.
12 | var isDisposed: Bool { get }
13 | }
14 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AsyncLock.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/21/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /**
10 | In case nobody holds this lock, the work will be queued and executed immediately
11 | on thread that is requesting lock.
12 |
13 | In case there is somebody currently holding that lock, action will be enqueued.
14 | When owned of the lock finishes with it's processing, it will also execute
15 | and pending work.
16 |
17 | That means that enqueued work could possibly be executed later on a different thread.
18 | */
19 | final class AsyncLock
20 | : Disposable
21 | , Lock
22 | , SynchronizedDisposeType {
23 | typealias Action = () -> Void
24 |
25 | var _lock = SpinLock()
26 |
27 | private var _queue: Queue = Queue(capacity: 0)
28 |
29 | private var _isExecuting: Bool = false
30 | private var _hasFaulted: Bool = false
31 |
32 | // lock {
33 | func lock() {
34 | _lock.lock()
35 | }
36 |
37 | func unlock() {
38 | _lock.unlock()
39 | }
40 | // }
41 |
42 | private func enqueue(_ action: I) -> I? {
43 | _lock.lock(); defer { _lock.unlock() } // {
44 | if _hasFaulted {
45 | return nil
46 | }
47 |
48 | if _isExecuting {
49 | _queue.enqueue(action)
50 | return nil
51 | }
52 |
53 | _isExecuting = true
54 |
55 | return action
56 | // }
57 | }
58 |
59 | private func dequeue() -> I? {
60 | _lock.lock(); defer { _lock.unlock() } // {
61 | if _queue.count > 0 {
62 | return _queue.dequeue()
63 | }
64 | else {
65 | _isExecuting = false
66 | return nil
67 | }
68 | // }
69 | }
70 |
71 | func invoke(_ action: I) {
72 | let firstEnqueuedAction = enqueue(action)
73 |
74 | if let firstEnqueuedAction = firstEnqueuedAction {
75 | firstEnqueuedAction.invoke()
76 | }
77 | else {
78 | // action is enqueued, it's somebody else's concern now
79 | return
80 | }
81 |
82 | while true {
83 | let nextAction = dequeue()
84 |
85 | if let nextAction = nextAction {
86 | nextAction.invoke()
87 | }
88 | else {
89 | return
90 | }
91 | }
92 | }
93 |
94 | func dispose() {
95 | synchronizedDispose()
96 | }
97 |
98 | func _synchronized_dispose() {
99 | _queue = Queue(capacity: 0)
100 | _hasFaulted = true
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Concurrency/Lock.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Lock.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/31/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | protocol Lock {
10 | func lock()
11 | func unlock()
12 | }
13 |
14 | // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html
15 | typealias SpinLock = RecursiveLock
16 |
17 | extension RecursiveLock : Lock {
18 | @inline(__always)
19 | final func performLocked(_ action: () -> Void) {
20 | lock(); defer { unlock() }
21 | action()
22 | }
23 |
24 | @inline(__always)
25 | final func calculateLocked(_ action: () -> T) -> T {
26 | lock(); defer { unlock() }
27 | return action()
28 | }
29 |
30 | @inline(__always)
31 | final func calculateLockedOrFail(_ action: () throws -> T) throws -> T {
32 | lock(); defer { unlock() }
33 | let result = try action()
34 | return result
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LockOwnerType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 10/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | protocol LockOwnerType : class, Lock {
10 | var _lock: RecursiveLock { get }
11 | }
12 |
13 | extension LockOwnerType {
14 | func lock() {
15 | _lock.lock()
16 | }
17 |
18 | func unlock() {
19 | _lock.unlock()
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SynchronizedDisposeType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 10/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | protocol SynchronizedDisposeType : class, Disposable, Lock {
10 | func _synchronized_dispose()
11 | }
12 |
13 | extension SynchronizedDisposeType {
14 | func synchronizedDispose() {
15 | lock(); defer { unlock() }
16 | _synchronized_dispose()
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SynchronizedOnType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 10/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | protocol SynchronizedOnType : class, ObserverType, Lock {
10 | func _synchronized_on(_ event: Event)
11 | }
12 |
13 | extension SynchronizedOnType {
14 | func synchronizedOn(_ event: Event) {
15 | lock(); defer { unlock() }
16 | _synchronized_on(event)
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SynchronizedSubscribeType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 10/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | protocol SynchronizedSubscribeType : class, ObservableType, Lock {
10 | func _synchronized_subscribe(_ observer: O) -> Disposable where O.E == E
11 | }
12 |
13 | extension SynchronizedSubscribeType {
14 | func synchronizedSubscribe(_ observer: O) -> Disposable where O.E == E {
15 | lock(); defer { unlock() }
16 | return _synchronized_subscribe(observer)
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SynchronizedUnsubscribeType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 10/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | protocol SynchronizedUnsubscribeType : class {
10 | associatedtype DisposeKey
11 |
12 | func synchronizedUnsubscribe(_ disposeKey: DisposeKey)
13 | }
14 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/ConnectableObservableType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ConnectableObservableType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/1/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /**
10 | Represents an observable sequence wrapper that can be connected and disconnected from its underlying observable sequence.
11 | */
12 | public protocol ConnectableObservableType : ObservableType {
13 | /**
14 | Connects the observable wrapper to its source. All subscribed observers will receive values from the underlying observable sequence as long as the connection is established.
15 |
16 | - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence.
17 | */
18 | func connect() -> Disposable
19 | }
20 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Deprecated.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Deprecated.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/5/17.
6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable {
10 | /**
11 | Converts a optional to an observable sequence.
12 |
13 | - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html)
14 |
15 | - parameter optional: Optional element in the resulting observable sequence.
16 | - returns: An observable sequence containing the wrapped value or not from given optional.
17 | */
18 | @available(*, deprecated, message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.", renamed: "from(optional:)")
19 | public static func from(_ optional: E?) -> Observable {
20 | return Observable.from(optional: optional)
21 | }
22 |
23 | /**
24 | Converts a optional to an observable sequence.
25 |
26 | - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html)
27 |
28 | - parameter optional: Optional element in the resulting observable sequence.
29 | - parameter: Scheduler to send the optional element on.
30 | - returns: An observable sequence containing the wrapped value or not from given optional.
31 | */
32 | @available(*, deprecated, message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.", renamed: "from(optional:scheduler:)")
33 | public static func from(_ optional: E?, scheduler: ImmediateSchedulerType) -> Observable {
34 | return Observable.from(optional: optional, scheduler: scheduler)
35 | }
36 | }
37 |
38 | extension Disposable {
39 | /// Deprecated in favor of `disposed(by:)`
40 | ///
41 | /// **@available(\*, deprecated, message="use disposed(by:) instead")**
42 | ///
43 | /// Adds `self` to `bag`.
44 | ///
45 | /// - parameter bag: `DisposeBag` to add `self` to.
46 | public func addDisposableTo(_ bag: DisposeBag) {
47 | disposed(by: bag)
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Disposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/8/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Respresents a disposable resource.
10 | public protocol Disposable {
11 | /// Dispose resource.
12 | func dispose()
13 | }
14 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AnonymousDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/15/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents an Action-based disposable.
10 | ///
11 | /// When dispose method is called, disposal action will be dereferenced.
12 | fileprivate final class AnonymousDisposable : DisposeBase, Cancelable {
13 | public typealias DisposeAction = () -> Void
14 |
15 | private var _isDisposed: AtomicInt = 0
16 | private var _disposeAction: DisposeAction?
17 |
18 | /// - returns: Was resource disposed.
19 | public var isDisposed: Bool {
20 | return _isDisposed == 1
21 | }
22 |
23 | /// Constructs a new disposable with the given action used for disposal.
24 | ///
25 | /// - parameter disposeAction: Disposal action which will be run upon calling `dispose`.
26 | fileprivate init(_ disposeAction: @escaping DisposeAction) {
27 | _disposeAction = disposeAction
28 | super.init()
29 | }
30 |
31 | // Non-deprecated version of the constructor, used by `Disposables.create(with:)`
32 | fileprivate init(disposeAction: @escaping DisposeAction) {
33 | _disposeAction = disposeAction
34 | super.init()
35 | }
36 |
37 | /// Calls the disposal action if and only if the current instance hasn't been disposed yet.
38 | ///
39 | /// After invoking disposal action, disposal action will be dereferenced.
40 | fileprivate func dispose() {
41 | if AtomicCompareAndSwap(0, 1, &_isDisposed) {
42 | assert(_isDisposed == 1)
43 |
44 | if let action = _disposeAction {
45 | _disposeAction = nil
46 | action()
47 | }
48 | }
49 | }
50 | }
51 |
52 | extension Disposables {
53 |
54 | /// Constructs a new disposable with the given action used for disposal.
55 | ///
56 | /// - parameter dispose: Disposal action which will be run upon calling `dispose`.
57 | public static func create(with dispose: @escaping () -> ()) -> Cancelable {
58 | return AnonymousDisposable(disposeAction: dispose)
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BinaryDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 6/12/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents two disposable resources that are disposed together.
10 | private final class BinaryDisposable : DisposeBase, Cancelable {
11 |
12 | private var _isDisposed: AtomicInt = 0
13 |
14 | // state
15 | private var _disposable1: Disposable?
16 | private var _disposable2: Disposable?
17 |
18 | /// - returns: Was resource disposed.
19 | var isDisposed: Bool {
20 | return _isDisposed > 0
21 | }
22 |
23 | /// Constructs new binary disposable from two disposables.
24 | ///
25 | /// - parameter disposable1: First disposable
26 | /// - parameter disposable2: Second disposable
27 | init(_ disposable1: Disposable, _ disposable2: Disposable) {
28 | _disposable1 = disposable1
29 | _disposable2 = disposable2
30 | super.init()
31 | }
32 |
33 | /// Calls the disposal action if and only if the current instance hasn't been disposed yet.
34 | ///
35 | /// After invoking disposal action, disposal action will be dereferenced.
36 | func dispose() {
37 | if AtomicCompareAndSwap(0, 1, &_isDisposed) {
38 | _disposable1?.dispose()
39 | _disposable2?.dispose()
40 | _disposable1 = nil
41 | _disposable2 = nil
42 | }
43 | }
44 | }
45 |
46 | extension Disposables {
47 |
48 | /// Creates a disposable with the given disposables.
49 | public static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Cancelable {
50 | return BinaryDisposable(disposable1, disposable2)
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BooleanDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Junior B. on 10/29/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents a disposable resource that can be checked for disposal status.
10 | public final class BooleanDisposable : Cancelable {
11 |
12 | internal static let BooleanDisposableTrue = BooleanDisposable(isDisposed: true)
13 | private var _isDisposed = false
14 |
15 | /// Initializes a new instance of the `BooleanDisposable` class
16 | public init() {
17 | }
18 |
19 | /// Initializes a new instance of the `BooleanDisposable` class with given value
20 | public init(isDisposed: Bool) {
21 | self._isDisposed = isDisposed
22 | }
23 |
24 | /// - returns: Was resource disposed.
25 | public var isDisposed: Bool {
26 | return _isDisposed
27 | }
28 |
29 | /// Sets the status to disposed, which can be observer through the `isDisposed` property.
30 | public func dispose() {
31 | _isDisposed = true
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/Disposables.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Disposables.swift
3 | // RxSwift
4 | //
5 | // Created by Mohsen Ramezanpoor on 01/08/2016.
6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// A collection of utility methods for common disposable operations.
10 | public struct Disposables {
11 | private init() {}
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DisposeBag.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Disposable {
10 | /// Adds `self` to `bag`
11 | ///
12 | /// - parameter bag: `DisposeBag` to add `self` to.
13 | public func disposed(by bag: DisposeBag) {
14 | bag.insert(self)
15 | }
16 | }
17 |
18 | /**
19 | Thread safe bag that disposes added disposables on `deinit`.
20 |
21 | This returns ARC (RAII) like resource management to `RxSwift`.
22 |
23 | In case contained disposables need to be disposed, just put a different dispose bag
24 | or create a new one in its place.
25 |
26 | self.existingDisposeBag = DisposeBag()
27 |
28 | In case explicit disposal is necessary, there is also `CompositeDisposable`.
29 | */
30 | public final class DisposeBag: DisposeBase {
31 |
32 | private var _lock = SpinLock()
33 |
34 | // state
35 | private var _disposables = [Disposable]()
36 | private var _isDisposed = false
37 |
38 | /// Constructs new empty dispose bag.
39 | public override init() {
40 | super.init()
41 | }
42 |
43 | /// Adds `disposable` to be disposed when dispose bag is being deinited.
44 | ///
45 | /// - parameter disposable: Disposable to add.
46 | public func insert(_ disposable: Disposable) {
47 | _insert(disposable)?.dispose()
48 | }
49 |
50 | private func _insert(_ disposable: Disposable) -> Disposable? {
51 | _lock.lock(); defer { _lock.unlock() }
52 | if _isDisposed {
53 | return disposable
54 | }
55 |
56 | _disposables.append(disposable)
57 |
58 | return nil
59 | }
60 |
61 | /// This is internal on purpose, take a look at `CompositeDisposable` instead.
62 | private func dispose() {
63 | let oldDisposables = _dispose()
64 |
65 | for disposable in oldDisposables {
66 | disposable.dispose()
67 | }
68 | }
69 |
70 | private func _dispose() -> [Disposable] {
71 | _lock.lock(); defer { _lock.unlock() }
72 |
73 | let disposables = _disposables
74 |
75 | _disposables.removeAll(keepingCapacity: false)
76 | _isDisposed = true
77 |
78 | return disposables
79 | }
80 |
81 | deinit {
82 | dispose()
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DisposeBase.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 4/4/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Base class for all disposables.
10 | public class DisposeBase {
11 | init() {
12 | #if TRACE_RESOURCES
13 | let _ = Resources.incrementTotal()
14 | #endif
15 | }
16 |
17 | deinit {
18 | #if TRACE_RESOURCES
19 | let _ = Resources.decrementTotal()
20 | #endif
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NopDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/15/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents a disposable that does nothing on disposal.
10 | ///
11 | /// Nop = No Operation
12 | fileprivate struct NopDisposable : Disposable {
13 |
14 | fileprivate static let noOp: Disposable = NopDisposable()
15 |
16 | fileprivate init() {
17 |
18 | }
19 |
20 | /// Does nothing.
21 | public func dispose() {
22 | }
23 | }
24 |
25 | extension Disposables {
26 | /**
27 | Creates a disposable that does nothing on disposal.
28 | */
29 | static public func create() -> Disposable {
30 | return NopDisposable.noOp
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ScheduledDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 6/13/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | private let disposeScheduledDisposable: (ScheduledDisposable) -> Disposable = { sd in
10 | sd.disposeInner()
11 | return Disposables.create()
12 | }
13 |
14 | /// Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler.
15 | public final class ScheduledDisposable : Cancelable {
16 | public let scheduler: ImmediateSchedulerType
17 |
18 | private var _isDisposed: AtomicInt = 0
19 |
20 | // state
21 | private var _disposable: Disposable?
22 |
23 | /// - returns: Was resource disposed.
24 | public var isDisposed: Bool {
25 | return _isDisposed == 1
26 | }
27 |
28 | /**
29 | Initializes a new instance of the `ScheduledDisposable` that uses a `scheduler` on which to dispose the `disposable`.
30 |
31 | - parameter scheduler: Scheduler where the disposable resource will be disposed on.
32 | - parameter disposable: Disposable resource to dispose on the given scheduler.
33 | */
34 | public init(scheduler: ImmediateSchedulerType, disposable: Disposable) {
35 | self.scheduler = scheduler
36 | _disposable = disposable
37 | }
38 |
39 | /// Disposes the wrapped disposable on the provided scheduler.
40 | public func dispose() {
41 | let _ = scheduler.schedule(self, action: disposeScheduledDisposable)
42 | }
43 |
44 | func disposeInner() {
45 | if AtomicCompareAndSwap(0, 1, &_isDisposed) {
46 | _disposable!.dispose()
47 | _disposable = nil
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SerialDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/12/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource.
10 | public final class SerialDisposable : DisposeBase, Cancelable {
11 | private var _lock = SpinLock()
12 |
13 | // state
14 | private var _current = nil as Disposable?
15 | private var _isDisposed = false
16 |
17 | /// - returns: Was resource disposed.
18 | public var isDisposed: Bool {
19 | return _isDisposed
20 | }
21 |
22 | /// Initializes a new instance of the `SerialDisposable`.
23 | override public init() {
24 | super.init()
25 | }
26 |
27 | /**
28 | Gets or sets the underlying disposable.
29 |
30 | Assigning this property disposes the previous disposable object.
31 |
32 | If the `SerialDisposable` has already been disposed, assignment to this property causes immediate disposal of the given disposable object.
33 | */
34 | public var disposable: Disposable {
35 | get {
36 | return _lock.calculateLocked {
37 | return self.disposable
38 | }
39 | }
40 | set (newDisposable) {
41 | let disposable: Disposable? = _lock.calculateLocked {
42 | if _isDisposed {
43 | return newDisposable
44 | }
45 | else {
46 | let toDispose = _current
47 | _current = newDisposable
48 | return toDispose
49 | }
50 | }
51 |
52 | if let disposable = disposable {
53 | disposable.dispose()
54 | }
55 | }
56 | }
57 |
58 | /// Disposes the underlying disposable as well as all future replacements.
59 | public func dispose() {
60 | _dispose()?.dispose()
61 | }
62 |
63 | private func _dispose() -> Disposable? {
64 | _lock.lock(); defer { _lock.unlock() }
65 | if _isDisposed {
66 | return nil
67 | }
68 | else {
69 | _isDisposed = true
70 | let current = _current
71 | _current = nil
72 | return current
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SingleAssignmentDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/15/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /**
10 | Represents a disposable resource which only allows a single assignment of its underlying disposable resource.
11 |
12 | If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an exception.
13 | */
14 | public final class SingleAssignmentDisposable : DisposeBase, Cancelable {
15 |
16 | fileprivate enum DisposeState: UInt32 {
17 | case disposed = 1
18 | case disposableSet = 2
19 | }
20 |
21 | // Jeej, swift API consistency rules
22 | fileprivate enum DisposeStateInt32: Int32 {
23 | case disposed = 1
24 | case disposableSet = 2
25 | }
26 |
27 | // state
28 | private var _state: AtomicInt = 0
29 | private var _disposable = nil as Disposable?
30 |
31 | /// - returns: A value that indicates whether the object is disposed.
32 | public var isDisposed: Bool {
33 | return AtomicFlagSet(DisposeState.disposed.rawValue, &_state)
34 | }
35 |
36 | /// Initializes a new instance of the `SingleAssignmentDisposable`.
37 | public override init() {
38 | super.init()
39 | }
40 |
41 | /// Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined.
42 | ///
43 | /// **Throws exception if the `SingleAssignmentDisposable` has already been assigned to.**
44 | public func setDisposable(_ disposable: Disposable) {
45 | _disposable = disposable
46 |
47 | let previousState = AtomicOr(DisposeState.disposableSet.rawValue, &_state)
48 |
49 | if (previousState & DisposeStateInt32.disposableSet.rawValue) != 0 {
50 | rxFatalError("oldState.disposable != nil")
51 | }
52 |
53 | if (previousState & DisposeStateInt32.disposed.rawValue) != 0 {
54 | disposable.dispose()
55 | _disposable = nil
56 | }
57 | }
58 |
59 | /// Disposes the underlying disposable.
60 | public func dispose() {
61 | let previousState = AtomicOr(DisposeState.disposed.rawValue, &_state)
62 |
63 | if (previousState & DisposeStateInt32.disposed.rawValue) != 0 {
64 | return
65 | }
66 |
67 | if (previousState & DisposeStateInt32.disposableSet.rawValue) != 0 {
68 | guard let disposable = _disposable else {
69 | rxFatalError("Disposable not set")
70 | }
71 | disposable.dispose()
72 | _disposable = nil
73 | }
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SubscriptionDisposable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 10/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | struct SubscriptionDisposable : Disposable {
10 | private let _key: T.DisposeKey
11 | private weak var _owner: T?
12 |
13 | init(owner: T, key: T.DisposeKey) {
14 | _owner = owner
15 | _key = key
16 | }
17 |
18 | func dispose() {
19 | _owner?.synchronizedUnsubscribe(_key)
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Errors.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Errors.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/28/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | let RxErrorDomain = "RxErrorDomain"
10 | let RxCompositeFailures = "RxCompositeFailures"
11 |
12 | /// Generic Rx error codes.
13 | public enum RxError
14 | : Swift.Error
15 | , CustomDebugStringConvertible {
16 | /// Unknown error occurred.
17 | case unknown
18 | /// Performing an action on disposed object.
19 | case disposed(object: AnyObject)
20 | /// Aritmetic overflow error.
21 | case overflow
22 | /// Argument out of range error.
23 | case argumentOutOfRange
24 | /// Sequence doesn't contain any elements.
25 | case noElements
26 | /// Sequence contains more than one element.
27 | case moreThanOneElement
28 | /// Timeout error.
29 | case timeout
30 | }
31 |
32 | extension RxError {
33 | /// A textual representation of `self`, suitable for debugging.
34 | public var debugDescription: String {
35 | switch self {
36 | case .unknown:
37 | return "Unknown error occurred."
38 | case .disposed(let object):
39 | return "Object `\(object)` was already disposed."
40 | case .overflow:
41 | return "Arithmetic overflow occurred."
42 | case .argumentOutOfRange:
43 | return "Argument out of range."
44 | case .noElements:
45 | return "Sequence doesn't contain any elements."
46 | case .moreThanOneElement:
47 | return "Sequence contains more than one element."
48 | case .timeout:
49 | return "Sequence timeout."
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Bag+Rx.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 10/19/16.
6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 |
10 | // MARK: forEach
11 |
12 | @inline(__always)
13 | func dispatch(_ bag: Bag<(Event) -> ()>, _ event: Event) {
14 | if bag._onlyFastPath {
15 | bag._value0?(event)
16 | return
17 | }
18 |
19 | let value0 = bag._value0
20 | let dictionary = bag._dictionary
21 |
22 | if let value0 = value0 {
23 | value0(event)
24 | }
25 |
26 | let pairs = bag._pairs
27 | for i in 0 ..< pairs.count {
28 | pairs[i].value(event)
29 | }
30 |
31 | if let dictionary = dictionary {
32 | for element in dictionary.values {
33 | element(event)
34 | }
35 | }
36 | }
37 |
38 | /// Dispatches `dispose` to all disposables contained inside bag.
39 | func disposeAll(in bag: Bag) {
40 | if bag._onlyFastPath {
41 | bag._value0?.dispose()
42 | return
43 | }
44 |
45 | let value0 = bag._value0
46 | let dictionary = bag._dictionary
47 |
48 | if let value0 = value0 {
49 | value0.dispose()
50 | }
51 |
52 | let pairs = bag._pairs
53 | for i in 0 ..< pairs.count {
54 | pairs[i].value.dispose()
55 | }
56 |
57 | if let dictionary = dictionary {
58 | for element in dictionary.values {
59 | element.dispose()
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift:
--------------------------------------------------------------------------------
1 | //
2 | // String+Rx.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 12/25/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension String {
10 | /// This is needed because on Linux Swift doesn't have `rangeOfString(..., options: .BackwardsSearch)`
11 | func lastIndexOf(_ character: Character) -> Index? {
12 | var index = endIndex
13 | while index > startIndex {
14 | index = self.index(before: index)
15 | if self[index] == character {
16 | return index
17 | }
18 | }
19 |
20 | return nil
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/GroupedObservable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GroupedObservable.swift
3 | // RxSwift
4 | //
5 | // Created by Tomi Koskinen on 01/12/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents an observable sequence of elements that have a common key.
10 | public struct GroupedObservable : ObservableType {
11 | public typealias E = Element
12 |
13 | /// Gets the common key.
14 | public let key: Key
15 |
16 | private let source: Observable
17 |
18 | /// Initializes grouped observable sequence with key and source observable sequence.
19 | ///
20 | /// - parameter key: Grouped observable sequence key
21 | /// - parameter source: Observable sequence that represents sequence of elements for the key
22 | /// - returns: Grouped observable sequence of elements for the specific key
23 | public init(key: Key, source: Observable) {
24 | self.key = key
25 | self.source = source
26 | }
27 |
28 | /// Subscribes `observer` to receive events for this sequence.
29 | public func subscribe(_ observer: O) -> Disposable where O.E == E {
30 | return self.source.subscribe(observer)
31 | }
32 |
33 | /// Converts `self` to `Observable` sequence.
34 | public func asObservable() -> Observable {
35 | return source
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ImmediateSchedulerType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 5/31/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents an object that immediately schedules units of work.
10 | public protocol ImmediateSchedulerType {
11 | /**
12 | Schedules an action to be executed immediately.
13 |
14 | - parameter state: State passed to the action to be executed.
15 | - parameter action: Action to be executed.
16 | - returns: The disposable object used to cancel the scheduled action (best effort).
17 | */
18 | func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable
19 | }
20 |
21 | extension ImmediateSchedulerType {
22 | /**
23 | Schedules an action to be executed recursively.
24 |
25 | - parameter state: State passed to the action to be executed.
26 | - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.
27 | - returns: The disposable object used to cancel the scheduled action (best effort).
28 | */
29 | public func scheduleRecursive(_ state: State, action: @escaping (_ state: State, _ recurse: (State) -> ()) -> ()) -> Disposable {
30 | let recursiveScheduler = RecursiveImmediateScheduler(action: action, scheduler: self)
31 |
32 | recursiveScheduler.schedule(state)
33 |
34 | return Disposables.create(with: recursiveScheduler.dispose)
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Observable.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/8/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// A type-erased `ObservableType`.
10 | ///
11 | /// It represents a push style sequence.
12 | public class Observable : ObservableType {
13 | /// Type of elements in sequence.
14 | public typealias E = Element
15 |
16 | init() {
17 | #if TRACE_RESOURCES
18 | let _ = Resources.incrementTotal()
19 | #endif
20 | }
21 |
22 | public func subscribe(_ observer: O) -> Disposable where O.E == E {
23 | rxAbstractMethod()
24 | }
25 |
26 | public func asObservable() -> Observable {
27 | return self
28 | }
29 |
30 | deinit {
31 | #if TRACE_RESOURCES
32 | let _ = Resources.decrementTotal()
33 | #endif
34 | }
35 |
36 | // this is kind of ugly I know :(
37 | // Swift compiler reports "Not supported yet" when trying to override protocol extensions, so ¯\_(ツ)_/¯
38 |
39 | /// Optimizations for map operator
40 | internal func composeMap(_ transform: @escaping (Element) throws -> R) -> Observable {
41 | return _map(source: self, transform: transform)
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ObservableConvertibleType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 9/17/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Type that can be converted to observable sequence (`Observable`).
10 | public protocol ObservableConvertibleType {
11 | /// Type of elements in sequence.
12 | associatedtype E
13 |
14 | /// Converts `self` to `Observable` sequence.
15 | ///
16 | /// - returns: Observable sequence that represents `self`.
17 | func asObservable() -> Observable
18 | }
19 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/ObservableType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ObservableType.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 8/8/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | /// Represents a push style sequence.
10 | public protocol ObservableType : ObservableConvertibleType {
11 | /// Type of elements in sequence.
12 | associatedtype E
13 |
14 | /**
15 | Subscribes `observer` to receive events for this sequence.
16 |
17 | ### Grammar
18 |
19 | **Next\* (Error | Completed)?**
20 |
21 | * sequences can produce zero or more elements so zero or more `Next` events can be sent to `observer`
22 | * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other elements
23 |
24 | It is possible that events are sent from different threads, but no two events can be sent concurrently to
25 | `observer`.
26 |
27 | ### Resource Management
28 |
29 | When sequence sends `Complete` or `Error` event all internal resources that compute sequence elements
30 | will be freed.
31 |
32 | To cancel production of sequence elements and free resources immediately, call `dispose` on returned
33 | subscription.
34 |
35 | - returns: Subscription for `observer` that can be used to cancel production of sequence elements and free resources.
36 | */
37 | func subscribe(_ observer: O) -> Disposable where O.E == E
38 | }
39 |
40 | extension ObservableType {
41 |
42 | /// Default implementation of converting `ObservableType` to `Observable`.
43 | public func asObservable() -> Observable {
44 | // temporary workaround
45 | //return Observable.create(subscribe: self.subscribe)
46 | return Observable.create { o in
47 | return self.subscribe(o)
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/AddRef.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AddRef.swift
3 | // RxSwift
4 | //
5 | // Created by Junior B. on 30/10/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | final class AddRefSink : Sink, ObserverType {
10 | typealias Element = O.E
11 |
12 | override init(observer: O, cancel: Cancelable) {
13 | super.init(observer: observer, cancel: cancel)
14 | }
15 |
16 | func on(_ event: Event) {
17 | switch event {
18 | case .next(_):
19 | forwardOn(event)
20 | case .completed, .error(_):
21 | forwardOn(event)
22 | dispose()
23 | }
24 | }
25 | }
26 |
27 | final class AddRef : Producer {
28 | typealias EventHandler = (Event) throws -> Void
29 |
30 | private let _source: Observable
31 | private let _refCount: RefCountDisposable
32 |
33 | init(source: Observable, refCount: RefCountDisposable) {
34 | _source = source
35 | _refCount = refCount
36 | }
37 |
38 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element {
39 | let releaseDisposable = _refCount.retain()
40 | let sink = AddRefSink(observer: observer, cancel: cancel)
41 | let subscription = Disposables.create(releaseDisposable, _source.subscribe(sink))
42 |
43 | return (sink: sink, subscription: subscription)
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AsMaybe.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/12/17.
6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | fileprivate final class AsMaybeSink : Sink, ObserverType {
10 | typealias ElementType = O.E
11 | typealias E = ElementType
12 |
13 | private var _element: Event? = nil
14 |
15 | func on(_ event: Event) {
16 | switch event {
17 | case .next:
18 | if _element != nil {
19 | forwardOn(.error(RxError.moreThanOneElement))
20 | dispose()
21 | }
22 |
23 | _element = event
24 | case .error:
25 | forwardOn(event)
26 | dispose()
27 | case .completed:
28 | if let element = _element {
29 | forwardOn(element)
30 | }
31 | forwardOn(.completed)
32 | dispose()
33 | }
34 | }
35 | }
36 |
37 | final class AsMaybe: Producer {
38 | fileprivate let _source: Observable
39 |
40 | init(source: Observable) {
41 | _source = source
42 | }
43 |
44 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element {
45 | let sink = AsMaybeSink(observer: observer, cancel: cancel)
46 | let subscription = _source.subscribe(sink)
47 | return (sink: sink, subscription: subscription)
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/AsSingle.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AsSingle.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 3/12/17.
6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | fileprivate final class AsSingleSink : Sink, ObserverType {
10 | typealias ElementType = O.E
11 | typealias E = ElementType
12 |
13 | private var _element: Event? = nil
14 |
15 | func on(_ event: Event) {
16 | switch event {
17 | case .next:
18 | if _element != nil {
19 | forwardOn(.error(RxError.moreThanOneElement))
20 | dispose()
21 | }
22 |
23 | _element = event
24 | case .error:
25 | forwardOn(event)
26 | dispose()
27 | case .completed:
28 | if let element = _element {
29 | forwardOn(element)
30 | forwardOn(.completed)
31 | }
32 | else {
33 | forwardOn(.error(RxError.noElements))
34 | }
35 | dispose()
36 | }
37 | }
38 | }
39 |
40 | final class AsSingle: Producer {
41 | fileprivate let _source: Observable
42 |
43 | init(source: Observable) {
44 | _source = source
45 | }
46 |
47 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element {
48 | let sink = AsSingleSink(observer: observer, cancel: cancel)
49 | let subscription = _source.subscribe(sink)
50 | return (sink: sink, subscription: subscription)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Create.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Create.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/8/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable {
10 | // MARK: create
11 |
12 | /**
13 | Creates an observable sequence from a specified subscribe method implementation.
14 |
15 | - seealso: [create operator on reactivex.io](http://reactivex.io/documentation/operators/create.html)
16 |
17 | - parameter subscribe: Implementation of the resulting observable sequence's `subscribe` method.
18 | - returns: The observable sequence with the specified implementation for the `subscribe` method.
19 | */
20 | public static func create(_ subscribe: @escaping (AnyObserver) -> Disposable) -> Observable {
21 | return AnonymousObservable(subscribe)
22 | }
23 | }
24 |
25 | final fileprivate class AnonymousObservableSink : Sink, ObserverType {
26 | typealias E = O.E
27 | typealias Parent = AnonymousObservable
28 |
29 | // state
30 | private var _isStopped: AtomicInt = 0
31 |
32 | #if DEBUG
33 | fileprivate let _synchronizationTracker = SynchronizationTracker()
34 | #endif
35 |
36 | override init(observer: O, cancel: Cancelable) {
37 | super.init(observer: observer, cancel: cancel)
38 | }
39 |
40 | func on(_ event: Event) {
41 | #if DEBUG
42 | _synchronizationTracker.register(synchronizationErrorMessage: .default)
43 | defer { _synchronizationTracker.unregister() }
44 | #endif
45 | switch event {
46 | case .next:
47 | if _isStopped == 1 {
48 | return
49 | }
50 | forwardOn(event)
51 | case .error, .completed:
52 | if AtomicCompareAndSwap(0, 1, &_isStopped) {
53 | forwardOn(event)
54 | dispose()
55 | }
56 | }
57 | }
58 |
59 | func run(_ parent: Parent) -> Disposable {
60 | return parent._subscribeHandler(AnyObserver(self))
61 | }
62 | }
63 |
64 | final fileprivate class AnonymousObservable : Producer {
65 | typealias SubscribeHandler = (AnyObserver) -> Disposable
66 |
67 | let _subscribeHandler: SubscribeHandler
68 |
69 | init(_ subscribeHandler: @escaping SubscribeHandler) {
70 | _subscribeHandler = subscribeHandler
71 | }
72 |
73 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element {
74 | let sink = AnonymousObservableSink(observer: observer, cancel: cancel)
75 | let subscription = sink.run(self)
76 | return (sink: sink, subscription: subscription)
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DefaultIfEmpty.swift
3 | // RxSwift
4 | //
5 | // Created by sergdort on 23/12/2016.
6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension ObservableType {
10 |
11 | /**
12 | Emits elements from the source observable sequence, or a default element if the source observable sequence is empty.
13 |
14 | - seealso: [DefaultIfEmpty operator on reactivex.io](http://reactivex.io/documentation/operators/defaultifempty.html)
15 |
16 | - parameter default: Default element to be sent if the source does not emit any elements
17 | - returns: An observable sequence which emits default element end completes in case the original sequence is empty
18 | */
19 | public func ifEmpty(default: E) -> Observable {
20 | return DefaultIfEmpty(source: self.asObservable(), default: `default`)
21 | }
22 | }
23 |
24 | final fileprivate class DefaultIfEmptySink: Sink, ObserverType {
25 | typealias E = O.E
26 | private let _default: E
27 | private var _isEmpty = true
28 |
29 | init(default: E, observer: O, cancel: Cancelable) {
30 | _default = `default`
31 | super.init(observer: observer, cancel: cancel)
32 | }
33 |
34 | func on(_ event: Event) {
35 | switch event {
36 | case .next(_):
37 | _isEmpty = false
38 | forwardOn(event)
39 | case .error(_):
40 | forwardOn(event)
41 | dispose()
42 | case .completed:
43 | if _isEmpty {
44 | forwardOn(.next(_default))
45 | }
46 | forwardOn(.completed)
47 | dispose()
48 | }
49 | }
50 | }
51 |
52 | final fileprivate class DefaultIfEmpty: Producer {
53 | private let _source: Observable
54 | private let _default: SourceType
55 |
56 | init(source: Observable, `default`: SourceType) {
57 | _source = source
58 | _default = `default`
59 | }
60 |
61 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == SourceType {
62 | let sink = DefaultIfEmptySink(default: _default, observer: observer, cancel: cancel)
63 | let subscription = _source.subscribe(sink)
64 | return (sink: sink, subscription: subscription)
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Deferred.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Deferred.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 4/19/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable {
10 | /**
11 | Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
12 |
13 | - seealso: [defer operator on reactivex.io](http://reactivex.io/documentation/operators/defer.html)
14 |
15 | - parameter observableFactory: Observable factory function to invoke for each observer that subscribes to the resulting sequence.
16 | - returns: An observable sequence whose observers trigger an invocation of the given observable factory function.
17 | */
18 | public static func deferred(_ observableFactory: @escaping () throws -> Observable)
19 | -> Observable {
20 | return Deferred(observableFactory: observableFactory)
21 | }
22 | }
23 |
24 | final fileprivate class DeferredSink : Sink, ObserverType where S.E == O.E {
25 | typealias E = O.E
26 |
27 | private let _observableFactory: () throws -> S
28 |
29 | init(observableFactory: @escaping () throws -> S, observer: O, cancel: Cancelable) {
30 | _observableFactory = observableFactory
31 | super.init(observer: observer, cancel: cancel)
32 | }
33 |
34 | func run() -> Disposable {
35 | do {
36 | let result = try _observableFactory()
37 | return result.subscribe(self)
38 | }
39 | catch let e {
40 | forwardOn(.error(e))
41 | dispose()
42 | return Disposables.create()
43 | }
44 | }
45 |
46 | func on(_ event: Event) {
47 | forwardOn(event)
48 |
49 | switch event {
50 | case .next:
51 | break
52 | case .error:
53 | dispose()
54 | case .completed:
55 | dispose()
56 | }
57 | }
58 | }
59 |
60 | final fileprivate class Deferred : Producer {
61 | typealias Factory = () throws -> S
62 |
63 | private let _observableFactory : Factory
64 |
65 | init(observableFactory: @escaping Factory) {
66 | _observableFactory = observableFactory
67 | }
68 |
69 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E {
70 | let sink = DeferredSink(observableFactory: _observableFactory, observer: observer, cancel: cancel)
71 | let subscription = sink.run()
72 | return (sink: sink, subscription: subscription)
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DelaySubscription.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 6/14/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension ObservableType {
10 |
11 | /**
12 | Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
13 |
14 | - seealso: [delay operator on reactivex.io](http://reactivex.io/documentation/operators/delay.html)
15 |
16 | - parameter dueTime: Relative time shift of the subscription.
17 | - parameter scheduler: Scheduler to run the subscription delay timer on.
18 | - returns: Time-shifted sequence.
19 | */
20 | public func delaySubscription(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
21 | -> Observable {
22 | return DelaySubscription(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler)
23 | }
24 | }
25 |
26 | final fileprivate class DelaySubscriptionSink
27 | : Sink, ObserverType {
28 | typealias E = O.E
29 | typealias Parent = DelaySubscription
30 |
31 | private let _parent: Parent
32 |
33 | init(parent: Parent, observer: O, cancel: Cancelable) {
34 | _parent = parent
35 | super.init(observer: observer, cancel: cancel)
36 | }
37 |
38 | func on(_ event: Event) {
39 | forwardOn(event)
40 | if event.isStopEvent {
41 | dispose()
42 | }
43 | }
44 |
45 | }
46 |
47 | final fileprivate class DelaySubscription: Producer {
48 | private let _source: Observable
49 | private let _dueTime: RxTimeInterval
50 | private let _scheduler: SchedulerType
51 |
52 | init(source: Observable, dueTime: RxTimeInterval, scheduler: SchedulerType) {
53 | _source = source
54 | _dueTime = dueTime
55 | _scheduler = scheduler
56 | }
57 |
58 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element {
59 | let sink = DelaySubscriptionSink(parent: self, observer: observer, cancel: cancel)
60 | let subscription = _scheduler.scheduleRelative((), dueTime: _dueTime) { _ in
61 | return self._source.subscribe(sink)
62 | }
63 |
64 | return (sink: sink, subscription: subscription)
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Dematerialize.swift
3 | // RxSwift
4 | //
5 | // Created by Jamie Pinkham on 3/13/17.
6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension ObservableType where E: EventConvertible {
10 | /**
11 | Convert any previously materialized Observable into it's original form.
12 | - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html)
13 | - returns: The dematerialized observable sequence.
14 | */
15 | public func dematerialize() -> Observable {
16 | return Dematerialize(source: self.asObservable())
17 | }
18 |
19 | }
20 |
21 | fileprivate final class DematerializeSink: Sink, ObserverType where O.E == Element.ElementType {
22 | fileprivate func on(_ event: Event) {
23 | switch event {
24 | case .next(let element):
25 | forwardOn(element.event)
26 | if element.event.isStopEvent {
27 | dispose()
28 | }
29 | case .completed:
30 | forwardOn(.completed)
31 | dispose()
32 | case .error(let error):
33 | forwardOn(.error(error))
34 | dispose()
35 | }
36 | }
37 | }
38 |
39 | final fileprivate class Dematerialize: Producer {
40 | private let _source: Observable
41 |
42 | init(source: Observable) {
43 | _source = source
44 | }
45 |
46 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element.ElementType {
47 | let sink = DematerializeSink(observer: observer, cancel: cancel)
48 | let subscription = _source.subscribe(sink)
49 | return (sink: sink, subscription: subscription)
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Empty.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Empty.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 8/30/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable {
10 | /**
11 | Returns an empty observable sequence, using the specified scheduler to send out the single `Completed` message.
12 |
13 | - seealso: [empty operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html)
14 |
15 | - returns: An observable sequence with no elements.
16 | */
17 | public static func empty() -> Observable {
18 | return EmptyProducer()
19 | }
20 | }
21 |
22 | final fileprivate class EmptyProducer : Producer {
23 | override func subscribe(_ observer: O) -> Disposable where O.E == Element {
24 | observer.on(.completed)
25 | return Disposables.create()
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Error.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Error.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 8/30/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable {
10 | /**
11 | Returns an observable sequence that terminates with an `error`.
12 |
13 | - seealso: [throw operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html)
14 |
15 | - returns: The observable sequence that terminates with specified error.
16 | */
17 | public static func error(_ error: Swift.Error) -> Observable {
18 | return ErrorProducer(error: error)
19 | }
20 | }
21 |
22 | final fileprivate class ErrorProducer : Producer {
23 | private let _error: Swift.Error
24 |
25 | init(error: Swift.Error) {
26 | _error = error
27 | }
28 |
29 | override func subscribe(_ observer: O) -> Disposable where O.E == Element {
30 | observer.on(.error(_error))
31 | return Disposables.create()
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Materialize.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Materialize.swift
3 | // RxSwift
4 | //
5 | // Created by sergdort on 08/03/2017.
6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension ObservableType {
10 | /**
11 | Convert any Observable into an Observable of its events.
12 | - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html)
13 | - returns: An observable sequence that wraps events in an Event. The returned Observable never errors, but it does complete after observing all of the events of the underlying Observable.
14 | */
15 | public func materialize() -> Observable> {
16 | return Materialize(source: self.asObservable())
17 | }
18 | }
19 |
20 | fileprivate final class MaterializeSink: Sink, ObserverType where O.E == Event {
21 |
22 | func on(_ event: Event) {
23 | forwardOn(.next(event))
24 | if event.isStopEvent {
25 | forwardOn(.completed)
26 | dispose()
27 | }
28 | }
29 | }
30 |
31 | final fileprivate class Materialize: Producer> {
32 | private let _source: Observable
33 |
34 | init(source: Observable) {
35 | _source = source
36 | }
37 |
38 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E {
39 | let sink = MaterializeSink(observer: observer, cancel: cancel)
40 | let subscription = _source.subscribe(sink)
41 |
42 | return (sink: sink, subscription: subscription)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Never.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Never.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 8/30/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable {
10 |
11 | /**
12 | Returns a non-terminating observable sequence, which can be used to denote an infinite duration.
13 |
14 | - seealso: [never operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html)
15 |
16 | - returns: An observable sequence whose observers will never get called.
17 | */
18 | public static func never() -> Observable {
19 | return NeverProducer()
20 | }
21 | }
22 |
23 | final fileprivate class NeverProducer : Producer {
24 | override func subscribe(_ observer: O) -> Disposable where O.E == Element {
25 | return Disposables.create()
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Range.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Range.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 9/13/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable where Element : SignedInteger {
10 | /**
11 | Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to generate and send out observer messages.
12 |
13 | - seealso: [range operator on reactivex.io](http://reactivex.io/documentation/operators/range.html)
14 |
15 | - parameter start: The value of the first integer in the sequence.
16 | - parameter count: The number of sequential integers to generate.
17 | - parameter scheduler: Scheduler to run the generator loop on.
18 | - returns: An observable sequence that contains a range of sequential integral numbers.
19 | */
20 | public static func range(start: E, count: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable {
21 | return RangeProducer(start: start, count: count, scheduler: scheduler)
22 | }
23 | }
24 |
25 | final fileprivate class RangeProducer : Producer {
26 | fileprivate let _start: E
27 | fileprivate let _count: E
28 | fileprivate let _scheduler: ImmediateSchedulerType
29 |
30 | init(start: E, count: E, scheduler: ImmediateSchedulerType) {
31 | if count < 0 {
32 | rxFatalError("count can't be negative")
33 | }
34 |
35 | if start &+ (count - 1) < start {
36 | rxFatalError("overflow of count")
37 | }
38 |
39 | _start = start
40 | _count = count
41 | _scheduler = scheduler
42 | }
43 |
44 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E {
45 | let sink = RangeSink(parent: self, observer: observer, cancel: cancel)
46 | let subscription = sink.run()
47 | return (sink: sink, subscription: subscription)
48 | }
49 | }
50 |
51 | final fileprivate class RangeSink : Sink where O.E: SignedInteger {
52 | typealias Parent = RangeProducer
53 |
54 | private let _parent: Parent
55 |
56 | init(parent: Parent, observer: O, cancel: Cancelable) {
57 | _parent = parent
58 | super.init(observer: observer, cancel: cancel)
59 | }
60 |
61 | func run() -> Disposable {
62 | return _parent._scheduler.scheduleRecursive(0 as O.E) { i, recurse in
63 | if i < self._parent._count {
64 | self.forwardOn(.next(self._parent._start + i))
65 | recurse(i + 1)
66 | }
67 | else {
68 | self.forwardOn(.completed)
69 | self.dispose()
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Repeat.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Repeat.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 9/13/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension Observable {
10 | /**
11 | Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
12 |
13 | - seealso: [repeat operator on reactivex.io](http://reactivex.io/documentation/operators/repeat.html)
14 |
15 | - parameter element: Element to repeat.
16 | - parameter scheduler: Scheduler to run the producer loop on.
17 | - returns: An observable sequence that repeats the given element infinitely.
18 | */
19 | public static func repeatElement(_ element: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable {
20 | return RepeatElement(element: element, scheduler: scheduler)
21 | }
22 | }
23 |
24 | final fileprivate class RepeatElement : Producer {
25 | fileprivate let _element: Element
26 | fileprivate let _scheduler: ImmediateSchedulerType
27 |
28 | init(element: Element, scheduler: ImmediateSchedulerType) {
29 | _element = element
30 | _scheduler = scheduler
31 | }
32 |
33 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element {
34 | let sink = RepeatElementSink(parent: self, observer: observer, cancel: cancel)
35 | let subscription = sink.run()
36 |
37 | return (sink: sink, subscription: subscription)
38 | }
39 | }
40 |
41 | final fileprivate class RepeatElementSink : Sink {
42 | typealias Parent = RepeatElement
43 |
44 | private let _parent: Parent
45 |
46 | init(parent: Parent, observer: O, cancel: Cancelable) {
47 | _parent = parent
48 | super.init(observer: observer, cancel: cancel)
49 | }
50 |
51 | func run() -> Disposable {
52 | return _parent._scheduler.scheduleRecursive(_parent._element) { e, recurse in
53 | self.forwardOn(.next(e))
54 | recurse(e)
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/Sink.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Sink.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 2/19/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | class Sink : Disposable {
10 | fileprivate let _observer: O
11 | fileprivate let _cancel: Cancelable
12 | fileprivate var _disposed: Bool
13 |
14 | #if DEBUG
15 | fileprivate let _synchronizationTracker = SynchronizationTracker()
16 | #endif
17 |
18 | init(observer: O, cancel: Cancelable) {
19 | #if TRACE_RESOURCES
20 | let _ = Resources.incrementTotal()
21 | #endif
22 | _observer = observer
23 | _cancel = cancel
24 | _disposed = false
25 | }
26 |
27 | final func forwardOn(_ event: Event) {
28 | #if DEBUG
29 | _synchronizationTracker.register(synchronizationErrorMessage: .default)
30 | defer { _synchronizationTracker.unregister() }
31 | #endif
32 | if _disposed {
33 | return
34 | }
35 | _observer.on(event)
36 | }
37 |
38 | final func forwarder() -> SinkForward {
39 | return SinkForward(forward: self)
40 | }
41 |
42 | final var disposed: Bool {
43 | return _disposed
44 | }
45 |
46 | func dispose() {
47 | _disposed = true
48 | _cancel.dispose()
49 | }
50 |
51 | deinit {
52 | #if TRACE_RESOURCES
53 | let _ = Resources.decrementTotal()
54 | #endif
55 | }
56 | }
57 |
58 | final class SinkForward: ObserverType {
59 | typealias E = O.E
60 |
61 | private let _forward: Sink
62 |
63 | init(forward: Sink) {
64 | _forward = forward
65 | }
66 |
67 | final func on(_ event: Event) {
68 | switch event {
69 | case .next:
70 | _forward._observer.on(event)
71 | case .error, .completed:
72 | _forward._observer.on(event)
73 | _forward._cancel.dispose()
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Example/Pods/RxSwift/RxSwift/Observables/StartWith.swift:
--------------------------------------------------------------------------------
1 | //
2 | // StartWith.swift
3 | // RxSwift
4 | //
5 | // Created by Krunoslav Zaher on 4/6/15.
6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved.
7 | //
8 |
9 | extension ObservableType {
10 |
11 | /**
12 | Prepends a sequence of values to an observable sequence.
13 |
14 | - seealso: [startWith operator on reactivex.io](http://reactivex.io/documentation/operators/startwith.html)
15 |
16 | - parameter elements: Elements to prepend to the specified sequence.
17 | - returns: The source sequence prepended with the specified values.
18 | */
19 | public func startWith(_ elements: E ...)
20 | -> Observable {
21 | return StartWith(source: self.asObservable(), elements: elements)
22 | }
23 | }
24 |
25 | final fileprivate class StartWith: Producer