Smart directory #341

Open
wants to merge 5 commits into
from

Conversation

Projects
None yet
1 participant

TL;DR: added Actions#smart_directory which takes the same arguments as #directory, but allows users to specify a ".zc" file to complement a ".tt" file such that content in the .zc file is rendered then inserted the ".tt" file in sections marked "### Insert here ###" so that re-invocations will inject code when it would otherwise overwrite.

Motivation: I am a web app code slave and, for my work, I spend all day writing extremely similar code for a Ruby on Rails shop. To keep me sane, I built a code scaffolder that uses thor to copy over fairly complicated rails resources setups (for example, suppose ":" represents a has_many relationship, and "+" represents no relation, I built something to rapidly scaffold out a bunch of assets "negotiation:(offer:(listing+user)+comment:user+listing:user" ). Unfortunately, using Actions#directory doesn't make use of the state of the destination folder already there, and so calling the #directory methods repeatedly makes thor want to just overwrite files instead of adding onto them.

foxnewsnetwork added some commits Jun 20, 2013

Sometimes, using actions/directory is not enough to scaffold out more…
… complicated projects or to rescaffold junk.

SmartDirectory solves this problem by allowing users to provide a ".zc" file in addition to a ".tt" file such that
zc files render out into tt files much like how rails views and render out partials

Changes
=
* added require smart directory in actions
* created smart directory in much the same way that regular directory is implemented by adding some
  conditionals in when files / folders are copied and added a way to handle .zc files
* put in a dirtest folder in spec/fixtures to help with testing the smart directory thing

Side Effects
=
* None, all the tests still pass, only difference is now, rolling in Actions now have access to the
  smart_directory method (it takes the same arguments as directory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment