Module: Hanami::Utils::FileList

Defined in:
gems/gems/hanami-utils-2.2.0.beta1/lib/hanami/utils/file_list.rb

Overview

Ordered file list, consistent across operating systems

Since:

  • 0.9.0

Class Method Summary collapse

Class Method Details

.[](*args) ⇒ Object

Returns an ordered list of files, consistent across operating systems

It has the same signature of Dir.glob, it just guarantees to order the results before to return them.

Examples:

simple usage

require "hanami/utils/file_list"

Hanami::Utils::FileList["spec/support/fixtures/file_list/*.rb"]
# => [
  "spec/support/fixtures/file_list/a.rb",
  "spec/support/fixtures/file_list/aa.rb",
  "spec/support/fixtures/file_list/ab.rb"
]

token usage

require "hanami/utils/file_list"

Hanami::Utils::FileList["spec", "support", "fixtures", "file_list", "*.rb"]
# => [
  "spec/support/fixtures/file_list/a.rb",
  "spec/support/fixtures/file_list/aa.rb",
  "spec/support/fixtures/file_list/ab.rb"
]

See Also:

Since:

  • 0.9.0

def self.[](*args)
  Dir.glob(::File.join(*args)).sort!
end