Sha256: 3f288f29185d226c3176a9b204c9ee21b7c9466b1dc6bb545a6e205dc1d867ee

Contents?: true

Size: 462 Bytes

Versions: 3

Compression:

Stored size: 462 Bytes

Contents

class ProgressBar
  class Time
    def self.now(time = ::Time)
      @@time = time

      @@time.send unmocked_time_method
    end

  private
    def self.unmocked_time_method
      time_mocking_library_mapping.values.find { |method| @@time.respond_to? method }
    end

    def self.time_mocking_library_mapping
      {
        :timecop  => :now_without_mock_time,
        :delorean => :now_without_delorean,
        :actual   => :now
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-progressbar-1.0.1 lib/progress_bar/time.rb
ruby-progressbar-1.0.0 lib/progress_bar/time.rb
ruby-progressbar-1.0.0rc1 lib/progress_bar/time.rb