Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorjoshua_tam
     
    When I was doing my project, I found it difficult to remove the generated controllers, models, etc, is there any way to tackle this problem?
    •  
      CommentAuthorbermi
     

    Nothing bundled with Akelos for this.

    You can create a delete generator based on the clone generator. Modifying it so it deletes files instead of copying them.

    If you get this to work, you could contribute it as a plugin.

    • CommentAuthorsuthern
     
    I second the request! (After manually removing two models/controllers)
    • CommentAuthorccornwell
     
    Very timely thread, as I need to clean up after a scaffolding mishap.

    I've taken a cut at the delete_generator class itself, and have created most of the files for the plug-in by following the structure of the acts_as_versioned plugin. I'm not so sure about what needs to go into the test fixtures, but I would be glad to follow some simple directions. (Didn't I notice someone working on that on another thread?) I'm guessing
    - the test setup would need to create a test table and generate scaffolding against it,
    - the test case would invoke the delete_generator then scan the app tree to verify removal of all scaffolded models, views and colntrollers.
    Also, am I understanding correctly that I need to have Subversion running on my server in order to do the plug-in install for testing?

    Carl
    • CommentAuthorKaste
     

    AFAIK we don' test our scripts/generators.

    and we dont have a mock for the plugin-installer. don't know if you could do this. it would be very useful for the unit-tests.

    • CommentAuthorccornwell
     
    OK. It seems that AkelosGenerator will only pick up generators from the lib/utils/generators directory, so I am doing initial testing with the delete_generator installed there manually. Initial results are encouraging. I noticed that scaffold puts test components in places that the clone_generator is not looking. It also creates installers in the app/installers and test/fixtures/app/installers paths, so I need to add those to the cleanup scan along with a few other things like compiled layouts, and to prune empty class_to_delete directories from the tree. Should have something to share early next week.

    I may be able to look into a plugin-installer mock once I have a better idea of how things are put together in akelos.

    Carl
    •  
      CommentAuthorbermi
     

    @ccornwell app/vendor/plugins/plugin_name/generators is the place for distributing generators as plugins.

    Have a look at the calendar_helper for an example.

    • CommentAuthorccornwell
     
    Thanks for the pointer. That seems to do the trick, although I still haven't made the leap to setting up a Subversion repository or a mock to test installation. I've attached a snapshot of the delete_generator file. For now, I couldn't see how to upload a ZIP archive, so the contents of the USAGE file are at the end of this post. Note that there are still some issues to address, such as pruning empty directories and removing compiled view/layout templates. If I find time to package this up properly I'll resubmit it as an official plug-in contribution.

    USE WITH CAUTION if you generated scaffolding with different model and controller names i.e.

    >> ... script/generate scaffold Account Bank

    running the delete script with the same arguments

    >> ... script/generate delete Account Bank

    will remove the controller and views as expected. If you only specify the model class

    >> ... script/generate delete Account

    it will ONLY remove the model because it can't determine what controller was created by the scaffold script without searching the controllers directory for controllers that reference the 'account' model. It seems as though the RAILS destroy script is able to determine this sort of information from a generator manifest. Does Akelos have such a thing? (I noticed an old enhancement request - #14 - that references this, but it seems to have been dormant since then.)

    Also, if you have interacted with a scaffolded interface, the delete_generator can delete the locale and other files created by the web server's PHP engine only if you are running it with sufficient privileges to delete system files.

    A few issues I ran into while putting this together are being submitted through trac.

    Carl
    ===========================================================
    app/vendor/plugins/delete_plugin/generators/delete/USAGE
    -----------------------------------------------------------------------------------
    Description:
    The delete generator removes previously created controllers, models and views.

    The generator takes a singular name for the desired model and controller. If the
    controller name is omitted, the model name is used for the controller.

    Example:
    >> generate delete Account Bank

    Remove access to Bank controller with URLs like /bank/deposit.

    Model: app/models/account.php
    Test: test/unit/app/models/account.php
    Fixtures: test/fixtures/app/models/account.php
    test/fixtures/app/installers/account_installer.php
    Controller: app/controllers/bank_controller.php
    Views: app/views/bank/deposit.tpl [...]
    Helper: app/helpers/bank_helper.php
    Test: test/functional/controllers/bank_controller.php
    test/fixtures/app/controllers/bank_controller.php
    test/fixtures/app/helpers/bank_helper.php
    --------------------------------------
    • CommentAuthorKaste
     
    1. can you attach your code as patch against HEAD (in TRAC). would be a lot easier to critize.

    2. I think this should end up in the core, not in a plugin. IMHO.

    • CommentAuthorKaste
     

    looks good BTW. and don't tab use spaces.

    • CommentAuthorccornwell
     
    RE 1: OK, I'll work on that (I'm still finding my way around Akelos in general and TRAC in particular).

    RE 2: If going by the RAILS model, it would end up as a top level (script/destroy) rather than as a generator, but I'm too new to Akelos and RAILS to have an opinion on this.

    Thanks for the feedback.