Swiftpack.co - junkpiano/scientist as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by junkpiano.
junkpiano/scientist 0.4.0
A Swift library for carefully refactoring critical paths.
⭐️ 13
🕓 1 week ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/junkpiano/scientist.git", from: "0.4.0")

Scientist

CocoaPods Carthage Build Status codecov

A Swift library for carefully refactoring critical paths.

Installation

Cocoapods

pod 'Scientist', '~> 0.4.0'

Carthage

github "junkpiano/scientist" ~> 0.4.0

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/junkpiano/scientist.git", from: "0.4.0")
]

Usage

    func allow(user: User) -> Bool {
      do {
        return try Scienctist<Bool>().science({
          experiment in
          // required to enable Experiment
          experiment.enabled = { return true }

          // alternatively, you can use A/B test-like logic.
          experiment.enabled = {
            return Int(arc4random_uniform(6) + 1) % 3 == 0
          }

          experiment.publish = { result in
            // do something to publish Result data.
            // send to your log server(Graphite, InfluxDB, etc.), or 3rd party logger like NewRelic, Firebase.
          }

          experiment.use {
            return module.check_user(user)
          }

          experiment.tryNew {
            return user.allowed
          }
        })
      } catch {
        return false
      }
    }

Full Documentation is available Here.

Development

Simply,

open Scientist.xcodeproj

please run test before you send pull request

swift test

Porting from

Author

GitHub

link
Stars: 13
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.4.0
1 week ago

Fixes

  • updated the overall project for Swift 5.
  • supported swift versions are 5.3, 5.4, and 5.5.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics