Class: WirisPlugin::FolderTreeStorageAndCache

Inherits:
Object
  • Object
show all
Extended by:
StorageAndCacheInterface
Includes:
Wiris
Defined in:
lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb

Constant Summary collapse

@@backwards_compat =
true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StorageAndCacheInterface

StorageAndCache

Constructor Details

#initializeFolderTreeStorageAndCache

Returns a new instance of FolderTreeStorageAndCache.



21
22
23
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 21

def initialize()
    super()
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



19
20
21
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 19

def cache
  @cache
end

#cacheFormulaObject

Returns the value of attribute cacheFormula.



20
21
22
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 20

def cacheFormula
  @cacheFormula
end

#configObject

Returns the value of attribute config.



11
12
13
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 11

def config
  @config
end

Class Method Details

.backwards_compatObject



13
14
15
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 13

def self.backwards_compat
    @@backwards_compat
end

.backwards_compat=(backwards_compat) ⇒ Object



16
17
18
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 16

def self.backwards_compat=(backwards_compat)
    @@backwards_compat = backwards_compat
end

Instance Method Details

#codeDigest(content) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 29

def codeDigest(content)
    digest = Md5Tools::encodeString(content)
    begin
    self.cacheFormula::set(digest + ".ini",Bytes::ofData(Utf8::toBytes(content)))
    end
    return digest
end

#decodeDigest(digest) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 36

def decodeDigest(digest)
    data = self.cacheFormula::get(digest + ".ini")
    if data != nil
        return Utf8::fromBytes(data::getData())
    else 
        return nil
    end
end

#deleteCacheObject



66
67
68
69
70
71
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 66

def deleteCache()
    cache = CacheImpl.new(self.config)
    begin
    cache::deleteAll()
    end
end

#getExtension(service) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 57

def getExtension(service)
    if (service == "png")
        return "png"
    end
    if (service == "svg")
        return "svg"
    end
    return service + ".txt"
end

#init(obj, config, cache, cacheFormula) ⇒ Object



24
25
26
27
28
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 24

def init(obj, config, cache, cacheFormula)
    self.config = config
    self.cache = cache
    self.cacheFormula = cacheFormula
end

#retreiveData(digest, service) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 44

def retreiveData(digest, service)
    data = self.cache::get((digest + ".") + getExtension(service))
    if data != nil
        return data::getData()
    else 
        return nil
    end
end

#storeData(digest, service, stream) ⇒ Object



52
53
54
55
56
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 52

def storeData(digest, service, stream)
    begin
    self.cache::set((digest + ".") + self.getExtension(service),Bytes::ofData(stream))
    end
end