Sha256: 405257f06a0ef076fba4df87790921c6d25bb7f651d780e947ec6ba35d498e57

Contents?: true

Size: 766 Bytes

Versions: 17

Compression:

Stored size: 766 Bytes

Contents

require 'puppetfactory'

class Puppetfactory::Helpers

  def self.configure(options)
    @@options = options
  end

  def self.environment_name(username)
    case @@options[:repomodel]
    when :peruser
      "#{username}_production"

    when :single
      username

    else
      raise "Invalid setting for repomodel (#{repomodel})"
    end
  end

  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

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
puppetfactory-0.6.5 lib/puppetfactory/helpers.rb
puppetfactory-0.6.4 lib/puppetfactory/helpers.rb
puppetfactory-0.6.3 lib/puppetfactory/helpers.rb
puppetfactory-0.6.2 lib/puppetfactory/helpers.rb
puppetfactory-0.6.1 lib/puppetfactory/helpers.rb
puppetfactory-0.6.0 lib/puppetfactory/helpers.rb
puppetfactory-0.5.9 lib/puppetfactory/helpers.rb
puppetfactory-0.5.8 lib/puppetfactory/helpers.rb
puppetfactory-0.5.7 lib/puppetfactory/helpers.rb
puppetfactory-0.5.6 lib/puppetfactory/helpers.rb
puppetfactory-0.5.5 lib/puppetfactory/helpers.rb
puppetfactory-0.5.4 lib/puppetfactory/helpers.rb
puppetfactory-0.5.3 lib/puppetfactory/helpers.rb
puppetfactory-0.5.2 lib/puppetfactory/helpers.rb
puppetfactory-0.5.1 lib/puppetfactory/helpers.rb
puppetfactory-0.5.0 lib/puppetfactory/helpers.rb
puppetfactory-0.4.0 lib/puppetfactory/helpers.rb