class Staticd::Datastore
Load the corresponding datastore driver from an URL.
This class use an URL to choose wich datastore library to use. It create a datastore instance with the correct driver and proxies its calls to it. It use the URL scheme to guess wich datastore library to use.
Example:
Staticd::Datastore.setup("s3://[...]") # Staticd::Datastores::S3 Staticd::Datastore.setup("local:/[...]") # Staticd::Datastores::Local Staticd::Datastore.put(file_path)
Public Class Methods
exist?(file_path)
click to toggle source
# File lib/staticd/datastore.rb, line 33 def self.exist?(file_path) instance.exist?(file_path) end
put(file_path)
click to toggle source
# File lib/staticd/datastore.rb, line 29 def self.put(file_path) instance.put(file_path) end
setup(url)
click to toggle source
# File lib/staticd/datastore.rb, line 25 def self.setup(url) instance.setup(url) end
Public Instance Methods
exist?(file_path)
click to toggle source
# File lib/staticd/datastore.rb, line 45 def exist?(file_path) datastore.exist?(file_path) end
put(file_path)
click to toggle source
# File lib/staticd/datastore.rb, line 41 def put(file_path) datastore.put(file_path) end
setup(url)
click to toggle source
# File lib/staticd/datastore.rb, line 37 def setup(url) @uri = URI(url) end
Private Instance Methods
datastore()
click to toggle source
# File lib/staticd/datastore.rb, line 55 def datastore @datastore ||= datastoreClass.new( host: @uri.host, path: @uri.path, username: @uri.user, password: @uri.password ) end
datastoreClass()
click to toggle source
# File lib/staticd/datastore.rb, line 51 def datastoreClass @datastoreClass ||= Datastores.const_get(@uri.scheme.capitalize) end