filestore 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/multitenant_filestore.rb +17 -5
- data/test/tc_multitenant.rb +7 -7
- metadata +1 -1
|
@@ -11,19 +11,31 @@ require 'log.rb'
|
|
|
11
11
|
require 'uuidtools'
|
|
12
12
|
require 'fileutils'
|
|
13
13
|
require 'yaml'
|
|
14
|
+
require 'singleton'
|
|
14
15
|
|
|
15
16
|
module FileStore
|
|
16
17
|
#
|
|
17
|
-
#
|
|
18
|
+
# Singleton class implementing a multitenant file store
|
|
18
19
|
#
|
|
19
20
|
class MultiTenantFileStore
|
|
20
|
-
|
|
21
|
+
# Make this class a singleton class
|
|
22
|
+
include Singleton
|
|
23
|
+
# Accessors
|
|
24
|
+
attr_reader :stores, :rootPath
|
|
21
25
|
#
|
|
22
26
|
# Initializes a new instance of MultiTenantFileStore
|
|
23
|
-
# @rootPath The path where all file stores are located
|
|
24
27
|
#
|
|
25
|
-
def initialize(
|
|
26
|
-
|
|
28
|
+
def initialize()
|
|
29
|
+
@rootPath = Dir.getwd
|
|
30
|
+
@stores = {}
|
|
31
|
+
end
|
|
32
|
+
#
|
|
33
|
+
# Sets the root path of the multitenant store. As FileStore::MultiTenantFileStore
|
|
34
|
+
# is a singleton class, this method must be used before any other
|
|
35
|
+
# @param rootPath The path to be used
|
|
36
|
+
#
|
|
37
|
+
def set_root_path(rootPath)
|
|
38
|
+
raise FileStoreException, "Root path #{rootPath} doesn't exist" if not File.exists?(rootPath)
|
|
27
39
|
|
|
28
40
|
@rootPath = rootPath
|
|
29
41
|
@stores = MultiTenantFileStore.recover(rootPath)
|
data/test/tc_multitenant.rb
CHANGED
|
@@ -11,16 +11,16 @@ require 'fileutils'
|
|
|
11
11
|
|
|
12
12
|
include FileStore
|
|
13
13
|
|
|
14
|
-
basePath = "/Users/thomas/Documents/DEV/ruby/
|
|
15
|
-
testFile = "/Users/thomas/Documents/DEV/ruby/
|
|
14
|
+
basePath = "/Users/thomas/Documents/DEV/ruby/FileStoreRepo/test/multi_store_test"
|
|
15
|
+
testFile = "/Users/thomas/Documents/DEV/ruby/FileStoreRepo/test/testfile.txt"
|
|
16
16
|
|
|
17
17
|
begin
|
|
18
|
-
|
|
19
|
-
tenant =
|
|
20
|
-
|
|
18
|
+
MultiTenantFileStore.instance.set_root_path basePath
|
|
19
|
+
tenant = MultiTenantFileStore.instance.create_tenant_store
|
|
20
|
+
MultiTenantFileStore.instance.add_to_tenant tenant, testFile, { :hugo => "boss" }
|
|
21
21
|
|
|
22
|
-
puts
|
|
23
|
-
|
|
22
|
+
puts MultiTenantFileStore.instance.stores
|
|
23
|
+
MultiTenantFileStore.instance.shutdown
|
|
24
24
|
rescue Exception => e
|
|
25
25
|
puts e
|
|
26
26
|
puts e.backtrace
|