Project

text-db

0.0
No commit activity in last 3 years
No release in over 3 years
Textdb is a database which structure is determined by folders and data are represented by files.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
 Project Readme

Textdb

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'
  }
}

Installation

Add this line to your application's Gemfile:

gem 'text-db'

And then execute:

$ bundle

Or install it yourself as:

$ gem install text-db

Configuration

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

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

Textdb.read { key1 }           # -> list of all in the folder /key1
Textdb.read { key2.value2_1 }  # -> content of file /key2/value2_1.data

Create

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.

Textdb.update("text") { a.b.c }   # -> update /a/b/c.data with new content

Delete

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.

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