[x] Swap __dir__ for File.dirname(__FILE__) for Ruby < 2
[x] Check Gem::Specification#metadata exists before setting it
Why?
Ruby 2 introduced __dir__ as a shorthand for directory-containing-current-file, so we can't use it in older rubies.
Rubygems 2 introduced the metadata method (exposed as spec.metadata in the gemspec), so if we try and use it on older rubygem versions it throws a NoMethodError. We can just check for the existence before setting those attributes.
What?
__dir__
forFile.dirname(__FILE__)
for Ruby < 2Gem::Specification#metadata
exists before setting itWhy?
Ruby 2 introduced
__dir__
as a shorthand for directory-containing-current-file, so we can't use it in older rubies.Rubygems 2 introduced the metadata method (exposed as
spec.metadata
in the gemspec), so if we try and use it on older rubygem versions it throws aNoMethodError
. We can just check for the existence before setting those attributes.