When writing a Ruby library, when is it acceptable practice to do this in one file?
module MyLib
# some definitions
end
include MyLib
I found that usually, one has to
require 'some_gem'
first, and then
include SomeGem
But I wonder, in some simpler cases, when you just want to add a bit of funcionality to the core, would it be O.K. to include the main module by default?
Yes, it is a bad practice. If you include it, then you are choosing how people can use it. You are making the decision for them that they want it included in the global namespace. That isn’t your decision to make, be a good Ruby citizen, don’t change your user’s environments. Allow them to choose how they want to use the code.