Skip to content
/ textdb Public

Textdb is a database which structure is determined by folders and data are represented by files.

License

Notifications You must be signed in to change notification settings

ondra-m/textdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Textdb is a database which structure is determined by folders and data are represented by files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages