README.md in to_collection-2.0.0 vs README.md in to_collection-2.0.1
- old
+ new
@@ -1,16 +1,18 @@
-# ToCollection 2.0.0 Ruby Refinement
+# ToCollection 2.0.1 Ruby Refinement
[![Gem Version](https://badge.fury.io/rb/to_collection.svg)](http://badge.fury.io/rb/to_collection)
[![Build Status](https://travis-ci.org/AndyObtiva/to_collection.svg?branch=master)](https://travis-ci.org/AndyObtiva/to_collection)
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/to_collection/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/to_collection?branch=master)
Treat an array of objects and a singular object uniformly as a collection of objects.
Especially useful in processing REST Web Service API JSON responses in a uniform functional approach.
`ToCollection` is a Ruby Refinement, so it may be safely enabled via `using ToCollection` where needed only.
+Now also supports [Opal Ruby](https://opalrb.com) by degrading gracefully to monkey-patching.
+
## Introduction
Canonicalize data to treat uniformly whether it comes in as a single object or an array of objects, dropping `nils` out automatically.
API: `object#to_collection(compact=true)` where `compact` is a boolean for whether to compact collection or not. It is true by default.
@@ -42,24 +44,30 @@
## Instructions
### Bundler
-- Add `gem 'to_collection', '~> 2.0.0'` to Gemfile
+- Add `gem 'to_collection', '~> 2.0.1'` to Gemfile
- Run `bundle`
- Require `to_collection` ruby gem in code (e.g. via `Bundler.require(:default)` or `require 'bundler/setup'` & `require 'to_collection'`)
- Add `using ToCollection` to the top of the Ruby file you would like to refine `Object` in with `#to_collection` method.
### Manual Gem Install
-- Run `gem install to_collection -v2.0.0`
+- Run `gem install to_collection -v2.0.1`
- Add `require 'to_collection'` to code
- Add `using ToCollection` to the top of the Ruby file you would like to refine `Object` in with `#to_collection` method.
+### Opal Ruby
+
+- Follow the first step in [Bundler](#bundler) or [Manual Gem Install](#manual-gem-install) instructions to add the gem.
+- Add Opal.use_gem 'to_collection' to "config/initializers/assets.rb" in Rails unless using as part of another gem.
+- Add `require 'to_collection'` to code (this adds the functionality via monkey-patching not refinements in [Opal](https://opalrb.com))
+
### Note
-If '#to_collection' was already defined on `Object` in a project, requiring the `to_collection` library will print a warning.
+If '#to_collection' was already defined on `Object` in a project, requiring the `to_collection` library will print a warning.
It is still safe to require as it does not overwrite `Object#to_collection` except in Ruby files where `using ToCollection` is added.
## Background
@@ -259,25 +267,17 @@
You asked for "Elegant" didn't you? I hope that was what you were looking for.
## How It Works
-A Ruby Refinement is activated via `using ToCollection` adding/overwriting the `#to_collection` method in `Object`, which
+A Ruby Refinement is activated via `using ToCollection` adding/overwriting the `#to_collection` method in `Object`, which
is the ancestor of all Ruby objects.
-## Release Notes
+## Change Log
-### v2.0.0
+[CHANGELOG.md](CHANGELOG.md)
-- Revamped API using Ruby Refinements (safer than monkey-patching)
-- Removed `super_module` gem dependency
-- Dropped safety options since Ruby Refinements already handle things safely
-
-### v1.0.1
-
-- Updated `super_module` gem version to relax indirect `method_source` gem version dependency
-
## Contributing
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
* Fork the project.
@@ -288,7 +288,8 @@
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. Also, do not upgrade `jeweler`. It is intentionally at an old version that is compatible with running tests in Travis with older verison of Ruby as well as supporting Coveralls, Simplecov, and Code Climate.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
## Copyright
-Copyright (c) 2017-2020 Andy Maleh. See LICENSE.txt for
-further details.
+[MIT](LICENSE.txt)
+
+Copyright (c) 2017-2020 Andy Maleh.