mini_sanity

In-line sanity checks, written as extensions to core Ruby objects. See API listing below, or browse the full documentation.

Example

require "json"
require "pathname"

path = Pathname.new("hosted_files.json").assert_exist!

hosted_files = JSON.parse(path.read).assert_instance_of!(Array)

urls = hosted_files.flat_map do |file_info|
  file_info.fetch("mirror_urls").refute_empty!
end

domains = urls.map do |url|
  url.assert_match!(%r"^https?://").split("/")[2]
end.uniq

API

Util API

mini_sanity also includes a few optional utility methods which perform some function, check an assertion on the result, and raise an error with a helpful message if the assertion fails. You must add require "mini_sanity/util" to your script to access these methods.

Installation

Install from Ruby Gems:

$ gem install mini_sanity

Then require in your Ruby script:

require "mini_sanity"
require "mini_sanity/util" # OPTIONAL

Contributing

Run rake test to run the tests. You can also run rake irb for an interactive prompt that pre-loads the project code.

License

MIT License