Scientist 0.4.0

Scientist 0.4.0

Yusuke Ohashi维护。



Scientist 0.4.0

  • Yusuke Ohashi

Scientist

CocoaPods Carthage Build Status codecov

一个用于精心重构关键路径的Swift库。

安装

CocoaPods

pod 'Scientist', '~> 0.4.0'

Carthage

github "junkpiano/scientist" ~> 0.4.0

Swift包管理器

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

用法

    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
      }
    }

完整文档可在此处找到。

开发

简单来说

打开 Scientist.xcodeproj

在提交 pull request 之前请先运行测试

swift test

迁移自

作者