Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

uklibraries/pairtree

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(r)pairtree

Ruby implementation of the Pairtree specification from the California Digital Library.

Description

A fork of the seemingly-abandoned pairtree.

Installation

Add this line to your application's Gemfile:

gem 'rpairtree'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rpairtree

Usage

  require 'pairtree' # You'll need to do this in rails, as it won't find it automatically.

  # Initiate a tree
  pairtree = Pairtree.at('./data', :prefix => 'pfx:', :create => true)
  
  # Create a ppath
  obj = pairtree.mk('pfx:abc123def')
  
  # Access an existing ppath
  obj = pairtree['pfx:abc123def']
  obj = pairtree.get('pfx:abc123def')
  
  # ppaths are Dir instances with some File and Dir class methods mixed in
  obj.read('content.xml')
  => "<content/>"
  obj.open('my_file.txt','w') { |io| io.write("Write text to file") }
  obj.entries
  => ["content.xml","my_file.txt"]
  obj['*.xml']
  => ["content.xml"]
  obj.each { |file| ... }
  obj.unlink('my_file.txt')
  
  # Delete a ppath and all its contents
  pairtree.purge!('pfx:abc123def')

About

Ruby Pairtree client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%