A summary of data about the Ruby ecosystem.

https://github.com/jarmo/require_all

A wonderfully simple way to load Ruby code
https://github.com/jarmo/require_all

Keywords from Contributors

rubygems code-formatter rubocop static-code-analysis activejob activerecord mvc rack code-quality coverage

Last synced: about 9 hours ago
JSON representation

Repository metadata

A wonderfully simple way to load Ruby code

README.md

require_all

Gem Version
Build Status
Coverage

A wonderfully simple way to load your code.

Tired of futzing around with require statements everywhere, littering your code
with require File.dirname(__FILE__) crap? What if you could just
point something at a big directory full of code and have everything just
automagically load?

Wouldn't that be nice? Well, now you can!

Installation

Add this line to your application's Gemfile:

gem 'require_all'

And then execute:

$ bundle

Or install it yourself as:

$ gem install require_all

Usage

require 'require_all'

# load all ruby files in the directory "lib" and its subdirectories
require_all 'lib'

# or load all files by using glob
require_all 'lib/**/*.rb'

# or load files in an Array
require_all Dir.glob("blah/**/*.rb").reject { |f| stupid_file? f }

# or load manually specified files
require_all 'lib/a.rb', 'lib/b.rb', 'lib/c.rb', 'lib/d.rb'

You can also load files relative to the current file by using require_rel:

# Instead of
require File.dirname(__FILE__) + '/foobar'

# you can do simply like this
require_rel 'foobar'

You can give all the same argument types to the require_rel as for require_all.

It is recommended to use require_rel instead of require_all since it will require files relatively
to the current file (__FILE__) as opposed to loading files relative from the working directory.

load_all and load_rel methods also exist to use Kernel#load instead of Kernel#require!

Files are required in alphabetical order and if there are files in nested directories, they are
required depth-first. If a NameError caused by a reference to an uninitialised constant is
encountered during the requiring process, then a RequireAll::LoadError will be thrown,
indicating the file that needs the dependency adding to.

autoload_all

This library also includes methods for performing autoload - what a bargain!

Similar syntax is used as for require_(all|rel) and load_(all|rel) methods with some caveats:

  • Directory and file names have to reflect namespaces and/or constant names:
# lib/dir1/dir2/my_file.rb
module Dir1
  module Dir2
    class MyFile
    end
  end
end

# lib/loader.rb
autoload_all File.dirname(__FILE__) + "/dir1"
  • A base_dir option has to be specified if loading directories or files from some other location
    than top-level directory:
# lib/dir1/other_file.rb
autoload_all File.dirname(__FILE__) + "/dir2/my_file.rb",
             base_dir: File.dirname(__FILE__) + "/../dir1"
  • All namespaces will be created dynamically by autoload_all - this means that defined?(Dir1) will
    return "constant" even if my_file.rb is not yet loaded!

Of course there's also an autoload_rel method:

autoload_rel "dir2/my_file.rb", base_dir: File.dirname(__FILE__) + "/../dir1"

If having some problems with autoload_all or autoload_rel then set $DEBUG=true to see how files
are mapped to their respective modules and classes.

Version compatibility and upgrading

As of version 2, RequireAll will raise a RequireAll::LoadError if it encounters a NameError
caused by a reference to an uninitialised constant during the requiring process. As such, it is not
backwards compatible with version 1.x, but simple to upgrade by adding any requires to load
dependencies in files that need them. See CHANGES for more details.

Questions? Comments? Concerns?

You can reach the author on github or by email jarmo.p@gmail.com

License

MIT (see the LICENSE file for details)


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 132
Total Committers: 12
Avg Commits per committer: 11.0
Development Distribution Score (DDS): 0.576

Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
Jarmo Pertman j****p@g****m 56
Tony Arcieri t****y@m****m 50
Aaron Klaassen a****n@o****m 8
Matijs van Zuijlen m****s@m****t 5
Eric Kessler m****8@g****m 5
Joe Horsnell g****b@j****m 2
Stefan Wrobel s****l 1
Owen Stephens o****n@o****k 1
James Le Cuirot j****t@y****m 1
Adam Daniels a****m@m****a 1
Shota Miyamoto m****o@f****p 1
Alexander Koltun A****n@v****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: 9 days ago

Total issues: 13
Total pull requests: 17
Average time to close issues: 8 months
Average time to close pull requests: 3 months
Total issue authors: 13
Total pull request authors: 12
Average comments per issue: 4.62
Average comments per pull request: 6.06
Merged pull request: 13
Bot issues: 0
Bot pull requests: 0

Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/jarmo/require_all

Top Issue Authors

  • jasonkarns (1)
  • lardcanoe (1)
  • olerass (1)
  • bf4 (1)
  • stanislaw (1)
  • kotp (1)
  • mvz (1)
  • jnardone (1)
  • kamenlitchev (1)
  • enkessler (1)
  • AutumnJ (1)
  • jjrussell (1)
  • dcalixto (1)

Top Pull Request Authors

  • enkessler (4)
  • joehorsnell (3)
  • mvz (1)
  • chewi (1)
  • akoltun (1)
  • richpeck (1)
  • swrobel (1)
  • owst (1)
  • surume (1)
  • wishdev (1)
  • aaronklaassen (1)
  • adam12 (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

gem.coop: require_all

A wonderfully simple way to load your code

rubygems.org: require_all

A wonderfully simple way to load your code

proxy.golang.org: github.com/jarmo/require_all

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/jarmo/require_all#section-documentation
  • Licenses: mit
  • Latest release: v3.0.0+incompatible (published about 6 years ago)
  • Last Synced: 2025-12-03T16:00:58.723Z (9 days ago)
  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.442%
    • Average: 5.624%
    • Dependent repos count: 5.807%

Dependencies

Gemfile rubygems
  • coveralls >= 0
require_all.gemspec rubygems
  • rake ~> 10.4 development
  • rspec ~> 3.2 development
  • simplecov ~> 0.7 development

Score: 28.111864199051293