Class: Puppetfactory::Helpers
- Inherits:
-
Object
- Object
- Puppetfactory::Helpers
- Defined in:
- lib/puppetfactory/helpers.rb
Class Method Summary collapse
- .approximate_time_difference(timestamp) ⇒ Object
- .configure(options) ⇒ Object
- .environment_name(username) ⇒ Object
Class Method Details
.approximate_time_difference(timestamp) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppetfactory/helpers.rb', line 22 def self.approximate_time_difference() return 'never' if .nil? start = .class == String ? Time.parse() : delta = (Time.now - start) if delta > 60 # This grossity is rounding to the nearest whole minute mins = ((delta / 600).round(1)*10).to_i "about #{mins} minutes ago" else "#{delta.to_i} seconds ago" end end |
.configure(options) ⇒ Object
5 6 7 |
# File 'lib/puppetfactory/helpers.rb', line 5 def self.configure() @@options = end |
.environment_name(username) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/puppetfactory/helpers.rb', line 9 def self.environment_name(username) case @@options[:repomodel] when :peruser "#{username}_production" when :single username else raise "Invalid setting for repomodel (#{repomodel})" end end |