https://github.com/folkengine/harshed
Ruby Serializable Hashed Array Utility
https://github.com/folkengine/harshed
Last synced: 20 days ago
JSON representation
Ruby Serializable Hashed Array Utility
- Host: GitHub
- URL: https://github.com/folkengine/harshed
- Owner: folkengine
- License: mit
- Created: 2016-04-18T01:57:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-30T19:05:31.000Z (over 9 years ago)
- Last Synced: 2025-03-04T08:02:45.730Z (10 months ago)
- Language: Ruby
- Size: 31.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Harshed
[](https://badge.fury.io/rb/harshed)
[](https://travis-ci.org/folkengine/harshed)
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](https://agilewarrior.wordpress.com/2015/04/18/classical-vs-mockist-testing/). Harshed helps with that.
You can an early version of Harshed in action over @ my [DX-EverCraft repo](https://github.com/folkengine/dx_evercraft).
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:
```ruby
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.