module GraphiteAPI::Utils
Public Class Methods
included(base)
click to toggle source
# File lib/graphite-api/utils.rb, line 7 def self.included base base.extend ClassUtils base.extend Forwardable base.__send__ :include, LoggerUtils end
Public Instance Methods
default_middleware_options()
click to toggle source
# File lib/graphite-api/utils.rb, line 65 def default_middleware_options default_options.merge(:interval => 60) end
default_options()
click to toggle source
# File lib/graphite-api/utils.rb, line 50 def default_options { :backends => [], :cleaner_interval => 43200, :port => 2003, :log_level => :info, :cache => nil, :host => "localhost", :prefix => [], :interval => 0, :slice => 60, :pid => "/tmp/graphite-middleware.pid" } end
expand_host(host)
click to toggle source
# File lib/graphite-api/utils.rb, line 39 def expand_host host if host =~ /:\/\// uri = URI.parse host [ uri.host, uri.port || default_options[:port] ] else host, port = host.split(":") port = port.nil? ? default_options[:port] : port.to_i [ host, port] end end
nested_zero_hash()
click to toggle source
# File lib/graphite-api/utils.rb, line 33 def nested_zero_hash Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = 0} } end
normalize_time(time, slice)
click to toggle source
# File lib/graphite-api/utils.rb, line 28 def normalize_time time, slice slice = 60 if slice.nil? ((time || Time.now).to_i / slice * slice).to_i end