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

Separate prefix options for directories and filenames in partial references #21

Merged
merged 10 commits into from
Oct 18, 2014

Conversation

corpulentcoffee
Copy link
Contributor

I'm introducing this as a possible resolution for issue #9.

This changeset adds options support for prefix_dir and prefix_file, which clarifies prefix configuration for partial references that use a path. The original prefix option continues to be available, and has the same behavior as before. The included documentation recommends prefix_dir and prefix_file but still mentions prefix.

Also included are new unit tests for a partial reference using a path but no configured partial directory or prefix (which works in the current version), prefix using a path (to test the old weird behavior), prefix_file by itself, prefix_dir by itself, and prefix_file/prefix_dir combined.

@5thWall, @franz-josef-kaiser: Feel free to take a look and let me know if you see any issues or problems with this approach.

Adds to test/fixtures/partials/sub-a and test/fixtures/partials/sub-b
for future unit tests involving testing partial references that use
directories rather than just bare filenames.

Included in each subdirectory are three partials analogous to those
found in the parent directory.
Introduces a new test to the testing suite that combines the existing
prefix option with a partial reference that uses a subdirectory. The aim
of this test of to ensure that the (arguably weird) behavior of applying
a prefix to the directory works in future versions of the plug-in after
changes are made to the prefix handling.
Introduces another unit test for the purposes of making sure that a user
who specifies a partial relative to the base of their project (i.e. such
a reference where they have left the 'directory' option blank) gets the
correct result with the upcoming prefix changes.
Adds support for these new options, including mapping usage of the
old-style prefix option to the new option depending on what kind of
partial reference is encountered.

For bare filenames, prefix behaves like filenamePrefix. For paths
including a directory, prefix behaves like directoryPrefix (which
matches the current weird behavior).
Adds unit tests for filenamePrefix, directoryPrefix, and a combination
of the two. Reuses existing fixture data and expectation output, except
for the combination unit test which uses new expectation output.
If the user attempts to use a partial reference that does not exist or
tries to use the old-style prefix option with a path, prints a warning
to the terminal.
Prints a warning to the terminal if the plug-in encounters a bare
filename partial in a ruleset that has specified a directoryPrefix.
Adds directoryPrefix and filenamePrefix to the options list, replacing
the old prefix option.
Switches directoryPrefix to prefix_dir and filenamePrefix to
prefix_file, which more closely matches the existing naming convention
used by the other options. By renaming directoryPrefix, this also avoids
the inherent confusion with the unrelated 'directory' option.
I did not end up using sub-b/ and also do not test alternate extensions
in combination, these files can safely be removed.
@franz-josef-kaiser
Copy link

Just came back from vacation and have to work on something else atm. Would you please ping me if I forget to get back on this issue? Thanks in advance.

@corpulentcoffee corpulentcoffee merged commit 8540865 into master Oct 18, 2014
corpulentcoffee added a commit that referenced this pull request Oct 18, 2014
Introduces prefix_file and prefix_dir as separate options for looking up
the paths of partials. The original prefix option is maintained for
backward-compatibility.

Fixes #9.
Closes #21.
@franz-josef-kaiser
Copy link

Of course I forgot about it :)

Thanks for the changes. This really makes it ultra flexible from what I can see in the unit tests. Great changes, will test them (hopefully) soon.

@corpulentcoffee
Copy link
Contributor Author

No problem. It's not too late for other changes if you find anything that needs fixing. Thanks, @franz-josef-kaiser!

@corpulentcoffee corpulentcoffee deleted the prefix-expansion branch June 9, 2015 17:09
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.

2 participants