Sha256: 75f3d855706625f2a13671d1c046f141349bf1d23e3fe83492c9d227c68cf92c

Contents?: true

Size: 835 Bytes

Versions: 3

Compression:

Stored size: 835 Bytes

Contents

##
# FileSet helper method for iterating and interacting with files inside a directory
#
module FileSet
  extend self
  ##
  # Iterates over every file in the glob pattern and yields to a block
  # Returns the list of files matching the glob pattern
  # FileSet.glob('padrino-core/application/*.rb', __FILE__) { |file| load file }
  #
  def glob(glob_pattern, file_path=nil, &block)
    glob_pattern = File.join(File.dirname(file_path), glob_pattern) if file_path
    file_list = Dir.glob(glob_pattern).sort
    file_list.each { |file| block.call(file) }
    file_list
  end

  ##
  # Requires each file matched in the glob pattern into the application
  # FileSet.glob_require('padrino-core/application/*.rb', __FILE__)
  #
  def glob_require(glob_pattern, file_path=nil)
    glob(glob_pattern, file_path) { |f| require f }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
padrino-support-0.12.3 lib/padrino-support/file_set.rb
padrino-support-0.12.2 lib/padrino-support/file_set.rb
padrino-support-0.12.1 lib/padrino-support/file_set.rb