-
Notifications
You must be signed in to change notification settings - Fork 444
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 XDG_DATA_DIRS to locate mime database #163
base: master
Are you sure you want to change the base?
Conversation
@jellybob could you have a look? |
@@ -3,7 +3,15 @@ require "rake/clean" | |||
|
|||
def locate_mime_database | |||
possible_paths = [ | |||
(File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) if ENV["FREEDESKTOP_MIME_TYPES_PATH"]), | |||
(File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) if ENV["FREEDESKTOP_MIME_TYPES_PATH"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion]
Should you consider creating a small method called listPossiblePaths and avoid having these hard-to-read (IMHO) lines?
For example:
def listPossibleMimePaths
paths = []
paths = File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"] if ENV["FREEDESKTOP_MIME_TYPES_PATH"]
...
paths
end
(File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) if ENV["FREEDESKTOP_MIME_TYPES_PATH"]), | ||
(File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) if ENV["FREEDESKTOP_MIME_TYPES_PATH"]) | ||
] + ( | ||
if ENV["XDG_DATA_DIRS"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion]
If you use ENV.fetch with [] as default you can avoid one extra if statement. Check it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I left some small comments that would make your code a bit easier to read.
I ran into issue #160. Not all operating systems are using /usr or /opt and
XDG_DATA_DIRS
was made to avoid hard-coding paths like /usr and /opt. This PR makes use ofXDG_DATA_DIRS
while still maintaining compatibility with systems that do not haveXDG_DATA_DIRS
.On my system
XDG_DATA_DIRS
looks like:Fixes #160
Possible replacement for #125