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
Implement postprocessing #726
Conversation
Looks good so far! I think there’s potential for quite a bit of refactoring here (e.g. unify code for pre- and postprocessor, move tests into specs) but that can wait. |
I can't seem to figure out how to get access to whether an item was created or modified. The only place I see such information use is right after a rep is written and notified. What would be the best way to store this information so it remains in the postprocess step? Should each item handle its own state via a new attribute? |
Hmm, that’s annoying. It seems like a good idea to have |
We won’t be able to add new items during the final postprocess
Also, the postprocessor should only have access to `context` and `items`. `layouts` seems superfluous.
I feel like I'm pretty close to getting On the bright side, it does seem like postprocessing as a whole is working. |
end | ||
|
||
def updated? | ||
reps.select { |rep| rep.status == :modified } |
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.
Can you replace :modified
with :updated
? This way, it reflects the name of the method.
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.
See other (big) comment—these two methods might not be necessary.
This is looking quite good so far. Making use of the |
Ah, thanks for the breakdown. I think the naming of the class was confusing me, without doing any inspection. I believe the class is actually called when the rep is going to be written to disk. It didn't occur to me that its created/modified checks could still be useful. I took nearly all of your suggestions. I kept the |
@@ -23,6 +23,9 @@ class ItemRep | |||
# @return [Enumerable<Nanoc::Int:SnapshotDef] | |||
attr_accessor :snapshot_defs | |||
|
|||
# @return [Boolean] | |||
attr_accessor :modified |
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.
Add alias_method :compiled?, :compiled
for extra sweetness
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 like sweetness.
@@ -27,6 +27,11 @@ def name | |||
@item_rep.name | |||
end | |||
|
|||
# @return [Boolean] |
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 like modified
(more than updated
which I use elsewhere) but I’m still hesitant to expose this as part of the public API just yet. I’d prefer to have it just on PostCompileItemView
for the time being.
(I’ve been bitten by trying to expose too much before, so I’d like to avoid that!)
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.
In other words, could you add # @api private
so it’s marked as private in the API docs?
👍 otherwise—looks awesome! |
Fair enough—it's your project! 🎆 |
Sweet! Will merge as soon as Travis CI gives the green light. |
Implement postprocessing
Thanks! |
This is a start to the implementation of a
postprocessor
block. I'm opening it up somewhat early to get some feedback on whether I'm on the right track.I mostly copied the work going on for the
preprocessor
block. I'd like to have an immutable items collection, with the addition of methods likeupdated?
andadded?
. That's what attributed_item_collection_view.rb is for.Closes #711.