mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 05:16:39 +00:00
make Redistat::Key abide by the hash_label option
This commit is contained in:
@@ -22,7 +22,7 @@ module Redistat
|
||||
def to_s(depth = nil)
|
||||
depth ||= @options[:depth] if !@options[:depth].nil?
|
||||
key = "#{@scope}"
|
||||
key << "/#{@label.hash}" if !label.nil?
|
||||
key << "/" + ((@options[:hash_label].nil? || @options[:hash_label] == true) ? @label.hash : @label.name) if !label.nil?
|
||||
key << ":#{@date.to_s(depth)}"
|
||||
end
|
||||
|
||||
|
||||
@@ -20,12 +20,18 @@ describe Redistat::Key do
|
||||
end
|
||||
|
||||
it "should convert to string properly" do
|
||||
@key.to_s.should == "#{@scope}/#{@label_hash}:" + [:year, :month, :day].map { |k| @now.send(k).to_s.rjust(2, '0') }.join
|
||||
@key.to_s.should == "#{@scope}/#{@label_hash}:#{@key.date.to_s(:day)}"
|
||||
props = [:year, :month, :day, :hour, :min, :sec]
|
||||
props.each do
|
||||
@key.to_s(props.last).should == "#{@scope}/#{@label_hash}:" + props.map { |k| @now.send(k).to_s.rjust(2, '0') if !k.nil? }.join
|
||||
@key.to_s(props.last).should == "#{@scope}/#{@label_hash}:#{@key.date.to_s(props.last)}"
|
||||
props.pop
|
||||
end
|
||||
end
|
||||
|
||||
it "should abide to hash_label option" do
|
||||
@label = "about_us"
|
||||
@key = Redistat::Key.new(@scope, @label, @now, {:depth => :day, :hash_label => false})
|
||||
@key.to_s.should == "#{@scope}/#{@label}:#{@key.date.to_s(:day)}"
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user