Textdb is a database which structure is determined by folders and data are represented by files.
Current state: beta version.
Example:
# .
# |-- key1
# | |-- key1_1
# | | `-- value1_1_1.data
# | `-- value1_1.data
# `-- key2
# `-- value2_1.data
{
'key1' => {
'key1_1' => {
'value1_1_1' => 'text'
},
'value1_1_1' => 'text'
},
'key2' => {
'value2_1' => 'text'
}
}
Add this line to your application's Gemfile:
gem 'text-db'
And then execute:
$ bundle
Or install it yourself as:
$ gem install text-db
Textdb.config
or Textdb.configuration(&block)
.
How:
Textdb.configuration do
key "/tmp/1"
end
# --- OR ---
Textdb.config.key = "/tmp/1"
Key | Default | Description |
---|---|---|
base_folder | /tmp/textdb | The root folder for Textdb. Folder must exist. |
data_file_extension | .data | Extension for data files. |
listen | false | Automatic listening for changes in the root folder |
Folder structure:
.
|-- key1
| |-- key1_1
| | `-- key1_1_1
| | |-- value1_1_1_1
| | `-- value1_1_1_2
| |-- value1_1
| `-- value1_2
`-- key2
`-- value2_1
Textdb.read { key1 } # -> list of all in the folder /key1
Textdb.read { key2.value2_1 } # -> content of file /key2/value2_1.data
Textdb.create { a.b.c } # -> create a file /a/b/c.data
Textdb.create { a.b.c }.update("text") # -> create a file /a/b/c.data with content "text"
\n
is not included at the end.
Textdb.update("text") { a.b.c } # -> update /a/b/c.data with new content
Textdb.delete { key1 } # -> delete everything in the folder /key1
Textdb.delete { key2.value2_1 } # -> delete only /key/value2_1.data
If listen is true.
Textdb.read { a.b } # -> "text"
# On FS -------------------------
File.open('/a/b.data', 'w') { |f|
f.write('text 2')
}
# -------------------------------
Textdb.read { a.b } # -> "text 2"
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request