class Puppetfactory::Helpers

Public Class Methods

approximate_time_difference(timestamp) click to toggle source
# File lib/puppetfactory/helpers.rb, line 22
def self.approximate_time_difference(timestamp)
  return 'never' if timestamp.nil?

  start = timestamp.class == String ? Time.parse(timestamp) : timestamp
  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) click to toggle source
# File lib/puppetfactory/helpers.rb, line 5
def self.configure(options)
  @@options = options
end
environment_name(username) click to toggle source
# 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