Giter VIP home page Giter VIP logo

rosterdev's Introduction

rosterdev

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

rosterdev is available through CocoaPods. To install it, add the following line to your Podfile:

pod 'rosterdev', '~> 0.1'

The intent is that these developer functions will only be available in debug builds of your app. To accomplish this in Swift, create a DEBUG OTHER_SWIFT_FLAGS for your debug build.

In your code, do:

import rosterdev

You will also need to enable the developer dashboard to be displayed. One way to do this is via a shake gesture. See the example here:

#if DEBUG
extension UIWindow {
    override open func motionBegan(_ motion: UIEventSubtype, with event: UIEvent?) {
        if motion == .motionShake {
            if let rootVC = UIApplication.shared.keyWindow?.rootViewController {
                RosterDevVC.show(fromViewController: rootVC, rowContents: [], options: .all)
            }
        }
    }
}
#endif

In the above example, if you want to put additional rows of your own design into the developer dashboard, you'll need to provide a non-empty list to the rowContents: parameter.

The class DebugDashboardData in the Example code provides an example of this:

class DebugDashboardData {
    private init() {
    }
    
    static let session = DebugDashboardData()
    
    var debugDashboardExampleSection: [RosterDevRowContents] = {
        var useDev = RosterDevRowContents(name: "Use staging environment", action: { parentVC in
            // Need to do something to setup staging environment
        })
        var useProd = RosterDevRowContents(name: "Use prod environment", action: { parentVC in
            // Need to do something to setup prod environment
        })
        
        return [useDev, useProd]
    }()
    
    func sections() -> [[RosterDevRowContents]] {
        return [debugDashboardExampleSection]
    }
}

To use this class, use DebugDashboardData.session.sections() for the rowContents parameter of RosterDevVC.show.

If you are doing test injection, you will need:

#if DEBUG
    TestCases.setup()
#endif

in your AppDelegate. See the example here:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
#if DEBUG
    TestCases.setup()
#endif
        return true
    }

Where TestCases looks something like:

import Foundation
import rosterdev

class TestCases {
    private init() {
    }
    
    static let session = TestCases()
    
    static func setup() {
        _ = session
    }
    
    // Make these text names fairly short. They are presented in a UI.
    
    let testFail1 = RosterDevInjectTest.define(testCaseName: "Endpoint1Failure")
    let testFail2 = RosterDevInjectTest.define(testCaseName: "Endpoint2Failure")
    ...
}

You will also need, of course, to inject some actual tests in your code. For example, this would look something like:

RosterDevInjectTest.if(TestCases.session.testFail1) {
    // This will only get executed if the DEBUG flag is set AND testFail1 is turned on from the developer dashboard.
    // So, do whatever test injection you need to do here.
}

Author

crspybits, [email protected]

License

rosterdev is available under the MIT license. See the LICENSE file for more info.

rosterdev's People

Contributors

crspybits avatar

Watchers

James Cloos avatar Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.