Class: PlatformGuard

Inherits:
SpecGuard show all
Defined in:
lib/extensions/mspec/mspec/guards/platform.rb

Instance Attribute Summary

Attributes inherited from SpecGuard

#name, #parameters

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SpecGuard

#===, #add, clear, clear_guards, finish, guards, #implementation?, #os?, #platform?, #record, report, #report_key, #reporting?, ruby_version, ruby_version_override, ruby_version_override=, #standard?, #unregister, #windows?, #wordsize?, #yield?

Constructor Details

#initialize(*args) ⇒ PlatformGuard

Returns a new instance of PlatformGuard.



8
9
10
11
12
13
14
15
# File 'lib/extensions/mspec/mspec/guards/platform.rb', line 8

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

Class Method Details

.windows?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/extensions/mspec/mspec/guards/platform.rb', line 4

def self.windows?
  PlatformGuard.new(:os => :windows).match?
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/extensions/mspec/mspec/guards/platform.rb', line 17

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