Sha256: f5b14fad7c6728761741d421ae9621e45103454531f7a9e0e5984e4b82d13e05

Contents?: true

Size: 1.22 KB

Versions: 15

Compression:

Stored size: 1.22 KB

Contents

require 'retriable'
require 'retriable/version'

module XamarinTestCloud
  # A class to bridge the gap between retriable 1.x and 2.0.
  class RetriableOptions

    def self.retriable_version
      parts = Retriable::VERSION.split('.')
      {
            :major => parts[0] ? parts[0].to_i : nil,
            :minor => parts[1] ? parts[1].to_i : nil,
            :patch => parts[2] ? parts[2].to_i : nil
      }
    end

    def self.tries_and_interval(tries, interval)
      version = self.retriable_version[:major]
      if version >= 2
        {:intervals => Array.new(tries, interval)}
      else
        {:tries => tries, :interval => interval}
      end
    end
  end
end

# Only in retriable 1.4.0 (so far).
unless Retriable.public_instance_methods.include?(:retriable)
  require 'retriable/retry'
  module Retriable
    extend self

    def retriable(opts = {}, &block)
      raise LocalJumpError unless block_given?

      Retry.new do |r|
        r.tries    = opts[:tries] if opts[:tries]
        r.on       = opts[:on] if opts[:on]
        r.interval = opts[:interval] if opts[:interval]
        r.timeout  = opts[:timeout] if opts[:timeout]
        r.on_retry = opts[:on_retry] if opts[:on_retry]
      end.perform(&block)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
xamarin-test-cloud-2.3.0 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.2.0 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.1.2 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.1.1 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.1.0 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.3 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.2 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.1 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.1.pre1 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.0 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.0.pre5 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.0.pre4 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.0.pre2 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-2.0.0.pre1 lib/xamarin-test-cloud/retriable_options.rb
xamarin-test-cloud-1.1.2 lib/xamarin-test-cloud/retriable_options.rb