Module: Mayl::Loader

Defined in:
lib/mayl/loader.rb

Overview

Public: This module is responsible for loading YAML files and converting them to Locale objects.

Example

Loader.load('config/locales')
# => [#<Locale:...>, #<Locale:...>]

Class Method Summary collapse

Class Method Details

.load(path) ⇒ Object

Public: Maps a set of YAML files in a directory to Locale objects, to work comfortably with them.

path - The path under which to scan for YAML files.

Returns an Array of Locale objects.



19
20
21
22
23
24
25
26
27
# File 'lib/mayl/loader.rb', line 19

def self.load(path)
  locales = Dir[File.expand_path(path) << "/*.yml"].map { |filename|
    Locale.new filename, YAML.load(File.read(filename))
  }

  abort "Error: No locales found under ./#{path}" if locales.empty?

  locales
end