lib/splash/backends/file.rb in prometheus-splash-0.0.3 vs lib/splash/backends/file.rb in prometheus-splash-0.1.0

- old
+ new

@@ -6,28 +6,34 @@ @config = get_config[:backends][:stores][store] @path = @config[:path] end def list(pattern='*') - return Dir.glob(pattern) + pattern = suffix_trace(pattern) + return Dir.glob("#{@path}/#{pattern}").map{|item| ::File.basename(item,".trace") } end def get(options) - return ::File.readlines("#{@path}/#{options[:key]}").join + return ::File.readlines("#{@path}/#{suffix_trace(options[:key])}").join end def put(options) - ::File.open("#{@path}/#{options[:key]}", 'w') { |file| + ::File.open("#{@path}/#{suffix_trace(options[:key])}", 'w') { |file| file.write options[:value] } end def del(options) - ::File.unlink("#{@path}/#{options[:key]}") if File.exist?("#{@path}/#{options[:key]}") + ::File.unlink("#{@path}/#{suffix_trace(options[:key])}") if File.exist?("#{@path}/#{suffix_trace(options[:key])}") end def exist?(options) - return ::File.exist?("#{@path}/#{options[:key]}") + return ::File.exist?("#{@path}/#{suffix_trace(options[:key])}") + end + + private + def suffix_trace(astring) + return "#{astring}.trace" end end end