<commit_before># Trither

Very simple implementations of Try, Either, and Option inspired by Scala


## Installation

Add this line to your application's Gemfile:

```ruby
gem 'trither'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install trither


## Usage

```ruby
require 'trither'

try = Try::Success.new('data')
another_try = try.flat_map do |data|
  do_something_and_return_a_try(data)
end
a_3rd_try = try.map do |data|
  do_something_and_return_new_data(data)
end
result = a_3rd_try.get_or_else do |error|
  handle_error(error)
end

either = Either::Right.new('data')
  .right_map { |right_data| do_righty_stuff(data) }
  .left_map { |left_data| do_lefty_stuff(left_data) }

if either.right?
  do_something(either.right)
else
  do_something_else(either.left)
end

# returns 'fail'
Option.make(nil).map { |s| s + ' world' }.fetch('fail')
# returns 'hello world'
Option.make('hello').map { |s| s + ' world' }.fetch('fail')
```


## Development

After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lj-ditrapani/trither.


## License
<commit_msg>Fix usage documentation typos<commit_after># Trither

Very simple implementations of Try, Either, and Option inspired by Scala


## Installation

Add this line to your application's Gemfile:

```ruby
gem 'trither'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install trither


## Usage

```ruby
require 'trither'

try = Try::Success.new('data')
another_try = try.flat_map do |data|
  do_something_and_return_a_try(data)
end
a_3rd_try = another_try.map do |data|
  do_something_and_return_new_data(data)
end
result = a_3rd_try.get_or_else do |error|
  handle_error(error)
end

either = Either::Right.new('data')
  .right_map { |right_data| do_righty_stuff(right_data) }
  .left_map { |left_data| do_lefty_stuff(left_data) }

if either.right?
  do_something(either.right)
else
  do_something_else(either.left)
end

# returns 'fail'
Option.make(nil).map { |s| s + ' world' }.fetch('fail')
# returns 'hello world'
Option.make('hello').map { |s| s + ' world' }.fetch('fail')
```


## Development

After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lj-ditrapani/trither.


## License

{'fraction_non_alphanumeric': 0.11230964467005077, 'fraction_numerical': 0.0012690355329949238, 'mean_word_length': 4.610320284697509, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1581670', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1036, 'n_words': 351}