Class: Splash::Backends::File
- Defined in:
- lib/splash/backends/file.rb
Overview
File backend definition
Constant Summary
Constants included from Loggers
Loggers::ALIAS, Loggers::LEVELS
Constants included from Constants
Constants::AUTHOR, Constants::BACKENDS_STRUCT, Constants::CONFIG_FILE, Constants::COPYRIGHT, Constants::DAEMON_LOGMON_SCHEDULING, Constants::DAEMON_METRICS_SCHEDULING, Constants::DAEMON_PID_FILE, Constants::DAEMON_PROCESS_NAME, Constants::DAEMON_PROCMON_SCHEDULING, Constants::DAEMON_STDERR_TRACE, Constants::DAEMON_STDOUT_TRACE, Constants::DEFAULT_RETENTION, Constants::EMAIL, Constants::EXECUTION_TEMPLATE, Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Constants::LICENSE, Constants::LOGGERS_STRUCT, Constants::PID_PATH, Constants::PROMETHEUS_ALERTMANAGER_URL, Constants::PROMETHEUS_PUSHGATEWAY_URL, Constants::PROMETHEUS_URL, Constants::TRACE_PATH, Constants::TRANSPORTS_STRUCT, Constants::VERSION, Constants::WEBADMIN_IP, Constants::WEBADMIN_PID_FILE, Constants::WEBADMIN_PID_PATH, Constants::WEBADMIN_PORT, Constants::WEBADMIN_PROCESS_NAME, Constants::WEBADMIN_PROXY, Constants::WEBADMIN_STDERR_TRACE, Constants::WEBADMIN_STDOUT_TRACE
Constants included from Exiter
Instance Method Summary collapse
-
#del(options) ⇒ Boolean
delete a specific record.
-
#exist?(options) ⇒ Boolean
verifiy a specific record existance.
-
#flush ⇒ Object
flush all records in backend.
-
#get(options) ⇒ String
return value of queried record.
-
#initialize(store) ⇒ Splash::Backends::File
constructor
Constructor.
-
#list(pattern = '*') ⇒ Array
return the list of find records in backend for a specific pattern.
-
#put(options) ⇒ String
defined and store value for specified key.
Methods included from Loggers
#change_logger, #get_logger, #get_session
Methods included from Config
Methods included from ConfigUtilities
#addservice, #checkconfig, #flush_backend, #setupsplash
Methods included from Helpers
#check_unicode_term, #daemonize, #format_by_extensions, #format_response, #get_processes, #group_root, #install_file, #is_root?, #make_folder, #make_link, #run_as_root, #search_file_in_gem, #user_root, #verify_file, #verify_folder, #verify_link, #verify_service
Methods included from Exiter
Constructor Details
#initialize(store) ⇒ Splash::Backends::File
Constructor
18 19 20 21 22 |
# File 'lib/splash/backends/file.rb', line 18 def initialize(store) @config = get_config[:backends][:stores][store] @path = @config[:path] ensure_backend end |
Instance Method Details
#del(options) ⇒ Boolean
delete a specific record
56 57 58 |
# File 'lib/splash/backends/file.rb', line 56 def del() ::File.unlink("#{@path}/#{suffix_trace([:key])}") if ::File.exist?("#{@path}/#{suffix_trace([:key])}") end |
#exist?(options) ⇒ Boolean
verifiy a specific record existance
64 65 66 |
# File 'lib/splash/backends/file.rb', line 64 def exist?() return ::File.exist?("#{@path}/#{suffix_trace([:key])}") end |
#flush ⇒ Object
flush all records in backend
69 70 71 |
# File 'lib/splash/backends/file.rb', line 69 def flush Dir.glob("#{@path}/*.trace").each { |file| ::File.delete(file)} end |
#get(options) ⇒ String
return value of queried record
37 38 39 |
# File 'lib/splash/backends/file.rb', line 37 def get() return ::File.readlines("#{@path}/#{suffix_trace([:key])}").join end |
#list(pattern = '*') ⇒ Array
return the list of find records in backend for a specific pattern
27 28 29 30 |
# File 'lib/splash/backends/file.rb', line 27 def list(pattern='*') pattern = suffix_trace(pattern) return Dir.glob("#{@path}/#{pattern}").map{|item| ::File.basename(item,".trace") } end |
#put(options) ⇒ String
defined and store value for specified key
46 47 48 49 50 |
# File 'lib/splash/backends/file.rb', line 46 def put() ::File.open("#{@path}/#{suffix_trace([:key])}", 'w') { |file| file.write [:value] } end |