Skip to content
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

Make the change easy #24

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Make the change easy #24

wants to merge 12 commits into from

Conversation

stevenharman
Copy link
Owner

Lots of refactoring and/or re-design, before making a change to allow a "template" or strategy-based mechanism for looking up the current "issue number." These changes are largely based on me returning to this code base for the first time, in earnest, in many years, and the experience, understanding, and aesthetics I've developed in that time.

This is pretty darn normalized on *nix systems these days, where this
will be installed via Homebrew. Let's rely on that rather than
hard-coding to a version of Ruby that can/will likely change over time.

Also, use the Regex#match? and avoid extra object; we don't need/use the
MatchData, so don't create it.
Whomever calls Hook::init should be responsible for saying where to
install. We also simplify things a bit by relying on a tempdir in the
tests.
The /o flag tells Ruby to only interpolate the regex once, cache the
result of that interpolation, and use it for the rest of the life of the
project. Effectively, it in-lines the result of the first time you
interpolate. This is a Bad Time™️ for us because that means we cache the
first story number we try. In most production usages this is fine b/c we
fire up the Ruby process and only check a single time. But that's not
true for tests, so depending on the order tests are run, they could
start breaking!

No more!
Instead we can use features of modern Ruby - the squiggly heredoc (<<~).
Which also means we no longer need ActiveSupport 🎉
We can rely on Pathname to do some of the heavy lifting, while also
hiding some implementation details (KEYWORD_REGEX), and optimizing some
of our regex usage by using #match? when we don't need the MatchData
object that would be created by a `#~`.

We also remove our dependence on the FakeFile object, trading off that
explicit isolation for a more pliable implementation. That is, our test
setup doesn't rely on stubbing out Stdlib file access. Instead we set up
some fixures via temp dirs and then read/write actual files.
Rather than bespoke and inconsistent "action" methods for these
execution objects, rely on a norm.
We don't want to try inlining something from stdlib, for example.
Which is where Gem archives are already being built, so why dirty up
our root dir?
i.e., we now use `--help` rather than a `help` sub-command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant