I've tried to create a Ruby gem by doing 'bundle gem [gem_name]' and all went well (there is a main folder and inside there is lib and spec folders). In the .gemspec file I saw this:
lib = File.expand_path('../lib', __FILE__) while produces an absolute path to the /lib. However, the same result can be accomplished with:
File.expand_path('lib') There was some explanation in this post File.expand_path("../../Gemfile", __FILE__) How does this work? Where is the file? on how complicated the first approach is, so I was wondering, does it really have an advantage relative to the second and simpler approach?
__dir__was added in Ruby 2.0.0. Your two code fragments are not equivalent, the second one does not use the current file path.