Name change.
This time it follows our project conventions.remotes/1708105384931250775/master
parent
472f173f6e
commit
aec1dc2011
|
@ -1,10 +1,10 @@
|
|||
name: fsdb
|
||||
name: dodb
|
||||
version: 0.2.0
|
||||
|
||||
authors:
|
||||
- Luka Vandervelden <lukc@upyum.com>
|
||||
|
||||
description: |
|
||||
Simple, embeddable document-oriented database in Crystal.
|
||||
Simple, embeddable Document-Oriented DataBase in Crystal.
|
||||
|
||||
license: MIT
|
||||
|
|
28
spec/test.cr
28
spec/test.cr
|
@ -57,7 +57,7 @@ class Ship
|
|||
end
|
||||
end
|
||||
|
||||
class FSDB::SpecDataBase < FSDB::DataBase(String, Ship)
|
||||
class DODB::SpecDataBase < DODB::DataBase(String, Ship)
|
||||
def initialize
|
||||
::FileUtils.rm_rf "test-storage"
|
||||
|
||||
|
@ -65,10 +65,10 @@ class FSDB::SpecDataBase < FSDB::DataBase(String, Ship)
|
|||
end
|
||||
end
|
||||
|
||||
describe "FSDB::DataBase" do
|
||||
describe "DODB::DataBase" do
|
||||
describe "basics" do
|
||||
it "store and get data" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
Ship.all_ships.each do |ship|
|
||||
db[ship.id] = ship
|
||||
|
@ -80,7 +80,7 @@ describe "FSDB::DataBase" do
|
|||
end
|
||||
|
||||
it "rewrite already stored data" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
ship = Ship.all_ships[0]
|
||||
|
||||
db[ship.id] = Ship.new "broken", id: ship.id
|
||||
|
@ -90,7 +90,7 @@ describe "FSDB::DataBase" do
|
|||
end
|
||||
|
||||
it "properly remove data" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
Ship.all_ships.each do |ship|
|
||||
db[ship.id] = ship
|
||||
|
@ -102,7 +102,7 @@ describe "FSDB::DataBase" do
|
|||
|
||||
Ship.all_ships.each do |ship|
|
||||
# FIXME: Should it raise a particular exception?
|
||||
expect_raises FSDB::MissingEntry do
|
||||
expect_raises DODB::MissingEntry do
|
||||
db[ship.id]
|
||||
end
|
||||
|
||||
|
@ -113,7 +113,7 @@ describe "FSDB::DataBase" do
|
|||
|
||||
describe "indices" do
|
||||
it "do basic indexing" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
db_ships_by_name = db.new_index "name", &.name
|
||||
|
||||
|
@ -127,7 +127,7 @@ describe "FSDB::DataBase" do
|
|||
end
|
||||
|
||||
it "raise on index overload" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
db_ships_by_name = db.new_index "name", &.name
|
||||
|
||||
|
@ -137,13 +137,13 @@ describe "FSDB::DataBase" do
|
|||
|
||||
# Should not be allowed to store an entry whose “name” field
|
||||
# already exists.
|
||||
expect_raises(FSDB::IndexOverload) do
|
||||
expect_raises(DODB::IndexOverload) do
|
||||
db["another id"] = some_ship
|
||||
end
|
||||
end
|
||||
|
||||
it "properly deindex" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
db_ships_by_name = db.new_index "name", &.name
|
||||
|
||||
|
@ -161,7 +161,7 @@ describe "FSDB::DataBase" do
|
|||
end
|
||||
|
||||
it "properly reindex" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
db_ships_by_name = db.new_index "name", &.name
|
||||
|
||||
|
@ -184,7 +184,7 @@ describe "FSDB::DataBase" do
|
|||
|
||||
describe "partitions" do
|
||||
it "do basic partitioning" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
db_ships_by_class = db.new_partition "class", &.class
|
||||
|
||||
|
@ -212,7 +212,7 @@ describe "FSDB::DataBase" do
|
|||
|
||||
describe "tags" do
|
||||
it "do basic tagging" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
db_ships_by_tags = db.new_tags "tags", &.tags
|
||||
|
||||
|
@ -233,7 +233,7 @@ describe "FSDB::DataBase" do
|
|||
end
|
||||
|
||||
it "properly removes tags" do
|
||||
db = FSDB::SpecDataBase.new
|
||||
db = DODB::SpecDataBase.new
|
||||
|
||||
db_ships_by_tags = db.new_tags "tags", &.tags
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require "json"
|
|||
|
||||
require "./fsdb/*"
|
||||
|
||||
class FSDB::DataBase(K, V)
|
||||
class DODB::DataBase(K, V)
|
||||
@indexers = [] of Indexer(V)
|
||||
|
||||
def initialize(@directory_name : String)
|
||||
|
@ -35,20 +35,20 @@ class FSDB::DataBase(K, V)
|
|||
def get_index(name : String, key)
|
||||
index = @indexers.find &.name.==(name)
|
||||
|
||||
index.not_nil!.as(FSDB::Index).get key
|
||||
index.not_nil!.as(DODB::Index).get key
|
||||
end
|
||||
|
||||
# FIXME: Is this “key” really a K, not just a String?
|
||||
def get_partition(table_name : String, partition_name : String)
|
||||
partition = @indexers.find &.name.==(table_name)
|
||||
|
||||
partition.not_nil!.as(FSDB::Partition).get partition_name
|
||||
partition.not_nil!.as(DODB::Partition).get partition_name
|
||||
end
|
||||
|
||||
def get_tags(name, key : K)
|
||||
partition = @indexers.find &.name.==(name)
|
||||
|
||||
partition.not_nil!.as(FSDB::Tags).get name, key
|
||||
partition.not_nil!.as(DODB::Tags).get name, key
|
||||
end
|
||||
|
||||
def []?(key : K) : V?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
class FSDB::MissingEntry < Exception
|
||||
class DODB::MissingEntry < Exception
|
||||
getter index : String?
|
||||
getter key : String
|
||||
|
||||
|
@ -12,6 +12,6 @@ class FSDB::MissingEntry < Exception
|
|||
end
|
||||
end
|
||||
|
||||
class FSDB::IndexOverload < Exception
|
||||
class DODB::IndexOverload < Exception
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ require "json"
|
|||
require "./exceptions.cr"
|
||||
require "./indexer.cr"
|
||||
|
||||
class FSDB::Index(V) < FSDB::Indexer(V)
|
||||
class DODB::Index(V) < DODB::Indexer(V)
|
||||
property name : String
|
||||
property key_proc : Proc(V, String)
|
||||
getter storage_root : String
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
abstract class FSDB::Indexer(V)
|
||||
abstract class DODB::Indexer(V)
|
||||
abstract def index (key : String, value : V)
|
||||
abstract def deindex (key : String, value : V)
|
||||
abstract def check! (key : String, value : V, old_value : V?)
|
||||
|
|
|
@ -3,7 +3,7 @@ require "json"
|
|||
|
||||
require "./indexer.cr"
|
||||
|
||||
class FSDB::Partition(V) < FSDB::Indexer(V)
|
||||
class DODB::Partition(V) < DODB::Indexer(V)
|
||||
property name : String
|
||||
property key_proc : Proc(V, String)
|
||||
getter storage_root : String
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require "file_utils"
|
||||
require "json"
|
||||
|
||||
class FSDB::Tags(V) < FSDB::Indexer(V)
|
||||
class DODB::Tags(V) < DODB::Indexer(V)
|
||||
property name : String
|
||||
property key_proc : Proc(V, Array(String))
|
||||
getter storage_root : String
|
||||
|
|
Loading…
Reference in New Issue