Closed dunn closed 8 years ago
Thanks for the PR! This is a good idea, but maybe we should mimic how Rubygems does it for consistency with other Ruby tools:
ENV['GEM_EDITOR'] ||
ENV['VISUAL'] ||
ENV['EDITOR'] ||
'/usr/local/bin/subl'
I think it is important to still provide a fallback in case $EDITOR
is not set.
Oh, even better. I'll try to update the PR later this evening.
How does that look?
Great! Now ideally we would have test coverage for this. Is that something you can take a stab at?
To make testing easier, it might be better to get rid of the DEFAULT_EDITOR
constant and move the ENV
logic into a private method. That way we can stub ENV[]
in the spec (otherwise ENV
is consulted only once, when the .rb file is parsed).
private
def default_editor
# ENV access goes here...
end
def default_config
{ editor: default_editor } # instead of DEFAULT_EDITOR
end
Does that make sense?
Think so; I'll see what I can do.
How's that look?
This is a good improvement, but I notice that the tests fail if I have a ~/.xrayconfig
file present. That's because the default editor is only used when ~/.xrayconfig
is absent.
I think we'll have to refactor a bit further to make the tests reliable. Any ideas?
Sorry I let this sit; I'll try to remember this weekend to look into the .xrayconfig
issue.
Done; sorry for the delay!
Great! Thanks for a great PR!
I'll publish a new release by the end of the week.
v0.1.22 has been released!
The
$EDITOR
variable is a well-established convention, and people using Sublime probably have it set tosubl
, so I think this is probably a better default setting.