# File lib/librarian/config/file_source.rb, line 12 def initialize(adapter_name, options = { }) super self.config_path = options.delete(:config_path) or raise ArgumentError, "must provide config_path" end
# File lib/librarian/config/file_source.rb, line 18 def to_s config_path end
# File lib/librarian/config/file_source.rb, line 24 def load return { } unless File.file?(config_path) raw = YAML.load_file(config_path) return { } unless Hash === raw translate_raw_to_config(raw) end
# File lib/librarian/config/file_source.rb, line 33 def save(config) raw = translate_config_to_raw(config) if config.empty? File.delete(config_path) if File.file?(config_path) else config_dir = File.dirname(config_path) FileUtils.mkpath(config_dir) unless File.directory?(config_dir) File.open(config_path, "wb"){|f| YAML.dump(raw, f)} end end