Skip to content

Instantly share code, notes, and snippets.

@michaelbaudino
Last active August 29, 2015 13:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbaudino/8884362 to your computer and use it in GitHub Desktop.
Save michaelbaudino/8884362 to your computer and use it in GitHub Desktop.
Rails version matching
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