Module: Machined::Utils

Defined in:
lib/machined/utils.rb

Class Method Summary collapse

Class Method Details

.available_templatesObject

Returns a hash of the Tilt templates that are registered and available to use, where the key is the extension the template’s registered for.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/machined/utils.rb', line 10

def self.available_templates
  @available_templates ||= {}.tap do |templates|
    Tilt.mappings.each_key do |ext|
      begin
        templates[Sprockets::Utils.normalize_extension(ext)] = Tilt[ext]
      rescue LoadError, NameError
        # safely ignore...
      end
    end
  end
end

.existent_directories(path) ⇒ Object

Returns an ‘Array` of the child directories that exist within the given path. If the path itself does not exist, an emtpy array is returned.



25
26
27
28
29
# File 'lib/machined/utils.rb', line 25

def self.existent_directories(path)
  pathname = Pathname.new path
  pathname.directory? or return []
  pathname.children.select &:directory?
end