Skip to content

Commit 549a454

Browse files
authored
Merge pull request #1 from witkwski/master
Fixed README description and usage
2 parents 5d5c293 + b016e2f commit 549a454

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
# Gdbm
1+
# GDBM
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gdbm`. To experiment with that code, run `bin/console` for an interactive prompt.
3+
[![Build Status](https://travis-ci.org/ruby/gdbm.svg?branch=master)](https://travis-ci.org/ruby/gdbm)
44

5-
TODO: Delete this and the text above, and describe your gem
5+
GNU dbm is a library for simple databases. A database is a file that stores
6+
key-value pairs. Gdbm allows the user to store, retrieve, and delete data by
7+
key. It furthermore allows a non-sorted traversal of all key-value pairs.
8+
A gdbm database thus provides the same functionality as a hash. As
9+
with objects of the Hash class, elements can be accessed with <tt>[]</tt>.
10+
Furthermore, GDBM mixes in the Enumerable module, thus providing convenient
11+
methods such as #find, #collect, #map, etc.
12+
13+
A process is allowed to open several different databases at the same time.
14+
A process can open a database as a "reader" or a "writer". Whereas a reader
15+
has only read-access to the database, a writer has read- and write-access.
16+
A database can be accessed either by any number of readers or by exactly one
17+
writer at the same time.
618

719
## Installation
820

@@ -22,13 +34,29 @@ Or install it yourself as:
2234

2335
## Usage
2436

25-
TODO: Write usage instructions here
2637

27-
## Development
38+
1. Opening/creating a database, and filling it with some entries:
39+
require 'gdbm'
40+
41+
```ruby
42+
gdbm = GDBM.new("fruitstore.db")
43+
gdbm["ananas"] = "3"
44+
gdbm["banana"] = "8"
45+
gdbm["cranberry"] = "4909"
46+
gdbm.close
47+
```
2848

29-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49+
2. Reading out a database:
3050

31-
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](https://rubygems.org).
51+
```ruby
52+
require 'gdbm'
53+
54+
gdbm = GDBM.new("fruitstore.db")
55+
gdbm.each_pair do |key, value|
56+
print "#{key}: #{value}\n"
57+
end
58+
gdbm.close
59+
```
3260

3361
## Contributing
3462

0 commit comments

Comments
 (0)