Sha256: 4fa02972861aeeeb6cdab8a0824d1bec515f47049307cbec7a17fbdf993bde08

Contents?: true

Size: 675 Bytes

Versions: 16

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

module KnapsackPro
  class Presenter
    class << self
      def global_time(time = nil)
        time = KnapsackPro.tracker.global_time if time.nil?
        global_time = pretty_seconds(time)
        "Global test execution duration: #{global_time}"
      end

      def pretty_seconds(seconds)
        sign = ''

        if seconds < 0
          seconds = seconds*-1
          sign = '-'
        end

        return "#{sign}#{seconds}s" if seconds.abs < 1

        time = Time.at(seconds).gmtime.strftime('%Hh %Mm %Ss')
        time_without_zeros = time.gsub(/00(h|m|s)/, '').strip
        sign + time_without_zeros
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
knapsack_pro-7.13.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.12.1 lib/knapsack_pro/presenter.rb
knapsack_pro-7.12.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.11.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.10.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.9.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.8.2 lib/knapsack_pro/presenter.rb
knapsack_pro-7.8.1 lib/knapsack_pro/presenter.rb
knapsack_pro-7.8.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.7.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.6.2 lib/knapsack_pro/presenter.rb
knapsack_pro-7.6.1 lib/knapsack_pro/presenter.rb
knapsack_pro-7.6.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.1.0 lib/knapsack_pro/presenter.rb
knapsack_pro-7.0.1 lib/knapsack_pro/presenter.rb
knapsack_pro-7.0.0 lib/knapsack_pro/presenter.rb