Created
March 16, 2012 18:51
-
-
Save kwilczynski/2051811 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Facter.add(:noop) do | |
confine :kernel => :linux | |
result = false | |
setcode do | |
unless Facter.value(:environment).match(/^(test|dev|qa)$/) | |
result = true unless Time.now.utc.hour.between?(1, 10) | |
end | |
result | |
end | |
end |
instead of writing Time.now.utc.to_a[2]
you can also use Time.now.utc.hour
which is more readable
+1 :)
Edit: Amended as per Stefan's suggestion :)
Good stuff, guys!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: this will work given that "environment" fact is set / present. Otherwise, there has to be a conditional guarding it from failure due to NilClass yielding as "environment".