You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-7Lines changed: 35 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,20 @@
1
-
# Gdbm
1
+
# GDBM
2
2
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.
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.
6
18
7
19
## Installation
8
20
@@ -22,13 +34,29 @@ Or install it yourself as:
22
34
23
35
## Usage
24
36
25
-
TODO: Write usage instructions here
26
37
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
+
```
28
48
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:
30
50
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).
0 commit comments