Class: PlatformGuard

Inherits:
SpecGuard show all
Defined in:
lib/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


12
13
14
15
16
17
18
19
# File 'lib/mspec/guards/platform.rb', line 12

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

.opal?Boolean


8
9
10
# File 'lib/mspec/guards/platform.rb', line 8

def self.opal?
  PlatformGuard.new(:opal)
end

.windows?Boolean


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

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

Instance Method Details

#match?Boolean


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mspec/guards/platform.rb', line 21

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