Here is small idea I've had for sometime that I quickly knocked up yesterday.
Generators are great but we have all had those "Oops!" moments where you realised that what you created was not quite what you wanted to do. Enter script/generate undo....
script/generate model WrongName
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/wrong_name.rb
create test/unit/wrong_name_test.rb
create test/fixtures/wrong_names.yml
exists db/migrate
create db/migrate/001_create_wrong_names.rb
.. ....
oops.. didn't want to do that.
script/generate undo
Undo'ing: model WrongName
notempty db/migrate
notempty db
rm db/migrate/001_create_wrong_names.rb
rm test/fixtures/wrong_names.yml
rm test/unit/wrong_name_test.rb
rm app/models/wrong_name.rb
notempty test/fixtures
notempty test
notempty test/unit
notempty test
notempty app/models
notempty app
Under the hood all it is doing is keeping a log of your generator history (see /log/generator.log). When undo is called it looks at the last log entry and passes it onto script/destroy. Pretty simple stuff but it saves you having to remember what it was that you typed previously.
The patch as it stands is pretty rough and ready. I'm posting this here to get some feedback to gauge whether it's worth pursuing further.
UPDATE Plugin on the way. I've created a new project on Rubyforge for any plugins I make - it should be setup soon. (just waiting for approval)
UPDATE 2: Plugin now released. See this post



