Sha256: ec940e0c47135a46c2259499b27aa39d7bef4004258a7cc79082e28b601811da
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
module Papertrail module CliHelpers def find_configfile begin if File.exists?(path = File.expand_path('.papertrail.yml')) return path end if File.exists?(path = File.expand_path('~/.papertrail.yml')) return path end rescue ArgumentError => e end end def load_configfile(file_path) symbolize_keys(YAML.load_file(file_path)) end def symbolize_keys(hash) new_hash = {} hash.each do |(key, value)| new_hash[(key.to_sym rescue key) || key] = value end new_hash end def set_min_max_time!(opts, q_opts) q_opts[:min_time] = parse_time(opts[:min_time]).to_i if opts[:min_time] q_opts[:max_time] = parse_time(opts[:max_time]).to_i if opts[:max_time] end def parse_time(tstring) Chronic.parse(tstring) || raise(ArgumentError, "Could not parse time string '#{tstring}'") end def output_http_error(e) if e.response && e.response.body puts "Error: #{e.response.body}\n\n" end puts e end end end
Version data entries
7 entries across 7 versions & 1 rubygems