Project

traipse

0.0
No commit activity in last 3 years
No release in over 3 years
Traipse is a library that allows you to address a data structure of Hashes & Arrays using a dot notated string & wildcards. ex: 'categories.*.name'. Like X-Path but dumber.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Traipse¶ ↑

Traipse allows you to address a data structure with a dot notated string. This is useful for extracting certain nodes in a data structure (expecially JSON-parsed) and storing the ‘path’ to those nodes in a database.

Installation¶ ↑

Traipse is available as a RubyGem:

gem install traipse

Example¶ ↑

data = {
  "name" => "Percival",
  "board" => {
    "name" => "cats"
  },
  "categories" => [
    { "name" => "animals" },
    { "name" => "kitties" },
    { "name" => "robots" },    
  ]
}

Traipse.find( data, 'name' ) # [ "Percival" ]
Traipse.find( data, 'board.name' ) # [ "cats" ]
Traipse.find( data, 'categories.name' ) # [ "animals", "kitties", "robots" ]
Traipse.find( data, '*.name' ) # [ "cats", "animals", "kitties", "robots" ]

Authors¶ ↑

  • Pawel Szymczykowski