-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use namespaced loaders rather than method with global scope #1481
Conversation
Thank you for taking on this @pyrmont |
@ashmaroli Ta! Do you think it needs anything else? |
Technically, module Rouge
class << self
def reload!
...
end
private
def load_file(path)
...
end
load_file 'version'
end
end In theory, it should work seamlessly with Rouge's existing workflow. However, I've not tested it and therefore if you feel it is unnecessary or if it won't work in practice, the pull request as of this comment looks good to be merged. |
@ashmaroli We can't actually make the methods private because they're called from outside Rouge (technically you could still call them using I did make one more change, though. Given that the methods are not intended to be part of a public API, I've moved them below the Thanks for the feedback and the initial PR! |
Yeah that's why I suggested moving the calls inside the Rouge singleton class in my comment. |
Ah, I see what you meant. Sorry about that—my misunderstanding. Agreed to see how this goes for now :) |
…#1481) Rouge currently uses two global methods defined in `lib/rouge.rb`, `#load_relative` and `#lexer_dir`, to load the various files in the Rouge library. Rather than add methods to the global namespace, it would be preferable if the loading methods were within the Rouge module. This commits adds two methods to Rouge's singleton class, `#load_file` and `#load_lexers`, and updates `lib/rouge.rb` to use these methods.
Rouge currently uses two global methods,
#load_relative
and#lexer_dir
, defined inlib/rouge.rb
to load the various files that constitute Rouge. Rather than pollute the global namespace, it would be preferable if the loading methods were within theRouge
module.This PR adds two top-level methods to
Rouge
's singleton class:#load_file
and#load_lexers
. It is a fork of, and builds on the work of @ashmaroli in, #1430.