Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ondra-m/textdb
Textdb is a database which structure is determined by folders and data are represented by files.
https://github.com/ondra-m/textdb
Last synced: 13 days ago
JSON representation
Textdb is a database which structure is determined by folders and data are represented by files.
- Host: GitHub
- URL: https://github.com/ondra-m/textdb
- Owner: ondra-m
- License: mit
- Created: 2013-07-15T10:56:06.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-16T18:38:21.000Z (over 11 years ago)
- Last Synced: 2023-03-27T13:56:34.542Z (almost 2 years ago)
- Language: Ruby
- Size: 156 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Textdb
Textdb is a database which structure is determined by folders and data are represented by files.
Current state: **beta version**.
Example:
```ruby
# .
# |-- 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'
}
}```
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'text-db'
```And then execute:
```bash
$ bundle
```Or install it yourself as:
```bash
$ gem install text-db
```## Configuration
`Textdb.config` or `Textdb.configuration(&block)`.
How:
```ruby
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
## Usage
Folder structure:
```
.
|-- key1
| |-- key1_1
| | `-- key1_1_1
| | |-- value1_1_1_1
| | `-- value1_1_1_2
| |-- value1_1
| `-- value1_2
`-- key2
`-- value2_1
```### Read
```ruby
Textdb.read { key1 } # -> list of all in the folder /key1
Textdb.read { key2.value2_1 } # -> content of file /key2/value2_1.data
```### Create
```ruby
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"
```### Update
`\n` is not included at the end.
```ruby
Textdb.update("text") { a.b.c } # -> update /a/b/c.data with new content
```### Delete
```ruby
Textdb.delete { key1 } # -> delete everything in the folder /key1
Textdb.delete { key2.value2_1 } # -> delete only /key/value2_1.data
```## Listen
If **listen** is true.
```ruby
Textdb.read { a.b } # -> "text"# On FS -------------------------
File.open('/a/b.data', 'w') { |f|
f.write('text 2')
}
# -------------------------------Textdb.read { a.b } # -> "text 2"
```## 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