Last active
August 29, 2015 13:56
-
-
Save michaelbaudino/8884362 to your computer and use it in GitHub Desktop.
Rails version matching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rails_version_matches?(requirement) | |
Gem::Requirement.new(requirement).satisfied_by? Gem::Version.new(::Rails::VERSION::STRING) | |
end | |
def rails_version_matches_any?(*requirements) | |
requirements.map{ |r| rails_version_matches?(r) }.reduce(:|) | |
end | |
def rails_version_matches_all?(*requirements) | |
requirements.map{ |r| rails_version_matches?(r) }.reduce(:&) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment