Plugin best practices

Discussion in 'Ruby' started by Intransition, Jun 15, 2011.

  1. Intransition

    Intransition Guest

    If your making a plugin/extension for another project, do you create a
    hyphenated lib file or do you put the library file in a subdirectory,
    e.g. say it's a plugin for rdoc,



    Intransition, Jun 15, 2011
    1. Advertisements

  2. I'd follow project conventions of how code is organized. If they do
    project/foo-lib.rb, I do that. If they do project/foo/lib.rb, I do

    If there is no discernible pattern, I'd go with project/plugin/foo/lib.rb.

    Phillip Gawlowski

    A method of solution is perfect if we can forsee from the start,
    and even prove, that following that method we shall attain our aim.
    =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Leibnitz
    Phillip Gawlowski, Jun 15, 2011
    1. Advertisements

  3. Intransition

    Josh Cheek Guest

    According to both of the resources I'd reference, it should be the latter.

    ions =3D=3D=3D=3D=3D

    Adding new functionality to an existing gem? Use a dash. Some examples
    include net-http-persistent and autotest-growl. Usually this implies that
    you=92ll have to require into their directory tree as well. For example, `g=
    install net-http-persistent` becomes `require 'net/http/persistent'`.

    =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D

    Project names SHOULD only contain underscores as separators in their
    names. If a project is an enhancement, plugin, extension, etc. for some
    other project it SHOULD contain a dash in the name between the original nam=
    and the project=92s name. File names and directory structure SHOULD corresp=
    like this:

    Library: foo-bar
    Directory: lib/foo/bar
    Namespace: Foo::Bar

    Library: foo_bar
    Directory: lib/foo_bar
    Namespace: FooBar
    Josh Cheek, Jun 15, 2011
  4. Intransition

    Intransition Guest

    Intransition, Jun 15, 2011
  5. Intransition

    Eric Hodel Guest

    (How many ruby packages have a setup.rb anymore, and who uses them? Is =
    it even 5% of rubyists? 1%?)
    If everybody agreed to foo-bar.rb instead of foo/bar.rb that wouldn't =
    solve the problem as they both share the same name.

    Giving two implementations the same file name is a social problem, not a =
    technical problem. We can't solve this with a technical solution.=
    Eric Hodel, Jun 15, 2011
  6. Intransition

    Intransition Guest

    ve the problem as they both share the same name.
    technical problem. =A0We can't solve this with a technical solution.

    If my plugin for `foo` is `bar` then my lib file will be `foo-bar.rb`
    and my gem's name `foo-bar`. So you won't have the same name, because
    I already have that gem. Clearly your gem and require will be `foo-
    baz`. No clash.
    Intransition, Jun 16, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.