0.01
No commit activity in last 3 years
No release in over 3 years
This library has Active Record like interface. Use pstore to store data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Active PStore Build Status Code Climate Test Coverage Gem Version git.legal

This library has Active Record like interface. Use pstore to store data.

SYNOPSIS

specify data store path

require 'active_pstore'

ActivePStore::Base.establish_connection(database: '/path/to/file')

class definition

class Artist < ActivePStore::Base
  attr_accessor :name
end

instantiate

randy_rhoads = Artist.new(name: 'Randy Rhoads')

or

randy_rhoads = Artist.new {|a|
  a.name = 'Randy Rhoads'
}

ActivePStore::Base.build method the same as ActivePStore::Base.new method.

save

randy_rhoads.save

database key is string of class name.

Artist.table_name # => 'Artist'

ex) Fetch stored artist objects by pure PStore.

database = PStore.new('/path/to/file')
database.transaction {|db| artist = db['Artist'] } # fetch instances of Artist class.

identifier

allocate value of ActivePStore::Base#id using SecureRandom.hex.

randy_rhoads = Artist.new(name: 'Randy Rhoads')
randy_rhoads.id # => nil

randy_rhoads.save
randy_rhoads.id # => "0b84ece5d5be3bce3ee2101c1c4f6fda"

instantiate with save

randy_rhoads = Artist.create(name: 'Randy Rhoads')

or

randy_rhoads = Artist.create {|a|
  a.name = 'Randy Rhoads'
}

find series

Artist.all
Artist.first
Artist.last
Artist.find('388980778246cbcbfcbb7a8292f28c37') # ActivePStore::Base#id is an SecureRandom.hex value
Artist.where(name: 'Randy Rhoads')

Range

Artist.where(birth_date: Date.new(1948, 12, 3)..Date.new(1956, 12, 6))

see spec codes for more information.

Integration with Rails

This library has following generators.

Generate config file

Execute these lines in your Rails application directory:

bundle exec rails g active_pstore:config

And then create config/active_pstore.yml

Using the config/database.yml file you can specify all the information needed to access your pstore database:

development:
  database: db/active_pstore_development.yml

Generate model file

Execute these lines in your Rails application directory:

bundle exec rails g active_pstore:model artist name associated_act instrument birth_date

And then create app/models/artist.rb

class Artist < ActivePStore::Base
  attr_accessor :name
  attr_accessor :associated_act
  attr_accessor :instrument
  attr_accessor :birth_date
end

REQUIREMENTS

INSTALL

Add these lines to your application's Gemfile:

gem 'active_pstore'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_pstore

And require it as:

require 'active_pstore'

Problems

  • Transaction NOT supported (caused by implementation)
  • Data Migration NOT supported
  • Performance (caused by implementation)
  • and Not solving the root cause for enterprise...

Presentation Document

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Active PStore is released under the MIT License.