Module: Carmen

Defined in:
lib/carmen.rb,
lib/carmen/i18n.rb,
lib/carmen/utils.rb,
lib/carmen/world.rb,
lib/carmen/region.rb,
lib/carmen/country.rb,
lib/carmen/version.rb,
lib/carmen/querying.rb,
lib/carmen/region_collection.rb

Defined Under Namespace

Modules: I18n, Querying, Utils Classes: Country, Region, RegionCollection, World

Constant Summary collapse

VERSION =
'1.1.3'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.data_pathsObject

Public: Return the current array of locations where data files are stored.

Data in entries that appear later in the array takes precedence.

Each path should follow the following structure: |- world.yml (all countries) - regions (directory for subregions, named by code)

|- be.yml   (subregion file for a country)

Defaults to only the the ‘iso_data` directory within the Carmen directory.



26
27
28
# File 'lib/carmen.rb', line 26

def data_paths
  @data_paths
end

.i18n_backendObject

Public: return the current I18n backend.

Defaults to an instance of Carmen::I18n::Simple.



38
39
40
# File 'lib/carmen.rb', line 38

def i18n_backend
  @i18n_backend
end

.root_pathObject

Public: the Carmen library’s root directory.

Provides a way to find the built-in data and locale files.



52
53
54
# File 'lib/carmen.rb', line 52

def root_path
  @root_path
end

Class Method Details

.append_data_path(path) ⇒ Object

Public: Append an additional data path. path - The String path to the data directory.



56
57
58
59
# File 'lib/carmen.rb', line 56

def append_data_path(path)
  World.instance.reset!
  self.data_paths << Pathname.new(path)
end

.clear_data_pathsObject

Public: Clear the data_paths array.



62
63
64
65
# File 'lib/carmen.rb', line 62

def clear_data_paths
  World.instance.reset!
  self.data_paths = []
end

.reset_data_pathsObject

Public: Reset the data_paths array to the defaults.



68
69
70
71
72
# File 'lib/carmen.rb', line 68

def reset_data_paths
  clear_data_paths
  append_data_path(root_path + 'iso_data/base')
  append_data_path(root_path + 'iso_data/overlay')
end

.reset_i18n_backendObject

Public: Reset the i18n_backend to a default backend.



75
76
77
78
79
80
# File 'lib/carmen.rb', line 75

def reset_i18n_backend
  base_locale_path = root_path + 'locale/base'
  override_locale_path = root_path + 'locale/overlay'
  self.i18n_backend = Carmen::I18n::Simple.new(base_locale_path,
                                               override_locale_path)
end