= Keymap
{}[http://travis-ci.org/rbuck/keymap]
{}[https://gemnasium.com/rbuck/keymap]
{}[https://codeclimate.com/github/rbuck/keymap]
Helping Ruby developers and their companies, unlock their key-value store data,
through associative and sequential based access, providing unprecedented support
for map reduce behaviors, native to the Ruby language.
Keymap provides a natural Ruby integration with NoSQL database, allowing direct
use of Enumerable operations on returned values (implying returned values are
always lists or hashes, or are manipulated to be represented in these forms).
== Installation
Add this line to your application's Gemfile:
gem 'keymap'
And then execute:
$ bundle
Or install it yourself as:
$ gem install keymap
== Usage
Here is a simple example of how to use keymap:
Keymap::Base.establish_connection 'test'
connection = Keymap::Base.connection
list = connection.list :what
(0..10).each do |value|
list << value
end
sum = list.inject(0) do |result, item|
result + item.to_i
end
The key observation here is this: no key-value store specific API, its plain ordinary Ruby.
One more example on how to use keymap, this time with a hash:
accounting = @connection.hash :accounting
salaries = {
Bob: 82000,
Jim: 94000,
Billy: 58000
}
accounting.merge! salaries
total = 0
accounting.each_value do |value|
total = total + value.to_i
end
total => # 234000
== 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
== Writing New Adapters
1. Create a new adapter file named #{database_name}_adapter.rb, placing it
in the connection adapters directory.
2. Add an entry to the list of supported databases in the Rakefile.
3. Add test configuration entries in the spec/support/config.yml file.
4. Verify all tests pass when the KEYCONN=#{database_name} environment
variable is set.
== Configure databases
Copy spec/support/config.example.yml to spec/support/config.yml and edit as needed. Or just run the tests for
the first time, which will do the copy automatically and use the default (redis).
You can set up redis using the redis:start_server rake tasks.
== Running the tests
You can run a particular test file from the command line, e.g.
$ ruby -Itest spec/functional/adapter_spec.rb
To run a specific test:
$ ruby -Itest spec/functional/adapter_spec.rb -n test_something_works
You can run with a database other than the default you set in spec/support/config.yml, using the KEYCONN
environment variable:
$ KEYCONN=redis ruby -Itest spec/functional/adapter_spec.rb
You can run all the tests for a given database via rake:
$ rake test_redis
The 'rake test' task will run all the tests for redis, couchdb, and riak,
== Config file
By default, the config file is expected to be at the path spec/support/config.yml. You can specify a
custom location with the KEYCONFIG environment variable.