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
- Host: GitHub
- URL: https://github.com/jarmo/require_all
- Owner: jarmo
- License: mit
- Created: 2010-09-14T18:39:18.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2020-10-10T10:33:18.000Z (about 5 years ago)
- Last Synced: 2025-11-14T13:10:27.792Z (28 days ago)
- Language: Ruby
- Homepage:
- Size: 98.6 KB
- Stars: 421
- Watchers: 11
- Forks: 29
- Open Issues: 2
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
README.md
require_all
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_diroption 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 thatdefined?(Dir1)will
return"constant"even ifmy_file.rbis 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
- Name: Jarmo Pertman
- Login: jarmo
- Email:
- Kind: user
- Description:
- Website: http://itreallymatters.net
- Location: Estonia
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/174160?v=4
- Repositories: 63
- Last ynced at: 2023-04-09T06:01:38.079Z
- Profile URL: https://github.com/jarmo
GitHub Events
Total
- Watch event: 3
Last Year
- Watch event: 3
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 | 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:
- vasco.com: 1
- feedforce.jp: 1
- mediadrive.ca: 1
- yakara.com: 1
- owenstephens.co.uk: 1
- joehorsnell.com: 1
- matijs.net: 1
- outerspacehero.com: 1
- medioh.com: 1
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
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
- Total packages: 3
-
Total downloads:
- rubygems: 167,271,650 total
- Total docker downloads: 151,355,560
- Total dependent packages: 440 (may contain duplicates)
- Total dependent repositories: 16,178 (may contain duplicates)
- Total versions: 34
- Total maintainers: 10
gem.coop: require_all
A wonderfully simple way to load your code
- Homepage: http://github.com/jarmo/require_all
- Documentation: http://www.rubydoc.info/gems/require_all/
- Licenses: MIT
- Latest release: 3.0.0 (published about 6 years ago)
- Last Synced: 2025-12-07T04:02:29.710Z (5 days ago)
- Versions: 13
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 83,653,343 Total
- Docker Downloads: 75,677,780
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.108%
- Downloads: 0.323%
- Maintainers (10)
rubygems.org: require_all
A wonderfully simple way to load your code
- Homepage: http://github.com/jarmo/require_all
- Documentation: http://www.rubydoc.info/gems/require_all/
- Licenses: MIT
- Latest release: 3.0.0 (published about 6 years ago)
- Last Synced: 2025-12-05T14:32:09.215Z (7 days ago)
- Versions: 13
- Dependent Packages: 440
- Dependent Repositories: 16,178
- Downloads: 83,618,307 Total
- Docker Downloads: 75,677,780
-
Rankings:
- Dependent packages count: 0.105%
- Dependent repos count: 0.279%
- Downloads: 0.35%
- Docker downloads count: 0.665%
- Average: 1.485%
- Stargazers count: 2.79%
- Forks count: 4.72%
- Maintainers (10)
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
- coveralls >= 0
- rake ~> 10.4 development
- rspec ~> 3.2 development
- simplecov ~> 0.7 development
Score: 28.111864199051293


