├── .gitignore ├── .travis.yml ├── Checkman.xcodeproj └── project.pbxproj ├── Checkman.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── Checkman.xccheckout ├── Checkman ├── ApplicationDelegate.h ├── ApplicationDelegate.m ├── AsyncTask.h ├── AsyncTask.m ├── Check.h ├── Check.m ├── CheckCollection.h ├── CheckCollection.m ├── CheckDebuggingView.h ├── CheckDebuggingView.m ├── CheckDebuggingWindow.h ├── CheckDebuggingWindow.m ├── CheckManager.h ├── CheckManager.m ├── CheckMenuItem.h ├── CheckMenuItem.m ├── CheckRun.h ├── CheckRun.m ├── Checkfile.h ├── Checkfile.m ├── CheckfileCollection.h ├── CheckfileCollection.m ├── CheckfileEntry.h ├── CheckfileEntry.m ├── Checkman-Info.plist ├── Checkman-Prefix.pch ├── CustomNotification.h ├── CustomNotification.m ├── CustomNotifier.h ├── CustomNotifier.m ├── FSChanges.h ├── FSChangesDispatchWatcher.h ├── FSChangesDispatchWatcher.m ├── FSChangesNotifier.h ├── FSChangesNotifier.m ├── FSChangesObserver.h ├── FSChangesObserver.m ├── FSChangesTracker.h ├── FSChangesTracker.m ├── Growl.framework │ ├── Growl │ ├── Headers │ ├── Resources │ └── Versions │ │ ├── A │ │ ├── Growl │ │ ├── Headers │ │ │ ├── Growl.h │ │ │ ├── GrowlApplicationBridge.h │ │ │ └── GrowlDefines.h │ │ ├── Resources │ │ │ └── Info.plist │ │ └── _CodeSignature │ │ │ └── CodeResources │ │ └── Current ├── GrowlNotification.h ├── GrowlNotification.m ├── GrowlNotifier.h ├── GrowlNotifier.m ├── HTTPConnection.h ├── HTTPConnection.m ├── HTTPRequest.h ├── HTTPRequest.m ├── HTTPServer.h ├── HTTPServer.m ├── Images │ ├── icon-fail-changing.png │ ├── icon-fail.png │ ├── icon-ok-changing.png │ ├── icon-ok.png │ ├── icon-undetermined-changing.png │ ├── icon-undetermined.png │ └── icons.sketch │ │ ├── Data │ │ ├── QuickLook │ │ ├── Preview.png │ │ └── Thumbnail.png │ │ ├── fonts │ │ └── version ├── InfoMenuItem.h ├── InfoMenuItem.m ├── MenuController.h ├── MenuController.m ├── NSCustomTicker.h ├── NSCustomTicker.m ├── NSObject+Delayed.h ├── NSObject+Delayed.m ├── NSWindow+KeepOpen.h ├── NSWindow+KeepOpen.m ├── NotificationPanel.h ├── NotificationPanel.m ├── NotificationPanelView.h ├── NotificationPanelView.m ├── NotificationsController.h ├── NotificationsController.m ├── SectionedMenu.h ├── SectionedMenu.m ├── SeparatorMenuItem.h ├── SeparatorMenuItem.m ├── Settings.h ├── Settings.m ├── StickiesController.h ├── StickiesController.m ├── Sticky.h ├── Sticky.m ├── StickyPanel.h ├── StickyPanel.m ├── StickyPanelView.h ├── StickyPanelView.m ├── TCPBufferedStreams.h ├── TCPBufferedStreams.m ├── TCPConnection.h ├── TCPConnection.m ├── TCPServer.h ├── TCPServer.m ├── TaggedObject.h ├── TaggedObject.m ├── WebSocketConnection.h ├── WebSocketConnection.m ├── WebSocketFrame.h ├── WebSocketFrame.m ├── WebSocketSec.h ├── WebSocketSec.m ├── WebUI.h ├── WebUI.m ├── WebUIHandler.h ├── WebUIHandler.m ├── WebUIMessages.h ├── WebUIMessages.m ├── WebUIStaticFileHandler.h ├── WebUIStaticFileHandler.m ├── WebUIWebSocketHandler.h ├── WebUIWebSocketHandler.m ├── en.lproj │ └── MainMenu.xib └── main.m ├── CheckmanTests ├── CedarAsync │ ├── Headers │ │ ├── AsyncActualValue.h │ │ ├── CedarAsync.h │ │ ├── InTimeShouldSyntax.h │ │ └── Timing.h │ └── Timing.mm ├── CheckCollectionSpec.mm ├── CheckmanTests-Info.plist ├── CheckmanTests-Prefix.pch ├── FSChangesNotifierSpec.mm ├── Frameworks │ └── Cedar.framework │ │ ├── Cedar │ │ ├── Headers │ │ ├── ActualValue.h │ │ ├── AnyArgument.h │ │ ├── AnyInstanceArgument.h │ │ ├── Argument.h │ │ ├── Base.h │ │ ├── BeCloseTo.h │ │ ├── BeEmpty.h │ │ ├── BeGTE.h │ │ ├── BeGreaterThan.h │ │ ├── BeInstanceOf.h │ │ ├── BeLTE.h │ │ ├── BeLessThan.h │ │ ├── BeNil.h │ │ ├── BeSameInstanceAs.h │ │ ├── BeTruthy.h │ │ ├── CDRClassFake.h │ │ ├── CDRExampleBase.h │ │ ├── CDRExampleParent.h │ │ ├── CDRExampleReporter.h │ │ ├── CDRFake.h │ │ ├── CDRFunctions.h │ │ ├── CDRProtocolFake.h │ │ ├── CDRSharedExampleGroupPool.h │ │ ├── CDRSpec.h │ │ ├── CDRSpecFailure.h │ │ ├── CDRSpy.h │ │ ├── Cedar.h │ │ ├── CedarComparators.h │ │ ├── CedarDouble.h │ │ ├── CedarDoubles.h │ │ ├── CedarMatchers.h │ │ ├── CedarStringifiers.h │ │ ├── ComparatorsBase.h │ │ ├── ComparatorsContainer.h │ │ ├── CompareEqual.h │ │ ├── CompareGreaterThan.h │ │ ├── Contain.h │ │ ├── Equal.h │ │ ├── HaveReceived.h │ │ ├── InvocationMatcher.h │ │ ├── RaiseException.h │ │ ├── ReturnValue.h │ │ ├── ShouldSyntax.h │ │ ├── SpecHelper.h │ │ ├── StringifiersBase.h │ │ ├── StringifiersContainer.h │ │ ├── StubbedMethod.h │ │ └── ValueArgument.h │ │ ├── Resources │ │ └── Info.plist │ │ └── Versions │ │ ├── A │ │ ├── Cedar │ │ ├── Headers │ │ │ ├── ActualValue.h │ │ │ ├── AnyArgument.h │ │ │ ├── AnyInstanceArgument.h │ │ │ ├── Argument.h │ │ │ ├── Base.h │ │ │ ├── BeCloseTo.h │ │ │ ├── BeEmpty.h │ │ │ ├── BeGTE.h │ │ │ ├── BeGreaterThan.h │ │ │ ├── BeInstanceOf.h │ │ │ ├── BeLTE.h │ │ │ ├── BeLessThan.h │ │ │ ├── BeNil.h │ │ │ ├── BeSameInstanceAs.h │ │ │ ├── BeTruthy.h │ │ │ ├── CDRClassFake.h │ │ │ ├── CDRExampleBase.h │ │ │ ├── CDRExampleParent.h │ │ │ ├── CDRExampleReporter.h │ │ │ ├── CDRFake.h │ │ │ ├── CDRFunctions.h │ │ │ ├── CDRProtocolFake.h │ │ │ ├── CDRSharedExampleGroupPool.h │ │ │ ├── CDRSpec.h │ │ │ ├── CDRSpecFailure.h │ │ │ ├── CDRSpy.h │ │ │ ├── Cedar.h │ │ │ ├── CedarComparators.h │ │ │ ├── CedarDouble.h │ │ │ ├── CedarDoubles.h │ │ │ ├── CedarMatchers.h │ │ │ ├── CedarStringifiers.h │ │ │ ├── ComparatorsBase.h │ │ │ ├── ComparatorsContainer.h │ │ │ ├── CompareEqual.h │ │ │ ├── CompareGreaterThan.h │ │ │ ├── Contain.h │ │ │ ├── Equal.h │ │ │ ├── HaveReceived.h │ │ │ ├── InvocationMatcher.h │ │ │ ├── RaiseException.h │ │ │ ├── ReturnValue.h │ │ │ ├── ShouldSyntax.h │ │ │ ├── SpecHelper.h │ │ │ ├── StringifiersBase.h │ │ │ ├── StringifiersContainer.h │ │ │ ├── StubbedMethod.h │ │ │ └── ValueArgument.h │ │ └── Resources │ │ │ └── Info.plist │ │ └── Current │ │ ├── Cedar │ │ ├── Headers │ │ ├── ActualValue.h │ │ ├── AnyArgument.h │ │ ├── AnyInstanceArgument.h │ │ ├── Argument.h │ │ ├── Base.h │ │ ├── BeCloseTo.h │ │ ├── BeEmpty.h │ │ ├── BeGTE.h │ │ ├── BeGreaterThan.h │ │ ├── BeInstanceOf.h │ │ ├── BeLTE.h │ │ ├── BeLessThan.h │ │ ├── BeNil.h │ │ ├── BeSameInstanceAs.h │ │ ├── BeTruthy.h │ │ ├── CDRClassFake.h │ │ ├── CDRExampleBase.h │ │ ├── CDRExampleParent.h │ │ ├── CDRExampleReporter.h │ │ ├── CDRFake.h │ │ ├── CDRFunctions.h │ │ ├── CDRProtocolFake.h │ │ ├── CDRSharedExampleGroupPool.h │ │ ├── CDRSpec.h │ │ ├── CDRSpecFailure.h │ │ ├── CDRSpy.h │ │ ├── Cedar.h │ │ ├── CedarComparators.h │ │ ├── CedarDouble.h │ │ ├── CedarDoubles.h │ │ ├── CedarMatchers.h │ │ ├── CedarStringifiers.h │ │ ├── ComparatorsBase.h │ │ ├── ComparatorsContainer.h │ │ ├── CompareEqual.h │ │ ├── CompareGreaterThan.h │ │ ├── Contain.h │ │ ├── Equal.h │ │ ├── HaveReceived.h │ │ ├── InvocationMatcher.h │ │ ├── RaiseException.h │ │ ├── ReturnValue.h │ │ ├── ShouldSyntax.h │ │ ├── SpecHelper.h │ │ ├── StringifiersBase.h │ │ ├── StringifiersContainer.h │ │ ├── StubbedMethod.h │ │ └── ValueArgument.h │ │ └── Resources │ │ └── Info.plist ├── SectionedMenu+InsertItemSpec.mm ├── SectionedMenu+InsertSectionSpec.mm ├── SectionedMenu+RemoveSectionSpec.mm └── en.lproj │ └── InfoPlist.strings ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── Checkman.zip ├── build └── install ├── screenshots └── checkman.jpg ├── scripts ├── airbrake.check ├── buildkite.check ├── cctray.check ├── cf_apps.check ├── circleci.check ├── circlecijson.check ├── codeship.check ├── concourse.check ├── github_issues.check ├── jenkins_build.check ├── semaphore.check ├── site.check ├── site_with_retry.check ├── snapci.check ├── specs │ ├── Gemfile │ ├── Gemfile.lock │ ├── buildkite_spec.rb │ ├── cctray_spec.rb │ ├── check_shared_examples.rb │ ├── circleci_spec.rb │ ├── circlecijson_spec.rb │ ├── concourse_spec.rb │ ├── fixtures │ │ └── .flyrc │ ├── github_issues_spec.rb │ ├── jenkins_build_spec.rb │ ├── semaphore_spec.rb │ ├── site_spec.rb │ ├── spec_helper.rb │ ├── tddium_spec.rb │ ├── test_spec.rb │ ├── tracker_spec.rb │ └── travis_spec.rb ├── tddium.check ├── test.check ├── tracker.check └── travis.check └── web_ui ├── check.js ├── checks.js ├── connection.js ├── heart_beat.js ├── index.html ├── styles.css └── ui.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | !default.xcworkspace 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | # Rubymine 16 | .idea 17 | # Finder 18 | .DS_Store 19 | #deploy script 20 | deploy 21 | rakefile*.rb 22 | upload*.sh 23 | pkg/ 24 | 25 | # default project workspace 26 | project.xcworkspace 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | rvm: 4 | - 2.3 5 | - 2.4 6 | - 2.5 7 | - 2.6 8 | 9 | script: > 10 | gem install bundler && 11 | bundle install --gemfile=./scripts/specs/Gemfile && 12 | LC_CTYPE="en_US.UTF-8" rake 13 | -------------------------------------------------------------------------------- /Checkman.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Checkman.xcworkspace/xcshareddata/Checkman.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | C87D0A9D-903A-4BC2-911F-60C857D77905 9 | IDESourceControlProjectName 10 | Checkman 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 317A134F-2B96-4CD2-A4A4-BCDEF0F1E398 14 | http://github.com/cppforlife/checkman 15 | 16 | IDESourceControlProjectPath 17 | Checkman.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 317A134F-2B96-4CD2-A4A4-BCDEF0F1E398 21 | .. 22 | 23 | IDESourceControlProjectURL 24 | http://github.com/cppforlife/checkman 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 317A134F-2B96-4CD2-A4A4-BCDEF0F1E398 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 317A134F-2B96-4CD2-A4A4-BCDEF0F1E398 36 | IDESourceControlWCCName 37 | checkman 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Checkman/ApplicationDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface ApplicationDelegate : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /Checkman/AsyncTask.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class AsyncTask; 4 | 5 | @protocol AsyncTaskDelegate 6 | // Will be executed on the thread started by -run. 7 | - (void)asyncTaskDidComplete:(AsyncTask *)task; 8 | @end 9 | 10 | @interface AsyncTask : NSObject 11 | 12 | @property (nonatomic, assign) id delegate; 13 | 14 | - (void)setLaunchPath:(NSString *)launchPath; 15 | - (void)setCurrentDirectoryPath:(NSString *)currentDirectoryPath; 16 | - (void)setArguments:(NSArray *)arguments; 17 | 18 | // Runs task on a separate thread in a non-blocking manner. 19 | - (void)run; 20 | 21 | - (NSData *)stdOutData; 22 | - (NSData *)stdErrData; 23 | @end 24 | 25 | @interface AsyncTask (Bash) 26 | + (AsyncTask *)bashTaskWithCommand:(NSString *)command 27 | directoryPath:(NSString *)directoryPath; 28 | @end 29 | 30 | @interface AsyncTask (Command) 31 | - (NSString *)executedCommand; 32 | @end 33 | -------------------------------------------------------------------------------- /Checkman/Check.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "TaggedObject.h" 3 | 4 | typedef enum { 5 | CheckStatusOk = 99, 6 | CheckStatusFail = 98, 7 | CheckStatusUndetermined = 97 8 | } CheckStatus; 9 | 10 | @class Check; 11 | 12 | @protocol CheckDelegate 13 | - (void)checkDidChangeStatus:(NSNotification *)notification; 14 | - (void)checkDidChangeChanging:(NSNotification *)notification; 15 | - (void)checkDidChangeRunning:(NSNotification *)notification; 16 | @end 17 | 18 | @interface Check : TaggedObject 19 | 20 | @property (nonatomic, strong) NSString *primaryContextName; 21 | @property (nonatomic, strong) NSString *secondaryContextName; 22 | 23 | @property (nonatomic, assign) NSUInteger runInterval; 24 | @property (nonatomic, assign, getter = isDisabled) BOOL disabled; 25 | 26 | - (id)initWithName:(NSString *)name 27 | command:(NSString *)command 28 | directoryPath:(NSString *)directoryPath; 29 | 30 | - (NSString *)name; 31 | - (NSString *)command; 32 | 33 | - (void)startImmediately:(BOOL)immediately; 34 | - (void)stop; 35 | - (BOOL)isRunning; 36 | - (BOOL)isAfterFirstRun; 37 | 38 | - (CheckStatus)status; 39 | - (BOOL)isChanging; 40 | 41 | - (NSArray *)info; 42 | - (NSURL *)url; 43 | @end 44 | 45 | @interface Check (Observers) 46 | - (void)addObserver:(id)observer; 47 | - (void)removeObserver:(id)observer; 48 | @end 49 | 50 | @interface Check (Image) 51 | + (NSString *)statusImageNameForCheckStatus:(CheckStatus)status changing:(BOOL)changing; 52 | @end 53 | 54 | @interface Check (Notification) 55 | - (NSString *)statusNotificationName; 56 | - (NSString *)statusNotificationStatus; 57 | - (NSString *)statusNotificationText; 58 | - (NSColor *)statusNotificationColor; 59 | @end 60 | 61 | @interface Check (Debugging) 62 | - (NSString *)executedCommand; 63 | - (NSString *)stdOut; 64 | - (NSString *)stdErr; 65 | @end 66 | -------------------------------------------------------------------------------- /Checkman/CheckCollection.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Check.h" 3 | 4 | @class CheckCollection; 5 | 6 | @protocol CheckCollectionDelegate 7 | - (void)checkCollection:(CheckCollection *)collection 8 | didUpdateStatusFromCheck:(Check *)check; 9 | 10 | - (void)checkCollection:(CheckCollection *)collection 11 | didUpdateChangingFromCheck:(Check *)check; 12 | 13 | @optional 14 | - (void)checkCollection:(CheckCollection *)collection 15 | checkDidChangeStatus:(Check *)check; 16 | 17 | - (void)checkCollection:(CheckCollection *)collection 18 | checkDidChangeChanging:(Check *)check; 19 | @end 20 | 21 | @interface CheckCollection : NSObject 22 | 23 | @property (nonatomic, assign) id delegate; 24 | 25 | - (void)addCheck:(Check *)check; 26 | - (void)removeCheck:(Check *)check; 27 | 28 | - (NSUInteger)indexOfCheck:(Check *)check; 29 | - (Check *)checkWithTag:(NSInteger)tag; 30 | 31 | - (CheckStatus)status; 32 | - (BOOL)isChanging; 33 | 34 | - (NSString *)statusDescription; 35 | - (NSString *)extendedStatusDescription; 36 | 37 | - (NSUInteger)numberOfDisabledChecks; 38 | - (NSUInteger)count; 39 | @end 40 | -------------------------------------------------------------------------------- /Checkman/CheckDebuggingView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Check; 4 | 5 | @interface CheckDebuggingView : NSView 6 | - (id)initWithCheck:(Check *)check; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/CheckDebuggingWindow.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NSWindow+KeepOpen.h" 3 | 4 | @class Check; 5 | 6 | @interface CheckDebuggingWindow : NSWindow 7 | - (id)initWithCheck:(Check *)check; 8 | - (void)show; 9 | @end 10 | -------------------------------------------------------------------------------- /Checkman/CheckDebuggingWindow.m: -------------------------------------------------------------------------------- 1 | #import "CheckDebuggingWindow.h" 2 | #import "CheckDebuggingView.h" 3 | #import "Check.h" 4 | 5 | @interface CheckDebuggingWindow () 6 | @property (nonatomic, strong) Check *check; 7 | @end 8 | 9 | @implementation CheckDebuggingWindow 10 | @synthesize check = _check; 11 | 12 | - (id)initWithCheck:(Check *)check { 13 | if (self = [super init]) { 14 | self.check = check; 15 | self.contentView = [[CheckDebuggingView alloc] initWithCheck:check]; 16 | 17 | self.title = check.name; 18 | self.styleMask = 19 | NSBorderlessWindowMask | NSTitledWindowMask | 20 | NSClosableWindowMask | NSResizableWindowMask; 21 | } 22 | return self; 23 | } 24 | 25 | - (void)show { 26 | [self setFrame:NSMakeRect(0, 0, 400, 500) display:NO]; 27 | [self center]; 28 | [self makeKeyAndOrderFront:nil]; 29 | [self orderFrontRegardless]; 30 | } 31 | @end 32 | -------------------------------------------------------------------------------- /Checkman/CheckManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class MenuController, StickiesController, NotificationsController, WebUI, Settings; 4 | 5 | @interface CheckManager : NSObject 6 | 7 | - (id)initWithMenuController:(MenuController *)menuController 8 | stickiesController:(StickiesController *)stickiesController 9 | notificationsController:(NotificationsController *)notificationsController 10 | webUI:(WebUI *)webUI 11 | settings:(Settings *)settings; 12 | 13 | - (void)loadCheckfiles; 14 | - (void)reloadCheckfiles; 15 | @end 16 | -------------------------------------------------------------------------------- /Checkman/CheckMenuItem.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class CheckMenuItem, Check; 4 | 5 | @protocol CheckMenuItemDelegate 6 | - (void)checkMenuItemWasClicked:(CheckMenuItem *)item; 7 | @end 8 | 9 | @interface CheckMenuItem : NSMenuItem 10 | 11 | @property (nonatomic, assign) id delegate; 12 | 13 | - (id)initWithCheck:(Check *)check; 14 | - (Check *)check; 15 | @end 16 | -------------------------------------------------------------------------------- /Checkman/CheckRun.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class CheckRun; 4 | 5 | @protocol CheckRunDelegate 6 | - (void)checkRunDidFinish:(CheckRun *)run; 7 | @end 8 | 9 | @interface CheckRun : NSObject 10 | 11 | @property (nonatomic, assign) id delegate; 12 | 13 | - (id)initWithCommand:(NSString *)command 14 | directoryPath:(NSString *)directoryPath; 15 | 16 | - (void)start; 17 | - (BOOL)isValid; 18 | 19 | - (BOOL)isSuccessful; 20 | - (BOOL)isChanging; 21 | - (NSURL *)url; 22 | - (NSArray *)info; 23 | @end 24 | 25 | @interface CheckRun (Debugging) 26 | - (NSString *)executedCommand; 27 | - (NSString *)stdOut; 28 | - (NSString *)stdErr; 29 | @end 30 | -------------------------------------------------------------------------------- /Checkman/Checkfile.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "TaggedObject.h" 3 | 4 | @class Checkfile, CheckfileEntry, FSChangesNotifier; 5 | 6 | @protocol CheckfileDelegate 7 | - (void)checkfile:(Checkfile *)checkfile didAddEntry:(CheckfileEntry *)entry; 8 | - (void)checkfile:(Checkfile *)checkfile willRemoveEntry:(CheckfileEntry *)entry; 9 | @end 10 | 11 | @interface Checkfile : TaggedObject 12 | 13 | @property (nonatomic, assign) id delegate; 14 | 15 | - (id)initWithFilePath:(NSString *)filePath 16 | fsChangesNotifier:(FSChangesNotifier *)fsChangesNotifier; 17 | 18 | - (NSString *)name; 19 | - (NSString *)resolvedDirectoryPath; 20 | 21 | - (void)trackChanges; 22 | 23 | - (NSArray *)entries; 24 | - (NSUInteger)indexOfEntry:(CheckfileEntry *)entry; 25 | @end 26 | -------------------------------------------------------------------------------- /Checkman/CheckfileCollection.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class CheckfileCollection, Checkfile; 4 | 5 | @protocol CheckfileCollectionDelegate 6 | - (void)checkfileCollection:(CheckfileCollection *)collection 7 | didAddCheckfile:(Checkfile *)checkfile; 8 | 9 | - (void)checkfileCollection:(CheckfileCollection *)collection 10 | willRemoveCheckfile:(Checkfile *)checkfile; 11 | @end 12 | 13 | @interface CheckfileCollection : NSObject 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | + (CheckfileCollection *)collectionFromCheckmanUserDirectoryPath; 18 | 19 | - (id)initWithDirectoryPath:(NSString *)directoryPath; 20 | 21 | - (void)trackChanges; 22 | - (void)reloadFiles; 23 | 24 | - (NSArray *)files; 25 | - (NSUInteger)indexOfCheckfile:(Checkfile *)checkfile; 26 | @end 27 | -------------------------------------------------------------------------------- /Checkman/CheckfileEntry.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "TaggedObject.h" 3 | 4 | @interface CheckfileEntry : TaggedObject 5 | + (CheckfileEntry *)fromLine:(NSString *)line; 6 | 7 | - (BOOL)isCommandEntry; 8 | - (BOOL)isSeparatorEntry; 9 | - (BOOL)isTitledSeparatorEntry; 10 | @end 11 | 12 | @interface CheckfileCommandEntry : CheckfileEntry 13 | // e.g. 'command-name: bash command' 14 | + (CheckfileCommandEntry *)fromLine:(NSString *)line; 15 | 16 | @property (nonatomic, retain) NSString *primaryContextName; 17 | @property (nonatomic, retain) NSString *secondaryContextName; 18 | 19 | - (id)initWithName:(NSString *)name command:(NSString *)command; 20 | - (NSString *)name; 21 | - (NSString *)command; 22 | @end 23 | 24 | @interface CheckfileSeparatorEntry : CheckfileEntry 25 | // e.g. '#-' 26 | + (CheckfileSeparatorEntry *)fromLine:(NSString *)line; 27 | @end 28 | 29 | @interface CheckfileTitledSeparatorEntry : CheckfileEntry 30 | // e.g. '#- title for a separator' 31 | + (CheckfileTitledSeparatorEntry *)fromLine:(NSString *)line; 32 | 33 | - (id)initWithTitle:(NSString *)title; 34 | - (NSString *)title; 35 | @end 36 | -------------------------------------------------------------------------------- /Checkman/Checkman-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.tomato.Checkman 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 7 25 | LSApplicationCategoryType 26 | public.app-category.utilities 27 | LSMinimumSystemVersion 28 | ${MACOSX_DEPLOYMENT_TARGET} 29 | LSUIElement 30 | 31 | NSMainNibFile 32 | MainMenu 33 | Git SHA 34 | GIT_SHA_PLACEHOLDER 35 | NSPrincipalClass 36 | NSApplication 37 | 38 | 39 | -------------------------------------------------------------------------------- /Checkman/Checkman-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Checkman' target in the 'Checkman' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | 7 | #import 8 | 9 | #endif 10 | 11 | #define F(f, ...) [NSString stringWithFormat:f, ##__VA_ARGS__] 12 | -------------------------------------------------------------------------------- /Checkman/CustomNotification.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface CustomNotification : NSObject 4 | @property (nonatomic, strong) NSString *name; 5 | @property (nonatomic, strong) NSString *status; 6 | @property (nonatomic, strong) NSColor *color; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/CustomNotification.m: -------------------------------------------------------------------------------- 1 | #import "CustomNotification.h" 2 | 3 | @implementation CustomNotification 4 | @synthesize 5 | name = _name, 6 | status = _status, 7 | color = _color; 8 | @end 9 | -------------------------------------------------------------------------------- /Checkman/CustomNotifier.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class CustomNotification; 4 | 5 | @interface CustomNotifier : NSObject 6 | - (void)showNotification:(CustomNotification *)notification; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/FSChanges.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol FSChangesObserver; 4 | 5 | @protocol FSChangesTracker 6 | - (void)startTrackingFilePath:(NSString *)filePath 7 | observer:(id)observer; 8 | 9 | - (void)stopTrackingFilePath:(NSString *)filePath 10 | observer:(id)observer; 11 | @end 12 | 13 | @protocol FSChangesObserver 14 | - (void)handleChangeForFilePath:(NSString *)path 15 | tracker:(id)tracker; 16 | @end 17 | -------------------------------------------------------------------------------- /Checkman/FSChangesDispatchWatcher.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class FSChangesDispatchWatcher; 4 | 5 | @protocol FSChangesDispatchWatcherDelegate 6 | - (void)fsChangesDispatchWatcher:(FSChangesDispatchWatcher *)watcher 7 | didNoticeChangeToPath:(NSString *)path; 8 | @end 9 | 10 | @interface FSChangesDispatchWatcher : NSObject 11 | @property (nonatomic, assign) id delegate; 12 | 13 | - (void)addPath:(NSString *)path; 14 | - (void)removePath:(NSString *)path; 15 | @end 16 | -------------------------------------------------------------------------------- /Checkman/FSChangesDispatchWatcher.m: -------------------------------------------------------------------------------- 1 | #import "FSChangesDispatchWatcher.h" 2 | 3 | @interface FSChangesDispatchWatcher () 4 | @property (nonatomic, assign) dispatch_queue_t queue; 5 | @property (nonatomic, assign) dispatch_group_t group; 6 | @property (nonatomic, strong) NSMutableDictionary *paths; 7 | @end 8 | 9 | @implementation FSChangesDispatchWatcher 10 | @synthesize 11 | delegate = _delegate, 12 | queue = _queue, 13 | group = _group, 14 | paths = _paths; 15 | 16 | - (id)init { 17 | if (self = [super init]) { 18 | self.queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 19 | self.group = dispatch_group_create(); 20 | self.paths = [NSMutableDictionary dictionary]; 21 | } 22 | return self; 23 | } 24 | 25 | - (void)dealloc { 26 | NSAssert(self.paths.count == 0, @"All paths must be removed."); 27 | dispatch_group_leave(self.group); 28 | #if !__has_feature(objc_arc) 29 | [super dealloc]; 30 | #endif 31 | } 32 | 33 | - (void)addPath:(NSString *)path { 34 | int fd = open(path.UTF8String, O_EVTONLY); 35 | if (fd <= 0) return NSLog(@"FSChangesDispatchWatcher - addPath: failed to add %@", path); 36 | 37 | dispatch_source_t source = dispatch_source_create( 38 | DISPATCH_SOURCE_TYPE_VNODE, (uintptr_t)fd, 39 | DISPATCH_VNODE_WRITE, self.queue); 40 | 41 | NSValue *sourcePointer = 42 | [NSValue value:&source withObjCType:@encode(dispatch_source_t)]; 43 | [self.paths setObject:sourcePointer forKey:path]; 44 | 45 | __block typeof(self) that = self; 46 | dispatch_source_set_cancel_handler(source, ^{ close(fd); }); 47 | dispatch_source_set_event_handler(source, ^{ 48 | [that.delegate fsChangesDispatchWatcher:that didNoticeChangeToPath:path]; 49 | }); 50 | 51 | dispatch_resume(source); 52 | } 53 | 54 | - (void)removePath:(NSString *)path { 55 | dispatch_source_t source = NULL; 56 | [[self.paths objectForKey:path] getValue:&source]; 57 | 58 | if (source) { 59 | dispatch_source_cancel(source); 60 | [self.paths removeObjectForKey:path]; 61 | } 62 | } 63 | @end 64 | -------------------------------------------------------------------------------- /Checkman/FSChangesNotifier.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class FSChangesNotifier; 4 | 5 | @protocol FSChangesNotifierDelegate 6 | - (void)fsChangesNotifier:(FSChangesNotifier *)notifier 7 | filePathDidChange:(NSString *)filePath; 8 | @end 9 | 10 | @interface FSChangesNotifier : NSObject 11 | 12 | + (FSChangesNotifier *)sharedNotifier; 13 | 14 | - (void)startNotifying:(id)delegate 15 | forFilePath:(NSString *)filePath; 16 | 17 | - (void)stopNotifying:(id)delegate; 18 | @end 19 | -------------------------------------------------------------------------------- /Checkman/FSChangesObserver.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "FSChanges.h" 3 | 4 | @class FSChangesObserver; 5 | 6 | @protocol FSChangesObserverDelegate 7 | - (void)fsChangesObserverDidNoticeChange:(FSChangesObserver *)observer; 8 | @end 9 | 10 | @interface FSChangesObserver : NSObject 11 | 12 | @property (nonatomic, assign) id delegate; 13 | 14 | - (id)initWithFilePath:(NSString *)filePath; 15 | - (NSString *)filePath; 16 | 17 | - (void)startTracking:(id)tracker; 18 | - (void)stopTracking:(id)tracker; 19 | 20 | - (void)handleChangeForFilePath:(NSString *)filePath 21 | tracker:(id)tracker; 22 | @end 23 | -------------------------------------------------------------------------------- /Checkman/FSChangesTracker.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "FSChanges.h" 3 | 4 | @interface FSChangesTracker : NSObject 5 | @end 6 | -------------------------------------------------------------------------------- /Checkman/Growl.framework/Growl: -------------------------------------------------------------------------------- 1 | Versions/Current/Growl -------------------------------------------------------------------------------- /Checkman/Growl.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /Checkman/Growl.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /Checkman/Growl.framework/Versions/A/Growl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Growl.framework/Versions/A/Growl -------------------------------------------------------------------------------- /Checkman/Growl.framework/Versions/A/Headers/Growl.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __OBJC__ 4 | # include 5 | #endif 6 | -------------------------------------------------------------------------------- /Checkman/Growl.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 12C60 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | Growl 11 | CFBundleIdentifier 12 | com.growl.growlframework 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.1 19 | CFBundleSignature 20 | GRRR 21 | CFBundleVersion 22 | 2.0.1 23 | DTCompiler 24 | com.apple.compilers.llvm.clang.1_0 25 | DTPlatformBuild 26 | 4G2008a 27 | DTPlatformVersion 28 | GM 29 | DTSDKBuild 30 | 12C37 31 | DTSDKName 32 | macosx10.8 33 | DTXcode 34 | 0452 35 | DTXcodeBuild 36 | 4G2008a 37 | NSPrincipalClass 38 | GrowlApplicationBridge 39 | 40 | 41 | -------------------------------------------------------------------------------- /Checkman/Growl.framework/Versions/A/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Info.plist 8 | 9 | VZb3f8My4te/5JwcjfvotgCXTAs= 10 | 11 | 12 | rules 13 | 14 | ^Resources/ 15 | 16 | ^Resources/.*\.lproj/ 17 | 18 | optional 19 | 20 | weight 21 | 1000 22 | 23 | ^Resources/.*\.lproj/locversion.plist$ 24 | 25 | omit 26 | 27 | weight 28 | 1100 29 | 30 | ^version.plist$ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Checkman/Growl.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /Checkman/GrowlNotification.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GrowlNotification : NSObject 4 | @property (nonatomic, strong) NSString *name; 5 | @property (nonatomic, strong) NSString *status; 6 | @property (nonatomic, strong) NSString *type; 7 | @property (nonatomic, assign) NSInteger tag; 8 | 9 | - (NSNumber *)tagAsNumber; 10 | @end 11 | -------------------------------------------------------------------------------- /Checkman/GrowlNotification.m: -------------------------------------------------------------------------------- 1 | #import "GrowlNotification.h" 2 | 3 | @implementation GrowlNotification 4 | @synthesize 5 | name = _name, 6 | status = _status, 7 | type = _type, 8 | tag = _tag; 9 | 10 | - (NSNumber *)tagAsNumber { 11 | return [NSNumber numberWithInteger:self.tag]; 12 | } 13 | @end 14 | -------------------------------------------------------------------------------- /Checkman/GrowlNotifier.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GrowlNotification, GrowlNotifier; 4 | 5 | @protocol GrowlNotifierDelegate 6 | - (void)growlNotifier:(GrowlNotifier *)notifier 7 | didClickOnNotificationWithTag:(NSInteger)tag; 8 | @end 9 | 10 | @interface GrowlNotifier : NSObject 11 | 12 | @property (nonatomic, assign) id delegate; 13 | 14 | - (id)initWithNotificationTypes:(NSDictionary *)notificationTypes; 15 | 16 | - (BOOL)canShowNotification; 17 | - (void)showNotification:(GrowlNotification *)notification; 18 | @end 19 | -------------------------------------------------------------------------------- /Checkman/GrowlNotifier.m: -------------------------------------------------------------------------------- 1 | #import "GrowlNotifier.h" 2 | #import "GrowlNotification.h" 3 | #import 4 | 5 | @interface GrowlNotifier () 6 | @property (nonatomic, strong) NSDictionary *notificationTypes; 7 | @property (nonatomic, assign) BOOL canShowNotification; 8 | @end 9 | 10 | @implementation GrowlNotifier 11 | @synthesize 12 | delegate = _delegate, 13 | notificationTypes = _notificationTypes, 14 | canShowNotification = _canShowNotification; 15 | 16 | - (id)initWithNotificationTypes:(NSDictionary *)notificationTypes { 17 | if (self = [super init]) { 18 | self.notificationTypes = notificationTypes; 19 | self.canShowNotification = GrowlApplicationBridge.isGrowlRunning; 20 | GrowlApplicationBridge.growlDelegate = self; 21 | } 22 | return self; 23 | } 24 | 25 | - (void)dealloc { 26 | GrowlApplicationBridge.growlDelegate = nil; 27 | } 28 | 29 | - (void)showNotification:(GrowlNotification *)notification { 30 | NSLog(@"GrowlNotifier - show: %@", notification.name); 31 | 32 | [GrowlApplicationBridge 33 | notifyWithTitle:notification.name 34 | description:notification.status 35 | notificationName:notification.type 36 | iconData:nil priority:0 isSticky:NO 37 | clickContext:notification.tagAsNumber]; 38 | } 39 | 40 | #pragma mark - GrowlApplicationBridgeDelegate 41 | 42 | - (NSDictionary *)registrationDictionaryForGrowl { 43 | return [NSDictionary dictionaryWithObjectsAndKeys: 44 | NSProcessInfo.processInfo.processName, GROWL_APP_NAME, 45 | GROWL_NOTIFICATIONS_ALL, GROWL_NOTIFICATIONS_DEFAULT, 46 | self.notificationTypes.allKeys, GROWL_NOTIFICATIONS_ALL, 47 | self.notificationTypes, GROWL_NOTIFICATIONS_HUMAN_READABLE_NAMES, nil]; 48 | } 49 | 50 | - (void)growlNotificationWasClicked:(id)clickContext { 51 | NSNumber *checkTag = (NSNumber *)clickContext; 52 | [self.delegate growlNotifier:self didClickOnNotificationWithTag:checkTag.integerValue]; 53 | } 54 | @end 55 | -------------------------------------------------------------------------------- /Checkman/HTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class TCPConnection, HTTPConnection, HTTPRequest; 4 | 5 | @protocol HTTPConnectionDelegate 6 | - (void)HTTPConnectionDidClose:(HTTPConnection *)connection; 7 | @end 8 | 9 | @protocol HTTPConnectionDataDelegate 10 | - (void)HTTPConnection:(HTTPConnection *)connection 11 | didReceiveHTTPRequest:(HTTPRequest *)request; 12 | @end 13 | 14 | @interface HTTPConnection : NSObject 15 | @property (nonatomic, assign) id ownerDelegate; 16 | @property (nonatomic, assign) id connectionDelegate; 17 | @property (nonatomic, assign) id dataDelegate; 18 | 19 | - (id)initWithTCPConnection:(TCPConnection *)connection; 20 | - (TCPConnection *)tcpConnection; 21 | 22 | - (void)close; 23 | 24 | // Indicates whether there are any pending HTTP responses. 25 | // (Pending here means: 26 | // - not all requests were answered by a response 27 | // - not all responses were written to tcp conn.) 28 | - (BOOL)isFlushed; 29 | @end 30 | -------------------------------------------------------------------------------- /Checkman/HTTPRequest.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPRequest; 4 | 5 | @protocol HTTPRequestDelegate 6 | - (void)HTTPRequestDidRespond:(HTTPRequest *)request; 7 | @end 8 | 9 | @interface HTTPRequest : NSObject 10 | 11 | @property (nonatomic, assign) id delegate; 12 | @property (nonatomic, assign) CFHTTPMessageRef request; 13 | @property (nonatomic, assign) CFHTTPMessageRef response; 14 | 15 | - (id)initWithRequest:(CFHTTPMessageRef)request; 16 | 17 | #pragma mark - Request 18 | 19 | - (NSString *)requestMethod; 20 | 21 | - (NSString *)requestVersion; 22 | - (BOOL)isHTTP11; 23 | 24 | - (NSURL *)requestURL; 25 | - (NSString *)requestNamedHeaderValue:(NSString *)name; 26 | 27 | #pragma mark - Response 28 | 29 | // Also sets HTTP 1.1 and Content-Length: 0 30 | - (void)setResponseStatus:(CFIndex)status; 31 | 32 | - (void)setResponseHeader:(NSString *)name value:(NSString *)value; 33 | - (NSString *)responseNamedHeaderValue:(NSString *)name; 34 | - (BOOL)isResponseConnectionUpgrade; 35 | 36 | // Automatically sets Content-Length: to data's length 37 | - (void)setResponseBody:(NSData *)data; 38 | 39 | - (void)respond; 40 | - (BOOL)hasResponded; 41 | - (NSData *)responseAsData; 42 | @end 43 | -------------------------------------------------------------------------------- /Checkman/HTTPServer.h: -------------------------------------------------------------------------------- 1 | #import "TCPServer.h" 2 | 3 | @class HTTPServer, HTTPConnection, HTTPRequest; 4 | 5 | @protocol HTTPServerDelegate 6 | - (void)HTTPServer:(HTTPServer *)server 7 | HTTPConnection:(HTTPConnection *)connection 8 | didReceiveHTTPRequest:(HTTPRequest *)request; 9 | @end 10 | 11 | @interface HTTPServer : TCPServer 12 | @property (nonatomic, assign) id requestDelegate; 13 | 14 | + (HTTPServer *)onPort:(uint16_t)port; 15 | 16 | - (id)initWithTCPServer:(TCPServer *)tcpServer; 17 | 18 | - (BOOL)start:(NSError **)error; 19 | - (BOOL)stop; 20 | 21 | - (void)hijackConnection:(HTTPConnection *)connection; 22 | @end 23 | -------------------------------------------------------------------------------- /Checkman/Images/icon-fail-changing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icon-fail-changing.png -------------------------------------------------------------------------------- /Checkman/Images/icon-fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icon-fail.png -------------------------------------------------------------------------------- /Checkman/Images/icon-ok-changing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icon-ok-changing.png -------------------------------------------------------------------------------- /Checkman/Images/icon-ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icon-ok.png -------------------------------------------------------------------------------- /Checkman/Images/icon-undetermined-changing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icon-undetermined-changing.png -------------------------------------------------------------------------------- /Checkman/Images/icon-undetermined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icon-undetermined.png -------------------------------------------------------------------------------- /Checkman/Images/icons.sketch/Data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icons.sketch/Data -------------------------------------------------------------------------------- /Checkman/Images/icons.sketch/QuickLook/Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icons.sketch/QuickLook/Preview.png -------------------------------------------------------------------------------- /Checkman/Images/icons.sketch/QuickLook/Thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icons.sketch/QuickLook/Thumbnail.png -------------------------------------------------------------------------------- /Checkman/Images/icons.sketch/fonts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/Checkman/Images/icons.sketch/fonts -------------------------------------------------------------------------------- /Checkman/Images/icons.sketch/version: -------------------------------------------------------------------------------- 1 | 4 -------------------------------------------------------------------------------- /Checkman/InfoMenuItem.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface InfoMenuItem : NSMenuItem 4 | + (InfoMenuItem *)menuItemWithName:(NSString *)name value:(NSString *)value; 5 | - (id)initWithName:(NSString *)name value:(NSString *)value; 6 | @end 7 | -------------------------------------------------------------------------------- /Checkman/InfoMenuItem.m: -------------------------------------------------------------------------------- 1 | #import "InfoMenuItem.h" 2 | 3 | @interface InfoMenuItem () 4 | @property (nonatomic, strong) NSString *value; 5 | @end 6 | 7 | @implementation InfoMenuItem 8 | @synthesize value = _value; 9 | 10 | + (InfoMenuItem *)menuItemWithName:(NSString *)name value:(NSString *)value { 11 | if ([name isEqualToString:@"-"]) { 12 | return (id)[self separatorItem]; 13 | } 14 | return [[self alloc] initWithName:name value:value]; 15 | } 16 | 17 | - (id)initWithName:(NSString *)name value:(NSString *)value { 18 | if (self = [super init]) { 19 | self.value = value; 20 | self.enabled = NO; 21 | 22 | NSString *title = F(@"%@: %@", name, value); 23 | NSMutableAttributedString *attributedTitle = 24 | [[NSMutableAttributedString alloc] initWithString:title]; 25 | [attributedTitle 26 | addAttribute:NSForegroundColorAttributeName 27 | value:NSColor.darkGrayColor 28 | range:NSMakeRange(0, title.length)]; 29 | self.attributedTitle = attributedTitle; 30 | 31 | self.target = self; 32 | self.action = @selector(performAction); 33 | } 34 | return self; 35 | } 36 | 37 | - (void)performAction { 38 | [self writeStringToPasteBoard:self.value]; 39 | } 40 | 41 | - (void)writeStringToPasteBoard:(NSString *)string { 42 | if (self.value) { 43 | NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard]; 44 | [pasteBoard clearContents]; 45 | [pasteBoard writeObjects:[NSArray arrayWithObject:string]]; 46 | } 47 | } 48 | @end 49 | -------------------------------------------------------------------------------- /Checkman/MenuController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Check, MenuController; 4 | 5 | @protocol MenuControllerDelegate 6 | - (void)menuController:(MenuController *)controller 7 | didActOnCheck:(Check *)check 8 | flags:(NSUInteger)flags; 9 | @end 10 | 11 | @interface MenuController : NSObject 12 | 13 | @property (nonatomic, assign) id delegate; 14 | 15 | - (id)initWithGitSha:(NSString *)gitSha; 16 | 17 | - (Check *)checkWithTag:(NSInteger)tag; 18 | 19 | #pragma mark - Sections 20 | 21 | - (void)insertSectionWithTag:(NSInteger)tag atIndex:(NSUInteger)index; 22 | - (void)removeSectionWithTag:(NSInteger)tag; 23 | 24 | #pragma mark - Items 25 | 26 | - (void)insertCheck:(Check *)check 27 | atIndex:(NSUInteger)index 28 | inSectionWithTag:(NSInteger)sectionTag; 29 | 30 | - (void)insertSeparatorItemWithTag:(NSInteger)tag 31 | atIndex:(NSUInteger)index 32 | inSectionWithTag:(NSInteger)sectionTag; 33 | 34 | - (void)insertTitledSeparatorItemWithTag:(NSInteger)tag 35 | title:(NSString *)title 36 | atIndex:(NSUInteger)index 37 | inSectionWithTag:(NSInteger)sectionTag; 38 | 39 | - (void)removeItemWithTag:(NSInteger)tag inSectionWithTag:(NSInteger)sectionTag; 40 | @end 41 | -------------------------------------------------------------------------------- /Checkman/NSCustomTicker.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class NSCustomTicker; 4 | 5 | @protocol NSCustomTickerDelegate 6 | - (void)customTickerDidTick:(NSCustomTicker *)ticker; 7 | @end 8 | 9 | @interface NSCustomTicker : NSObject 10 | @property (nonatomic, assign) id delegate; 11 | - (id)initWithInterval:(NSTimeInterval)interval; 12 | @end 13 | -------------------------------------------------------------------------------- /Checkman/NSCustomTicker.m: -------------------------------------------------------------------------------- 1 | #import "NSCustomTicker.h" 2 | 3 | @interface NSCustomTickerTarget : NSObject 4 | @property (nonatomic, assign) NSCustomTicker *ticker; 5 | @end 6 | 7 | 8 | @interface NSCustomTicker () 9 | @property (nonatomic, assign) NSTimer *timer; 10 | @property (nonatomic, strong) NSCustomTickerTarget *target; 11 | @end 12 | 13 | @implementation NSCustomTicker 14 | @synthesize 15 | delegate = _delegate, 16 | timer = _timer, 17 | target = _target; 18 | 19 | - (id)initWithInterval:(NSTimeInterval)interval { 20 | if (self = [super init]) { 21 | // Need to creat an object to refer to self 22 | // since NSTimer retains the target and we want to 23 | // dealloc ourselves without first needing to invalidate. 24 | self.target = [[NSCustomTickerTarget alloc] init]; 25 | self.target.ticker = self; 26 | 27 | self.timer = 28 | [NSTimer scheduledTimerWithTimeInterval:interval 29 | target:self.target selector:@selector(perform) 30 | userInfo:nil repeats:YES]; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)dealloc { 36 | self.target.ticker = nil; 37 | [self.timer invalidate]; 38 | } 39 | 40 | - (void)perform { 41 | [self.delegate customTickerDidTick:self]; 42 | } 43 | @end 44 | 45 | 46 | @implementation NSCustomTickerTarget 47 | @synthesize ticker = _ticker; 48 | 49 | - (void)perform { 50 | [self.ticker perform]; 51 | } 52 | @end 53 | -------------------------------------------------------------------------------- /Checkman/NSObject+Delayed.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSObject (Delayed) 4 | - (void)performSelectorOnNextTick:(SEL)selector; 5 | - (void)performSelectorOnNextTick:(SEL)selector afterDelay:(NSTimeInterval)delay; 6 | - (void)cancelPerformSelectorOnNextTick:(SEL)selector; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/NSObject+Delayed.m: -------------------------------------------------------------------------------- 1 | #import "NSObject+Delayed.h" 2 | 3 | @implementation NSObject (Delayed) 4 | - (void)performSelectorOnNextTick:(SEL)selector { 5 | [self performSelectorOnNextTick:selector afterDelay:0]; 6 | } 7 | 8 | - (void)performSelectorOnNextTick:(SEL)selector afterDelay:(NSTimeInterval)delay { 9 | NSArray *modes = [NSArray arrayWithObjects:NSRunLoopCommonModes, NSEventTrackingRunLoopMode, nil]; 10 | [self performSelector:selector withObject:nil afterDelay:delay inModes:modes]; 11 | } 12 | 13 | - (void)cancelPerformSelectorOnNextTick:(SEL)selector { 14 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:selector object:nil]; 15 | } 16 | @end 17 | -------------------------------------------------------------------------------- /Checkman/NSWindow+KeepOpen.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSWindow (KeepOpen) 4 | - (void)keepOpenUntilClosed; 5 | @end 6 | -------------------------------------------------------------------------------- /Checkman/NSWindow+KeepOpen.m: -------------------------------------------------------------------------------- 1 | #import "NSWindow+KeepOpen.h" 2 | 3 | @implementation NSWindow (KeepOpen) 4 | - (void)keepOpenUntilClosed { 5 | self.releasedWhenClosed = YES; 6 | [self retain]; 7 | } 8 | @end 9 | -------------------------------------------------------------------------------- /Checkman/NotificationPanel.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class CustomNotification; 4 | 5 | @interface NotificationPanel : NSPanel 6 | - (id)initWithNotification:(CustomNotification *)notification; 7 | - (void)show; 8 | @end 9 | -------------------------------------------------------------------------------- /Checkman/NotificationPanel.m: -------------------------------------------------------------------------------- 1 | #import "NotificationPanel.h" 2 | #import "NotificationPanelView.h" 3 | #import "CustomNotification.h" 4 | 5 | @interface NotificationPanel () 6 | @property (nonatomic, strong) CustomNotification *notification; 7 | @end 8 | 9 | @implementation NotificationPanel 10 | @synthesize notification = _notification; 11 | 12 | - (id)initWithNotification:(CustomNotification *)notification { 13 | if (self = [super init]) { 14 | self.notification = notification; 15 | 16 | self.level = NSStatusWindowLevel; 17 | self.styleMask = NSBorderlessWindowMask | NSNonactivatingPanelMask; 18 | self.backgroundColor = NSColor.clearColor; 19 | self.alphaValue = 0.95; 20 | self.opaque = NO; 21 | 22 | NotificationPanelView *view = 23 | [[NotificationPanelView alloc] initWithNotification:notification]; 24 | self.minSize = view.frame.size; 25 | self.contentView = view; 26 | [self useOptimizedDrawing:YES]; 27 | 28 | self.excludedFromWindowsMenu = NO; 29 | self.hidesOnDeactivate = NO; 30 | self.oneShot = YES; 31 | self.canHide = NO; 32 | } 33 | return self; 34 | } 35 | 36 | - (void)show { 37 | [self setFrame:CGRectMake(0, 0, self.minSize.width, self.minSize.height) display:NO]; 38 | [self center]; 39 | [self makeKeyAndOrderFront:nil]; 40 | [self orderFrontRegardless]; 41 | } 42 | @end 43 | -------------------------------------------------------------------------------- /Checkman/NotificationPanelView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class CustomNotification; 4 | 5 | @interface NotificationPanelView : NSView 6 | - (id)initWithNotification:(CustomNotification *)notification; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/NotificationsController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Check, NotificationsController; 4 | 5 | @protocol NotificationsControllerDelegate 6 | - (void)notificationsController:(NotificationsController *)controller 7 | didActOnCheck:(Check *)check; 8 | @end 9 | 10 | @interface NotificationsController : NSObject 11 | 12 | @property (nonatomic, assign) id delegate; 13 | @property (nonatomic, assign) BOOL allowCustom; 14 | @property (nonatomic, assign) BOOL allowGrowl; 15 | @property (nonatomic, assign) BOOL allowNotificationCenter; 16 | 17 | - (void)addCheck:(Check *)check; 18 | - (void)removeCheck:(Check *)check; 19 | @end 20 | -------------------------------------------------------------------------------- /Checkman/SectionedMenu.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SectionedMenu : NSMenu 4 | 5 | #pragma mark - Sections 6 | 7 | - (void)insertSectionWithTag:(NSInteger)tag atIndex:(NSUInteger)index; 8 | - (void)removeSectionWithTag:(NSInteger)tag; 9 | 10 | #pragma mark - Section items 11 | 12 | - (void)insertItem:(NSMenuItem *)item 13 | atIndex:(NSUInteger)index 14 | inSectionWithTag:(NSInteger)sectionTag; 15 | 16 | - (NSMenuItem *)itemWithTag:(NSInteger)tag 17 | inSectionWithTag:(NSInteger)sectionTag; 18 | 19 | - (void)removeItemWithTag:(NSInteger)tag 20 | inSectionWithTag:(NSInteger)sectionTag; 21 | @end 22 | -------------------------------------------------------------------------------- /Checkman/SeparatorMenuItem.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SeparatorMenuItem : NSMenuItem 4 | + (SeparatorMenuItem *)separator; 5 | + (SeparatorMenuItem *)separatorWithTitle:(NSString *)title; 6 | @end 7 | -------------------------------------------------------------------------------- /Checkman/SeparatorMenuItem.m: -------------------------------------------------------------------------------- 1 | #import "SeparatorMenuItem.h" 2 | #import 3 | 4 | @implementation SeparatorMenuItem 5 | + (SeparatorMenuItem *)separator { 6 | NSMenuItem *item = NSMenuItem.separatorItem; 7 | object_setClass(item, [SeparatorMenuItem class]); 8 | return (SeparatorMenuItem *)item; 9 | } 10 | 11 | + (SeparatorMenuItem *)separatorWithTitle:(NSString *)title { 12 | SeparatorMenuItem *item = [[SeparatorMenuItem alloc] init]; 13 | item.attributedTitle = [self _separatorTitle:title]; 14 | item.enabled = NO; 15 | return item; 16 | } 17 | 18 | + (NSAttributedString *)_separatorTitle:(NSString *)title { 19 | NSDictionary *attributes = 20 | [NSDictionary dictionaryWithObjectsAndKeys: 21 | NSCursor.arrowCursor, NSCursorAttributeName, 22 | NSColor.lightGrayColor, NSForegroundColorAttributeName, 23 | [NSFont fontWithName:@"Lucida Grande" size:10], NSFontAttributeName, nil]; 24 | return [[NSAttributedString alloc] initWithString:title attributes:attributes]; 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /Checkman/Settings.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Settings; 4 | 5 | @protocol SettingsDelegate 6 | - (void)settingsDidChange:(Settings *)settings; 7 | @end 8 | 9 | @interface Settings : NSObject 10 | 11 | @property (nonatomic, assign) id delegate; 12 | 13 | + (Settings *)userSettings; 14 | 15 | - (void)trackChanges; 16 | 17 | #pragma mark - Check specific 18 | 19 | - (NSUInteger)runIntervalForCheckWithName:(NSString *)name 20 | inCheckfileWithName:(NSString *)checkfileName; 21 | 22 | - (BOOL)isCheckWithNameDisabled:(NSString *)name 23 | inCheckfileWithName:(NSString *)checkfileName; 24 | 25 | #pragma mark - Stickies 26 | 27 | - (BOOL)allowStickies; 28 | 29 | #pragma mark - Notifications 30 | 31 | - (BOOL)allowCustomNotifications; 32 | - (BOOL)allowGrowlNotifications; 33 | - (BOOL)allowNotificationCenterNotifications; 34 | 35 | #pragma mark - WebUI 36 | 37 | - (uint16_t)webUIPort; 38 | @end 39 | -------------------------------------------------------------------------------- /Checkman/StickiesController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Check; 4 | 5 | @interface StickiesController : NSObject 6 | 7 | @property (nonatomic, assign, getter = isAllowed) BOOL allow; 8 | 9 | - (void)addCheck:(Check *)check; 10 | - (void)removeCheck:(Check *)check; 11 | @end 12 | -------------------------------------------------------------------------------- /Checkman/Sticky.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface Sticky : NSObject 4 | @property (nonatomic, strong) NSString *name; 5 | @property (nonatomic, strong) NSString *status; 6 | @property (nonatomic, strong) NSColor *color; 7 | @property (nonatomic, assign) NSInteger tag; 8 | @end 9 | -------------------------------------------------------------------------------- /Checkman/Sticky.m: -------------------------------------------------------------------------------- 1 | #import "Sticky.h" 2 | 3 | @implementation Sticky 4 | @synthesize 5 | name = _name, 6 | status = _status, 7 | color = _color, 8 | tag = _tag; 9 | @end 10 | -------------------------------------------------------------------------------- /Checkman/StickyPanel.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Sticky; 4 | 5 | @interface StickyPanel : NSPanel 6 | - (id)initWithSticky:(Sticky *)sticky; 7 | - (Sticky *)sticky; 8 | 9 | - (void)showOnRightScreenEdge:(NSPoint)origin; 10 | - (void)moveDownBy:(CGFloat)distance; 11 | - (void)moveDownOffScreen; 12 | @end 13 | -------------------------------------------------------------------------------- /Checkman/StickyPanel.m: -------------------------------------------------------------------------------- 1 | #import "StickyPanel.h" 2 | #import "StickyPanelView.h" 3 | #import "Sticky.h" 4 | 5 | @interface StickyPanel () 6 | @property (nonatomic, strong) Sticky *sticky; 7 | @end 8 | 9 | @implementation StickyPanel 10 | @synthesize sticky = _sticky; 11 | 12 | - (id)initWithSticky:(Sticky *)sticky { 13 | if (self = [super init]) { 14 | self.sticky = sticky; 15 | 16 | self.level = NSStatusWindowLevel; 17 | self.styleMask = NSBorderlessWindowMask | NSNonactivatingPanelMask; 18 | self.backgroundColor = NSColor.clearColor; 19 | self.alphaValue = 0.95; 20 | self.opaque = NO; 21 | 22 | StickyPanelView *view = 23 | [[StickyPanelView alloc] initWithSticky:sticky]; 24 | self.minSize = view.frame.size; 25 | self.contentView = view; 26 | [self useOptimizedDrawing:YES]; 27 | 28 | self.excludedFromWindowsMenu = NO; 29 | self.hidesOnDeactivate = NO; 30 | self.oneShot = YES; 31 | self.canHide = NO; 32 | } 33 | return self; 34 | } 35 | 36 | - (void)showOnRightScreenEdge:(NSPoint)origin { 37 | NSScreen *mainScreen = [NSScreen.screens objectAtIndex:0]; 38 | [self setFrame:CGRectMake( 39 | mainScreen.frame.size.width - self.minSize.width - origin.x, 40 | origin.y, 41 | self.minSize.width, 42 | self.minSize.height 43 | ) display:NO]; 44 | 45 | [self makeKeyAndOrderFront:nil]; 46 | [self orderFrontRegardless]; 47 | } 48 | 49 | - (void)moveDownBy:(CGFloat)distance { 50 | NSRect frame = self.frame; 51 | NSPoint origin = frame.origin; 52 | origin.y -= distance; 53 | frame.origin = origin; 54 | [self setFrame:frame display:YES animate:YES]; 55 | } 56 | 57 | - (void)moveDownOffScreen { 58 | NSRect frame = self.frame; 59 | NSPoint origin = frame.origin; 60 | origin.y = -frame.size.height; 61 | frame.origin = origin; 62 | [self setFrame:frame display:YES animate:YES]; 63 | } 64 | @end 65 | -------------------------------------------------------------------------------- /Checkman/StickyPanelView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Sticky; 4 | 5 | @interface StickyPanelView : NSView 6 | - (id)initWithSticky:(Sticky *)sticky; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/TCPBufferedStreams.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface TCPBufferedStream : NSObject 4 | @property (nonatomic, assign) id delegate; 5 | - (NSStream *)stream; 6 | - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; 7 | - (void)open; 8 | - (void)close; 9 | @end 10 | 11 | 12 | @interface TCPBufferedInputStream : TCPBufferedStream 13 | - (id)initWithStream:(NSInputStream *)stream; 14 | 15 | - (const void *)bufferBytes; 16 | - (NSUInteger)bufferLength; 17 | 18 | - (NSUInteger)read; 19 | - (void)takeUntilLengthLeft:(NSUInteger)length; 20 | @end 21 | 22 | 23 | @interface TCPBufferedOutputStream : TCPBufferedStream 24 | - (id)initWithStream:(NSOutputStream *)stream; 25 | 26 | - (NSInteger)writeData:(NSData *)data; 27 | 28 | - (NSInteger)flush; 29 | - (BOOL)isFlushed; 30 | @end 31 | -------------------------------------------------------------------------------- /Checkman/TCPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class TCPConnection, TCPBufferedInputStream, TCPBufferedOutputStream; 4 | 5 | @protocol TCPConnectionDelegate 6 | - (void)TCPConnectionDidClose:(TCPConnection *)connection; 7 | @end 8 | 9 | @protocol TCPConnectionDataDelegate 10 | - (void)TCPConnectionProcessIncomingBytes:(TCPConnection *)connection; 11 | - (void)TCPConnectionProcessOutgoingBytes:(TCPConnection *)connection; 12 | @end 13 | 14 | @interface TCPConnection : NSObject 15 | @property (nonatomic, assign) id ownerDelegate; 16 | @property (nonatomic, assign) id connectionDelegate; 17 | @property (nonatomic, assign) id dataDelegate; 18 | 19 | // If set to true connection will be closed next time 20 | // something is written to the wire and everything is flushed. 21 | @property (nonatomic, assign) BOOL canClose; 22 | 23 | - (id)initWithAddress:(NSData *)address 24 | socketHandle:(CFSocketNativeHandle)socketHandle 25 | inputStream:(NSInputStream *)inputStream 26 | outputStream:(NSOutputStream *)outputStream; 27 | 28 | - (TCPBufferedInputStream *)istream; 29 | - (TCPBufferedOutputStream *)ostream; 30 | 31 | - (void)close; 32 | @end 33 | -------------------------------------------------------------------------------- /Checkman/TCPServer.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | NSString * const TCPServerErrorDomain; 5 | 6 | typedef enum { 7 | kTCPServerCouldNotBindToIPv4Address = 1, 8 | kTCPServerCouldNotBindToIPv6Address = 2, 9 | kTCPServerNoSocketsAvailable = 3, 10 | } TCPServerErrorCode; 11 | 12 | @class TCPServer, TCPConnection; 13 | 14 | @protocol TCPServerDelegate 15 | - (void)TCPServer:(TCPServer *)server 16 | TCPConnectionDidStart:(TCPConnection *)connection; 17 | @end 18 | 19 | @interface TCPServer : NSObject 20 | @property (nonatomic, assign) id delegate; 21 | 22 | - (id)initWithPort:(uint16_t)port; 23 | - (uint16_t)port; 24 | 25 | - (BOOL)start:(NSError **)error; 26 | - (BOOL)stop; 27 | 28 | - (void)hijackConnection:(TCPConnection *)connection; 29 | @end 30 | -------------------------------------------------------------------------------- /Checkman/TaggedObject.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface TaggedObject : NSObject 4 | @property (nonatomic, assign) NSInteger tag; 5 | - (NSNumber *)tagAsNumber; 6 | @end 7 | -------------------------------------------------------------------------------- /Checkman/TaggedObject.m: -------------------------------------------------------------------------------- 1 | #import "TaggedObject.h" 2 | 3 | @implementation TaggedObject 4 | @synthesize tag = _tag; 5 | 6 | + (NSInteger)_nextTag { 7 | static NSInteger tag = 0; 8 | NSAssert(++tag != 0, @"Tag must not be zero."); 9 | return tag; 10 | } 11 | 12 | - (id)init { 13 | if (self = [super init]) { 14 | self.tag = self.class._nextTag; 15 | } 16 | return self; 17 | } 18 | 19 | - (NSNumber *)tagAsNumber { 20 | return [NSNumber numberWithInteger:self.tag]; 21 | } 22 | 23 | - (BOOL)isEqual:(id)object { 24 | if ([object respondsToSelector:@selector(tag)] && [object tag]) { 25 | return self.tag == [object tag]; 26 | } else { 27 | return self == object; 28 | } 29 | } 30 | @end 31 | -------------------------------------------------------------------------------- /Checkman/WebSocketConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class TCPConnection, WebSocketConnection, WebSocketFrame; 4 | 5 | @protocol WebSocketConnectionDelegate 6 | - (void)WebSocketConnectionDidClose:(WebSocketConnection *)connection; 7 | @end 8 | 9 | @protocol WebSocketConnectionDataDelegate 10 | - (void)WebSocketConnection:(WebSocketConnection *)connection 11 | didReceiveFrame:(WebSocketFrame *)frame; 12 | @end 13 | 14 | @interface WebSocketConnection : NSObject 15 | @property (nonatomic, assign) id ownerDelegate; 16 | @property (nonatomic, assign) id connectionDelegate; 17 | @property (nonatomic, assign) id dataDelegate; 18 | 19 | - (id)initWithTCPConnection:(TCPConnection *)connection; 20 | - (TCPConnection *)tcpConnection; 21 | 22 | - (void)close; 23 | 24 | - (void)sendMessage:(NSString *)message; 25 | @end 26 | -------------------------------------------------------------------------------- /Checkman/WebSocketConnection.m: -------------------------------------------------------------------------------- 1 | #import "WebSocketConnection.h" 2 | #import "TCPConnection.h" 3 | #import "TCPBufferedStreams.h" 4 | #import "WebSocketFrame.h" 5 | 6 | @interface WebSocketConnection () 7 | 8 | @property (nonatomic, retain) TCPConnection *tcpConnection; 9 | @end 10 | 11 | @implementation WebSocketConnection 12 | @synthesize 13 | ownerDelegate = _ownerDelegate, 14 | connectionDelegate = _connectionDelegate, 15 | dataDelegate = _dataDelegate, 16 | tcpConnection = _tcpConnection; 17 | 18 | - (id)initWithTCPConnection:(TCPConnection *)tcpConnection { 19 | if (self = [super init]) { 20 | self.tcpConnection = tcpConnection; 21 | self.tcpConnection.dataDelegate = self; 22 | } 23 | return self; 24 | } 25 | 26 | - (void)dealloc { 27 | self.ownerDelegate = nil; 28 | self.connectionDelegate = nil; 29 | self.dataDelegate = nil; 30 | } 31 | 32 | #pragma mark - Closing connection 33 | 34 | - (void)close { 35 | [self.tcpConnection close]; 36 | } 37 | 38 | - (void)TCPConnectionDidClose:(TCPConnection *)connection { 39 | [self.connectionDelegate WebSocketConnectionDidClose:self]; 40 | [self.ownerDelegate WebSocketConnectionDidClose:self]; 41 | } 42 | 43 | #pragma mark - 44 | 45 | - (void)sendMessage:(NSString *)message { 46 | WebSocketFrame *frame = [[WebSocketFrame alloc] init]; 47 | frame.data = message; 48 | [self.tcpConnection.ostream writeData:frame.asWireData]; 49 | } 50 | 51 | #pragma mark - TCPConnectionDataDelegate 52 | 53 | - (void)TCPConnectionProcessIncomingBytes:(TCPConnection *)connection { 54 | // Not implemented 55 | } 56 | 57 | - (void)TCPConnectionProcessOutgoingBytes:(TCPConnection *)connection {} 58 | @end 59 | -------------------------------------------------------------------------------- /Checkman/WebSocketFrame.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface WebSocketFrame : NSObject 4 | @property (nonatomic, retain) id data; 5 | 6 | - (NSData *)asWireData; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/WebSocketSec.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface WebSocketSec : NSObject 4 | // Use to populate Sec-WebSocket-Accept header value 5 | // (secKey is Sec-WebSocket-Key header value). 6 | + (NSString *)secAcceptWithSecKey:(NSString *)secKey; 7 | @end 8 | -------------------------------------------------------------------------------- /Checkman/WebSocketSec.m: -------------------------------------------------------------------------------- 1 | #import "WebSocketSec.h" 2 | 3 | @implementation WebSocketSec 4 | 5 | + (NSString *)secAcceptWithSecKey:(NSString *)secKey { 6 | static NSString *magic = @"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 7 | NSString *secKeyMagic = [NSString stringWithFormat:@"%@%@", secKey, magic]; 8 | return [self _sha1ThenBase64EncodeString:secKeyMagic]; 9 | } 10 | 11 | #pragma mark - 12 | 13 | + (NSString *)_sha1ThenBase64EncodeString:(NSString *)string { 14 | NSString *cmd = [NSString stringWithFormat: 15 | @"echo -n '%@' | openssl dgst -binary -sha1 | openssl enc -base64", string]; 16 | 17 | NSTask *task = [[NSTask alloc] init]; 18 | task.launchPath = @"/bin/bash"; 19 | task.arguments = [NSArray arrayWithObjects:@"-c", cmd, nil]; 20 | 21 | task.standardOutput = [NSPipe pipe]; 22 | task.standardError = [NSPipe pipe]; 23 | [task launch]; 24 | [task waitUntilExit]; 25 | 26 | NSData *output = 27 | [[task.standardOutput fileHandleForReading] readDataToEndOfFile]; 28 | NSString *outputString = 29 | [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding]; 30 | 31 | return [outputString stringByTrimmingCharactersInSet: 32 | NSCharacterSet.whitespaceAndNewlineCharacterSet]; 33 | } 34 | @end 35 | -------------------------------------------------------------------------------- /Checkman/WebUI.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Check; 4 | 5 | @interface WebUI : NSObject 6 | 7 | - (id)initWithPort:(uint16_t)port; 8 | - (void)start; 9 | 10 | - (void)addCheck:(Check *)check; 11 | - (void)removeCheck:(Check *)check; 12 | @end 13 | -------------------------------------------------------------------------------- /Checkman/WebUIHandler.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer, HTTPConnection, HTTPRequest; 4 | 5 | @interface WebUIHandler : NSObject 6 | - (id)initWithHTTPServer:(HTTPServer *)server 7 | HTTPConnection:(HTTPConnection *)connection 8 | HTTPRequest:(HTTPRequest *)request; 9 | 10 | - (HTTPServer *)server; 11 | - (HTTPConnection *)connection; 12 | - (HTTPRequest *)request; 13 | 14 | // Override in subclass 15 | - (void)handle; 16 | @end 17 | 18 | @interface WebUIHandler (Helpers) 19 | - (BOOL)_handleUnsupportedVersion; 20 | - (BOOL)_handleUnsupportedRequest; 21 | - (BOOL)_handleNonGetRequest; 22 | - (BOOL)_respondWithStatus:(CFIndex)status; 23 | @end 24 | -------------------------------------------------------------------------------- /Checkman/WebUIHandler.m: -------------------------------------------------------------------------------- 1 | #import "WebUIHandler.h" 2 | #import "HTTPServer.h" 3 | #import "HTTPConnection.h" 4 | #import "HTTPRequest.h" 5 | 6 | @interface WebUIHandler () 7 | @property (nonatomic, retain) HTTPServer *server; 8 | @property (nonatomic, retain) HTTPConnection *connection; 9 | @property (nonatomic, retain) HTTPRequest *request; 10 | @end 11 | 12 | @implementation WebUIHandler 13 | @synthesize 14 | server = _server, 15 | connection = _connection, 16 | request = _request; 17 | 18 | - (id)initWithHTTPServer:(HTTPServer *)server 19 | HTTPConnection:(HTTPConnection *)connection 20 | HTTPRequest:(HTTPRequest *)request { 21 | if (self = [super init]) { 22 | self.server = server; 23 | self.connection = connection; 24 | self.request = request; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)handle { 30 | NSAssert(NO, @"Override in subclass"); 31 | } 32 | @end 33 | 34 | @implementation WebUIHandler (Helpers) 35 | 36 | - (BOOL)_handleUnsupportedVersion { 37 | if (!self.request.isHTTP11) { 38 | return [self _respondWithStatus:505]; 39 | } 40 | return NO; 41 | } 42 | 43 | - (BOOL)_handleUnsupportedRequest { 44 | if (!self.request.requestMethod) { 45 | return [self _respondWithStatus:400]; 46 | } 47 | return NO; 48 | } 49 | 50 | - (BOOL)_handleNonGetRequest { 51 | if (![self.request.requestMethod isEqual:@"GET"]) { 52 | return [self _respondWithStatus:405]; 53 | } 54 | return NO; 55 | } 56 | 57 | - (BOOL)_respondWithStatus:(CFIndex)status { 58 | self.request.responseStatus = status; 59 | [self.request respond]; 60 | return YES; 61 | } 62 | @end 63 | -------------------------------------------------------------------------------- /Checkman/WebUIMessages.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class CheckCollection, Check; 4 | 5 | @interface WebUIMessages : NSObject 6 | 7 | - (NSString *)heartBeatJSONMessage:(CheckCollection *)checks; 8 | 9 | - (NSString *)showCheckJSONMessage:(Check *)check; 10 | - (NSString *)hideCheckJSONMessage:(Check *)check; 11 | @end 12 | -------------------------------------------------------------------------------- /Checkman/WebUIStaticFileHandler.h: -------------------------------------------------------------------------------- 1 | #import "WebUIHandler.h" 2 | 3 | @interface WebUIStaticFileHandler : WebUIHandler 4 | @end 5 | -------------------------------------------------------------------------------- /Checkman/WebUIStaticFileHandler.m: -------------------------------------------------------------------------------- 1 | #import "WebUIStaticFileHandler.h" 2 | #import "HTTPRequest.h" 3 | 4 | @implementation WebUIStaticFileHandler 5 | 6 | - (void)handle { 7 | [self _handleUnsupportedVersion] 8 | || [self _handleUnsupportedRequest] 9 | || [self _handleNonGetRequest] 10 | || [self _respondWithData] 11 | || [self _respondWithStatus:404]; 12 | } 13 | 14 | #pragma mark - Responding with data 15 | 16 | - (NSData *)_fetchDataAtPath:(NSString *)path { 17 | NSString *filePath = 18 | [NSString stringWithFormat:@"%@%@", NSBundle.mainBundle.resourcePath, path]; 19 | NSLog(@"WebUIStaticFileHandler - returning: %@", filePath); 20 | return [NSData dataWithContentsOfFile:filePath]; 21 | } 22 | 23 | - (BOOL)_respondWithData { 24 | NSData *data = [self _fetchDataAtPath:self.request.requestURL.path]; 25 | if (data) { 26 | self.request.responseStatus = 200; 27 | self.request.responseBody = data; 28 | [self.request 29 | setResponseHeader:@"Content-Length" 30 | value:[NSString stringWithFormat:@"%ld", data.length]]; 31 | [self.request respond]; 32 | return YES; 33 | } 34 | return NO; 35 | } 36 | @end 37 | -------------------------------------------------------------------------------- /Checkman/WebUIWebSocketHandler.h: -------------------------------------------------------------------------------- 1 | #import "WebUIHandler.h" 2 | 3 | @class WebUIWebSocketHandler, WebSocketConnection; 4 | 5 | @protocol WebUIWebSocketHandlerDelegate 6 | - (void)WebUIWebSocketHandler:(WebUIWebSocketHandler *)handler 7 | WebSocketConnectionDidStart:(WebSocketConnection *)connection; 8 | - (void)WebUIWebSocketHandler:(WebUIWebSocketHandler *)handler 9 | WebSocketConnectionDidEnd:(WebSocketConnection *)connection; 10 | @end 11 | 12 | @interface WebUIWebSocketHandler : WebUIHandler 13 | @property (nonatomic, assign) id delegate; 14 | - (void)sendMessage:(NSString *)string; 15 | @end 16 | -------------------------------------------------------------------------------- /Checkman/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | return NSApplicationMain(argc, (const char **)argv); 5 | } 6 | -------------------------------------------------------------------------------- /CheckmanTests/CedarAsync/Headers/CedarAsync.h: -------------------------------------------------------------------------------- 1 | #import "AsyncActualValue.h" 2 | #import "InTimeShouldSyntax.h" 3 | #import "Timing.h" 4 | 5 | #ifndef CEDAR_ASYNC_COMPATIBLITY_MODE 6 | using namespace CedarAsync; 7 | #endif 8 | -------------------------------------------------------------------------------- /CheckmanTests/CedarAsync/Headers/InTimeShouldSyntax.h: -------------------------------------------------------------------------------- 1 | #import "AsyncActualValue.h" 2 | 3 | namespace CedarAsync { 4 | template 5 | struct InTimeMarker { 6 | T(^actualExpression)(void); 7 | const char *fileName; 8 | int lineNumber; 9 | }; 10 | 11 | template 12 | const AsyncActualValue operator,(const InTimeMarker & marker, const Cedar::Matchers::ActualValueMarker & _) { 13 | return AsyncActualValue(marker.fileName, marker.lineNumber, marker.actualExpression); 14 | } 15 | 16 | template 17 | const AsyncActualValueMatchProxy operator,(const AsyncActualValue & actualValue, bool negate) { 18 | return negate ? actualValue.to_not : actualValue.to; 19 | } 20 | 21 | template 22 | void operator,(const AsyncActualValueMatchProxy & matchProxy, const MatcherType & matcher) { 23 | matchProxy(matcher); 24 | } 25 | } 26 | 27 | #ifndef CEDAR_ASYNC_DISALLOW_IN_TIME 28 | #define in_time(x) (InTimeMarker){^{return x;}, __FILE__, __LINE__} 29 | #endif 30 | -------------------------------------------------------------------------------- /CheckmanTests/CedarAsync/Headers/Timing.h: -------------------------------------------------------------------------------- 1 | #import 2 | #include 3 | 4 | namespace CedarAsync { 5 | namespace Timing { 6 | extern NSTimeInterval default_poll, current_poll; 7 | extern NSTimeInterval default_timeout, current_timeout; 8 | } 9 | 10 | void with_timeout(NSTimeInterval, void(^)(void)); 11 | } 12 | 13 | typedef enum { 14 | CDRATimingPollContinue = 99, 15 | CDRATimingPollStop = 98 16 | } CDRATimingPoll; 17 | 18 | @interface CDRATiming : NSObject 19 | + (void)pollRunLoop:(CDRATimingPoll(^)(BOOL))block 20 | every:(NSTimeInterval)poll 21 | timeout:(NSTimeInterval)timeout; 22 | @end 23 | 24 | @interface CDRAResetTimeout : NSObject 25 | + (void)beforeEach; 26 | @end 27 | -------------------------------------------------------------------------------- /CheckmanTests/CedarAsync/Timing.mm: -------------------------------------------------------------------------------- 1 | #import "Timing.h" 2 | 3 | namespace CedarAsync { 4 | namespace Timing { 5 | NSTimeInterval default_poll = 0.1; 6 | NSTimeInterval current_poll = default_poll; 7 | 8 | NSTimeInterval default_timeout = 1; 9 | NSTimeInterval current_timeout = default_timeout; 10 | } 11 | 12 | void with_timeout(NSTimeInterval timeout, void(^block)(void)) { 13 | NSTimeInterval before = Timing::current_timeout; 14 | Timing::current_timeout = timeout; 15 | block(); 16 | Timing::current_timeout = before; 17 | } 18 | } 19 | 20 | @implementation CDRATiming 21 | + (void)pollRunLoop:(CDRATimingPoll(^)(BOOL))block 22 | every:(NSTimeInterval)poll 23 | timeout:(NSTimeInterval)timeout { 24 | 25 | NSAssert(poll > 0, @"Poll must be > 0"); 26 | 27 | while (block(timeout <= 0) == CDRATimingPollContinue) { 28 | NSTimeInterval step = MIN(timeout, poll); 29 | timeout -= step; 30 | 31 | NSDate *futureDate = [NSDate dateWithTimeIntervalSinceNow:step]; 32 | [[NSRunLoop currentRunLoop] runUntilDate:futureDate]; 33 | } 34 | } 35 | @end 36 | 37 | @implementation CDRAResetTimeout 38 | + (void)beforeEach { 39 | using namespace CedarAsync::Timing; 40 | current_poll = default_poll; 41 | current_timeout = default_timeout; 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /CheckmanTests/CheckmanTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.tomato.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CheckmanTests/CheckmanTests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'CheckmanTests' target in the 'CheckmanTests' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | 10 | #define F(f, ...) [NSString stringWithFormat:f, ##__VA_ARGS__] 11 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Cedar: -------------------------------------------------------------------------------- 1 | Versions/Current/Cedar -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/AnyArgument.h: -------------------------------------------------------------------------------- 1 | #import "Argument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | class AnyArgument : public Argument { 6 | private: 7 | AnyArgument & operator=(const AnyArgument &); 8 | 9 | public: 10 | AnyArgument() {}; 11 | virtual ~AnyArgument() {}; 12 | // Allow default copy ctor. 13 | 14 | virtual const char * const value_encoding() const { return ""; }; 15 | virtual void * value_bytes() const { return NULL; }; 16 | virtual NSString * value_string() const { return @"anything"; }; 17 | 18 | virtual bool matches_encoding(const char *) const { return true; } 19 | virtual bool matches_bytes(void *) const { return true; } 20 | 21 | }; 22 | 23 | namespace Arguments { 24 | static const Argument::shared_ptr_t anything = Argument::shared_ptr_t(new Doubles::AnyArgument()); 25 | } 26 | 27 | }} 28 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/AnyInstanceArgument.h: -------------------------------------------------------------------------------- 1 | #import "Argument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | class AnyInstanceArgument : public Argument { 6 | private: 7 | AnyInstanceArgument & operator=(const AnyInstanceArgument &); 8 | 9 | public: 10 | explicit AnyInstanceArgument(const Class); 11 | virtual ~AnyInstanceArgument(); 12 | // Allow default copy ctor. 13 | 14 | virtual const char * const value_encoding() const; 15 | virtual void * value_bytes() const { return NULL; } 16 | virtual NSString * value_string() const; 17 | 18 | virtual bool matches_encoding(const char *) const; 19 | virtual bool matches_bytes(void *) const; 20 | 21 | private: 22 | const Class class_; 23 | }; 24 | 25 | 26 | namespace Arguments { 27 | Argument::shared_ptr_t any(Class); 28 | } 29 | }} 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/Argument.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CompareEqual.h" 3 | #import "CedarStringifiers.h" 4 | #import "CedarComparators.h" 5 | #import 6 | 7 | namespace Cedar { namespace Doubles { 8 | 9 | #pragma mark - Argument 10 | class Argument { 11 | public: 12 | virtual ~Argument() = 0; 13 | 14 | virtual const char * const value_encoding() const = 0; 15 | virtual void * value_bytes() const = 0; 16 | virtual NSString * value_string() const = 0; 17 | 18 | virtual bool matches_encoding(const char *) const = 0; 19 | virtual bool matches_bytes(void *) const = 0; 20 | 21 | typedef std::shared_ptr shared_ptr_t; 22 | }; 23 | 24 | inline /* virtual */ Argument::~Argument() {} 25 | 26 | }} 27 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/BeEmpty.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | class BeEmpty : public Base<> { 5 | private: 6 | BeEmpty & operator=(const BeEmpty &); 7 | 8 | public: 9 | inline BeEmpty() : Base<>() {} 10 | inline ~BeEmpty() {} 11 | // Allow default copy ctor. 12 | 13 | inline const BeEmpty & operator()() const { return *this; } 14 | 15 | template 16 | bool matches(const U &) const; 17 | 18 | protected: 19 | inline /*virtual*/ NSString * failure_message_end() const { return @"be empty"; } 20 | }; 21 | 22 | static const BeEmpty be_empty = BeEmpty(); 23 | 24 | #pragma mark Generic 25 | template 26 | bool BeEmpty::matches(const U & actualValue) const { 27 | return Comparators::compare_empty(actualValue); 28 | } 29 | }} 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/BeGreaterThan.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | template 7 | class BeGreaterThan : public Base<> { 8 | private: 9 | BeGreaterThan & operator=(const BeGreaterThan &); 10 | 11 | public: 12 | explicit BeGreaterThan(const T & expectedValue); 13 | ~BeGreaterThan(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | virtual NSString * failure_message_end() const; 21 | 22 | private: 23 | const T & expectedValue_; 24 | }; 25 | 26 | template 27 | BeGreaterThan be_greater_than(const T & expectedValue) { 28 | return BeGreaterThan(expectedValue); 29 | } 30 | 31 | template 32 | BeGreaterThan::BeGreaterThan(const T & expectedValue) 33 | : Base<>(), expectedValue_(expectedValue) { 34 | } 35 | 36 | template 37 | BeGreaterThan::~BeGreaterThan() { 38 | } 39 | 40 | template 41 | /*virtual*/ NSString * BeGreaterThan::failure_message_end() const { 42 | NSString * expectedValueString = Stringifiers::string_for(expectedValue_); 43 | return [NSString stringWithFormat:@"be greater than <%@>", expectedValueString]; 44 | } 45 | 46 | template template 47 | bool BeGreaterThan::matches(const U & actualValue) const { 48 | return Comparators::compare_greater_than(actualValue, expectedValue_); 49 | } 50 | 51 | #pragma mark operators 52 | template 53 | bool operator>(const ActualValue & actualValue, const U & expectedValue) { 54 | return actualValue.to > expectedValue; 55 | } 56 | 57 | template 58 | bool operator>(const ActualValueMatchProxy & actualValueMatchProxy, const U & expectedValue) { 59 | actualValueMatchProxy(be_greater_than(expectedValue)); 60 | return true; 61 | } 62 | }} 63 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/BeLessThan.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | template 7 | class BeLessThan : public Base<> { 8 | private: 9 | BeLessThan & operator=(const BeLessThan &); 10 | 11 | public: 12 | explicit BeLessThan(const T & expectedValue); 13 | ~BeLessThan(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | virtual NSString * failure_message_end() const; 21 | 22 | private: 23 | const T & expectedValue_; 24 | }; 25 | 26 | template 27 | BeLessThan be_less_than(const T & expectedValue) { 28 | return BeLessThan(expectedValue); 29 | } 30 | 31 | template 32 | BeLessThan::BeLessThan(const T & expectedValue) 33 | : Base<>(), expectedValue_(expectedValue) { 34 | } 35 | 36 | template 37 | BeLessThan::~BeLessThan() { 38 | } 39 | 40 | template 41 | /*virtual*/ NSString * BeLessThan::failure_message_end() const { 42 | NSString * expectedValueString = Stringifiers::string_for(expectedValue_); 43 | return [NSString stringWithFormat:@"be less than <%@>", expectedValueString]; 44 | } 45 | 46 | template template 47 | bool BeLessThan::matches(const U & actualValue) const { 48 | return !Comparators::compare_greater_than(actualValue, expectedValue_) && !Comparators::compare_equal(actualValue, expectedValue_); 49 | } 50 | 51 | #pragma mark operators 52 | template 53 | bool operator<(const ActualValue & actualValue, const U & expectedValue) { 54 | return actualValue.to < expectedValue; 55 | } 56 | 57 | template 58 | bool operator<(const ActualValueMatchProxy & actualValueMatchProxy, const U & expectedValue) { 59 | actualValueMatchProxy(be_less_than(expectedValue)); 60 | return true; 61 | } 62 | }} 63 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/BeNil.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | #import "CDRSpecFailure.h" 4 | 5 | #include 6 | 7 | namespace Cedar { namespace Matchers { 8 | struct BeNilMessageBuilder { 9 | template 10 | static NSString * string_for_actual_value(const U & value) { 11 | throw std::logic_error("Should never generate a failure message for a nil comparison to non-pointer type."); 12 | } 13 | 14 | template 15 | static NSString * string_for_actual_value(U * const & value) { 16 | return value ? [NSString stringWithFormat:@"%p", value] : @"nil"; 17 | } 18 | }; 19 | 20 | class BeNil : public Base { 21 | private: 22 | BeNil & operator=(const BeNil &); 23 | 24 | public: 25 | inline BeNil() : Base() {} 26 | inline ~BeNil() {} 27 | // Allow default copy ctor. 28 | 29 | inline const BeNil & operator()() const { return *this; } 30 | 31 | template 32 | bool matches(const U &) const; 33 | 34 | template 35 | bool matches(U * const &) const; 36 | 37 | protected: 38 | inline /*virtual*/ NSString * failure_message_end() const { return @"be nil"; } 39 | }; 40 | 41 | static const BeNil be_nil = BeNil(); 42 | 43 | #pragma mark Generic 44 | template 45 | bool BeNil::matches(const U & actualValue) const { 46 | [[CDRSpecFailure specFailureWithReason:@"Attempt to compare non-pointer type to nil"] raise]; 47 | return NO; 48 | } 49 | 50 | template 51 | bool BeNil::matches(U * const & actualValue) const { 52 | return !actualValue; 53 | } 54 | 55 | }} 56 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/BeSameInstanceAs.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | template 6 | class BeSameInstanceAs : public Base<> { 7 | private: 8 | BeSameInstanceAs & operator=(const BeSameInstanceAs &); 9 | 10 | public: 11 | explicit BeSameInstanceAs(T * const expectedValue); 12 | ~BeSameInstanceAs(); 13 | // Allow default copy ctor. 14 | 15 | template 16 | bool matches(const U &) const; 17 | 18 | template 19 | bool matches(U * const &) const; 20 | 21 | protected: 22 | virtual NSString * failure_message_end() const; 23 | 24 | private: 25 | const T * expectedValue_; 26 | }; 27 | 28 | template 29 | BeSameInstanceAs be_same_instance_as(T * const expectedValue) { 30 | return BeSameInstanceAs(expectedValue); 31 | } 32 | 33 | template 34 | BeSameInstanceAs::BeSameInstanceAs(T * const expectedValue) 35 | : Base<>(), expectedValue_(expectedValue) { 36 | } 37 | 38 | template 39 | BeSameInstanceAs::~BeSameInstanceAs() { 40 | } 41 | 42 | template 43 | /*virtual*/ NSString * BeSameInstanceAs::failure_message_end() const { 44 | return [NSString stringWithFormat:@"be same instance as <%p>", expectedValue_]; 45 | } 46 | 47 | #pragma mark Generic 48 | template template 49 | bool BeSameInstanceAs::matches(const U & actualValue) const { 50 | [[CDRSpecFailure specFailureWithReason:@"Attempt to compare non-pointer type for sameness."] raise]; 51 | return NO; 52 | } 53 | 54 | template template 55 | bool BeSameInstanceAs::matches(U * const & actualValue) const { 56 | return actualValue == expectedValue_; 57 | } 58 | 59 | }} 60 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/BeTruthy.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | class BeTruthy : public Base<> { 6 | private: 7 | BeTruthy & operator=(const BeTruthy &); 8 | 9 | public: 10 | inline BeTruthy() : Base<>() {} 11 | inline ~BeTruthy() {} 12 | // Allow default copy ctor. 13 | 14 | inline const BeTruthy & operator()() const { return *this; } 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | inline /*virtual*/ NSString * failure_message_end() const { return @"evaluate to true"; } 21 | }; 22 | 23 | static const BeTruthy be_truthy = BeTruthy(); 24 | 25 | #pragma mark Generic 26 | template 27 | bool BeTruthy::matches(const U & actualValue) const { 28 | return !!actualValue; 29 | } 30 | 31 | }} 32 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRClassFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CDRFake.h" 3 | #import "CedarDouble.h" 4 | 5 | @interface CDRClassFake : CDRFake 6 | 7 | @end 8 | 9 | id CDR_fake_for(Class klass, bool require_explicit_stubs = true); 10 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRExampleBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CDRExampleParent.h" 3 | 4 | @protocol CDRExampleReporter; 5 | 6 | typedef void (^CDRSpecBlock)(void); 7 | 8 | enum CDRExampleState { 9 | CDRExampleStateIncomplete = 0x00, 10 | CDRExampleStateSkipped = 0x01, 11 | CDRExampleStatePassed = 0x03, 12 | CDRExampleStatePending = 0x07, 13 | CDRExampleStateFailed = 0x0F, 14 | CDRExampleStateError = 0x1F 15 | }; 16 | typedef enum CDRExampleState CDRExampleState; 17 | 18 | @interface CDRExampleBase : NSObject { 19 | NSString *text_; 20 | id parent_; 21 | BOOL focused_; 22 | NSTimeInterval runTime_; 23 | } 24 | 25 | @property (nonatomic, readonly) NSString *text; 26 | @property (nonatomic, assign) id parent; 27 | @property (nonatomic, assign, getter=isFocused) BOOL focused; 28 | @property (nonatomic) NSUInteger stackAddress; 29 | 30 | - (id)initWithText:(NSString *)text; 31 | 32 | - (void)run; 33 | - (BOOL)shouldRun; 34 | 35 | - (BOOL)hasChildren; 36 | - (BOOL)hasFocusedExamples; 37 | 38 | - (NSString *)message; 39 | - (NSString *)fullText; 40 | - (NSMutableArray *)fullTextInPieces; 41 | @end 42 | 43 | @interface CDRExampleBase (RunReporting) 44 | - (CDRExampleState)state; 45 | - (NSTimeInterval)runTime; 46 | - (float)progress; 47 | @end 48 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRExampleParent.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRExampleParent 4 | 5 | - (BOOL)shouldRun; 6 | 7 | - (void)setUp; 8 | - (void)tearDown; 9 | 10 | @optional 11 | - (BOOL)hasFullText; 12 | - (NSString *)fullText; 13 | - (NSMutableArray *)fullTextInPieces; 14 | 15 | - (NSUInteger)stackAddress; 16 | @end 17 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRExampleReporter.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRExampleReporter 4 | 5 | - (void)runWillStartWithGroups:(NSArray *)groups andRandomSeed:(unsigned int)seed; 6 | - (void)runDidComplete; 7 | - (int)result; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | 4 | @interface CDRFake : NSObject 5 | 6 | @property (nonatomic, assign) Class klass; 7 | 8 | - (id)initWithClass:(Class)klass requireExplicitStubs:(bool)requireExplicitStubs; 9 | 10 | @end 11 | 12 | #ifndef CEDAR_DOUBLES_COMPATIBILITY_MODE 13 | #define fake_for(x) CDR_fake_for((x)) 14 | #define nice_fake_for(x) CDR_fake_for((x), false) 15 | #endif 16 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRFunctions.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSArray *CDRReportersFromEnv(const char*defaultReporterClassName); 4 | 5 | int runSpecs(); 6 | int runAllSpecs() __attribute__((deprecated)); 7 | int runSpecsWithCustomExampleReporters(NSArray *reporters); 8 | NSArray *specClassesToRun(); 9 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRProtocolFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | #import "CDRFake.h" 4 | 5 | #import 6 | #import 7 | 8 | @interface CDRProtocolFake : CDRFake 9 | 10 | - (id)initWithClass:(Class)klass forProtocol:(Protocol *)protocol requireExplicitStubs:(bool)requireExplicitStubs; 11 | 12 | @end 13 | 14 | id CDR_fake_for(Protocol *protocol, bool require_explicit_stubs = true); 15 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRSharedExampleGroupPool.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRSharedExampleGroupPool 4 | @end 5 | 6 | typedef void (^CDRSharedExampleGroupBlock)(NSDictionary *); 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | void sharedExamplesFor(NSString *, CDRSharedExampleGroupBlock); 12 | void itShouldBehaveLike(NSString *); 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | @interface CDRSharedExampleGroupPool : NSObject 18 | @end 19 | 20 | @interface CDRSharedExampleGroupPool (SharedExampleGroupDeclaration) 21 | - (void)declareSharedExampleGroups; 22 | @end 23 | 24 | #define SHARED_EXAMPLE_GROUPS_BEGIN(name) \ 25 | @interface SharedExampleGroupPoolFor##name : CDRSharedExampleGroupPool \ 26 | @end \ 27 | @implementation SharedExampleGroupPoolFor##name \ 28 | - (void)declareSharedExampleGroups { 29 | 30 | #define SHARED_EXAMPLE_GROUPS_END \ 31 | } \ 32 | @end 33 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRSpecFailure.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface CDRSpecFailure : NSException { 4 | NSString *fileName_; 5 | int lineNumber_; 6 | } 7 | 8 | @property (nonatomic, retain, readonly) NSString *fileName; 9 | @property (nonatomic, assign, readonly) int lineNumber; 10 | 11 | + (id)specFailureWithReason:(NSString *)reason; 12 | + (id)specFailureWithReason:(NSString *)reason fileName:(NSString *)fileName lineNumber:(int)lineNumber; 13 | + (id)specFailureWithRaisedObject:(NSObject *)object; 14 | 15 | - (id)initWithReason:(NSString *)reason; 16 | - (id)initWithReason:(NSString *)reason fileName:(NSString *)fileName lineNumber:(int)lineNumber; 17 | - (id)initWithRaisedObject:(NSObject *)object; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CDRSpy.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | 4 | @interface CDRSpy : NSProxy 5 | 6 | + (void)interceptMessagesForInstance:(id)instance; 7 | 8 | @end 9 | 10 | namespace Cedar { namespace Doubles { 11 | inline void CDR_spy_on(id instance) { 12 | if (![[instance class] conformsToProtocol:@protocol(CedarDouble)]) { 13 | [CDRSpy interceptMessagesForInstance:instance]; 14 | } 15 | } 16 | }} 17 | 18 | #ifndef CEDAR_DOUBLES_COMPATIBILITY_MODE 19 | #define spy_on(x) CDR_spy_on((x)) 20 | #endif 21 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/Cedar.h: -------------------------------------------------------------------------------- 1 | #import "CDRFunctions.h" 2 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CedarComparators.h: -------------------------------------------------------------------------------- 1 | #import "ComparatorsBase.h" 2 | #import "ComparatorsContainer.h" 3 | 4 | #ifdef CEDAR_CUSTOM_COMPARATORS 5 | #import CEDAR_CUSTOM_COMPARATORS 6 | #endif 7 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CedarDouble.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | namespace Cedar { namespace Doubles { 4 | class StubbedMethod; 5 | }} 6 | 7 | @protocol CedarDouble 8 | 9 | - (Cedar::Doubles::StubbedMethod &)add_stub:(const Cedar::Doubles::StubbedMethod &)stubbed_method; 10 | - (NSArray *)sent_messages; 11 | - (void)reset_sent_messages; 12 | 13 | @end 14 | 15 | namespace Cedar { namespace Doubles { 16 | 17 | struct MethodStubbingMarker { 18 | const char *fileName; 19 | int lineNumber; 20 | }; 21 | 22 | id operator,(id, const MethodStubbingMarker &); 23 | 24 | void operator,(id, const StubbedMethod &); 25 | }} 26 | 27 | #ifndef CEDAR_MATCHERS_DISALLOW_STUB_METHOD 28 | #define stub_method(x) ,(Cedar::Doubles::MethodStubbingMarker){__FILE__, __LINE__},Cedar::Doubles::StubbedMethod((x)) 29 | #endif 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CedarDoubles.h: -------------------------------------------------------------------------------- 1 | #import "CDRSpy.h" 2 | #import "CDRFake.h" 3 | #import "CDRClassFake.h" 4 | #import "CDRProtocolFake.h" 5 | #import "HaveReceived.h" 6 | #import "StubbedMethod.h" 7 | 8 | #import "Argument.h" 9 | #import "AnyArgument.h" 10 | #import "ValueArgument.h" 11 | #import "AnyInstanceArgument.h" 12 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CedarMatchers.h: -------------------------------------------------------------------------------- 1 | // Base 2 | #import "Equal.h" 3 | #import "BeTruthy.h" 4 | #import "BeNil.h" 5 | #import "BeCloseTo.h" 6 | #import "BeSameInstanceAs.h" 7 | #import "BeInstanceOf.h" 8 | #import "BeGreaterThan.h" 9 | #import "BeGTE.h" 10 | #import "BeLessThan.h" 11 | #import "BeLTE.h" 12 | #import "RaiseException.h" 13 | 14 | // Container 15 | #import "BeEmpty.h" 16 | #import "Contain.h" 17 | 18 | #ifdef CEDAR_CUSTOM_MATCHERS 19 | #import CEDAR_CUSTOM_MATCHERS 20 | #endif 21 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/CedarStringifiers.h: -------------------------------------------------------------------------------- 1 | #import "StringifiersBase.h" 2 | #import "StringifiersContainer.h" 3 | 4 | #ifdef CEDAR_CUSTOM_STRINGIFIERS 5 | #import CEDAR_CUSTOM_STRINGIFIERS 6 | #endif 7 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/ComparatorsBase.h: -------------------------------------------------------------------------------- 1 | #import "CompareEqual.h" 2 | #import "CompareGreaterThan.h" 3 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/Contain.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | template 5 | class Contain : public Base<> { 6 | private: 7 | Contain & operator=(const Contain &); 8 | 9 | public: 10 | explicit Contain(const T & element); 11 | ~Contain(); 12 | // Allow default copy ctor. 13 | 14 | template 15 | bool matches(const U &) const; 16 | 17 | protected: 18 | virtual NSString * failure_message_end() const; 19 | 20 | private: 21 | const T & element_; 22 | }; 23 | 24 | template 25 | inline Contain contain(const T & element) { 26 | return Contain(element); 27 | } 28 | 29 | template 30 | inline Contain::Contain(const T & element) 31 | : Base<>(), element_(element) { 32 | } 33 | 34 | template 35 | Contain::~Contain() { 36 | } 37 | 38 | template 39 | inline /*virtual*/ NSString * Contain::failure_message_end() const { 40 | NSString * elementString = Stringifiers::string_for(element_); 41 | return [NSString stringWithFormat:@"contain <%@>", elementString]; 42 | } 43 | 44 | #pragma mark Generic 45 | template template 46 | bool Contain::matches(const U & actualValue) const { 47 | return Comparators::compare_contains(actualValue, element_); 48 | } 49 | }} 50 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/HaveReceived.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | #import "Argument.h" 3 | #import "InvocationMatcher.h" 4 | 5 | namespace Cedar { namespace Doubles { 6 | 7 | class HaveReceived : public Matchers::Base<>, private InvocationMatcher { 8 | private: 9 | HaveReceived & operator=(const HaveReceived &); 10 | 11 | public: 12 | explicit HaveReceived(const SEL); 13 | ~HaveReceived(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | HaveReceived & with(const T &); 18 | template 19 | HaveReceived & with(const T &, ArgumentPack... pack); 20 | template 21 | HaveReceived & and_with(const T & argument) { return with(argument); } 22 | 23 | bool matches(id) const; 24 | 25 | protected: 26 | virtual NSString * failure_message_end() const; 27 | 28 | private: 29 | void verify_object_is_a_double(id) const; 30 | }; 31 | 32 | HaveReceived have_received(const SEL expectedSelector); 33 | HaveReceived have_received(const char * expectedMethod); 34 | 35 | template 36 | HaveReceived & HaveReceived::with(const T & value) { 37 | this->add_argument(value); 38 | return *this; 39 | } 40 | 41 | template 42 | HaveReceived & HaveReceived::with(const T & value, ArgumentPack... pack) { 43 | this->with(value); 44 | this->with(pack...); 45 | return *this; 46 | } 47 | 48 | }} 49 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/InvocationMatcher.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "ValueArgument.h" 3 | 4 | namespace Cedar { namespace Doubles { 5 | 6 | class InvocationMatcher { 7 | public: 8 | typedef std::vector arguments_vector_t; 9 | enum { OBJC_DEFAULT_ARGUMENT_COUNT = 2 }; 10 | 11 | public: 12 | InvocationMatcher(const SEL); 13 | virtual ~InvocationMatcher() {} 14 | 15 | void add_argument(const Argument::shared_ptr_t argument); 16 | template 17 | void add_argument(const T &); 18 | 19 | bool matches(NSInvocation * const) const; 20 | NSString *mismatch_reason(); 21 | 22 | const SEL selector() const { return expectedSelector_; } 23 | const arguments_vector_t & arguments() const { return arguments_; } 24 | const bool match_any_arguments() const { return arguments_.empty(); } 25 | void verify_count_and_types_of_arguments(id instance) const; 26 | 27 | private: 28 | bool matches_arguments(NSInvocation * const) const; 29 | NSMethodSignature *method_signature_for_instance(id instance) const; 30 | void compare_argument_count_to_method_signature(NSMethodSignature * const methodSignature) const; 31 | void compare_argument_types_to_method_signature(NSMethodSignature * const methodSignature) const; 32 | 33 | private: 34 | const SEL expectedSelector_; 35 | arguments_vector_t arguments_; 36 | }; 37 | 38 | template 39 | void InvocationMatcher::add_argument(const T & value) { 40 | this->add_argument(Argument::shared_ptr_t(new ValueArgument(value))); 41 | } 42 | 43 | }} 44 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/RaiseException.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | #import 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | typedef void (^empty_block_t)(); 7 | 8 | struct RaiseExceptionMessageBuilder { 9 | static NSString * string_for_actual_value(empty_block_t value) { 10 | return [value description]; 11 | } 12 | }; 13 | 14 | class RaiseException : public Base { 15 | private: 16 | RaiseException & operator=(const RaiseException &); 17 | 18 | public: 19 | explicit RaiseException(NSObject * = nil, Class = nil, bool = false, NSString * = nil); 20 | ~RaiseException(); 21 | // Allow default copy ctor. 22 | 23 | RaiseException operator()() const; 24 | RaiseException operator()(Class) const; 25 | RaiseException operator()(NSObject *) const; 26 | 27 | RaiseException & or_subclass(); 28 | 29 | RaiseException & with_reason(NSString * const reason); 30 | RaiseException with_reason(NSString * const reason) const; 31 | 32 | bool matches(empty_block_t) const; 33 | 34 | protected: 35 | virtual NSString * failure_message_end() const; 36 | 37 | private: 38 | bool exception_matches_expected_class(NSObject * const exception) const; 39 | bool exception_matches_expected_instance(NSObject * const exception) const; 40 | bool exception_matches_expected_reason(NSObject * const exception) const; 41 | 42 | private: 43 | const NSObject *expectedExceptionInstance_; 44 | const Class expectedExceptionClass_; 45 | bool allowSubclasses_; 46 | NSString *expectedReason_; 47 | }; 48 | 49 | RaiseException raise() __attribute__((deprecated)); // Please use raise_exception 50 | RaiseException raise(); 51 | 52 | static const RaiseException raise_exception; 53 | 54 | }} 55 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/ReturnValue.h: -------------------------------------------------------------------------------- 1 | #import "ValueArgument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | template 6 | class ReturnValue : public ValueArgument { 7 | private: 8 | ReturnValue & operator=(const ReturnValue &); 9 | 10 | public: 11 | explicit ReturnValue(const T &); 12 | virtual ~ReturnValue(); 13 | 14 | virtual bool matches_encoding(const char *) const; 15 | }; 16 | 17 | template 18 | ReturnValue::ReturnValue(const T & value) : ValueArgument(value) {} 19 | 20 | template 21 | /* virtual */ ReturnValue::~ReturnValue() {} 22 | 23 | template 24 | /* virtual */ bool ReturnValue::matches_encoding(const char * actual_argument_encoding) const { 25 | return 0 == strcmp(@encode(T), actual_argument_encoding); 26 | } 27 | 28 | }} 29 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/ShouldSyntax.h: -------------------------------------------------------------------------------- 1 | #import "ActualValue.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | 5 | struct ActualValueMarker { 6 | const char *fileName; 7 | int lineNumber; 8 | }; 9 | 10 | template 11 | const ActualValue operator,(const T & actualValue, const ActualValueMarker & marker) { 12 | return ActualValue(marker.fileName, marker.lineNumber, actualValue); 13 | } 14 | 15 | template 16 | const ActualValueMatchProxy operator,(const ActualValue & actualValue, bool negate) { 17 | return negate ? actualValue.to_not : actualValue.to; 18 | } 19 | 20 | template 21 | void operator,(const ActualValueMatchProxy & matchProxy, const MatcherType & matcher) { 22 | matchProxy(matcher); 23 | } 24 | 25 | }} 26 | 27 | #ifndef CEDAR_MATCHERS_DISALLOW_SHOULD 28 | #define should ,(ActualValueMarker){__FILE__, __LINE__},false, 29 | #define should_not ,(ActualValueMarker){__FILE__, __LINE__},true, 30 | #endif 31 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/SpecHelper.h: -------------------------------------------------------------------------------- 1 | #import "CDRSpec.h" 2 | #import "CDRSharedExampleGroupPool.h" 3 | #import "CDRExampleParent.h" 4 | 5 | @interface SpecHelper : NSObject { 6 | NSMutableDictionary *sharedExampleContext_, *sharedExampleGroups_; 7 | NSArray *globalBeforeEachClasses_, *globalAfterEachClasses_; 8 | BOOL shouldOnlyRunFocused_; 9 | } 10 | 11 | @property (nonatomic, retain, readonly) NSMutableDictionary *sharedExampleContext; 12 | @property (nonatomic, retain) NSArray *globalBeforeEachClasses, *globalAfterEachClasses; 13 | 14 | @property (nonatomic, assign) BOOL shouldOnlyRunFocused; 15 | 16 | + (SpecHelper *)specHelper; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/StringifiersBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | #include 3 | 4 | namespace Cedar { namespace Matchers { namespace Stringifiers { 5 | template 6 | NSString * string_for(const U & value) { 7 | if (0 == strncmp(@encode(U), "@", 1)) { 8 | NSValue *valueId = [NSValue value:&value withObjCType:@encode(id)]; 9 | return [[valueId nonretainedObjectValue] description]; 10 | } else { 11 | std::stringstream temp; 12 | temp << value; 13 | return [NSString stringWithCString:temp.str().c_str() encoding:NSUTF8StringEncoding]; 14 | } 15 | } 16 | 17 | inline NSString * string_for(const char value) { 18 | return string_for(static_cast(value)); 19 | } 20 | 21 | inline NSString * string_for(const Class & value) { 22 | return NSStringFromClass(value); 23 | } 24 | 25 | inline NSString * string_for(const BOOL value) { 26 | return value ? @"YES" : @"NO"; 27 | } 28 | 29 | inline NSString * string_for(NSNumber * const value) { 30 | return string_for([value floatValue]); 31 | } 32 | }}} 33 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Headers/StringifiersContainer.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | namespace Cedar { namespace Matchers { namespace Stringifiers { 6 | namespace { 7 | template 8 | NSString * comma_and_newline_delimited_list(const Container & container) { 9 | NSMutableString *result = [NSMutableString string]; 10 | bool first = true; 11 | for (typename Container::const_iterator it = container.begin(); it != container.end(); ++it, first = false) { 12 | if (!first) { 13 | [result appendString:@","]; 14 | } 15 | 16 | NSString * string = string_for(*it); 17 | [result appendString:[NSString stringWithFormat:@"\n %@", string]]; 18 | } 19 | return result; 20 | } 21 | } 22 | 23 | template 24 | NSString * string_for(const typename std::vector & container) { 25 | NSString * delimitedList = comma_and_newline_delimited_list(container); 26 | return [NSString stringWithFormat:@"(%@\n)", delimitedList]; 27 | } 28 | 29 | template 30 | NSString * string_for(const typename std::map & container) { 31 | NSMutableString *result = [NSMutableString stringWithString:@"{"]; 32 | 33 | for (typename std::map::const_iterator it = container.begin(); it != container.end(); ++it) { 34 | NSString * keyString = string_for(it->first); 35 | NSString * valueString = string_for(it->second); 36 | [result appendString:[NSString stringWithFormat:@"\n %@ = %@;", keyString, valueString]]; 37 | } 38 | [result appendString:@"\n}"]; 39 | return result; 40 | } 41 | 42 | template 43 | NSString * string_for(const typename std::set & container) { 44 | NSString * delimitedList = comma_and_newline_delimited_list(container); 45 | return [NSString stringWithFormat:@"{(%@\n)}", delimitedList]; 46 | } 47 | }}} 48 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 12A269 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | Cedar 11 | CFBundleIdentifier 12 | com.yourcompany.Cedar 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | DTCompiler 24 | com.apple.compilers.llvm.clang.1_0 25 | DTPlatformBuild 26 | 4F250 27 | DTPlatformVersion 28 | GM 29 | DTSDKBuild 30 | 12A269 31 | DTSDKName 32 | 33 | DTXcode 34 | 0440 35 | DTXcodeBuild 36 | 4F250 37 | 38 | 39 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Cedar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/CheckmanTests/Frameworks/Cedar.framework/Versions/A/Cedar -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/AnyArgument.h: -------------------------------------------------------------------------------- 1 | #import "Argument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | class AnyArgument : public Argument { 6 | private: 7 | AnyArgument & operator=(const AnyArgument &); 8 | 9 | public: 10 | AnyArgument() {}; 11 | virtual ~AnyArgument() {}; 12 | // Allow default copy ctor. 13 | 14 | virtual const char * const value_encoding() const { return ""; }; 15 | virtual void * value_bytes() const { return NULL; }; 16 | virtual NSString * value_string() const { return @"anything"; }; 17 | 18 | virtual bool matches_encoding(const char *) const { return true; } 19 | virtual bool matches_bytes(void *) const { return true; } 20 | 21 | }; 22 | 23 | namespace Arguments { 24 | static const Argument::shared_ptr_t anything = Argument::shared_ptr_t(new Doubles::AnyArgument()); 25 | } 26 | 27 | }} 28 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/AnyInstanceArgument.h: -------------------------------------------------------------------------------- 1 | #import "Argument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | class AnyInstanceArgument : public Argument { 6 | private: 7 | AnyInstanceArgument & operator=(const AnyInstanceArgument &); 8 | 9 | public: 10 | explicit AnyInstanceArgument(const Class); 11 | virtual ~AnyInstanceArgument(); 12 | // Allow default copy ctor. 13 | 14 | virtual const char * const value_encoding() const; 15 | virtual void * value_bytes() const { return NULL; } 16 | virtual NSString * value_string() const; 17 | 18 | virtual bool matches_encoding(const char *) const; 19 | virtual bool matches_bytes(void *) const; 20 | 21 | private: 22 | const Class class_; 23 | }; 24 | 25 | 26 | namespace Arguments { 27 | Argument::shared_ptr_t any(Class); 28 | } 29 | }} 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/Argument.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CompareEqual.h" 3 | #import "CedarStringifiers.h" 4 | #import "CedarComparators.h" 5 | #import 6 | 7 | namespace Cedar { namespace Doubles { 8 | 9 | #pragma mark - Argument 10 | class Argument { 11 | public: 12 | virtual ~Argument() = 0; 13 | 14 | virtual const char * const value_encoding() const = 0; 15 | virtual void * value_bytes() const = 0; 16 | virtual NSString * value_string() const = 0; 17 | 18 | virtual bool matches_encoding(const char *) const = 0; 19 | virtual bool matches_bytes(void *) const = 0; 20 | 21 | typedef std::shared_ptr shared_ptr_t; 22 | }; 23 | 24 | inline /* virtual */ Argument::~Argument() {} 25 | 26 | }} 27 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/BeEmpty.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | class BeEmpty : public Base<> { 5 | private: 6 | BeEmpty & operator=(const BeEmpty &); 7 | 8 | public: 9 | inline BeEmpty() : Base<>() {} 10 | inline ~BeEmpty() {} 11 | // Allow default copy ctor. 12 | 13 | inline const BeEmpty & operator()() const { return *this; } 14 | 15 | template 16 | bool matches(const U &) const; 17 | 18 | protected: 19 | inline /*virtual*/ NSString * failure_message_end() const { return @"be empty"; } 20 | }; 21 | 22 | static const BeEmpty be_empty = BeEmpty(); 23 | 24 | #pragma mark Generic 25 | template 26 | bool BeEmpty::matches(const U & actualValue) const { 27 | return Comparators::compare_empty(actualValue); 28 | } 29 | }} 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/BeGreaterThan.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | template 7 | class BeGreaterThan : public Base<> { 8 | private: 9 | BeGreaterThan & operator=(const BeGreaterThan &); 10 | 11 | public: 12 | explicit BeGreaterThan(const T & expectedValue); 13 | ~BeGreaterThan(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | virtual NSString * failure_message_end() const; 21 | 22 | private: 23 | const T & expectedValue_; 24 | }; 25 | 26 | template 27 | BeGreaterThan be_greater_than(const T & expectedValue) { 28 | return BeGreaterThan(expectedValue); 29 | } 30 | 31 | template 32 | BeGreaterThan::BeGreaterThan(const T & expectedValue) 33 | : Base<>(), expectedValue_(expectedValue) { 34 | } 35 | 36 | template 37 | BeGreaterThan::~BeGreaterThan() { 38 | } 39 | 40 | template 41 | /*virtual*/ NSString * BeGreaterThan::failure_message_end() const { 42 | NSString * expectedValueString = Stringifiers::string_for(expectedValue_); 43 | return [NSString stringWithFormat:@"be greater than <%@>", expectedValueString]; 44 | } 45 | 46 | template template 47 | bool BeGreaterThan::matches(const U & actualValue) const { 48 | return Comparators::compare_greater_than(actualValue, expectedValue_); 49 | } 50 | 51 | #pragma mark operators 52 | template 53 | bool operator>(const ActualValue & actualValue, const U & expectedValue) { 54 | return actualValue.to > expectedValue; 55 | } 56 | 57 | template 58 | bool operator>(const ActualValueMatchProxy & actualValueMatchProxy, const U & expectedValue) { 59 | actualValueMatchProxy(be_greater_than(expectedValue)); 60 | return true; 61 | } 62 | }} 63 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/BeLessThan.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | template 7 | class BeLessThan : public Base<> { 8 | private: 9 | BeLessThan & operator=(const BeLessThan &); 10 | 11 | public: 12 | explicit BeLessThan(const T & expectedValue); 13 | ~BeLessThan(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | virtual NSString * failure_message_end() const; 21 | 22 | private: 23 | const T & expectedValue_; 24 | }; 25 | 26 | template 27 | BeLessThan be_less_than(const T & expectedValue) { 28 | return BeLessThan(expectedValue); 29 | } 30 | 31 | template 32 | BeLessThan::BeLessThan(const T & expectedValue) 33 | : Base<>(), expectedValue_(expectedValue) { 34 | } 35 | 36 | template 37 | BeLessThan::~BeLessThan() { 38 | } 39 | 40 | template 41 | /*virtual*/ NSString * BeLessThan::failure_message_end() const { 42 | NSString * expectedValueString = Stringifiers::string_for(expectedValue_); 43 | return [NSString stringWithFormat:@"be less than <%@>", expectedValueString]; 44 | } 45 | 46 | template template 47 | bool BeLessThan::matches(const U & actualValue) const { 48 | return !Comparators::compare_greater_than(actualValue, expectedValue_) && !Comparators::compare_equal(actualValue, expectedValue_); 49 | } 50 | 51 | #pragma mark operators 52 | template 53 | bool operator<(const ActualValue & actualValue, const U & expectedValue) { 54 | return actualValue.to < expectedValue; 55 | } 56 | 57 | template 58 | bool operator<(const ActualValueMatchProxy & actualValueMatchProxy, const U & expectedValue) { 59 | actualValueMatchProxy(be_less_than(expectedValue)); 60 | return true; 61 | } 62 | }} 63 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/BeNil.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | #import "CDRSpecFailure.h" 4 | 5 | #include 6 | 7 | namespace Cedar { namespace Matchers { 8 | struct BeNilMessageBuilder { 9 | template 10 | static NSString * string_for_actual_value(const U & value) { 11 | throw std::logic_error("Should never generate a failure message for a nil comparison to non-pointer type."); 12 | } 13 | 14 | template 15 | static NSString * string_for_actual_value(U * const & value) { 16 | return value ? [NSString stringWithFormat:@"%p", value] : @"nil"; 17 | } 18 | }; 19 | 20 | class BeNil : public Base { 21 | private: 22 | BeNil & operator=(const BeNil &); 23 | 24 | public: 25 | inline BeNil() : Base() {} 26 | inline ~BeNil() {} 27 | // Allow default copy ctor. 28 | 29 | inline const BeNil & operator()() const { return *this; } 30 | 31 | template 32 | bool matches(const U &) const; 33 | 34 | template 35 | bool matches(U * const &) const; 36 | 37 | protected: 38 | inline /*virtual*/ NSString * failure_message_end() const { return @"be nil"; } 39 | }; 40 | 41 | static const BeNil be_nil = BeNil(); 42 | 43 | #pragma mark Generic 44 | template 45 | bool BeNil::matches(const U & actualValue) const { 46 | [[CDRSpecFailure specFailureWithReason:@"Attempt to compare non-pointer type to nil"] raise]; 47 | return NO; 48 | } 49 | 50 | template 51 | bool BeNil::matches(U * const & actualValue) const { 52 | return !actualValue; 53 | } 54 | 55 | }} 56 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/BeSameInstanceAs.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | template 6 | class BeSameInstanceAs : public Base<> { 7 | private: 8 | BeSameInstanceAs & operator=(const BeSameInstanceAs &); 9 | 10 | public: 11 | explicit BeSameInstanceAs(T * const expectedValue); 12 | ~BeSameInstanceAs(); 13 | // Allow default copy ctor. 14 | 15 | template 16 | bool matches(const U &) const; 17 | 18 | template 19 | bool matches(U * const &) const; 20 | 21 | protected: 22 | virtual NSString * failure_message_end() const; 23 | 24 | private: 25 | const T * expectedValue_; 26 | }; 27 | 28 | template 29 | BeSameInstanceAs be_same_instance_as(T * const expectedValue) { 30 | return BeSameInstanceAs(expectedValue); 31 | } 32 | 33 | template 34 | BeSameInstanceAs::BeSameInstanceAs(T * const expectedValue) 35 | : Base<>(), expectedValue_(expectedValue) { 36 | } 37 | 38 | template 39 | BeSameInstanceAs::~BeSameInstanceAs() { 40 | } 41 | 42 | template 43 | /*virtual*/ NSString * BeSameInstanceAs::failure_message_end() const { 44 | return [NSString stringWithFormat:@"be same instance as <%p>", expectedValue_]; 45 | } 46 | 47 | #pragma mark Generic 48 | template template 49 | bool BeSameInstanceAs::matches(const U & actualValue) const { 50 | [[CDRSpecFailure specFailureWithReason:@"Attempt to compare non-pointer type for sameness."] raise]; 51 | return NO; 52 | } 53 | 54 | template template 55 | bool BeSameInstanceAs::matches(U * const & actualValue) const { 56 | return actualValue == expectedValue_; 57 | } 58 | 59 | }} 60 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/BeTruthy.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | class BeTruthy : public Base<> { 6 | private: 7 | BeTruthy & operator=(const BeTruthy &); 8 | 9 | public: 10 | inline BeTruthy() : Base<>() {} 11 | inline ~BeTruthy() {} 12 | // Allow default copy ctor. 13 | 14 | inline const BeTruthy & operator()() const { return *this; } 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | inline /*virtual*/ NSString * failure_message_end() const { return @"evaluate to true"; } 21 | }; 22 | 23 | static const BeTruthy be_truthy = BeTruthy(); 24 | 25 | #pragma mark Generic 26 | template 27 | bool BeTruthy::matches(const U & actualValue) const { 28 | return !!actualValue; 29 | } 30 | 31 | }} 32 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRClassFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CDRFake.h" 3 | #import "CedarDouble.h" 4 | 5 | @interface CDRClassFake : CDRFake 6 | 7 | @end 8 | 9 | id CDR_fake_for(Class klass, bool require_explicit_stubs = true); 10 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRExampleBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CDRExampleParent.h" 3 | 4 | @protocol CDRExampleReporter; 5 | 6 | typedef void (^CDRSpecBlock)(void); 7 | 8 | enum CDRExampleState { 9 | CDRExampleStateIncomplete = 0x00, 10 | CDRExampleStateSkipped = 0x01, 11 | CDRExampleStatePassed = 0x03, 12 | CDRExampleStatePending = 0x07, 13 | CDRExampleStateFailed = 0x0F, 14 | CDRExampleStateError = 0x1F 15 | }; 16 | typedef enum CDRExampleState CDRExampleState; 17 | 18 | @interface CDRExampleBase : NSObject { 19 | NSString *text_; 20 | id parent_; 21 | BOOL focused_; 22 | NSTimeInterval runTime_; 23 | } 24 | 25 | @property (nonatomic, readonly) NSString *text; 26 | @property (nonatomic, assign) id parent; 27 | @property (nonatomic, assign, getter=isFocused) BOOL focused; 28 | @property (nonatomic) NSUInteger stackAddress; 29 | 30 | - (id)initWithText:(NSString *)text; 31 | 32 | - (void)run; 33 | - (BOOL)shouldRun; 34 | 35 | - (BOOL)hasChildren; 36 | - (BOOL)hasFocusedExamples; 37 | 38 | - (NSString *)message; 39 | - (NSString *)fullText; 40 | - (NSMutableArray *)fullTextInPieces; 41 | @end 42 | 43 | @interface CDRExampleBase (RunReporting) 44 | - (CDRExampleState)state; 45 | - (NSTimeInterval)runTime; 46 | - (float)progress; 47 | @end 48 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRExampleParent.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRExampleParent 4 | 5 | - (BOOL)shouldRun; 6 | 7 | - (void)setUp; 8 | - (void)tearDown; 9 | 10 | @optional 11 | - (BOOL)hasFullText; 12 | - (NSString *)fullText; 13 | - (NSMutableArray *)fullTextInPieces; 14 | 15 | - (NSUInteger)stackAddress; 16 | @end 17 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRExampleReporter.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRExampleReporter 4 | 5 | - (void)runWillStartWithGroups:(NSArray *)groups andRandomSeed:(unsigned int)seed; 6 | - (void)runDidComplete; 7 | - (int)result; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | 4 | @interface CDRFake : NSObject 5 | 6 | @property (nonatomic, assign) Class klass; 7 | 8 | - (id)initWithClass:(Class)klass requireExplicitStubs:(bool)requireExplicitStubs; 9 | 10 | @end 11 | 12 | #ifndef CEDAR_DOUBLES_COMPATIBILITY_MODE 13 | #define fake_for(x) CDR_fake_for((x)) 14 | #define nice_fake_for(x) CDR_fake_for((x), false) 15 | #endif 16 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRFunctions.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSArray *CDRReportersFromEnv(const char*defaultReporterClassName); 4 | 5 | int runSpecs(); 6 | int runAllSpecs() __attribute__((deprecated)); 7 | int runSpecsWithCustomExampleReporters(NSArray *reporters); 8 | NSArray *specClassesToRun(); 9 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRProtocolFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | #import "CDRFake.h" 4 | 5 | #import 6 | #import 7 | 8 | @interface CDRProtocolFake : CDRFake 9 | 10 | - (id)initWithClass:(Class)klass forProtocol:(Protocol *)protocol requireExplicitStubs:(bool)requireExplicitStubs; 11 | 12 | @end 13 | 14 | id CDR_fake_for(Protocol *protocol, bool require_explicit_stubs = true); 15 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRSharedExampleGroupPool.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRSharedExampleGroupPool 4 | @end 5 | 6 | typedef void (^CDRSharedExampleGroupBlock)(NSDictionary *); 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | void sharedExamplesFor(NSString *, CDRSharedExampleGroupBlock); 12 | void itShouldBehaveLike(NSString *); 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | @interface CDRSharedExampleGroupPool : NSObject 18 | @end 19 | 20 | @interface CDRSharedExampleGroupPool (SharedExampleGroupDeclaration) 21 | - (void)declareSharedExampleGroups; 22 | @end 23 | 24 | #define SHARED_EXAMPLE_GROUPS_BEGIN(name) \ 25 | @interface SharedExampleGroupPoolFor##name : CDRSharedExampleGroupPool \ 26 | @end \ 27 | @implementation SharedExampleGroupPoolFor##name \ 28 | - (void)declareSharedExampleGroups { 29 | 30 | #define SHARED_EXAMPLE_GROUPS_END \ 31 | } \ 32 | @end 33 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRSpecFailure.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface CDRSpecFailure : NSException { 4 | NSString *fileName_; 5 | int lineNumber_; 6 | } 7 | 8 | @property (nonatomic, retain, readonly) NSString *fileName; 9 | @property (nonatomic, assign, readonly) int lineNumber; 10 | 11 | + (id)specFailureWithReason:(NSString *)reason; 12 | + (id)specFailureWithReason:(NSString *)reason fileName:(NSString *)fileName lineNumber:(int)lineNumber; 13 | + (id)specFailureWithRaisedObject:(NSObject *)object; 14 | 15 | - (id)initWithReason:(NSString *)reason; 16 | - (id)initWithReason:(NSString *)reason fileName:(NSString *)fileName lineNumber:(int)lineNumber; 17 | - (id)initWithRaisedObject:(NSObject *)object; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CDRSpy.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | 4 | @interface CDRSpy : NSProxy 5 | 6 | + (void)interceptMessagesForInstance:(id)instance; 7 | 8 | @end 9 | 10 | namespace Cedar { namespace Doubles { 11 | inline void CDR_spy_on(id instance) { 12 | if (![[instance class] conformsToProtocol:@protocol(CedarDouble)]) { 13 | [CDRSpy interceptMessagesForInstance:instance]; 14 | } 15 | } 16 | }} 17 | 18 | #ifndef CEDAR_DOUBLES_COMPATIBILITY_MODE 19 | #define spy_on(x) CDR_spy_on((x)) 20 | #endif 21 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/Cedar.h: -------------------------------------------------------------------------------- 1 | #import "CDRFunctions.h" 2 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CedarComparators.h: -------------------------------------------------------------------------------- 1 | #import "ComparatorsBase.h" 2 | #import "ComparatorsContainer.h" 3 | 4 | #ifdef CEDAR_CUSTOM_COMPARATORS 5 | #import CEDAR_CUSTOM_COMPARATORS 6 | #endif 7 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CedarDouble.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | namespace Cedar { namespace Doubles { 4 | class StubbedMethod; 5 | }} 6 | 7 | @protocol CedarDouble 8 | 9 | - (Cedar::Doubles::StubbedMethod &)add_stub:(const Cedar::Doubles::StubbedMethod &)stubbed_method; 10 | - (NSArray *)sent_messages; 11 | - (void)reset_sent_messages; 12 | 13 | @end 14 | 15 | namespace Cedar { namespace Doubles { 16 | 17 | struct MethodStubbingMarker { 18 | const char *fileName; 19 | int lineNumber; 20 | }; 21 | 22 | id operator,(id, const MethodStubbingMarker &); 23 | 24 | void operator,(id, const StubbedMethod &); 25 | }} 26 | 27 | #ifndef CEDAR_MATCHERS_DISALLOW_STUB_METHOD 28 | #define stub_method(x) ,(Cedar::Doubles::MethodStubbingMarker){__FILE__, __LINE__},Cedar::Doubles::StubbedMethod((x)) 29 | #endif 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CedarDoubles.h: -------------------------------------------------------------------------------- 1 | #import "CDRSpy.h" 2 | #import "CDRFake.h" 3 | #import "CDRClassFake.h" 4 | #import "CDRProtocolFake.h" 5 | #import "HaveReceived.h" 6 | #import "StubbedMethod.h" 7 | 8 | #import "Argument.h" 9 | #import "AnyArgument.h" 10 | #import "ValueArgument.h" 11 | #import "AnyInstanceArgument.h" 12 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CedarMatchers.h: -------------------------------------------------------------------------------- 1 | // Base 2 | #import "Equal.h" 3 | #import "BeTruthy.h" 4 | #import "BeNil.h" 5 | #import "BeCloseTo.h" 6 | #import "BeSameInstanceAs.h" 7 | #import "BeInstanceOf.h" 8 | #import "BeGreaterThan.h" 9 | #import "BeGTE.h" 10 | #import "BeLessThan.h" 11 | #import "BeLTE.h" 12 | #import "RaiseException.h" 13 | 14 | // Container 15 | #import "BeEmpty.h" 16 | #import "Contain.h" 17 | 18 | #ifdef CEDAR_CUSTOM_MATCHERS 19 | #import CEDAR_CUSTOM_MATCHERS 20 | #endif 21 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/CedarStringifiers.h: -------------------------------------------------------------------------------- 1 | #import "StringifiersBase.h" 2 | #import "StringifiersContainer.h" 3 | 4 | #ifdef CEDAR_CUSTOM_STRINGIFIERS 5 | #import CEDAR_CUSTOM_STRINGIFIERS 6 | #endif 7 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/ComparatorsBase.h: -------------------------------------------------------------------------------- 1 | #import "CompareEqual.h" 2 | #import "CompareGreaterThan.h" 3 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/Contain.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | template 5 | class Contain : public Base<> { 6 | private: 7 | Contain & operator=(const Contain &); 8 | 9 | public: 10 | explicit Contain(const T & element); 11 | ~Contain(); 12 | // Allow default copy ctor. 13 | 14 | template 15 | bool matches(const U &) const; 16 | 17 | protected: 18 | virtual NSString * failure_message_end() const; 19 | 20 | private: 21 | const T & element_; 22 | }; 23 | 24 | template 25 | inline Contain contain(const T & element) { 26 | return Contain(element); 27 | } 28 | 29 | template 30 | inline Contain::Contain(const T & element) 31 | : Base<>(), element_(element) { 32 | } 33 | 34 | template 35 | Contain::~Contain() { 36 | } 37 | 38 | template 39 | inline /*virtual*/ NSString * Contain::failure_message_end() const { 40 | NSString * elementString = Stringifiers::string_for(element_); 41 | return [NSString stringWithFormat:@"contain <%@>", elementString]; 42 | } 43 | 44 | #pragma mark Generic 45 | template template 46 | bool Contain::matches(const U & actualValue) const { 47 | return Comparators::compare_contains(actualValue, element_); 48 | } 49 | }} 50 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/HaveReceived.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | #import "Argument.h" 3 | #import "InvocationMatcher.h" 4 | 5 | namespace Cedar { namespace Doubles { 6 | 7 | class HaveReceived : public Matchers::Base<>, private InvocationMatcher { 8 | private: 9 | HaveReceived & operator=(const HaveReceived &); 10 | 11 | public: 12 | explicit HaveReceived(const SEL); 13 | ~HaveReceived(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | HaveReceived & with(const T &); 18 | template 19 | HaveReceived & with(const T &, ArgumentPack... pack); 20 | template 21 | HaveReceived & and_with(const T & argument) { return with(argument); } 22 | 23 | bool matches(id) const; 24 | 25 | protected: 26 | virtual NSString * failure_message_end() const; 27 | 28 | private: 29 | void verify_object_is_a_double(id) const; 30 | }; 31 | 32 | HaveReceived have_received(const SEL expectedSelector); 33 | HaveReceived have_received(const char * expectedMethod); 34 | 35 | template 36 | HaveReceived & HaveReceived::with(const T & value) { 37 | this->add_argument(value); 38 | return *this; 39 | } 40 | 41 | template 42 | HaveReceived & HaveReceived::with(const T & value, ArgumentPack... pack) { 43 | this->with(value); 44 | this->with(pack...); 45 | return *this; 46 | } 47 | 48 | }} 49 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/InvocationMatcher.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "ValueArgument.h" 3 | 4 | namespace Cedar { namespace Doubles { 5 | 6 | class InvocationMatcher { 7 | public: 8 | typedef std::vector arguments_vector_t; 9 | enum { OBJC_DEFAULT_ARGUMENT_COUNT = 2 }; 10 | 11 | public: 12 | InvocationMatcher(const SEL); 13 | virtual ~InvocationMatcher() {} 14 | 15 | void add_argument(const Argument::shared_ptr_t argument); 16 | template 17 | void add_argument(const T &); 18 | 19 | bool matches(NSInvocation * const) const; 20 | NSString *mismatch_reason(); 21 | 22 | const SEL selector() const { return expectedSelector_; } 23 | const arguments_vector_t & arguments() const { return arguments_; } 24 | const bool match_any_arguments() const { return arguments_.empty(); } 25 | void verify_count_and_types_of_arguments(id instance) const; 26 | 27 | private: 28 | bool matches_arguments(NSInvocation * const) const; 29 | NSMethodSignature *method_signature_for_instance(id instance) const; 30 | void compare_argument_count_to_method_signature(NSMethodSignature * const methodSignature) const; 31 | void compare_argument_types_to_method_signature(NSMethodSignature * const methodSignature) const; 32 | 33 | private: 34 | const SEL expectedSelector_; 35 | arguments_vector_t arguments_; 36 | }; 37 | 38 | template 39 | void InvocationMatcher::add_argument(const T & value) { 40 | this->add_argument(Argument::shared_ptr_t(new ValueArgument(value))); 41 | } 42 | 43 | }} 44 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/RaiseException.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | #import 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | typedef void (^empty_block_t)(); 7 | 8 | struct RaiseExceptionMessageBuilder { 9 | static NSString * string_for_actual_value(empty_block_t value) { 10 | return [value description]; 11 | } 12 | }; 13 | 14 | class RaiseException : public Base { 15 | private: 16 | RaiseException & operator=(const RaiseException &); 17 | 18 | public: 19 | explicit RaiseException(NSObject * = nil, Class = nil, bool = false, NSString * = nil); 20 | ~RaiseException(); 21 | // Allow default copy ctor. 22 | 23 | RaiseException operator()() const; 24 | RaiseException operator()(Class) const; 25 | RaiseException operator()(NSObject *) const; 26 | 27 | RaiseException & or_subclass(); 28 | 29 | RaiseException & with_reason(NSString * const reason); 30 | RaiseException with_reason(NSString * const reason) const; 31 | 32 | bool matches(empty_block_t) const; 33 | 34 | protected: 35 | virtual NSString * failure_message_end() const; 36 | 37 | private: 38 | bool exception_matches_expected_class(NSObject * const exception) const; 39 | bool exception_matches_expected_instance(NSObject * const exception) const; 40 | bool exception_matches_expected_reason(NSObject * const exception) const; 41 | 42 | private: 43 | const NSObject *expectedExceptionInstance_; 44 | const Class expectedExceptionClass_; 45 | bool allowSubclasses_; 46 | NSString *expectedReason_; 47 | }; 48 | 49 | RaiseException raise() __attribute__((deprecated)); // Please use raise_exception 50 | RaiseException raise(); 51 | 52 | static const RaiseException raise_exception; 53 | 54 | }} 55 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/ReturnValue.h: -------------------------------------------------------------------------------- 1 | #import "ValueArgument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | template 6 | class ReturnValue : public ValueArgument { 7 | private: 8 | ReturnValue & operator=(const ReturnValue &); 9 | 10 | public: 11 | explicit ReturnValue(const T &); 12 | virtual ~ReturnValue(); 13 | 14 | virtual bool matches_encoding(const char *) const; 15 | }; 16 | 17 | template 18 | ReturnValue::ReturnValue(const T & value) : ValueArgument(value) {} 19 | 20 | template 21 | /* virtual */ ReturnValue::~ReturnValue() {} 22 | 23 | template 24 | /* virtual */ bool ReturnValue::matches_encoding(const char * actual_argument_encoding) const { 25 | return 0 == strcmp(@encode(T), actual_argument_encoding); 26 | } 27 | 28 | }} 29 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/ShouldSyntax.h: -------------------------------------------------------------------------------- 1 | #import "ActualValue.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | 5 | struct ActualValueMarker { 6 | const char *fileName; 7 | int lineNumber; 8 | }; 9 | 10 | template 11 | const ActualValue operator,(const T & actualValue, const ActualValueMarker & marker) { 12 | return ActualValue(marker.fileName, marker.lineNumber, actualValue); 13 | } 14 | 15 | template 16 | const ActualValueMatchProxy operator,(const ActualValue & actualValue, bool negate) { 17 | return negate ? actualValue.to_not : actualValue.to; 18 | } 19 | 20 | template 21 | void operator,(const ActualValueMatchProxy & matchProxy, const MatcherType & matcher) { 22 | matchProxy(matcher); 23 | } 24 | 25 | }} 26 | 27 | #ifndef CEDAR_MATCHERS_DISALLOW_SHOULD 28 | #define should ,(ActualValueMarker){__FILE__, __LINE__},false, 29 | #define should_not ,(ActualValueMarker){__FILE__, __LINE__},true, 30 | #endif 31 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/SpecHelper.h: -------------------------------------------------------------------------------- 1 | #import "CDRSpec.h" 2 | #import "CDRSharedExampleGroupPool.h" 3 | #import "CDRExampleParent.h" 4 | 5 | @interface SpecHelper : NSObject { 6 | NSMutableDictionary *sharedExampleContext_, *sharedExampleGroups_; 7 | NSArray *globalBeforeEachClasses_, *globalAfterEachClasses_; 8 | BOOL shouldOnlyRunFocused_; 9 | } 10 | 11 | @property (nonatomic, retain, readonly) NSMutableDictionary *sharedExampleContext; 12 | @property (nonatomic, retain) NSArray *globalBeforeEachClasses, *globalAfterEachClasses; 13 | 14 | @property (nonatomic, assign) BOOL shouldOnlyRunFocused; 15 | 16 | + (SpecHelper *)specHelper; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/StringifiersBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | #include 3 | 4 | namespace Cedar { namespace Matchers { namespace Stringifiers { 5 | template 6 | NSString * string_for(const U & value) { 7 | if (0 == strncmp(@encode(U), "@", 1)) { 8 | NSValue *valueId = [NSValue value:&value withObjCType:@encode(id)]; 9 | return [[valueId nonretainedObjectValue] description]; 10 | } else { 11 | std::stringstream temp; 12 | temp << value; 13 | return [NSString stringWithCString:temp.str().c_str() encoding:NSUTF8StringEncoding]; 14 | } 15 | } 16 | 17 | inline NSString * string_for(const char value) { 18 | return string_for(static_cast(value)); 19 | } 20 | 21 | inline NSString * string_for(const Class & value) { 22 | return NSStringFromClass(value); 23 | } 24 | 25 | inline NSString * string_for(const BOOL value) { 26 | return value ? @"YES" : @"NO"; 27 | } 28 | 29 | inline NSString * string_for(NSNumber * const value) { 30 | return string_for([value floatValue]); 31 | } 32 | }}} 33 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Headers/StringifiersContainer.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | namespace Cedar { namespace Matchers { namespace Stringifiers { 6 | namespace { 7 | template 8 | NSString * comma_and_newline_delimited_list(const Container & container) { 9 | NSMutableString *result = [NSMutableString string]; 10 | bool first = true; 11 | for (typename Container::const_iterator it = container.begin(); it != container.end(); ++it, first = false) { 12 | if (!first) { 13 | [result appendString:@","]; 14 | } 15 | 16 | NSString * string = string_for(*it); 17 | [result appendString:[NSString stringWithFormat:@"\n %@", string]]; 18 | } 19 | return result; 20 | } 21 | } 22 | 23 | template 24 | NSString * string_for(const typename std::vector & container) { 25 | NSString * delimitedList = comma_and_newline_delimited_list(container); 26 | return [NSString stringWithFormat:@"(%@\n)", delimitedList]; 27 | } 28 | 29 | template 30 | NSString * string_for(const typename std::map & container) { 31 | NSMutableString *result = [NSMutableString stringWithString:@"{"]; 32 | 33 | for (typename std::map::const_iterator it = container.begin(); it != container.end(); ++it) { 34 | NSString * keyString = string_for(it->first); 35 | NSString * valueString = string_for(it->second); 36 | [result appendString:[NSString stringWithFormat:@"\n %@ = %@;", keyString, valueString]]; 37 | } 38 | [result appendString:@"\n}"]; 39 | return result; 40 | } 41 | 42 | template 43 | NSString * string_for(const typename std::set & container) { 44 | NSString * delimitedList = comma_and_newline_delimited_list(container); 45 | return [NSString stringWithFormat:@"{(%@\n)}", delimitedList]; 46 | } 47 | }}} 48 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 12A269 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | Cedar 11 | CFBundleIdentifier 12 | com.yourcompany.Cedar 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | DTCompiler 24 | com.apple.compilers.llvm.clang.1_0 25 | DTPlatformBuild 26 | 4F250 27 | DTPlatformVersion 28 | GM 29 | DTSDKBuild 30 | 12A269 31 | DTSDKName 32 | 33 | DTXcode 34 | 0440 35 | DTXcodeBuild 36 | 4F250 37 | 38 | 39 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Cedar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Cedar -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/AnyArgument.h: -------------------------------------------------------------------------------- 1 | #import "Argument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | class AnyArgument : public Argument { 6 | private: 7 | AnyArgument & operator=(const AnyArgument &); 8 | 9 | public: 10 | AnyArgument() {}; 11 | virtual ~AnyArgument() {}; 12 | // Allow default copy ctor. 13 | 14 | virtual const char * const value_encoding() const { return ""; }; 15 | virtual void * value_bytes() const { return NULL; }; 16 | virtual NSString * value_string() const { return @"anything"; }; 17 | 18 | virtual bool matches_encoding(const char *) const { return true; } 19 | virtual bool matches_bytes(void *) const { return true; } 20 | 21 | }; 22 | 23 | namespace Arguments { 24 | static const Argument::shared_ptr_t anything = Argument::shared_ptr_t(new Doubles::AnyArgument()); 25 | } 26 | 27 | }} 28 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/AnyInstanceArgument.h: -------------------------------------------------------------------------------- 1 | #import "Argument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | class AnyInstanceArgument : public Argument { 6 | private: 7 | AnyInstanceArgument & operator=(const AnyInstanceArgument &); 8 | 9 | public: 10 | explicit AnyInstanceArgument(const Class); 11 | virtual ~AnyInstanceArgument(); 12 | // Allow default copy ctor. 13 | 14 | virtual const char * const value_encoding() const; 15 | virtual void * value_bytes() const { return NULL; } 16 | virtual NSString * value_string() const; 17 | 18 | virtual bool matches_encoding(const char *) const; 19 | virtual bool matches_bytes(void *) const; 20 | 21 | private: 22 | const Class class_; 23 | }; 24 | 25 | 26 | namespace Arguments { 27 | Argument::shared_ptr_t any(Class); 28 | } 29 | }} 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/Argument.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CompareEqual.h" 3 | #import "CedarStringifiers.h" 4 | #import "CedarComparators.h" 5 | #import 6 | 7 | namespace Cedar { namespace Doubles { 8 | 9 | #pragma mark - Argument 10 | class Argument { 11 | public: 12 | virtual ~Argument() = 0; 13 | 14 | virtual const char * const value_encoding() const = 0; 15 | virtual void * value_bytes() const = 0; 16 | virtual NSString * value_string() const = 0; 17 | 18 | virtual bool matches_encoding(const char *) const = 0; 19 | virtual bool matches_bytes(void *) const = 0; 20 | 21 | typedef std::shared_ptr shared_ptr_t; 22 | }; 23 | 24 | inline /* virtual */ Argument::~Argument() {} 25 | 26 | }} 27 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/BeEmpty.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | class BeEmpty : public Base<> { 5 | private: 6 | BeEmpty & operator=(const BeEmpty &); 7 | 8 | public: 9 | inline BeEmpty() : Base<>() {} 10 | inline ~BeEmpty() {} 11 | // Allow default copy ctor. 12 | 13 | inline const BeEmpty & operator()() const { return *this; } 14 | 15 | template 16 | bool matches(const U &) const; 17 | 18 | protected: 19 | inline /*virtual*/ NSString * failure_message_end() const { return @"be empty"; } 20 | }; 21 | 22 | static const BeEmpty be_empty = BeEmpty(); 23 | 24 | #pragma mark Generic 25 | template 26 | bool BeEmpty::matches(const U & actualValue) const { 27 | return Comparators::compare_empty(actualValue); 28 | } 29 | }} 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/BeGreaterThan.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | template 7 | class BeGreaterThan : public Base<> { 8 | private: 9 | BeGreaterThan & operator=(const BeGreaterThan &); 10 | 11 | public: 12 | explicit BeGreaterThan(const T & expectedValue); 13 | ~BeGreaterThan(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | virtual NSString * failure_message_end() const; 21 | 22 | private: 23 | const T & expectedValue_; 24 | }; 25 | 26 | template 27 | BeGreaterThan be_greater_than(const T & expectedValue) { 28 | return BeGreaterThan(expectedValue); 29 | } 30 | 31 | template 32 | BeGreaterThan::BeGreaterThan(const T & expectedValue) 33 | : Base<>(), expectedValue_(expectedValue) { 34 | } 35 | 36 | template 37 | BeGreaterThan::~BeGreaterThan() { 38 | } 39 | 40 | template 41 | /*virtual*/ NSString * BeGreaterThan::failure_message_end() const { 42 | NSString * expectedValueString = Stringifiers::string_for(expectedValue_); 43 | return [NSString stringWithFormat:@"be greater than <%@>", expectedValueString]; 44 | } 45 | 46 | template template 47 | bool BeGreaterThan::matches(const U & actualValue) const { 48 | return Comparators::compare_greater_than(actualValue, expectedValue_); 49 | } 50 | 51 | #pragma mark operators 52 | template 53 | bool operator>(const ActualValue & actualValue, const U & expectedValue) { 54 | return actualValue.to > expectedValue; 55 | } 56 | 57 | template 58 | bool operator>(const ActualValueMatchProxy & actualValueMatchProxy, const U & expectedValue) { 59 | actualValueMatchProxy(be_greater_than(expectedValue)); 60 | return true; 61 | } 62 | }} 63 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/BeNil.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | #import "CDRSpecFailure.h" 4 | 5 | #include 6 | 7 | namespace Cedar { namespace Matchers { 8 | struct BeNilMessageBuilder { 9 | template 10 | static NSString * string_for_actual_value(const U & value) { 11 | throw std::logic_error("Should never generate a failure message for a nil comparison to non-pointer type."); 12 | } 13 | 14 | template 15 | static NSString * string_for_actual_value(U * const & value) { 16 | return value ? [NSString stringWithFormat:@"%p", value] : @"nil"; 17 | } 18 | }; 19 | 20 | class BeNil : public Base { 21 | private: 22 | BeNil & operator=(const BeNil &); 23 | 24 | public: 25 | inline BeNil() : Base() {} 26 | inline ~BeNil() {} 27 | // Allow default copy ctor. 28 | 29 | inline const BeNil & operator()() const { return *this; } 30 | 31 | template 32 | bool matches(const U &) const; 33 | 34 | template 35 | bool matches(U * const &) const; 36 | 37 | protected: 38 | inline /*virtual*/ NSString * failure_message_end() const { return @"be nil"; } 39 | }; 40 | 41 | static const BeNil be_nil = BeNil(); 42 | 43 | #pragma mark Generic 44 | template 45 | bool BeNil::matches(const U & actualValue) const { 46 | [[CDRSpecFailure specFailureWithReason:@"Attempt to compare non-pointer type to nil"] raise]; 47 | return NO; 48 | } 49 | 50 | template 51 | bool BeNil::matches(U * const & actualValue) const { 52 | return !actualValue; 53 | } 54 | 55 | }} 56 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/BeSameInstanceAs.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | template 6 | class BeSameInstanceAs : public Base<> { 7 | private: 8 | BeSameInstanceAs & operator=(const BeSameInstanceAs &); 9 | 10 | public: 11 | explicit BeSameInstanceAs(T * const expectedValue); 12 | ~BeSameInstanceAs(); 13 | // Allow default copy ctor. 14 | 15 | template 16 | bool matches(const U &) const; 17 | 18 | template 19 | bool matches(U * const &) const; 20 | 21 | protected: 22 | virtual NSString * failure_message_end() const; 23 | 24 | private: 25 | const T * expectedValue_; 26 | }; 27 | 28 | template 29 | BeSameInstanceAs be_same_instance_as(T * const expectedValue) { 30 | return BeSameInstanceAs(expectedValue); 31 | } 32 | 33 | template 34 | BeSameInstanceAs::BeSameInstanceAs(T * const expectedValue) 35 | : Base<>(), expectedValue_(expectedValue) { 36 | } 37 | 38 | template 39 | BeSameInstanceAs::~BeSameInstanceAs() { 40 | } 41 | 42 | template 43 | /*virtual*/ NSString * BeSameInstanceAs::failure_message_end() const { 44 | return [NSString stringWithFormat:@"be same instance as <%p>", expectedValue_]; 45 | } 46 | 47 | #pragma mark Generic 48 | template template 49 | bool BeSameInstanceAs::matches(const U & actualValue) const { 50 | [[CDRSpecFailure specFailureWithReason:@"Attempt to compare non-pointer type for sameness."] raise]; 51 | return NO; 52 | } 53 | 54 | template template 55 | bool BeSameInstanceAs::matches(U * const & actualValue) const { 56 | return actualValue == expectedValue_; 57 | } 58 | 59 | }} 60 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/BeTruthy.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Base.h" 3 | 4 | namespace Cedar { namespace Matchers { 5 | class BeTruthy : public Base<> { 6 | private: 7 | BeTruthy & operator=(const BeTruthy &); 8 | 9 | public: 10 | inline BeTruthy() : Base<>() {} 11 | inline ~BeTruthy() {} 12 | // Allow default copy ctor. 13 | 14 | inline const BeTruthy & operator()() const { return *this; } 15 | 16 | template 17 | bool matches(const U &) const; 18 | 19 | protected: 20 | inline /*virtual*/ NSString * failure_message_end() const { return @"evaluate to true"; } 21 | }; 22 | 23 | static const BeTruthy be_truthy = BeTruthy(); 24 | 25 | #pragma mark Generic 26 | template 27 | bool BeTruthy::matches(const U & actualValue) const { 28 | return !!actualValue; 29 | } 30 | 31 | }} 32 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRClassFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CDRFake.h" 3 | #import "CedarDouble.h" 4 | 5 | @interface CDRClassFake : CDRFake 6 | 7 | @end 8 | 9 | id CDR_fake_for(Class klass, bool require_explicit_stubs = true); 10 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRExampleBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CDRExampleParent.h" 3 | 4 | @protocol CDRExampleReporter; 5 | 6 | typedef void (^CDRSpecBlock)(void); 7 | 8 | enum CDRExampleState { 9 | CDRExampleStateIncomplete = 0x00, 10 | CDRExampleStateSkipped = 0x01, 11 | CDRExampleStatePassed = 0x03, 12 | CDRExampleStatePending = 0x07, 13 | CDRExampleStateFailed = 0x0F, 14 | CDRExampleStateError = 0x1F 15 | }; 16 | typedef enum CDRExampleState CDRExampleState; 17 | 18 | @interface CDRExampleBase : NSObject { 19 | NSString *text_; 20 | id parent_; 21 | BOOL focused_; 22 | NSTimeInterval runTime_; 23 | } 24 | 25 | @property (nonatomic, readonly) NSString *text; 26 | @property (nonatomic, assign) id parent; 27 | @property (nonatomic, assign, getter=isFocused) BOOL focused; 28 | @property (nonatomic) NSUInteger stackAddress; 29 | 30 | - (id)initWithText:(NSString *)text; 31 | 32 | - (void)run; 33 | - (BOOL)shouldRun; 34 | 35 | - (BOOL)hasChildren; 36 | - (BOOL)hasFocusedExamples; 37 | 38 | - (NSString *)message; 39 | - (NSString *)fullText; 40 | - (NSMutableArray *)fullTextInPieces; 41 | @end 42 | 43 | @interface CDRExampleBase (RunReporting) 44 | - (CDRExampleState)state; 45 | - (NSTimeInterval)runTime; 46 | - (float)progress; 47 | @end 48 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRExampleParent.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRExampleParent 4 | 5 | - (BOOL)shouldRun; 6 | 7 | - (void)setUp; 8 | - (void)tearDown; 9 | 10 | @optional 11 | - (BOOL)hasFullText; 12 | - (NSString *)fullText; 13 | - (NSMutableArray *)fullTextInPieces; 14 | 15 | - (NSUInteger)stackAddress; 16 | @end 17 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRExampleReporter.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRExampleReporter 4 | 5 | - (void)runWillStartWithGroups:(NSArray *)groups andRandomSeed:(unsigned int)seed; 6 | - (void)runDidComplete; 7 | - (int)result; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | 4 | @interface CDRFake : NSObject 5 | 6 | @property (nonatomic, assign) Class klass; 7 | 8 | - (id)initWithClass:(Class)klass requireExplicitStubs:(bool)requireExplicitStubs; 9 | 10 | @end 11 | 12 | #ifndef CEDAR_DOUBLES_COMPATIBILITY_MODE 13 | #define fake_for(x) CDR_fake_for((x)) 14 | #define nice_fake_for(x) CDR_fake_for((x), false) 15 | #endif 16 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRFunctions.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSArray *CDRReportersFromEnv(const char*defaultReporterClassName); 4 | 5 | int runSpecs(); 6 | int runAllSpecs() __attribute__((deprecated)); 7 | int runSpecsWithCustomExampleReporters(NSArray *reporters); 8 | NSArray *specClassesToRun(); 9 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRProtocolFake.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | #import "CDRFake.h" 4 | 5 | #import 6 | #import 7 | 8 | @interface CDRProtocolFake : CDRFake 9 | 10 | - (id)initWithClass:(Class)klass forProtocol:(Protocol *)protocol requireExplicitStubs:(bool)requireExplicitStubs; 11 | 12 | @end 13 | 14 | id CDR_fake_for(Protocol *protocol, bool require_explicit_stubs = true); 15 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRSharedExampleGroupPool.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol CDRSharedExampleGroupPool 4 | @end 5 | 6 | typedef void (^CDRSharedExampleGroupBlock)(NSDictionary *); 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | void sharedExamplesFor(NSString *, CDRSharedExampleGroupBlock); 12 | void itShouldBehaveLike(NSString *); 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | @interface CDRSharedExampleGroupPool : NSObject 18 | @end 19 | 20 | @interface CDRSharedExampleGroupPool (SharedExampleGroupDeclaration) 21 | - (void)declareSharedExampleGroups; 22 | @end 23 | 24 | #define SHARED_EXAMPLE_GROUPS_BEGIN(name) \ 25 | @interface SharedExampleGroupPoolFor##name : CDRSharedExampleGroupPool \ 26 | @end \ 27 | @implementation SharedExampleGroupPoolFor##name \ 28 | - (void)declareSharedExampleGroups { 29 | 30 | #define SHARED_EXAMPLE_GROUPS_END \ 31 | } \ 32 | @end 33 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRSpecFailure.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface CDRSpecFailure : NSException { 4 | NSString *fileName_; 5 | int lineNumber_; 6 | } 7 | 8 | @property (nonatomic, retain, readonly) NSString *fileName; 9 | @property (nonatomic, assign, readonly) int lineNumber; 10 | 11 | + (id)specFailureWithReason:(NSString *)reason; 12 | + (id)specFailureWithReason:(NSString *)reason fileName:(NSString *)fileName lineNumber:(int)lineNumber; 13 | + (id)specFailureWithRaisedObject:(NSObject *)object; 14 | 15 | - (id)initWithReason:(NSString *)reason; 16 | - (id)initWithReason:(NSString *)reason fileName:(NSString *)fileName lineNumber:(int)lineNumber; 17 | - (id)initWithRaisedObject:(NSObject *)object; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CDRSpy.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "CedarDouble.h" 3 | 4 | @interface CDRSpy : NSProxy 5 | 6 | + (void)interceptMessagesForInstance:(id)instance; 7 | 8 | @end 9 | 10 | namespace Cedar { namespace Doubles { 11 | inline void CDR_spy_on(id instance) { 12 | if (![[instance class] conformsToProtocol:@protocol(CedarDouble)]) { 13 | [CDRSpy interceptMessagesForInstance:instance]; 14 | } 15 | } 16 | }} 17 | 18 | #ifndef CEDAR_DOUBLES_COMPATIBILITY_MODE 19 | #define spy_on(x) CDR_spy_on((x)) 20 | #endif 21 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/Cedar.h: -------------------------------------------------------------------------------- 1 | #import "CDRFunctions.h" 2 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CedarComparators.h: -------------------------------------------------------------------------------- 1 | #import "ComparatorsBase.h" 2 | #import "ComparatorsContainer.h" 3 | 4 | #ifdef CEDAR_CUSTOM_COMPARATORS 5 | #import CEDAR_CUSTOM_COMPARATORS 6 | #endif 7 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CedarDouble.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | namespace Cedar { namespace Doubles { 4 | class StubbedMethod; 5 | }} 6 | 7 | @protocol CedarDouble 8 | 9 | - (Cedar::Doubles::StubbedMethod &)add_stub:(const Cedar::Doubles::StubbedMethod &)stubbed_method; 10 | - (NSArray *)sent_messages; 11 | - (void)reset_sent_messages; 12 | 13 | @end 14 | 15 | namespace Cedar { namespace Doubles { 16 | 17 | struct MethodStubbingMarker { 18 | const char *fileName; 19 | int lineNumber; 20 | }; 21 | 22 | id operator,(id, const MethodStubbingMarker &); 23 | 24 | void operator,(id, const StubbedMethod &); 25 | }} 26 | 27 | #ifndef CEDAR_MATCHERS_DISALLOW_STUB_METHOD 28 | #define stub_method(x) ,(Cedar::Doubles::MethodStubbingMarker){__FILE__, __LINE__},Cedar::Doubles::StubbedMethod((x)) 29 | #endif 30 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CedarDoubles.h: -------------------------------------------------------------------------------- 1 | #import "CDRSpy.h" 2 | #import "CDRFake.h" 3 | #import "CDRClassFake.h" 4 | #import "CDRProtocolFake.h" 5 | #import "HaveReceived.h" 6 | #import "StubbedMethod.h" 7 | 8 | #import "Argument.h" 9 | #import "AnyArgument.h" 10 | #import "ValueArgument.h" 11 | #import "AnyInstanceArgument.h" 12 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CedarMatchers.h: -------------------------------------------------------------------------------- 1 | // Base 2 | #import "Equal.h" 3 | #import "BeTruthy.h" 4 | #import "BeNil.h" 5 | #import "BeCloseTo.h" 6 | #import "BeSameInstanceAs.h" 7 | #import "BeInstanceOf.h" 8 | #import "BeGreaterThan.h" 9 | #import "BeGTE.h" 10 | #import "BeLessThan.h" 11 | #import "BeLTE.h" 12 | #import "RaiseException.h" 13 | 14 | // Container 15 | #import "BeEmpty.h" 16 | #import "Contain.h" 17 | 18 | #ifdef CEDAR_CUSTOM_MATCHERS 19 | #import CEDAR_CUSTOM_MATCHERS 20 | #endif 21 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/CedarStringifiers.h: -------------------------------------------------------------------------------- 1 | #import "StringifiersBase.h" 2 | #import "StringifiersContainer.h" 3 | 4 | #ifdef CEDAR_CUSTOM_STRINGIFIERS 5 | #import CEDAR_CUSTOM_STRINGIFIERS 6 | #endif 7 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/ComparatorsBase.h: -------------------------------------------------------------------------------- 1 | #import "CompareEqual.h" 2 | #import "CompareGreaterThan.h" 3 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/Contain.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | template 5 | class Contain : public Base<> { 6 | private: 7 | Contain & operator=(const Contain &); 8 | 9 | public: 10 | explicit Contain(const T & element); 11 | ~Contain(); 12 | // Allow default copy ctor. 13 | 14 | template 15 | bool matches(const U &) const; 16 | 17 | protected: 18 | virtual NSString * failure_message_end() const; 19 | 20 | private: 21 | const T & element_; 22 | }; 23 | 24 | template 25 | inline Contain contain(const T & element) { 26 | return Contain(element); 27 | } 28 | 29 | template 30 | inline Contain::Contain(const T & element) 31 | : Base<>(), element_(element) { 32 | } 33 | 34 | template 35 | Contain::~Contain() { 36 | } 37 | 38 | template 39 | inline /*virtual*/ NSString * Contain::failure_message_end() const { 40 | NSString * elementString = Stringifiers::string_for(element_); 41 | return [NSString stringWithFormat:@"contain <%@>", elementString]; 42 | } 43 | 44 | #pragma mark Generic 45 | template template 46 | bool Contain::matches(const U & actualValue) const { 47 | return Comparators::compare_contains(actualValue, element_); 48 | } 49 | }} 50 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/HaveReceived.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | #import "Argument.h" 3 | #import "InvocationMatcher.h" 4 | 5 | namespace Cedar { namespace Doubles { 6 | 7 | class HaveReceived : public Matchers::Base<>, private InvocationMatcher { 8 | private: 9 | HaveReceived & operator=(const HaveReceived &); 10 | 11 | public: 12 | explicit HaveReceived(const SEL); 13 | ~HaveReceived(); 14 | // Allow default copy ctor. 15 | 16 | template 17 | HaveReceived & with(const T &); 18 | template 19 | HaveReceived & with(const T &, ArgumentPack... pack); 20 | template 21 | HaveReceived & and_with(const T & argument) { return with(argument); } 22 | 23 | bool matches(id) const; 24 | 25 | protected: 26 | virtual NSString * failure_message_end() const; 27 | 28 | private: 29 | void verify_object_is_a_double(id) const; 30 | }; 31 | 32 | HaveReceived have_received(const SEL expectedSelector); 33 | HaveReceived have_received(const char * expectedMethod); 34 | 35 | template 36 | HaveReceived & HaveReceived::with(const T & value) { 37 | this->add_argument(value); 38 | return *this; 39 | } 40 | 41 | template 42 | HaveReceived & HaveReceived::with(const T & value, ArgumentPack... pack) { 43 | this->with(value); 44 | this->with(pack...); 45 | return *this; 46 | } 47 | 48 | }} 49 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/InvocationMatcher.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "ValueArgument.h" 3 | 4 | namespace Cedar { namespace Doubles { 5 | 6 | class InvocationMatcher { 7 | public: 8 | typedef std::vector arguments_vector_t; 9 | enum { OBJC_DEFAULT_ARGUMENT_COUNT = 2 }; 10 | 11 | public: 12 | InvocationMatcher(const SEL); 13 | virtual ~InvocationMatcher() {} 14 | 15 | void add_argument(const Argument::shared_ptr_t argument); 16 | template 17 | void add_argument(const T &); 18 | 19 | bool matches(NSInvocation * const) const; 20 | NSString *mismatch_reason(); 21 | 22 | const SEL selector() const { return expectedSelector_; } 23 | const arguments_vector_t & arguments() const { return arguments_; } 24 | const bool match_any_arguments() const { return arguments_.empty(); } 25 | void verify_count_and_types_of_arguments(id instance) const; 26 | 27 | private: 28 | bool matches_arguments(NSInvocation * const) const; 29 | NSMethodSignature *method_signature_for_instance(id instance) const; 30 | void compare_argument_count_to_method_signature(NSMethodSignature * const methodSignature) const; 31 | void compare_argument_types_to_method_signature(NSMethodSignature * const methodSignature) const; 32 | 33 | private: 34 | const SEL expectedSelector_; 35 | arguments_vector_t arguments_; 36 | }; 37 | 38 | template 39 | void InvocationMatcher::add_argument(const T & value) { 40 | this->add_argument(Argument::shared_ptr_t(new ValueArgument(value))); 41 | } 42 | 43 | }} 44 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/RaiseException.h: -------------------------------------------------------------------------------- 1 | #import "Base.h" 2 | #import 3 | 4 | namespace Cedar { namespace Matchers { 5 | 6 | typedef void (^empty_block_t)(); 7 | 8 | struct RaiseExceptionMessageBuilder { 9 | static NSString * string_for_actual_value(empty_block_t value) { 10 | return [value description]; 11 | } 12 | }; 13 | 14 | class RaiseException : public Base { 15 | private: 16 | RaiseException & operator=(const RaiseException &); 17 | 18 | public: 19 | explicit RaiseException(NSObject * = nil, Class = nil, bool = false, NSString * = nil); 20 | ~RaiseException(); 21 | // Allow default copy ctor. 22 | 23 | RaiseException operator()() const; 24 | RaiseException operator()(Class) const; 25 | RaiseException operator()(NSObject *) const; 26 | 27 | RaiseException & or_subclass(); 28 | 29 | RaiseException & with_reason(NSString * const reason); 30 | RaiseException with_reason(NSString * const reason) const; 31 | 32 | bool matches(empty_block_t) const; 33 | 34 | protected: 35 | virtual NSString * failure_message_end() const; 36 | 37 | private: 38 | bool exception_matches_expected_class(NSObject * const exception) const; 39 | bool exception_matches_expected_instance(NSObject * const exception) const; 40 | bool exception_matches_expected_reason(NSObject * const exception) const; 41 | 42 | private: 43 | const NSObject *expectedExceptionInstance_; 44 | const Class expectedExceptionClass_; 45 | bool allowSubclasses_; 46 | NSString *expectedReason_; 47 | }; 48 | 49 | RaiseException raise() __attribute__((deprecated)); // Please use raise_exception 50 | RaiseException raise(); 51 | 52 | static const RaiseException raise_exception; 53 | 54 | }} 55 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/ReturnValue.h: -------------------------------------------------------------------------------- 1 | #import "ValueArgument.h" 2 | 3 | namespace Cedar { namespace Doubles { 4 | 5 | template 6 | class ReturnValue : public ValueArgument { 7 | private: 8 | ReturnValue & operator=(const ReturnValue &); 9 | 10 | public: 11 | explicit ReturnValue(const T &); 12 | virtual ~ReturnValue(); 13 | 14 | virtual bool matches_encoding(const char *) const; 15 | }; 16 | 17 | template 18 | ReturnValue::ReturnValue(const T & value) : ValueArgument(value) {} 19 | 20 | template 21 | /* virtual */ ReturnValue::~ReturnValue() {} 22 | 23 | template 24 | /* virtual */ bool ReturnValue::matches_encoding(const char * actual_argument_encoding) const { 25 | return 0 == strcmp(@encode(T), actual_argument_encoding); 26 | } 27 | 28 | }} 29 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/ShouldSyntax.h: -------------------------------------------------------------------------------- 1 | #import "ActualValue.h" 2 | 3 | namespace Cedar { namespace Matchers { 4 | 5 | struct ActualValueMarker { 6 | const char *fileName; 7 | int lineNumber; 8 | }; 9 | 10 | template 11 | const ActualValue operator,(const T & actualValue, const ActualValueMarker & marker) { 12 | return ActualValue(marker.fileName, marker.lineNumber, actualValue); 13 | } 14 | 15 | template 16 | const ActualValueMatchProxy operator,(const ActualValue & actualValue, bool negate) { 17 | return negate ? actualValue.to_not : actualValue.to; 18 | } 19 | 20 | template 21 | void operator,(const ActualValueMatchProxy & matchProxy, const MatcherType & matcher) { 22 | matchProxy(matcher); 23 | } 24 | 25 | }} 26 | 27 | #ifndef CEDAR_MATCHERS_DISALLOW_SHOULD 28 | #define should ,(ActualValueMarker){__FILE__, __LINE__},false, 29 | #define should_not ,(ActualValueMarker){__FILE__, __LINE__},true, 30 | #endif 31 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/SpecHelper.h: -------------------------------------------------------------------------------- 1 | #import "CDRSpec.h" 2 | #import "CDRSharedExampleGroupPool.h" 3 | #import "CDRExampleParent.h" 4 | 5 | @interface SpecHelper : NSObject { 6 | NSMutableDictionary *sharedExampleContext_, *sharedExampleGroups_; 7 | NSArray *globalBeforeEachClasses_, *globalAfterEachClasses_; 8 | BOOL shouldOnlyRunFocused_; 9 | } 10 | 11 | @property (nonatomic, retain, readonly) NSMutableDictionary *sharedExampleContext; 12 | @property (nonatomic, retain) NSArray *globalBeforeEachClasses, *globalAfterEachClasses; 13 | 14 | @property (nonatomic, assign) BOOL shouldOnlyRunFocused; 15 | 16 | + (SpecHelper *)specHelper; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/StringifiersBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | #include 3 | 4 | namespace Cedar { namespace Matchers { namespace Stringifiers { 5 | template 6 | NSString * string_for(const U & value) { 7 | if (0 == strncmp(@encode(U), "@", 1)) { 8 | NSValue *valueId = [NSValue value:&value withObjCType:@encode(id)]; 9 | return [[valueId nonretainedObjectValue] description]; 10 | } else { 11 | std::stringstream temp; 12 | temp << value; 13 | return [NSString stringWithCString:temp.str().c_str() encoding:NSUTF8StringEncoding]; 14 | } 15 | } 16 | 17 | inline NSString * string_for(const char value) { 18 | return string_for(static_cast(value)); 19 | } 20 | 21 | inline NSString * string_for(const Class & value) { 22 | return NSStringFromClass(value); 23 | } 24 | 25 | inline NSString * string_for(const BOOL value) { 26 | return value ? @"YES" : @"NO"; 27 | } 28 | 29 | inline NSString * string_for(NSNumber * const value) { 30 | return string_for([value floatValue]); 31 | } 32 | }}} 33 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Headers/StringifiersContainer.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | namespace Cedar { namespace Matchers { namespace Stringifiers { 6 | namespace { 7 | template 8 | NSString * comma_and_newline_delimited_list(const Container & container) { 9 | NSMutableString *result = [NSMutableString string]; 10 | bool first = true; 11 | for (typename Container::const_iterator it = container.begin(); it != container.end(); ++it, first = false) { 12 | if (!first) { 13 | [result appendString:@","]; 14 | } 15 | 16 | NSString * string = string_for(*it); 17 | [result appendString:[NSString stringWithFormat:@"\n %@", string]]; 18 | } 19 | return result; 20 | } 21 | } 22 | 23 | template 24 | NSString * string_for(const typename std::vector & container) { 25 | NSString * delimitedList = comma_and_newline_delimited_list(container); 26 | return [NSString stringWithFormat:@"(%@\n)", delimitedList]; 27 | } 28 | 29 | template 30 | NSString * string_for(const typename std::map & container) { 31 | NSMutableString *result = [NSMutableString stringWithString:@"{"]; 32 | 33 | for (typename std::map::const_iterator it = container.begin(); it != container.end(); ++it) { 34 | NSString * keyString = string_for(it->first); 35 | NSString * valueString = string_for(it->second); 36 | [result appendString:[NSString stringWithFormat:@"\n %@ = %@;", keyString, valueString]]; 37 | } 38 | [result appendString:@"\n}"]; 39 | return result; 40 | } 41 | 42 | template 43 | NSString * string_for(const typename std::set & container) { 44 | NSString * delimitedList = comma_and_newline_delimited_list(container); 45 | return [NSString stringWithFormat:@"{(%@\n)}", delimitedList]; 46 | } 47 | }}} 48 | -------------------------------------------------------------------------------- /CheckmanTests/Frameworks/Cedar.framework/Versions/Current/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 12A269 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | Cedar 11 | CFBundleIdentifier 12 | com.yourcompany.Cedar 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | DTCompiler 24 | com.apple.compilers.llvm.clang.1_0 25 | DTPlatformBuild 26 | 4F250 27 | DTPlatformVersion 28 | GM 29 | DTSDKBuild 30 | 12A269 31 | DTSDKName 32 | 33 | DTXcode 34 | 0440 35 | DTXcodeBuild 36 | 4F250 37 | 38 | 39 | -------------------------------------------------------------------------------- /CheckmanTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Dmitriy Kalinin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME = "Checkman" 2 | CONFIGURATION = "Release" 3 | OCUNIT_LOGIC_SPECS_TARGET_NAME = "CheckmanTests" 4 | 5 | PROJECT_ROOT = File.dirname(__FILE__) 6 | BUILD_DIR = File.join(PROJECT_ROOT, "build") 7 | 8 | def system_or_exit(cmd, stdout=nil) 9 | puts "Executing #{cmd}" 10 | cmd += " >#{stdout}" if stdout 11 | system(cmd) or raise "** Build failed **" 12 | end 13 | 14 | task :default => %w( 15 | included_scripts:verify_ruby_syntax 16 | included_scripts:integration_specs 17 | ) 18 | 19 | %w(install build).each do |task_name| 20 | task(task_name) do 21 | system_or_exit "./bin/#{task_name}" 22 | end 23 | end 24 | 25 | desc "Clean all targets" 26 | task :clean do 27 | system_or_exit "rm -rf #{BUILD_DIR}/*", "/dev/null" 28 | end 29 | 30 | namespace :included_scripts do 31 | desc "Verifies Ruby syntax for included scripts" 32 | task :verify_ruby_syntax do 33 | Dir["./scripts/*.check"].each do |file| 34 | system_or_exit "ruby -c #{file}" 35 | end 36 | end 37 | 38 | desc "Run integration specs" 39 | task :integration_specs do 40 | rspec = `which rspec`.strip 41 | raise "** Install rspec **" if rspec.empty? 42 | system_or_exit "#{rspec} scripts/specs/*_spec.rb" 43 | end 44 | end 45 | 46 | namespace :ocunit do 47 | desc "Build and run OCUnit logic specs (#{OCUNIT_LOGIC_SPECS_TARGET_NAME})" 48 | task :logic do 49 | ENV["CEDAR_REPORTER_CLASS"] = "CDRColorizedReporter" 50 | system_or_exit <<-SHELL 51 | xcodebuild \ 52 | -project #{PROJECT_NAME}.xcodeproj \ 53 | -scheme #{OCUNIT_LOGIC_SPECS_TARGET_NAME} \ 54 | -configuration #{CONFIGURATION} \ 55 | -destination 'arch=x86_64' \ 56 | test SYMROOT=#{BUILD_DIR} 57 | SHELL 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /bin/Checkman.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cppforlife/checkman/e5e6fa3132f92bf145b59642489df55b87399fcb/bin/Checkman.zip -------------------------------------------------------------------------------- /bin/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BIN_DIR=./bin 4 | BUILD_DIR=./build 5 | RELEASE_CONF=Release 6 | 7 | set -e 8 | set -x 9 | 10 | # Make sure we are running out of root of the project 11 | if [ -f install ]; then 12 | cd .. 13 | fi 14 | 15 | if ! git diff-index --quiet HEAD; then 16 | echo "Changes must be committed before release" 17 | exit 1 18 | fi 19 | 20 | rm -rf $BUILD_DIR 21 | xcodebuild -project Checkman.xcodeproj -target Checkman -configuration $RELEASE_CONF build 22 | 23 | (cd "$BUILD_DIR/$RELEASE_CONF"; zip -r "Checkman.zip" Checkman.app) 24 | cp "$BUILD_DIR/$RELEASE_CONF/Checkman.zip" $BIN_DIR 25 | 26 | rm -rf $BUILD_DIR 27 | git commit -am "release `git rev-parse --short HEAD`" 28 | -------------------------------------------------------------------------------- /bin/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BIN_DIR=./bin 4 | TMP_DIR=/tmp/CheckmanInstall 5 | INSTALL_DIR=/Applications 6 | 7 | set -e 8 | set -x 9 | 10 | function sudoable() { # $1=command 11 | if $1 2>&1 | grep --quiet "Permission denied"; then 12 | sudo -k $1 13 | fi 14 | } 15 | 16 | # Allow running out of root of the project 17 | if [ -d Checkman.xcodeproj ]; then 18 | cd $BIN_DIR 19 | fi 20 | 21 | sudoable "rm -rf $TMP_DIR" 22 | mkdir -p $TMP_DIR 23 | 24 | # Unpack and install local Checkman.zip if it's present in current directory 25 | if [ -e Checkman.zip ]; then 26 | cp Checkman.zip $TMP_DIR 27 | cd $TMP_DIR 28 | else 29 | cd $TMP_DIR 30 | curl -L -sO https://raw.githubusercontent.com/cppforlife/checkman/master/bin/Checkman.zip 31 | fi 32 | 33 | unzip Checkman.zip 34 | 35 | # Add example checks for first time users 36 | if [ ! -d ~/Checkman ]; then 37 | mkdir -p ~/Checkman 38 | cat > ~/Checkman/example < @projects.all? { |p| p.attr('lastBuildStatus') == "Success" }, 17 | :changing => @projects.any? { |p| p.attr('activity') == "Building" }, 18 | } 19 | end 20 | 21 | def to_json(*) 22 | JSON.dump(as_json) 23 | end 24 | end 25 | 26 | class CCTray 27 | def initialize(feed_url, pipeline, stage=nil, job=nil) 28 | feed_uri = URI(WEBrick::HTTPUtils.escape(feed_url)) 29 | username = feed_uri.user 30 | password = feed_uri.password 31 | 32 | feed_uri.user = nil 33 | feed_uri.password = nil 34 | 35 | username = WEBrick::HTTPUtils.unescape(username) if username 36 | password = WEBrick::HTTPUtils.unescape(password) if password 37 | 38 | @feed = Nokogiri::XML(open(feed_uri, :http_basic_authentication => [username, password])) 39 | @pipeline = pipeline 40 | @stage = stage 41 | @job = job 42 | end 43 | 44 | def latest_status 45 | name = [@pipeline, @stage, @job].compact.join(" :: ") 46 | 47 | projects = @feed.xpath('//Project').select do |proj| 48 | proj.attr('name').downcase.include?(name.downcase) 49 | end 50 | 51 | CCTrayMultiProjectStatus.new(projects) 52 | end 53 | end 54 | 55 | puts CCTray.new(*ARGV).latest_status.to_json if __FILE__ == $0 56 | -------------------------------------------------------------------------------- /scripts/site.check: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "rubygems" 3 | require "json" 4 | 5 | class SiteStatus 6 | def initialize(url, curl_output) 7 | @url = url 8 | @curl_lines = curl_output.split("\r\n") 9 | 10 | raise ArgumentError, "invalid curl_output: '#{curl_output}'" \ 11 | if @curl_lines.empty? 12 | end 13 | 14 | def ok? 15 | @curl_lines.first.include?("200 OK") 16 | end 17 | 18 | def headers 19 | @curl_lines[1..-1].map { |l| l.split(": ", 2).map { |e| ellipsis(e) } }.sort 20 | end 21 | 22 | def as_json(*) 23 | { 24 | :result => ok?, 25 | :changing => false, 26 | :url => @url, 27 | :info => [ 28 | [:Url, @url], 29 | [:Status, @curl_lines.first] 30 | ] + headers 31 | } 32 | end 33 | 34 | def to_json(*) 35 | JSON.dump(as_json) 36 | end 37 | 38 | private 39 | 40 | def ellipsis(text) 41 | text[0..59].tap { |short_text| short_text << '...' if short_text != text } 42 | end 43 | end 44 | 45 | class Site 46 | def initialize(url) 47 | raise ArgumentError "url must not be nil" \ 48 | unless @url = url 49 | end 50 | 51 | def latest_status 52 | SiteStatus.new(@url, http_get(@url)) 53 | end 54 | 55 | private 56 | 57 | def http_get(url) 58 | curl = "curl -sIk -A \"CheckmanSite (Hostname: $HOSTNAME)\" '#{url}'" 59 | `#{curl}`.tap { |o| $stderr.puts curl, o } 60 | end 61 | end 62 | 63 | puts Site.new(*ARGV).latest_status.to_json if __FILE__ == $0 64 | -------------------------------------------------------------------------------- /scripts/site_with_retry.check: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "rubygems" 3 | require "json" 4 | 5 | class SiteStatus 6 | def initialize(url, curl_output) 7 | @url = url 8 | @curl_lines = curl_output.split("\r\n") 9 | 10 | raise ArgumentError, "invalid curl_output: '#{curl_output}'" \ 11 | if @curl_lines.empty? 12 | end 13 | 14 | def ok? 15 | @curl_lines.any? { |line| line =~ /200 OK$/ } 16 | end 17 | 18 | def headers 19 | @curl_lines[1..-1].map { |l| l.split(": ", 2).map { |e| ellipsis(e) } }.sort 20 | end 21 | 22 | def as_json(*) 23 | { 24 | :result => ok?, 25 | :changing => false, 26 | :url => @url, 27 | :info => [ 28 | [:Url, @url], 29 | [:Status, @curl_lines.first] 30 | ] + headers 31 | } 32 | end 33 | 34 | def to_json(*) 35 | JSON.dump(as_json) 36 | end 37 | 38 | private 39 | 40 | def ellipsis(text) 41 | text[0..59].tap { |short_text| short_text << '...' if short_text != text } 42 | end 43 | end 44 | 45 | class Site 46 | def initialize(url) 47 | raise ArgumentError "url must not be nil" \ 48 | unless @url = url 49 | end 50 | 51 | def latest_status 52 | SiteStatus.new(@url, http_get(@url)) 53 | end 54 | 55 | private 56 | 57 | def http_get(url) 58 | curl = "curl -v -sIk --connect-timeout 5 --retry 3 --retry-max-time 15 -A \"CheckmanSite (Hostname: $HOSTNAME)\" '#{url}'" 59 | `#{curl} 2>&1`.tap { |o| $stderr.puts curl, o } 60 | end 61 | end 62 | 63 | puts Site.new(*ARGV).latest_status.to_json if __FILE__ == $0 64 | -------------------------------------------------------------------------------- /scripts/snapci.check: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'rubygems' 3 | require 'open-uri' 4 | require 'nokogiri' 5 | require 'net/https' 6 | require 'json' 7 | require 'webrick' 8 | 9 | class SnapCI 10 | def initialize(feed_url, pipeline, stage) 11 | feed_uri = URI(WEBrick::HTTPUtils.escape(feed_url)) 12 | @feed = Nokogiri::XML(open(feed_uri)) 13 | @pipeline = pipeline 14 | @stage = stage 15 | end 16 | 17 | def latest_status 18 | name = [@pipeline, @stage].compact.join(" :: ") 19 | 20 | project = @feed.xpath('//Project').find do |proj| 21 | proj.attr('name').downcase.include?(name.downcase) 22 | end 23 | 24 | ProjectStatus.new(project) 25 | end 26 | 27 | class ProjectStatus 28 | def initialize(project) 29 | @project = project 30 | end 31 | 32 | def as_json(*) 33 | { 34 | :result => @project.attr('lastBuildStatus') == "Success", 35 | :changing => @project.attr('activity') != "Sleeping", 36 | :url => @project.attr('webUrl'), 37 | :info => info 38 | } 39 | end 40 | 41 | def to_json(*) 42 | JSON.dump(as_json) 43 | end 44 | 45 | private 46 | 47 | def info 48 | [ 49 | ["Build Time", @project.attr('lastBuildTime') ], 50 | ["Build Number", @project.attr('lastBuildLabel')] 51 | ] 52 | end 53 | end 54 | end 55 | 56 | puts SnapCI.new(*ARGV).latest_status.to_json if __FILE__ == $0 57 | -------------------------------------------------------------------------------- /scripts/specs/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # All gems must be installable on 1.8.7 4 | 5 | gem "rspec" 6 | gem "json" 7 | gem "webmock" 8 | 9 | # Below versions work on 1.8.7 10 | gem "nokogiri", "~> 1.10" 11 | -------------------------------------------------------------------------------- /scripts/specs/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.3.6) 5 | crack (0.4.3) 6 | safe_yaml (~> 1.0.0) 7 | diff-lcs (1.2.4) 8 | hashdiff (0.4.0) 9 | json (2.2.0) 10 | mini_portile2 (2.4.0) 11 | nokogiri (1.10.4) 12 | mini_portile2 (~> 2.4.0) 13 | rspec (2.14.1) 14 | rspec-core (~> 2.14.0) 15 | rspec-expectations (~> 2.14.0) 16 | rspec-mocks (~> 2.14.0) 17 | rspec-core (2.14.7) 18 | rspec-expectations (2.14.3) 19 | diff-lcs (>= 1.1.3, < 2.0) 20 | rspec-mocks (2.14.4) 21 | safe_yaml (1.0.5) 22 | webmock (3.5.1) 23 | addressable (>= 2.3.6) 24 | crack (>= 0.3.2) 25 | hashdiff 26 | 27 | PLATFORMS 28 | ruby 29 | 30 | DEPENDENCIES 31 | json 32 | nokogiri (~> 1.10) 33 | rspec 34 | webmock 35 | 36 | BUNDLED WITH 37 | 1.17.3 38 | -------------------------------------------------------------------------------- /scripts/specs/buildkite_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :Buildkite, "buildkite" do 5 | buildkite_xml = <<-XML 6 | 7 | 9 | 11 | 13 | 14 | XML 15 | 16 | before(:all) {WebMock.disable_net_connect!} 17 | after(:all) {WebMock.allow_net_connect!} 18 | 19 | before(:each) do 20 | WebMock.stub_request(:get, "https://cc.buildkite.com/myorg.xml?access_token=abcde12345&branch=master"). 21 | to_return(:status => 200, :body => buildkite_xml, :headers => {}) 22 | end 23 | 24 | context 'when using pipeline specific api' do 25 | it_returns_ok ['myorg', 'MyPipeline Successful Project', 'master', 'abcde12345'] 26 | it_returns_fail ['myorg', 'OtherPipeline Failed Project', 'master', 'abcde12345'] 27 | it_returns_changing ['myorg', 'ThirdPipeline Building Project', 'master', 'abcde12345'] 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /scripts/specs/check_shared_examples.rb: -------------------------------------------------------------------------------- 1 | module CheckSharedExamples 2 | def it_returns_ok(opts) 3 | context "when check indicates a success" do 4 | let(:opts) { opts } 5 | 6 | it "returns successful result" do 7 | subject.latest_status.as_json[:result].should == true 8 | end 9 | end 10 | end 11 | 12 | def it_returns_fail(opts) 13 | context "when check indicates a failure" do 14 | let(:opts) { opts } 15 | 16 | it "returns failure result" do 17 | subject.latest_status.as_json[:result].should == false 18 | end 19 | end 20 | end 21 | 22 | def it_returns_changing(opts) 23 | context "when check indicates changing" do 24 | let(:opts) { opts } 25 | 26 | it "returns changing result" do 27 | subject.latest_status.as_json[:changing].should == true 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /scripts/specs/circleci_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :CircleCi do 5 | pending "trial account expired" 6 | # it_returns_ok %w(dontfidget checkman ok 73e86a18efba7df5cfc5e03c4b67ff06685c5a75) 7 | # it_returns_fail %w(dontfidget checkman failing 73e86a18efba7df5cfc5e03c4b67ff06685c5a75) 8 | end 9 | -------------------------------------------------------------------------------- /scripts/specs/circlecijson_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :CircleCiJson do 5 | pending "trial account expired" 6 | # it_returns_ok %w(dontfidget checkman ok 6cadaa96f7c455a658e00dd4500adc8f654342cc) 7 | # it_returns_fail %w(dontfidget checkman failing 6cadaa96f7c455a658e00dd4500adc8f654342cc) 8 | end 9 | -------------------------------------------------------------------------------- /scripts/specs/fixtures/.flyrc: -------------------------------------------------------------------------------- 1 | targets: 2 | target-name: 3 | api: http://server.example.com 4 | team: some-git-team 5 | insecure: true 6 | token: 7 | type: Bearer 8 | value: some-token 9 | -------------------------------------------------------------------------------- /scripts/specs/semaphore_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :Semaphore do 5 | pending "trial account expired" 6 | # it_returns_ok %w(0691ba134341d1baa978436535b6f2b79fec91 27680 1iGx6asGJHk6aMdsB4eu) 7 | # it_returns_fail %w(0691ba134341d1baa978436535b6f2b79fec91 27680 1iGx6asGJHk6aMdsB4eu) 8 | end 9 | -------------------------------------------------------------------------------- /scripts/specs/site_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :Site do 5 | it_returns_ok %w(http://www.google.com) 6 | 7 | # Google's non-www version redirects to www 8 | it_returns_fail %w(http://google.com) 9 | end 10 | -------------------------------------------------------------------------------- /scripts/specs/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "check_shared_examples" 2 | 3 | def describe_check(name, file_name=name, &block) 4 | check_file = check_require(file_name.to_s.downcase) 5 | check_class = check_file.const_get(name.to_s) 6 | 7 | include CheckSharedExamples 8 | 9 | describe(check_class) do 10 | subject { described_class.new(*opts) } 11 | instance_eval(&block) 12 | end 13 | end 14 | 15 | def check_require(name) 16 | eval_require("#{name}.check") 17 | end 18 | 19 | def eval_require(file_name) 20 | ruby = file_contents(file_name) 21 | Class.new.tap do |k| 22 | k.class_eval(ruby, __FILE__, __LINE__) 23 | end 24 | end 25 | 26 | def file_contents(file_name) 27 | specs_path = File.dirname(File.expand_path(__FILE__)) 28 | file_path = File.join(specs_path, "..", file_name) 29 | contents = File.read(file_path) 30 | end 31 | 32 | require 'webmock/rspec' 33 | require "stringio" 34 | 35 | def capture_stderr 36 | old_stderr = $stderr 37 | $stderr = StringIO.new 38 | yield 39 | $stderr.string 40 | ensure 41 | $stderr = old_stderr 42 | end 43 | 44 | RSpec.configure do |config| 45 | config.around(:each) do |example| 46 | # Checks usually spit out lots of debugging info to stderr 47 | capture_stderr { example.call } 48 | end unless ENV["SHOW_STDERR"] 49 | 50 | config.before(:suite) { WebMock.allow_net_connect! } 51 | end 52 | -------------------------------------------------------------------------------- /scripts/specs/tddium_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :TddiumJob, "tddium" do 5 | pending "trial account expired" 6 | # Branches must actually be ok/failing for these tests to pass 7 | # it_returns_ok %w(4ee7ab3c716d0d0703901410dca129f85fef40eb checkman ok) 8 | # it_returns_fail %w(4ee7ab3c716d0d0703901410dca129f85fef40eb checkman failing) 9 | end 10 | -------------------------------------------------------------------------------- /scripts/specs/test_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :Test do 5 | context "when no options are provided" do 6 | let(:opts) { %w() } 7 | 8 | it "returns successful result" do 9 | subject.as_json[:result].should == true 10 | end 11 | 12 | it "returns non-changing result" do 13 | subject.as_json[:changing].should == nil 14 | end 15 | 16 | it "does not return url" do 17 | subject.as_json[:url].should be_nil 18 | end 19 | 20 | it "does not return info" do 21 | subject.as_json[:info].should be_nil 22 | end 23 | end 24 | 25 | it_returns_fail %w(fail) 26 | 27 | context "when changing option is given" do 28 | let(:opts) { %w(changing) } 29 | 30 | it "returns changing result" do 31 | subject.as_json[:changing].should == true 32 | end 33 | end 34 | 35 | context "when url option is given" do 36 | let(:opts) { %w(url) } 37 | 38 | it "returns url" do 39 | subject.as_json[:url].should match %r{http://} 40 | end 41 | end 42 | 43 | context "when info option is given" do 44 | let(:opts) { %w(info) } 45 | 46 | it "returns info" do 47 | subject.as_json[:info].should be_an(Array) 48 | end 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /scripts/specs/tracker_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :Tracker, "tracker" do 5 | it_returns_ok %w(829747 00bedcc48d3d8484e244dbad6bf8941c Checkman OK) 6 | it_returns_changing %w(829747 07ebaa44be590bf33b93a9b8c059db63 Checkman Changing) 7 | it_returns_fail %w(829747 213d9b96fa4dbd9a0cf04b3fe8b34f82 Checkman Failing) 8 | end 9 | -------------------------------------------------------------------------------- /scripts/specs/travis_spec.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require "spec_helper" 3 | 4 | describe_check :Travis do 5 | it_returns_ok %w(cppforlife checkman-travis-fixture master) 6 | it_returns_fail %w(cppforlife checkman-travis-fixture fail) 7 | end 8 | -------------------------------------------------------------------------------- /scripts/test.check: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "rubygems" 3 | require "json" 4 | 5 | # Simple testing fixture 6 | # ok: test.check 7 | # url: test.check url 8 | # info: test.check info 9 | # ok-changing: test.check changing 10 | # fail: test.check fail 11 | # fail-changing: test.check fail changing 12 | # slow: test.check slow 13 | # error: test.check error 14 | # flapping: test.check flapping 15 | 16 | class Test 17 | def initialize(*tests) 18 | @tests = tests 19 | end 20 | 21 | def has?(option, &block) 22 | if @tests.include?(option.to_s) 23 | block ? block.call : true 24 | end 25 | end 26 | 27 | def ok? 28 | if has?(:flapping) 29 | case Time.now.sec / 6 30 | when 0..3 then true 31 | when 3..6 then false 32 | else raise 33 | end 34 | else 35 | !has?(:fail) 36 | end 37 | end 38 | 39 | # Look like other checks... 40 | def latest_status 41 | self 42 | end 43 | 44 | def as_json(*) 45 | has?(:slow) { sleep 10 } 46 | has?(:error) { raise } 47 | { 48 | :result => ok?, 49 | :changing => has?(:changing), 50 | :url => has?(:url) { "http://www.google.com" }, 51 | :info => has?(:info) { [["Key", "value"]] } 52 | } 53 | end 54 | 55 | def to_json(*) 56 | JSON.dump(as_json) 57 | end 58 | end 59 | 60 | puts Test.new(*ARGV).to_json if __FILE__ == $0 61 | -------------------------------------------------------------------------------- /scripts/tracker.check: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "rubygems" 3 | require "json" 4 | require "erb" 5 | require "open-uri" 6 | 7 | class TrackerStatus 8 | def initialize(project_view) 9 | @project_view = project_view 10 | end 11 | 12 | def ok? 13 | @project_view.rejected_stories.empty? 14 | end 15 | 16 | def changing? 17 | @project_view.started_stories.empty? && \ 18 | @project_view.rejected_stories.empty? 19 | end 20 | 21 | def as_json(*) 22 | { 23 | :result => ok?, 24 | :changing => changing?, 25 | :url => @project_view.url, 26 | :info => nil 27 | } 28 | end 29 | 30 | def to_json(*) 31 | JSON.dump(as_json) 32 | end 33 | end 34 | 35 | class TrackerProjectView 36 | def initialize(project_id, stories) 37 | @project_id, @stories = project_id, stories 38 | end 39 | 40 | def started_stories; stories_marked_as(:started); end 41 | def rejected_stories; stories_marked_as(:rejected); end 42 | 43 | def url 44 | "https://pivotaltracker.com/s/projects/#{@project_id}" 45 | end 46 | 47 | 48 | private 49 | 50 | def stories_marked_as(state) 51 | @stories.select { |s| s["current_state"] == state.to_s } 52 | end 53 | end 54 | 55 | class Tracker 56 | def initialize(project_id, user_token, *user_name) 57 | @project_id, @user_token, @user_name = project_id, user_token, user_name.join(" ") 58 | end 59 | 60 | def fetch_owned_stories 61 | url = "https://pivotaltracker.com/services/v5/projects/#{@project_id}/stories?filter=owner:\"#{@user_name}\"" 62 | JSON.parse(open(url, "X-TrackerToken" => @user_token).read) 63 | end 64 | 65 | def latest_status 66 | stories = fetch_owned_stories 67 | project_view = TrackerProjectView.new(@project_id, stories) 68 | TrackerStatus.new(project_view) 69 | end 70 | end 71 | 72 | puts Tracker.new(*ARGV).latest_status.to_json if __FILE__ == $0 73 | -------------------------------------------------------------------------------- /web_ui/checks.js: -------------------------------------------------------------------------------- 1 | // require "check.js" 2 | 3 | function WebUICheckCollection(domId) { 4 | return { 5 | show: show, 6 | hide: hide, 7 | }; 8 | 9 | // Converges UI based on check's state 10 | function show(check, filter) { 11 | hide(check); 12 | 13 | if (check.isDisabled()) { 14 | return console.log( 15 | "WebUICheckCollection - show: disabled check", 16 | check.contextualName() 17 | ); 18 | } 19 | 20 | if (!check.matchesFilter(filter)) { 21 | return console.log( 22 | "WebUICheckCollection - show: filtered check", 23 | check.contextualName() 24 | ); 25 | } 26 | 27 | // Build DOM element for the check 28 | var checksEl = document.getElementById(domId); 29 | var checkDom = _checkDom(check); 30 | 31 | // Add green checks to the end of the list 32 | // and keep red/undetermined checks in the begginning 33 | if (check.isOk()) { 34 | checksEl.innerHTML += checkDom; 35 | } else { 36 | checksEl.innerHTML = checkDom + checksEl.innerHTML; 37 | } 38 | } 39 | 40 | function hide(check) { 41 | var checkEl = document.getElementById(_checkDomId(check)); 42 | if (checkEl) { 43 | checkEl.remove(); 44 | } 45 | } 46 | 47 | function _checkDom(check) { 48 | var tpl = "
$check_content_dom
"; 49 | tpl = tpl.replace("$check_dom_id", _checkDomId(check)); 50 | tpl = tpl.replace("$check_content_dom", _checkContentDom(check)); 51 | return tpl; 52 | } 53 | 54 | function _checkContentDom(check) { 55 | var tpl = "
$check_name
"; 56 | tpl = tpl.replace("$check_status", check.status()); 57 | tpl = tpl.replace("$check_changing", check.isChanging() ? "changing" : ""); 58 | tpl = tpl.replace("$check_name", check.contextualName()); 59 | return tpl; 60 | } 61 | 62 | function _checkDomId(check) { 63 | return domId + "-check-" + check.uniqueId(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /web_ui/connection.js: -------------------------------------------------------------------------------- 1 | function WebUIConnection(url, callbacks) { 2 | var socket = new WebSocket(url); 3 | console.log("WebUIConnection - connecting:", url); 4 | 5 | socket.onopen = function() 6 | { console.log("WebUIConnection - open"); }; 7 | socket.onerror = function(error) 8 | { console.log("WebUIConnection - error:", error); } 9 | 10 | var _lastMessageReceivedAt = null; 11 | 12 | socket.onmessage = function(msg) { 13 | var parsedMsg = JSON.parse(msg.data); 14 | if (parsedMsg.type && callbacks[parsedMsg.type]) { 15 | _lastMessageReceivedAt = Date.now(); 16 | callbacks[parsedMsg.type](parsedMsg); 17 | } else { 18 | console.log("WebUIConnection - unhandled:", msg); 19 | } 20 | }; 21 | 22 | return { 23 | secsSinceLastMessageReceived: secsSinceLastMessageReceived 24 | }; 25 | 26 | function secsSinceLastMessageReceived() { 27 | if (_lastMessageReceivedAt) { 28 | return (Date.now() - _lastMessageReceivedAt) / 1000; 29 | } else { 30 | return null; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /web_ui/heart_beat.js: -------------------------------------------------------------------------------- 1 | function WebUIHeartBeat(domId, callbacks) { 2 | var _lastReceivedAt = null; 3 | var _timeoutError = null; 4 | var _died = false; 5 | 6 | // Schedule one initially in case 7 | // we never receive a single beat. 8 | _scheduleTimeoutError(); 9 | 10 | return { 11 | beat: beat 12 | }; 13 | 14 | function beat(msg) { 15 | _lastReceivedAt = new Date(); 16 | _updateStats(msg); 17 | _scheduleTimeoutError(); 18 | if (_died) _onLive(); 19 | } 20 | 21 | function _scheduleTimeoutError() { 22 | if (_timeoutError) clearTimeout(_timeoutError); 23 | _timeoutError = setTimeout(_onDead, 10 * 1000); 24 | } 25 | 26 | function _onLive() { 27 | console.log("WebUIHeartBeat - onLive"); 28 | _died = false; 29 | if (callbacks.live) callbacks.live(); 30 | } 31 | 32 | function _onDead() { 33 | console.log("WebUIHeartBeat - onDead"); 34 | _died = true; 35 | if (callbacks.dead) callbacks.dead(); 36 | } 37 | 38 | function _updateStats(msg) { 39 | var text = 40 | msg.total_checks_count 41 | + " total checks
" 42 | + msg.disabled_checks_count 43 | + " disabled checks
@ " 44 | + _formattedLastReceivedAt(); 45 | document.getElementById(domId).innerHTML = text; 46 | } 47 | 48 | function _formattedLastReceivedAt() { 49 | if (_lastReceivedAt) { 50 | return _lastReceivedAt.toLocaleTimeString(); 51 | } else { 52 | return "?"; 53 | } 54 | } 55 | } 56 | 57 | function WebUIHeartBeatOverlay(domId) { 58 | return { 59 | show: show, 60 | hide: hide 61 | }; 62 | 63 | function show() { 64 | var el = document.getElementById(domId); 65 | el.setAttribute("data-show", "true"); 66 | } 67 | 68 | function hide() { 69 | var el = document.getElementById(domId); 70 | el.removeAttribute("data-show"); 71 | } 72 | } 73 | 74 | function WebUILastUpdated(domId, getSecs) { 75 | var timer = setInterval(function() { 76 | var secs = getSecs(); 77 | var secsText = (secs ? secs : "?") + "s ago"; 78 | document.getElementById(domId).innerHTML = secsText; 79 | }, 2000); 80 | 81 | return {}; 82 | } 83 | -------------------------------------------------------------------------------- /web_ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 |
10 | 11 |
12 | 13 |
14 | 15 |
16 | 17 |
18 | 19 |
20 | 21 |

Lost connection

22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /web_ui/ui.js: -------------------------------------------------------------------------------- 1 | // require "connection.js" 2 | // require "heart_beat.js" 3 | // require "checks.js" 4 | // require "check.js" 5 | 6 | function WebUI(connectionUrl, checkFilter, domIds) { 7 | var checks = WebUICheckCollection(domIds.checks); 8 | 9 | var heartBeatOverlay = 10 | WebUIHeartBeatOverlay(domIds.heartBeatOverlay); 11 | 12 | // Make sure every so often that proper number 13 | // of checks are presented; otherwise, alert the viewer 14 | var heartBeat = WebUIHeartBeat(domIds.heartBeat, { 15 | "live": function() { heartBeatOverlay.hide(); }, 16 | "dead": function() { heartBeatOverlay.show(); } 17 | }); 18 | 19 | // Respond to events received from Checkman app 20 | var connection = WebUIConnection(connectionUrl, { 21 | "check.show": function(msg) { checks.show(WebUICheck(msg), checkFilter); }, 22 | "check.hide": function(msg) { checks.hide(WebUICheck(msg)); }, 23 | "heartbeat": heartBeat.beat 24 | }); 25 | 26 | // Present heart beat information 27 | var lastUpdated = WebUILastUpdated(domIds.lastUpdated, function() { 28 | return connection.secsSinceLastMessageReceived(); 29 | }); 30 | 31 | return {}; 32 | } 33 | 34 | function WebUIPageLocation(location) { 35 | return { 36 | connectionUrl: connectionUrl, 37 | checkFilter: checkFilter 38 | } 39 | 40 | function connectionUrl() { 41 | var url = "ws://" + location.host + "/check_updates"; 42 | console.log("WebUIPageLocation - connectionUrl", url); 43 | return url; 44 | } 45 | 46 | function checkFilter() { 47 | var filter = parseQueryString()["filter"] || "*"; 48 | console.log("WebUIPageLocation - checkFilter", filter); 49 | return filter; 50 | } 51 | 52 | function parseQueryString() { 53 | var query = location.search.substr(1); // remove '?' 54 | var data = query.split("&"); 55 | var result = {}; 56 | for (var i=0; i