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

Allow calling #write twice #1085

Merged
merged 10 commits into from Feb 17, 2017
Merged

Allow calling #write twice #1085

merged 10 commits into from Feb 17, 2017

Conversation

@ddfreyne
Copy link
Member

@ddfreyne ddfreyne commented Feb 17, 2017

Fixes #1037. Allows calling #write multiple times.

Steps:

  • Allow snapshot actions to have multiple names
  • Allow snapshot actions to have multiple paths
  • Allow item reps to have multiple paths per snapshot
  • Merge consecutive snapshot actions into one
  • Assign unique names to snapshot actions with no names
@ddfreyne ddfreyne force-pushed the write-twice branch 2 times, most recently from 22c9ce8 to 6c0b848 Feb 17, 2017
@ddfreyne
Copy link
Member Author

@ddfreyne ddfreyne commented Feb 17, 2017

Forward path references continue to be a pain… e.g.

compile '/foo.*' do
  snapshot :raw
  filter :relativize_paths, type: :html unless rep.path.nil?
  write item.identifier.without_ext + '.html'
  snapshot :last
end

(:raw and :last snapshots added for clarity.)

The issue is here is that rep.path is hard to predict. If it were to return a string, then the :last snapshot will have a path, while the :raw snapshot does not. This is in line with expectations.

Now consider this example, where write and filter are inverted:

compile '/foo.*' do
  snapshot :raw
  write item.identifier.without_ext + '.html'
  filter :relativize_paths, type: :html unless rep.path.nil?
  snapshot :last
end

If rep.path were to return a string, then the :last snapshot will not have a path. Inversely, if rep.path returns nil, then the :last snapshot will have a path. This contradicts itself!

Loading

@ddfreyne
Copy link
Member Author

@ddfreyne ddfreyne commented Feb 17, 2017

I’ve decided to not deal with the non-convergence issue yet. I believe this could be detected (i.e. if the paths have not yet converged after two attempts at calculating them, raise an error).

Loading

@ddfreyne ddfreyne added this to the 4.6.1 milestone Feb 17, 2017
@ddfreyne ddfreyne added this to the 4.6.2 milestone Feb 17, 2017
@ddfreyne ddfreyne removed this from the 4.6.1 milestone Feb 17, 2017
@ddfreyne ddfreyne merged commit 1378038 into master Feb 17, 2017
1 check passed
Loading
@ddfreyne ddfreyne deleted the write-twice branch Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant