Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonathanhefner/mini_sanity
In-line sanity checks in Ruby
https://github.com/jonathanhefner/mini_sanity
assertions ruby sanity-check utility
Last synced: 7 days ago
JSON representation
In-line sanity checks in Ruby
- Host: GitHub
- URL: https://github.com/jonathanhefner/mini_sanity
- Owner: jonathanhefner
- License: mit
- Created: 2017-08-26T17:43:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-18T21:01:50.000Z (over 1 year ago)
- Last Synced: 2024-10-09T13:09:15.503Z (29 days ago)
- Topics: assertions, ruby, sanity-check, utility
- Language: Ruby
- Homepage:
- Size: 69.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# mini_sanity
In-line [sanity checks], written as extensions to core Ruby objects.
See API listing below, or browse the [full documentation].[sanity checks]: https://en.wikipedia.org/wiki/Sanity_check
[full documentation]: https://www.rubydoc.info/gems/mini_sanity/## Example
```ruby
require "json"
require "pathname"path = Pathname.new("hosted_files.json").assert!(&:exist?)
hosted_files = JSON.parse(path.read).assert!(Array)
urls = hosted_files.flat_map do |file_info|
file_info.fetch("mirror_urls").refute!(&:empty?)
enddomains = urls.map do |url|
url.assert!(%r"^https?://").split("/")[2]
end.uniq
```## API
- `"mini_sanity/assert"`
- [Object#assert!](https://www.rubydoc.info/gems/mini_sanity/Object:assert%21)
- [Object#refute!](https://www.rubydoc.info/gems/mini_sanity/Object:refute%21)
- `"mini_sanity/change"`
- [String#change](https://www.rubydoc.info/gems/mini_sanity/String:change)
- [String#change!](https://www.rubydoc.info/gems/mini_sanity/String:change%21)
- `"mini_sanity/match"`
- [Regexp#match!](https://www.rubydoc.info/gems/mini_sanity/Regexp:match%21)
- [String#match!](https://www.rubydoc.info/gems/mini_sanity/String:match%21)
- `"mini_sanity/results"`
- [Enumerator#result!](https://www.rubydoc.info/gems/mini_sanity/Enumerator:result%21)
- [Enumerator#results!](https://www.rubydoc.info/gems/mini_sanity/Enumerator:results%21)## Installation
Install the [`mini_sanity` gem](https://rubygems.org/gems/mini_sanity).
## Contributing
Run `rake test` to run the tests.
## License
[MIT License](LICENSE.txt)