require-magic

Utility functions to facilitate importing (require) ruby files in complex Ruby project, such as gem with complex folder hierarchies. See unit tests in /test directory to see how to use the tools for the best effect. Using this toolset should really simplify your require statements and make your application more flexible to change.

USAGE

See unit tests for demonstrations of how to use it:

To require all files within the top level folder ‘data’ (non-recursively)

  • required_files = Require.folder(‘data’)

The required_files returned is a list of the paths of the files that were required

To require all files within the top level folder ‘data’ (non-recursively) and apply tracing to see output for the process of requiring the files

  • required_files = Require.folder(‘data’)

To require all files within the top level folder ‘data’ recursively

  • required_files = Require.rfolder(‘data’)

To require all files within the top level folders ‘data’ and ‘data2’ (non-recursively)

  • required_files = Require.rfolders([‘data’, ‘data2’])

To require all files within the top level folders ‘data’ and ‘data2’ recursively

  • required_files = Require.rfolders([‘data’, ‘data2’])

To require files within the top level folders ‘data’ and ‘data2’ and also files within the subdirectory ‘blip’ if it exists

  • required_files = Require.folders([‘data’, ‘data2’], => [‘blip])

To require files within ‘data/blip’ and ‘data2/blip’ only

  • required_files = Require.folders([‘data’, ‘data2’], => [‘blip], :ignore_root_files => true)

To require files within ‘data’ and ‘data2’ first and then any files within the subdirectory ‘blip’ (default order)

  • required_files = Require.folders([‘data’, ‘data2’], => [‘blip], :root_files => :before)

To require files within ‘data/blip’ and ‘data2/blip’ first and then any files within ‘data’ and ‘data2’ folders

  • required_files = Require.folders([‘data’, ‘data2’], => [‘blip], :root_files => :after)

To require files within ‘data’ and ‘data2’ first and then any files within the subdirectory ‘blip’

  • required_files = Require.folders([‘data’, ‘data2’], => [‘blip], :root_files => :before)

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but

    bump version in a commit by itself I can ignore when I pull)
    
  • Send me a pull request. Bonus points for topic branches.

Copyright © 2009 Kristian Mandrup. See LICENSE for details.