-
Notifications
You must be signed in to change notification settings - Fork 95
Refactor InMemory Stuff -> {InMemory,FileSystem}Storage #148
Conversation
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.
Beautiful refactoring 👏
Just a few optimization ideas.
def lines | ||
# Retain trailing newline character | ||
@lines ||= source.split("\n", -1) | ||
end | ||
|
||
# Not entirely obvious but lines is mutable, corrections are to be |
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.
Instead we should just reset @lines
in write
, this way lines
will always be the correct method to call:
def write
# ...
@lines = nil
end
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.
Not sure I understand this one. The intention behind this method was to do a check on source != updated_source before writing. And to use it in tests rather than the path.read we had in test_helper.
a3c783a
to
a8bb556
Compare
test/template_test.rb
Outdated
storage = make_storage(files) | ||
@template = ThemeCheck::Template.new( | ||
"templates/index.liquid", | ||
storage |
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.
Now that we're back at one. Can probably inline a couple of those vars.
77a1178
to
cc68206
Compare
cc68206
to
90799f5
Compare
Follow up on #145
From
to