Permalink
Browse files

Added support for `-d yesterday` so you can run the script once a day…

… and get all of yesterday's messages
  • Loading branch information...
1 parent 950f703 commit 2cb6c2badac7cfae66b41d892768b4a8afa21331 @jesilz jesilz committed Sep 28, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/hipchatlogger/hiplogger.rb
@@ -91,8 +91,17 @@ def initialize_logging
end
def set_hipchat_date
- # use what is passed through '-d' if given -- Example: '-d 2012-09-27'
- @config["log_date"] = (@params["d"] ? @params["d"] : Time.now.strftime('%Y-%m-%d'))
+ # use what is passed through '-d' if given -- Example: '-d 2012-09-27' or '-d yesterday'
+ if @params["d"]
+ case @params["d"]
+ when "yesterday"
+ @config["log_date"] = (Time.now - (24*60*60)).strftime('%Y-%m-%d')
+ else
+ @config["log_date"] = @params["d"]
+ end
+ else
+ @config["log_date"] = Time.now.strftime('%Y-%m-%d')
+ end
end
def connect_to_hipchat

0 comments on commit 2cb6c2b

Please sign in to comment.