Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Adding a class to a module - Can Module::Starter or Dist::Zilla help?

by kcott (Archbishop)
on Aug 13, 2012 at 15:09 UTC ( [id://987139]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Adding a class to a module - Can Module::Starter or Dist::Zilla help?
in thread Adding a class to a module - Can Module::Starter or Dist::Zilla help?

Nothing you have here leaps out at me as being wrong.

I had a dig around in some of the source code. Module::Starter::PBP inherits from Module::Starter::Simple. It is Module::Starter::Simple's create_basedir() method that generates the "... already exists.  Use --force if you want to stomp on it." message. As far as I can see, you can't use Module::Starter::PBP to add a module to an existing distribution - I'm happy to be contradicted on that if someone knows a way to do it.

None of the examples in my original reply used Module::Starter::PBP. You may find excluding that plugin fixes the immediate problem but I wouldn't really consider that a particularly good solution. You could subclass Module::Starter::PBP and write your own create_basedir() method - that's just a suggestion, there may be other implications which you should look into first.

-- Ken

Replies are listed 'Best First'.
Re^4: Adding a class to a module - Can Module::Starter or Dist::Zilla help?
by mascip (Pilgrim) on Aug 13, 2012 at 17:35 UTC

    Thank you for feedback. I've tried without the PBP plugin and templates, and it did the same anyway.

    I just peeked in the Module::Starter::Smart source code, to find the same thing as you, the error message comes from create_basedir().

    The documentation says:
    "When invoked, the plugin checks if the distribution is already created. If so, the plugin would bypass C<create_basedir>) and go ahead pull in all the existing modules and test files; these information would be used later in the corresponding file creation subroutines for skipping already-created files"

    So, it means that the create_distro() function doesn't do its job : it should not call create_basedir(), when the C:/My-Example already exists.

    * Tweaking-searching in the modules... *

    Ah !!! Here you go, i found the problem ! By adding print() statements both in Module/Starter/Simple.pm and Module/Starter/Smart.pm, i realized that when i use module-starter, it's Module::Starter::Simple who runs, not Module::Starter::Smart

    If anybody knew why, it'd be good to hear. Otherwise, i'll have to try and understand how Module::Starter::Simple checks for plugin in the configuration file, and then uses them. I'll see if-when i have the time.

    At least, part of the mystery is solved.

    Edit-bis : my last Edit was wrong.

      I found that i could use the --plugin=Module::Starter::Smart argument, to use the plugin. Now it works properly.

      I still don't know why the configuration line's plugin: Module::Starter::Smart didn't work previously. While all the others worked properly.

      Edit: Well, i get it now. I can use one plugin or the other, but not both, as they inherit from the same class (Module::Starter::Simple). So, Module::Starter::PBP and Module::Starter::Smart won't work simultaneously.
      Well... They will, if i cheat. I just changed Module/Starter/Smart.pm, so that it inherits from Module::Starter::PBP, instead of Module::Starter::Simple. It works !

      Is there any way to make a cleaner solution, from this dirty one?

        Ok, i found my solution for now. It also works when i do the opposite inheritance : when Module::Starter::PBP inherits from Module::Starter::Smart.

        So, i'll create my own plugin, maybe called Module::Starter::PBP::Perso. It will just be a copy-paste of Module::Starter::PBP, inheriting from MS-Smart instead of MS-Simple.

        And anyway, i'll have to read the source code and change little details in the module, in order to add the creation of the ./t/My/Example/Class/01_unit_test.t file, as well as ./t/lib My/Example/Class/Builder.pm. And i'll try to add my Log4perl configuration stuff at the same time.

        ~ ~ ~ I'm still curious on whether Dist::Zilla proposes something to do this.

        I appreciate this post immensely! I dont know if this helps to identify any additional issues, but local::lib can add confusion with this on top of use of multiple prefixes. Of course this means multiple module destinations, depending on "package" install or "manual" install. When I say "package" i mean stuff like apt, yum, rpm.. manual here refers to using cpan(p/m) and the like, which isn't what you would usually imagine.

        Furthermore, I never came across an initial install sequence that would result in ::Smart being used instead of ::Simple (without the --plugin argument, or script editing directly).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://987139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-28 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found