Project

harshed

0.0
No commit activity in last 3 years
No release in over 3 years
Utility to quickly save and retrieve objects from disk
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.7.6
~> 10.0

Runtime

>= 0.0.2
 Project Readme

Harshed

Gem Version Build Status

Ruby Serializable Hashed Array Utility

A Harsh is a hashed array that can be quickly written to and read from disk in a format that can be easily reviewed. Take a collection of same type objects. Pick a pivot point, aka, a field unique to each object that can be used as the key for the hash.

I wrote this module to support development/testing techniques that I've grown use to. As a developer I am squarely in the classical, anti-mockist camp. Harshed helps with that. You can an early version of Harshed in action over @ my DX-EverCraft repo.

Eventually, I'd like to update this module to support the following features:

  1. Support for JSON
  2. Support for XML
  3. Ability to pivot on a field not in the object being serialized.
  4. Harshed DB support
  5. Deal with the sure to be their defect of spaces on the pivot field

Installation

Add this line to your application's Gemfile:

gem 'harshed'

And then execute:

$> bundle

Or install it yourself as:

$> gem install harshed

Usage

  class Character
    attr_reader :character_name, :strength, :dexterity, :constitution, :wisdom, :intelligence, :charisma

    def initialize(character_name)
      @character_name = character_name
      @strength = 10
      @dexterity = 10
      @constitution = 10
      @wisdom = 10
      @intelligence = 10
      @charisma = 10
    end
  end
  
  @heroes = Harshed::Harsh.new(:character_name, storage_folder: 'characters')
  
  sir_fumblealot = Character.new('SirFumbleAlot')
  stinky = Character.new('StinkyTheBeggar')
  
  @heroes.store([sir_fumblealot, stinky])
  
  @heroes.to_disk
  
  @heroes_reborn = Harshed::Harsh.new(:character_name, storage_folder: 'characters')
                       .from_disk

Development

To run tests:

$> rake 

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/folkengine/harshed.