Skip to content

Instantly share code, notes, and snippets.

@kenjij
Created March 23, 2017 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenjij/14a5f001de7cdf43913f157ff7f0204b to your computer and use it in GitHub Desktop.
Save kenjij/14a5f001de7cdf43913f157ff7f0204b to your computer and use it in GitHub Desktop.
Load files from list of directories in Ruby
def load_from_path(path)
Dir.chdir(path) {
Dir.foreach('.') { |f| load f unless File.directory?(f) }
}
end
paths = [
'conf.d',
'plugins'
]
paths.each { |path|
load_from_path(path)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment