• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    Ruby
  • License
    Do What The F*ck ...
  • Created over 9 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Git as a KV store in Ruby

Gkv

Join the chat at https://gitter.im/ybur-yug/gkv Gem Version Build Status

Gkv is a simple git wrapper that allows you to use it as a kv store

proof in our pudding

The documentation says thats what it does. So why not yo?

Installation

Add this line to your application's Gemfile:

gem 'gkv'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gkv

API

Types are implicitly understood, and are automatically set/loaded. Only symbols are excluded. There are 4 main functions:

Set

db[key] = value

db = Gkv::Database.new
db['Pants'] = 'red leather'
# => 'red leather'

This allows a shorthand notation using operator overloading to set without invoking set directly.

set(key, value)

db = Gkv::Database.new
db.set('key', '12')
# => 'key'
db.set('test', 12)
# => 'test'

Get

db[key]

db = Gkv::Database.new
db['Pants']
# => 'red leather'

This allows a shorthand notation using operator overloading to get without invoking get directly.

get(key)

db = Gkv::Database.new
db.set('apples', '10')
# => 'apples'
db.get('apples')
# => '10'

The type is inferred from when you initially set the value. Note that saving the string '1' will return the integer 1 due to the naive nature of the implementation. Hashes, arrays and booleans behave as expected when saved.

Get Version

get_version(version, key)

db = Gkv::Database.new
db.set('apples', '20')
# => 'apples'
db.set('apples', '50')
# => 'apples'
db.get_version(1, 'apples')
# => '20'
db.get_version(2, 'apples')
# => '50'

All

all

db.set('apples', 20.0)
db.set('ants',   'pants')
db.set('things', {})
db.all
# =>[{ 'apples': 20.0 }, { 'ants': 'pants'}, { 'things': {} }]

all_versions(key)

db.set('apples', 5)
db.set('apples', 'pants')
db.set('apples', 5.0)
db.all_versions('apples')
# => [ 5, 'pants', 5.0]

Destroy

db.set('apples', 20.0)
db.set('ants',   'pants')
db.set('things', {})
db.destroy!
db['apples']
# => KeyError
db['ants']
# => KeyError
db['things']
# => KeyError

Usage

db = Gkv::Database.new

db.set('Apples', '10')
# => 'Apples'
db.get('Apples')
# => '10'

# update some values
db.set('Apples', '12')
# => 'Apples'
db.get('Apples')
# => '12'
db.get_version(1, 'Apples')
#=> '10'

# keys that do not exist return KeyError
db.get('magic')
# => KeyError

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

It is a typical bundle install to get things running. We use Guard for testing. To initialize it simply run

$ guard

And you will be good to go!

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Dev Roadmap

0.3

  • Remote synchronization & Backup []
  • Persistance & Dump Loading [x]
  • Stop wrapping git via it's CLI []

Contributing

Feel free to check out the gitter room and ask whats on the agenda.

Bug reports and pull requests are welcome on GitHub at https://github.com/ybur-yug/gkv.

License

See this.

More Repositories

1

python_ocr_tutorial

This is a tutorial on getting OCR running on a simple web server, using python, flask, tesseract-ocr, and leptonica
CSS
253
star
2

genstage_tutorial

A tutorial diving into GenStage building a task-runner in the vein of DelayedJob inspired by @josevalim's talk at the Elixir London Meetup & a lesson proposal for [Elixir School](http://elixirschool.com)
Elixir
33
star
3

volt_tutorial

An introduction to Volt, and isomorphic application development with Ruby
Ruby
30
star
4

git_kv_store_tutorial

exploring git
10
star
5

volt_task_example

an example of rick carlino's volt task screencast
Ruby
7
star
6

volt-d3

D3.js for Volt
Ruby
6
star
7

nerd_apis

An unofficial collection of API's for nerdy sites
Ruby
6
star
8

all_about_iex

I wanted to explore IEx, so I did.
Elixir
3
star
9

hobos

A utility to retrieve Hobo names
Ruby
3
star
10

elixir_koans

Elixir Koans. WIP.
Elixir
1
star
11

elixirdaze-api-demo

Elixir
1
star
12

ruby_tutorial-zero-to-advanced

A Dive into Ruby starting at 0 and going up through advanced topics
Ruby
1
star
13

barfoo

JavaScript
1
star
14

volt-card

card.js for Volt --- beautiful and simple credit card forms with support for all major vendors in 1 LOC
JavaScript
1
star
15

getting_started_with_volt

From 0 to a Hello World application
Ruby
1
star
16

genserver_periodic_worker_example

Elixir
1
star
17

youTV

youtube TV-like viewer that constantly loops videos based off a search term and allows skipping
JavaScript
1
star
18

volt-packjs

A gem to automatically grab, minify, and add a JS lib to a Volt app's assets.
Ruby
1
star
19

elixir_streams_exercise-github

API using streams to interface w/the github API, based on http://justincalleja.com/2016/01/26/elixir-streams-reload/?utm_campaign=elixir_radar_35&utm_medium=email&utm_source=RD+Station
Elixir
1
star
20

amazon_price_check

Checks prices on amazon and returns a hash or CSV through a simple web client that intakes a list of descriptions or UPC's
CSS
1
star
21

speedreaderjs

A speed reader application written using the windows jquery extension and preloaded with a book, or you can read your own copypasta of some sort.
JavaScript
1
star