Project

empirical

0.0
No release in over 3 years
There's a lot of open issues
Based on, concerned with, or verifiable by observation or experience rather than theory or pure logic.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

Empirical

(adjective) based on what is experienced or seen rather than on theory (noun) enhancements for Ruby with a runtime type system

Empirical catches bugs early and makes your code self-documenting by enhancing Ruby with beautiful syntax to define runtime type assertions.

fun word_frequency(text: String) => _Hash(String, Integer) do
  text
    .downcase
    .scan(/\w+/)
    .tally
    .sort_by { |word, count| -count }
    .first(10)
    .to_h
end

(see below).

Setup

Install the gem by adding it to your Gemfile and running bundle install. You’ll probably want to set it to require: false here because you should require it manually at precisely the right moment.

gem "empirical", require: false

Now the gem is installed, you should require and initialize the gem as early as possible in your boot process. Ideally, this should be right after Bootsnap is set up. In Rails, this will be in your boot.rb file.

require "empirical"

You can pass an array of globs to Empirical.init as include: and exclude:

Empirical.init(include: ["#{Dir.pwd}/**/*"], exclude: ["#{Dir.pwd}/vendor/**/*"])