No commit activity in last 3 years
No release in over 3 years
Write a longer description. Optional.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 0
~> 10.0
 Project Readme

RequirePatternXt

Build Status

__ a fork from https://github.com/Wardrop/RequirePattern with some impovements __

This library provides a simple extension to the Kernel module that allows files to be conveniantly require'd based on a glob pattern.

This library does NOT use load paths. Instead, it provides methods that load files either relative to the current working directory (require_pattern), or relative to the current file (require_relative_pattern).

Why?

At this point you may be wondering why would I not just do this:

Dir.glob('**/*.rb') { |f| require f }

In some instances you will get away with that, but what happens when file x must be required before file y? This is what this library intends to resolve. It will load files in a loop, keeping track of what succeeds, and fails with an exception. This process continues until either all files have been required, or until a loop iteration fails to load any files at all.

Installation

Add this line to your application's Gemfile:

gem 'require_pattern_xt'

And then execute:

$ bundle

Or install it yourself as:

$ gem install require_pattern_xt

Usage

Usage is relatively intuitive. Simply call either require_pattern or require_relative_pattern with one or more glob patterns, and all files matching those patterns will be required.

require_pattern 'lib/**/*.rb', 'models/**/*.rb'

Any files that refuse to load will be reported to STDERR with backtrace information.

Tests

$ sh/test

Interactive testing

$ sh/c
$ require_pattern 'test/dummy/**/**.rb'
irb(main):001:0> require_pattern 'test/dummy/**/**.rb'

Some files failed:
    test/dummy/bad.rb:
/Users/roman/Desktop/sand/require_pattern_xt/test/dummy/bad.rb:1:in `<top (required)>' uninitialized constant EvenWorse

Contributing

  1. Fork it ( https://github.com/[my-github-username]/require_pattern_xt/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request