fix: Rename freeflowuniverse to incubaid
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
module vfs_calendar
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
|
||||
// new creates a new calendar_db VFS instance
|
||||
pub fn new(calendar_db &core.CalendarDB) !vfs.VFSImplementation {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_calendar
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.models as calendars
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.models as calendars
|
||||
|
||||
// CalendarFSEntry represents a file system entry in the calendar VFS
|
||||
pub struct CalendarFSEntry {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_calendar
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
|
||||
// CalendarVFS represents the virtual file system for calendar data
|
||||
// It provides a read-only view of calendar data organized by calendars
|
||||
|
||||
@@ -2,9 +2,9 @@ module vfs_calendar
|
||||
|
||||
import json
|
||||
import time
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.models as calendar
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.models as calendar
|
||||
import incubaid.herolib.core.texttools
|
||||
|
||||
// Basic operations
|
||||
pub fn (mut myvfs CalendarVFS) root_get() !vfs.FSEntry {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module vfs_calendar
|
||||
|
||||
import freeflowuniverse.herolib.circles.mcc.models as calendar
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import freeflowuniverse.herolib.data.ourtime
|
||||
import freeflowuniverse.herolib.circles.base
|
||||
import incubaid.herolib.circles.mcc.models as calendar
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.data.ourtime
|
||||
import incubaid.herolib.circles.base
|
||||
import json
|
||||
|
||||
// get_sample_events provides a set of test events
|
||||
|
||||
@@ -30,6 +30,7 @@ The Contacts VFS implementation provides a read-only virtual file system interfa
|
||||
The Contacts VFS organizes contact groups as directories, with contacts as JSON files, browsable by name and email.
|
||||
|
||||
**Example Structure**:
|
||||
|
||||
```
|
||||
/personal/
|
||||
├── by_name/
|
||||
@@ -44,40 +45,41 @@ The Contacts VFS organizes contact groups as directories, with contacts as JSON
|
||||
```
|
||||
|
||||
**Usage Example**:
|
||||
|
||||
```v
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
import vfs_contacts
|
||||
import freeflowuniverse.herolib.circles.dbs.core
|
||||
import incubaid.herolib.circles.dbs.core
|
||||
|
||||
fn main() ! {
|
||||
// Setup mock database
|
||||
mut contacts_db := core.new_mock_contacts_db()
|
||||
contact1 := contacts.Contact{
|
||||
id: 1
|
||||
id: 1
|
||||
first_name: 'John'
|
||||
last_name: 'Doe'
|
||||
email: 'john.doe@example.com'
|
||||
group: 'personal'
|
||||
created_at: 1698777600
|
||||
modified_at: 1698777600
|
||||
}
|
||||
}
|
||||
|
||||
contact2 := contacts.Contact{
|
||||
id: 2
|
||||
id: 2
|
||||
first_name: 'Said'
|
||||
last_name: 'Moaawad'
|
||||
email: 'said.moaawad@example.com'
|
||||
group: 'personal'
|
||||
created_at: 1698777600
|
||||
modified_at: 1698777600
|
||||
}
|
||||
}
|
||||
|
||||
// Add contacts to the database
|
||||
contacts_db.set(contact1) or { panic(err) }
|
||||
contacts_db.set(contact2) or { panic(err) }
|
||||
// Add contacts to the database
|
||||
contacts_db.set(contact1) or { panic(err) }
|
||||
contacts_db.set(contact2) or { panic(err) }
|
||||
|
||||
// Create VFS instance
|
||||
mut contacts_vfs := new(&contacts_db) or { panic(err) }
|
||||
// Create VFS instance
|
||||
mut contacts_vfs := new(&contacts_db) or { panic(err) }
|
||||
|
||||
// List groups at root
|
||||
groups := contacts_vfs.dir_list('')!
|
||||
@@ -118,16 +120,19 @@ fn main() ! {
|
||||
The Contacts VFS implementation includes comprehensive unit tests in the `vfs_implementation_test.v` file. To run the tests:
|
||||
|
||||
1. **Navigate to the Module Directory**:
|
||||
|
||||
```bash
|
||||
cd lib/vfs/vfs_contacts/
|
||||
```
|
||||
|
||||
2. **Run Tests**:
|
||||
|
||||
```bash
|
||||
v test .
|
||||
```
|
||||
|
||||
The tests cover:
|
||||
|
||||
- Listing groups, subdirectories, and contact files
|
||||
- Reading contact file contents
|
||||
- Existence checks
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_contacts
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
|
||||
// new creates a new contacts_db VFS instance
|
||||
pub fn new(contacts_db &core.ContactsDB) !vfs.VFSImplementation {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_contacts
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.models as contacts
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.models as contacts
|
||||
|
||||
// ContactsFSEntry implements FSEntry for contacts objects
|
||||
pub struct ContactsFSEntry {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module vfs_contacts
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
// import freeflowuniverse.herolib.circles.mcc.models as mcc
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
// import incubaid.herolib.circles.mcc.models as mcc
|
||||
|
||||
// ContactsVFS represents the virtual file system for contacts
|
||||
pub struct ContactsVFS {
|
||||
|
||||
@@ -2,9 +2,9 @@ module vfs_contacts
|
||||
|
||||
import json
|
||||
import time
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.models as contacts
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.models as contacts
|
||||
import incubaid.herolib.core.texttools
|
||||
|
||||
// Basic operations
|
||||
pub fn (mut myvfs ContactsVFS) root_get() !vfs.FSEntry {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module vfs_contacts
|
||||
|
||||
import freeflowuniverse.herolib.circles.base
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import freeflowuniverse.herolib.circles.mcc.models as contacts
|
||||
// import freeflowuniverse.herolib.circles.mcc.models
|
||||
import incubaid.herolib.circles.base
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.circles.mcc.models as contacts
|
||||
// import incubaid.herolib.circles.mcc.models
|
||||
|
||||
fn test_contacts_vfs() ! {
|
||||
// Create a session state
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module vfs_db
|
||||
|
||||
import arrays
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import freeflowuniverse.herolib.data.encoder
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.data.ourdb
|
||||
import incubaid.herolib.data.encoder
|
||||
import time
|
||||
import log
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module vfs_db
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.data.ourdb
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
import rand
|
||||
|
||||
fn setup_vfs() !(&DatabaseVFS, string) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module vfs_db
|
||||
|
||||
import arrays
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import freeflowuniverse.herolib.data.encoder
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.data.ourdb
|
||||
import incubaid.herolib.data.encoder
|
||||
import time
|
||||
import log
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.data.encoder
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.data.encoder
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// decode_directory decodes a binary format back to Directory
|
||||
pub fn decode_directory(data []u8) !Directory {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.data.encoder
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.data.encoder
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// encode_metadata encodes the common metadata structure
|
||||
fn encode_metadata(mut e encoder.Encoder, m vfs.Metadata) {
|
||||
|
||||
@@ -2,7 +2,7 @@ module vfs_db
|
||||
|
||||
import os
|
||||
import time
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
fn test_directory_encoder_decoder() ! {
|
||||
println('Testing encoding/decoding directories...')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_db
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import incubaid.herolib.data.ourdb
|
||||
import rand
|
||||
|
||||
fn test_new() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// Directory represents a directory in the virtual filesystem
|
||||
pub struct Directory {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
|
||||
fn test_directory_get_metadata() {
|
||||
// Create a directory with metadata
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// File represents a file in the virtual filesystem
|
||||
pub struct File {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import incubaid.herolib.data.ourdb
|
||||
import rand
|
||||
|
||||
fn setup_vfs() !&DatabaseVFS {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// FSEntry represents any type of filesystem entry
|
||||
pub type FSEntry = Directory | File | Symlink
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
|
||||
fn test_fsentry_directory() {
|
||||
// Create a directory entry
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// Symlink represents a symbolic link in the virtual filesystem
|
||||
pub struct Symlink {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
|
||||
fn test_symlink_get_metadata() {
|
||||
// Create a symlink with metadata
|
||||
|
||||
@@ -14,6 +14,7 @@ A virtual filesystem implementation that uses OurDB as its storage backend, prov
|
||||
## Implementation Details
|
||||
|
||||
### Structure
|
||||
|
||||
```
|
||||
vfs_db/
|
||||
├── factory.v # VFS factory implementation
|
||||
@@ -33,6 +34,7 @@ vfs_db/
|
||||
### Key Components
|
||||
|
||||
- `DatabaseVFS`: Main implementation struct
|
||||
|
||||
```v
|
||||
pub struct DatabaseVFS {
|
||||
pub mut:
|
||||
@@ -46,6 +48,7 @@ pub mut:
|
||||
```
|
||||
|
||||
- `FSEntry` implementations:
|
||||
|
||||
```v
|
||||
pub type FSEntry = Directory | File | Symlink
|
||||
```
|
||||
@@ -53,6 +56,7 @@ pub type FSEntry = Directory | File | Symlink
|
||||
### Data Storage
|
||||
|
||||
#### Metadata Structure
|
||||
|
||||
```v
|
||||
struct Metadata {
|
||||
id u32 // Unique identifier
|
||||
@@ -69,6 +73,7 @@ struct Metadata {
|
||||
```
|
||||
|
||||
#### Database Interface
|
||||
|
||||
```v
|
||||
pub interface Database {
|
||||
mut:
|
||||
@@ -81,7 +86,7 @@ mut:
|
||||
## Usage
|
||||
|
||||
```v
|
||||
import freeflowuniverse.herolib.vfs.vfs_db
|
||||
import incubaid.herolib.vfs.vfs_db
|
||||
|
||||
// Create separate databases for data and metadata
|
||||
mut db_data := ourdb.new(
|
||||
@@ -148,6 +153,7 @@ fs.destroy()!
|
||||
## Testing
|
||||
|
||||
The implementation includes tests for:
|
||||
|
||||
- Basic operations (create, read, write, delete)
|
||||
- Directory operations and traversal
|
||||
- Symlink handling
|
||||
@@ -157,6 +163,7 @@ The implementation includes tests for:
|
||||
- Data consistency
|
||||
|
||||
Run tests with:
|
||||
|
||||
```bash
|
||||
v test vfs/vfs_db/
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs { Metadata }
|
||||
import incubaid.herolib.vfs { Metadata }
|
||||
import time
|
||||
import log
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module vfs_db
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.data.ourdb
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
import rand
|
||||
|
||||
fn setup_fs() !(&DatabaseVFS, string) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_db
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.core.texttools
|
||||
import arrays
|
||||
import log
|
||||
import os
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_db
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import incubaid.herolib.data.ourdb
|
||||
import rand
|
||||
|
||||
fn setup_vfs() !(&DatabaseVFS, string) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module vfs_db
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.data.ourdb
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
import rand
|
||||
|
||||
fn setup_fs() !(&DatabaseVFS, string) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module vfs_db
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import incubaid.herolib.data.ourdb
|
||||
import rand
|
||||
import freeflowuniverse.herolib.vfs as vfs_mod
|
||||
import incubaid.herolib.vfs as vfs_mod
|
||||
|
||||
fn setup_vfs() !(&DatabaseVFS, string) {
|
||||
test_data_dir := os.join_path(os.temp_dir(), 'vfsourdb_vfs_test_${rand.string(3)}')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_local
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// LocalVFS implements vfs.VFSImplementation for local filesystem
|
||||
pub struct LocalVFS {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_local
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// LocalFSEntry implements FSEntry for local filesystem
|
||||
struct LocalFSEntry {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_local
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// Basic operations
|
||||
pub fn (myvfs LocalVFS) root_get() !vfs.FSEntry {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_local
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
|
||||
// Convert path to vfs.Metadata with improved security and information gathering
|
||||
fn (myvfs LocalVFS) os_attr_to_metadata(path string) !vfs.Metadata {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_mail
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
|
||||
// new creates a new mail VFS instance
|
||||
pub fn new(mail_db &core.MailDB) !vfs.VFSImplementation {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_mail
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.models as mail
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.models as mail
|
||||
|
||||
// MailFSEntry implements FSEntry for mail objects
|
||||
pub struct MailFSEntry {
|
||||
|
||||
@@ -2,9 +2,9 @@ module vfs_mail
|
||||
|
||||
import json
|
||||
import time
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.models as mail
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.models as mail
|
||||
import incubaid.herolib.core.texttools
|
||||
|
||||
// Basic operations
|
||||
pub fn (mut myvfs MailVFS) root_get() !vfs.FSEntry {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module vfs_mail
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
// import freeflowuniverse.herolib.circles.mcc.models
|
||||
import freeflowuniverse.herolib.circles.mcc.models as mail
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import freeflowuniverse.herolib.circles.base
|
||||
import incubaid.herolib.vfs
|
||||
// import incubaid.herolib.circles.mcc.models
|
||||
import incubaid.herolib.circles.mcc.models as mail
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.circles.base
|
||||
import json
|
||||
import time
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module vfs_mail
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import freeflowuniverse.herolib.circles.mcc.db as core
|
||||
import incubaid.herolib.vfs
|
||||
import incubaid.herolib.circles.mcc.db as core
|
||||
|
||||
// MailVFS implements the VFS interface for mail objects
|
||||
pub struct MailVFS {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_nested
|
||||
|
||||
import freeflowuniverse.herolib.vfs.vfs_local
|
||||
import incubaid.herolib.vfs.vfs_local
|
||||
import os
|
||||
|
||||
fn test_nested() ! {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module vfs_nested
|
||||
|
||||
import freeflowuniverse.herolib.vfs
|
||||
import incubaid.herolib.vfs
|
||||
import time
|
||||
|
||||
// NestedVFS represents a VFS that can contain multiple nested VFS instances
|
||||
|
||||
Reference in New Issue
Block a user