Class: IbmAppconfigurationRubySdk::FileManager
- Inherits:
-
Object
- Object
- IbmAppconfigurationRubySdk::FileManager
- Includes:
- Singleton
- Defined in:
- lib/ibm_appconfiguration_ruby_sdk/file_manager.rb
Instance Method Summary collapse
- #delete_file_data(file_path) ⇒ Object
-
#initialize ⇒ FileManager
constructor
A new instance of FileManager.
- #read_bootstrap_configurations_from_file(file_path) ⇒ Object
- #read_persistent_cache_configurations(file_path) ⇒ Object
- #store_files(json, file_path) ⇒ Object
Constructor Details
#initialize ⇒ FileManager
Returns a new instance of FileManager.
26 27 28 |
# File 'lib/ibm_appconfiguration_ruby_sdk/file_manager.rb', line 26 def initialize @logger = Logger.instance end |
Instance Method Details
#delete_file_data(file_path) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/ibm_appconfiguration_ruby_sdk/file_manager.rb', line 62 def delete_file_data(file_path) return unless File.exist?(file_path) File.truncate(file_path, 0) rescue StandardError => e @logger.warning(e) end |
#read_bootstrap_configurations_from_file(file_path) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/ibm_appconfiguration_ruby_sdk/file_manager.rb', line 52 def read_bootstrap_configurations_from_file(file_path) raise "given bootstrap file path doesn't exist: #{file_path}" unless File.exist?(file_path) data = File.read(file_path).strip raise "given bootstrap file is empty: #{file_path}" if data.empty? data end |
#read_persistent_cache_configurations(file_path) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ibm_appconfiguration_ruby_sdk/file_manager.rb', line 34 def read_persistent_cache_configurations(file_path) unless File.exist?(file_path) @logger.log(Constants::PERSISTENT_CACHE_FILE_NOT_FOUND) return "" end data = File.read(file_path).strip if data.empty? @logger.log(Constants::PERSISTENT_CACHE_FILE_EMPTY) return "" end data rescue StandardError "" end |
#store_files(json, file_path) ⇒ Object
30 31 32 |
# File 'lib/ibm_appconfiguration_ruby_sdk/file_manager.rb', line 30 def store_files(json, file_path) File.write(file_path, json) end |