Sha256: 76a719994001b8e733122d54104704d5365a623d9efced55813b5625a3c71a50

Contents?: true

Size: 725 Bytes

Versions: 17

Compression:

Stored size: 725 Bytes

Contents

require 'mspec/guards/guard'

class PlatformGuard < SpecGuard
  def initialize(*args)
    if args.last.is_a?(Hash)
      @options, @platforms = args.last, args[0..-2]
    else
      @options, @platforms = {}, args
    end
  end

  def match?
    match = @platforms.empty? ? true : platform?(*@platforms)
    @options.each do |key, value|
      case key
      when :os
        match &&= os?(*value)
      when :wordsize
        match &&= wordsize? value
      end
    end
    match
  end
end

class Object
  def platform_is(*args)
    g = PlatformGuard.new(*args)
    yield if g.yield?
    g.unregister
  end

  def platform_is_not(*args)
    g = PlatformGuard.new(*args)
    yield if g.yield? true
    g.unregister
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mspec-1.0.0 lib/mspec/guards/platform.rb
mspec-1.3.0 lib/mspec/guards/platform.rb
mspec-1.5.3 lib/mspec/guards/platform.rb
mspec-1.5.4 lib/mspec/guards/platform.rb
mspec-1.5.0 lib/mspec/guards/platform.rb
mspec-1.1.0 lib/mspec/guards/platform.rb
mspec-1.2.0 lib/mspec/guards/platform.rb
mspec-1.5.1 lib/mspec/guards/platform.rb
mspec-1.5.2 lib/mspec/guards/platform.rb
mspec-1.4.0 lib/mspec/guards/platform.rb
mspec-1.1.1 lib/mspec/guards/platform.rb
mspec-1.3.1 lib/mspec/guards/platform.rb
mspec-1.5.6 lib/mspec/guards/platform.rb
mspec-1.5.7 lib/mspec/guards/platform.rb
mspec-1.5.5 lib/mspec/guards/platform.rb
mspec-1.5.9 lib/mspec/guards/platform.rb
mspec-1.5.8 lib/mspec/guards/platform.rb