Class: VersionGuard
- Defined in:
- lib/extensions/mspec/mspec/guards/version.rb
Direct Known Subclasses
Constant Summary collapse
- FULL_RUBY_VERSION =
SpecVersion.new SpecGuard.ruby_version(:full)
Instance Attribute Summary
Attributes inherited from SpecGuard
Instance Method Summary collapse
-
#initialize(version) ⇒ VersionGuard
constructor
A new instance of VersionGuard.
- #match? ⇒ Boolean
Methods inherited from SpecGuard
#add, clear, clear_guards, finish, guards, #record, report, #report_key, #reporting?, ruby_version, #run_if, #run_unless, #unregister, #yield?
Constructor Details
#initialize(version) ⇒ VersionGuard
Returns a new instance of VersionGuard.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/extensions/mspec/mspec/guards/version.rb', line 8 def initialize(version) case version when String @version = SpecVersion.new version when Range MSpec.deprecate "an empty version range end", 'a specific version' if version.end.empty? a = SpecVersion.new version.begin b = SpecVersion.new version.end unless version.exclude_end? MSpec.deprecate "ruby_version_is with an inclusive range", 'an exclusive range ("2.1"..."2.3")' end @version = version.exclude_end? ? a...b : a..b else raise "version must be a String or Range but was a #{version.class}" end @parameters = [version] end |
Instance Method Details
#match? ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/extensions/mspec/mspec/guards/version.rb', line 26 def match? if Range === @version @version.include? FULL_RUBY_VERSION else FULL_RUBY_VERSION >= @version end end |