Class: ChupaText::ConfigurationLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/chupa-text/configuration-loader.rb

Defined Under Namespace

Classes: DecomposerLoader, MIMETypesLoader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ ConfigurationLoader

Returns a new instance of ConfigurationLoader.



23
24
25
26
27
28
29
30
# File 'lib/chupa-text/configuration-loader.rb', line 23

def initialize(configuration)
  @configuration = configuration
  @decomposer = DecomposerLoader.new(@configuration.decomposer)
  @mime_types = MIMETypesLoader.new(@configuration.mime_type_registry)
  @load_paths = []
  data_dir = Pathname(__dir__) + ".." + ".." + "data"
  @load_paths << data_dir.expand_path
end

Instance Attribute Details

#decomposerObject (readonly)

Returns the value of attribute decomposer.



21
22
23
# File 'lib/chupa-text/configuration-loader.rb', line 21

def decomposer
  @decomposer
end

#mime_typesObject (readonly)

Returns the value of attribute mime_types.



22
23
24
# File 'lib/chupa-text/configuration-loader.rb', line 22

def mime_types
  @mime_types
end

Instance Method Details

#load(path) ⇒ Object



32
33
34
35
36
37
# File 'lib/chupa-text/configuration-loader.rb', line 32

def load(path)
  path = resolve_path(path)
  File.open(path) do |file|
    instance_eval(file.read, path.to_path, 1)
  end
end