No commit activity in last 3 years
No release in over 3 years
Recursively search enumerable objects for a given object or string.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
 Project Readme

EnumerableDeepSearch

Recursively searches enumerable objects and their nested objects for a given object or string.

Build Status Code Climate

Installation

Add this line to your application's Gemfile:

gem 'enumerable_deep_search'

And then execute:

$ bundle

Or install it yourself as:

$ gem install enumerable_deep_search

Usage

In practice it's an exploration tool, I recommend using it with Pry and extending objects as needed. You can also include it on a class and all the instances will inherit the functionality.

Personally I've found this the most useful for searching web apis converted from XML and JSON into Ruby objects. Its useful on any large nested data, such as configuration structures dumped from YAML files.

example:

object.extend EnumerableDeepSearch
object.search 'something'

It will return a facimile of the path to the matching object, for hash-like objects it will return a Hash containing the match as well as the opposite pair (either the key or the value), for array-like objects it will return a two element Array where the first element is the index of the match and second element the match itself.

example:

object.search 'something'
#=> {:foo => [1, 'something']}

Ideas? Complaints?

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request