Sha256: a56ffae952880d6a6fd809cfc0e2881f2305c443befec5248f90537d84aa1c54

Contents?: true

Size: 826 Bytes

Versions: 117

Compression:

Stored size: 826 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
    self.parameters = args
  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)
    g.name = :platform_is
    yield if g.yield?
  ensure
    g.unregister
  end

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

Version data entries

117 entries across 93 versions & 3 rubygems

Version Path
rhodes-2.0.0.beta6 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta4 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta4 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta3 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta3 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-1.5.5 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-1.5.5 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta2 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta2 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta1 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-2.0.0.beta1 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-1.5.4 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-1.5.4 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-1.5.3 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-1.5.3 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-1.5.2 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-1.5.2 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-1.5.1 spec/framework_spec/app/mspec/guards/platform.rb
rhodes-1.5.1 res/generators/templates/spec/app/mspec/guards/platform.rb
rhodes-1.5.0 res/generators/templates/spec/app/mspec/guards/platform.rb