Class: VersionGuard

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

Direct Known Subclasses

BugGuard

Instance Attribute Summary

Attributes inherited from SpecGuard

#name, #parameters

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(version) ⇒ VersionGuard

Returns a new instance of VersionGuard.



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

def initialize(version)
  case version
  when String
    @version = SpecVersion.new version
  when Range
    a = SpecVersion.new version.first
    b = SpecVersion.new version.last
    @version = version.exclude_end? ? a...b : a..b
  end
  self.parameters = [version]
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/extensions/mspec/mspec/guards/version.rb', line 21

def match?
  if Range === @version
    @version.include? ruby_version
  else
    ruby_version >= @version
  end
end

#ruby_versionObject



17
18
19
# File 'lib/extensions/mspec/mspec/guards/version.rb', line 17

def ruby_version
  @ruby_version ||= SpecVersion.new self.class.ruby_version(:full)
end