New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

crnixon-active_files

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crnixon-active_files

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= ActiveFiles

by Clinton R. Nixon

URL: http://github.com/crnixon/active_files

== Description

This library attempts to implement an ActiveRecord-like interface to a directory structure of flat files containing serialized objects, probably in YAML.

== Features/problems

  • Serializes any object
  • No validations yet

== Requirements

To run tests, you need the spect and Shoulda gems.

== Synopsis

ActiveFiles.base_dir = '/tmp/af'

class Person < Hash
  include ActiveFiles::Record
  add_file_id_to_initialize
end

class Wingdom
  include ActiveFiles::Record

  attr_reader :feathers, :color

  def initialize(id, feathers, color)
    self.file_id = id
    @feathers = feathers
    @color = color
  end

  def to_activefile
    { :plumoj => @feathers.to_s.split(//).reverse,
      :koloro => [@color, @color, @color].join('\/') }.to_yaml.reverse
  end

  def self.from_activefile(yaml, file_id)
    hash = YAML::load(yaml.reverse)
    feathers = hash[:plumoj].reverse.inject("") { |s, c| s << c }.to_i
    color = hash[:koloro].split('\/')[1]
    Wingdom.new(file_id, feathers, color)
  end
end

herbert = Person.new('herbert')
herbert['address'] = '103 Choctaw Dr'
herbert['birthday'] = Date.parse('2/4/1979')
herbert.save

also_herbert = Person.find("herbert")
also_herbert = Person.find(:first, "herb*")
herbs = Person.find("herb*")
herbs = Person.find(:all, "herb*")

== License

(ISC License)

Copyright (c) 2008 Clinton R. Nixon of Viget Labs

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc