-
Notifications
You must be signed in to change notification settings - Fork 2
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
Extract ExternalCommand class #72
base: master
Are you sure you want to change the base?
Conversation
This outlines the expected usage for the ExternalCommand class.
This class encapsulates running an external command and gathering up the output.
a929fa6
to
7dbcf6a
Compare
a62b715
to
2976cbf
Compare
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.
This is very old now, and I can't remember any of the context for why it got left hanging. There have been other substantial changes to the code in the meantime, which means this would need to be rebased over master
if we continue with it, but the underlying principle seems good, so it's probably worth picking up again.
@env = env | ||
end | ||
|
||
def run |
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.
I got tripped up by this being named as if it were a pure command method (i.e. would have no return value). I think it would be better to name this result
or equivalent to highlight that you're actually getting something back from it.
|
||
class ExternalCommand | ||
class Result | ||
attr_reader :output |
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.
it's a bit of a red flag for one of the constructor parameters to be public, and for there to be no behaviour whatsoever in this class related to it.
As the only method is really only a very simple delegation to the other constructor, I wonder if this really needs to be a full class at all, or whether a Struct might be enough for now. Or, perhaps this is a sign that this class should really be taking care of things like cleaning up the output, rather than returning it as-is for the caller to clean up?
This adds a new
ExternalCommand
class which encapsulates calling an external command and checking its exit status. This means that the code for running external commands is now nicely tested and easier to reason about.Fixes #45
Part of #62
Notes to merger
Please complete the following before merging:
master
once Do a shallow clone of everypolitician-data repo #71 has been merged.